[#190] Refactor cryptographic functionality

Remove `signature` and `util/signature` packages. Re-implement their
functionality in new `crypto` package. Generalize the approach of
digital signature computation and verification by adding `Signer` and
`PublicKey` primitives similar to standard `crypto` package. Support
already exising in protocol signature schemes.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2022-04-05 14:13:34 +03:00 committed by LeL
parent 2deaaeef05
commit ea043f4ca3
33 changed files with 728 additions and 627 deletions

View file

@ -8,10 +8,10 @@ import (
"github.com/nspcc-dev/neofs-api-go/v2/refs"
"github.com/nspcc-dev/neofs-sdk-go/checksum"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
neofscrypto "github.com/nspcc-dev/neofs-sdk-go/crypto"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
"github.com/nspcc-dev/neofs-sdk-go/owner"
"github.com/nspcc-dev/neofs-sdk-go/session"
"github.com/nspcc-dev/neofs-sdk-go/signature"
"github.com/nspcc-dev/neofs-sdk-go/version"
)
@ -109,14 +109,29 @@ func (o *Object) SetID(v oid.ID) {
}
// Signature returns signature of the object identifier.
func (o *Object) Signature() *signature.Signature {
return signature.NewFromV2(
(*object.Object)(o).GetSignature())
func (o *Object) Signature() *neofscrypto.Signature {
sigv2 := (*object.Object)(o).GetSignature()
if sigv2 == nil {
return nil
}
var sig neofscrypto.Signature
sig.ReadFromV2(*sigv2)
return &sig
}
// SetSignature sets signature of the object identifier.
func (o *Object) SetSignature(v *signature.Signature) {
(*object.Object)(o).SetSignature(v.ToV2())
func (o *Object) SetSignature(v *neofscrypto.Signature) {
var sigv2 *refs.Signature
if v != nil {
sigv2 = new(refs.Signature)
v.WriteToV2(sigv2)
}
(*object.Object)(o).SetSignature(sigv2)
}
// Payload returns payload bytes.