frostfs-sdk-go/pool/tree/pool_signature.go

26 lines
513 B
Go
Raw Normal View History

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)
}