forked from TrueCloudLab/frostfs-sdk-go
25 lines
513 B
Go
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)
|
|
}
|