frostfs-sdk-go/pool/tree/pool_signature.go
Denis Kirillov 51e022ab8c [#73] pool/tree: Add tree pool
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
2023-06-08 14:37:57 +03:00

25 lines
513 B
Go

package tree
import (
crypto "git.frostfs.info/TrueCloudLab/frostfs-crypto"
"google.golang.org/protobuf/proto"
)
func (p *Pool) signData(buf []byte, f func(key, sign []byte)) error {
sign, err := crypto.Sign(&p.key.PrivateKey, buf)
if err != nil {
return err
}
f(p.key.PublicKey().Bytes(), sign)
return nil
}
func (p *Pool) signRequest(requestBody proto.Message, f func(key, sign []byte)) error {
buf, err := proto.Marshal(requestBody)
if err != nil {
return err
}
return p.signData(buf, f)
}