2022-12-20 08:38:58 +00:00
|
|
|
/*REMOVE THIS AFTER SIGNATURE WILL BE AVAILABLE IN TREE CLIENT FROM FROSTFS NODE*/
|
2023-03-14 14:31:15 +00:00
|
|
|
package tree
|
2022-05-18 13:40:09 +00:00
|
|
|
|
|
|
|
import (
|
2023-03-07 14:38:08 +00:00
|
|
|
crypto "git.frostfs.info/TrueCloudLab/frostfs-crypto"
|
2022-05-18 13:40:09 +00:00
|
|
|
"google.golang.org/protobuf/proto"
|
|
|
|
)
|
|
|
|
|
2023-03-14 14:31:15 +00:00
|
|
|
func (c *ServiceClientGRPC) signData(buf []byte, f func(key, sign []byte)) error {
|
2022-08-24 16:03:48 +00:00
|
|
|
// crypto package should not be used outside of API libraries (see neofs-node#491).
|
|
|
|
// For now tree service does not include into SDK Client nor SDK Pool, so there is no choice.
|
|
|
|
// When SDK library adopts Tree service client, this should be dropped.
|
|
|
|
sign, err := crypto.Sign(&c.key.PrivateKey, buf)
|
2022-05-18 13:40:09 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
f(c.key.PublicKey().Bytes(), sign)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-03-14 14:31:15 +00:00
|
|
|
func (c *ServiceClientGRPC) signRequest(requestBody proto.Message, f func(key, sign []byte)) error {
|
2022-05-18 13:40:09 +00:00
|
|
|
buf, err := proto.Marshal(requestBody)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return c.signData(buf, f)
|
|
|
|
}
|