2022-05-31 09:13:55 +00:00
|
|
|
/*REMOVE THIS AFTER SIGNATURE WILL BE AVAILABLE IN TREE CLIENT FROM NEOFS NODE*/
|
2022-05-18 13:40:09 +00:00
|
|
|
package neofs
|
|
|
|
|
|
|
|
import (
|
2022-08-24 16:03:48 +00:00
|
|
|
crypto "github.com/nspcc-dev/neofs-crypto"
|
2022-05-18 13:40:09 +00:00
|
|
|
"google.golang.org/protobuf/proto"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (c *TreeClient) 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
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *TreeClient) signRequest(requestBody proto.Message, f func(key, sign []byte)) error {
|
|
|
|
buf, err := proto.Marshal(requestBody)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return c.signData(buf, f)
|
|
|
|
}
|