forked from TrueCloudLab/frostfs-sdk-go
[#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:
parent
2deaaeef05
commit
ea043f4ca3
33 changed files with 728 additions and 627 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue