From e40995b5d4d92ffab7f57bc7234acb1738f4e9a1 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Thu, 10 Sep 2020 16:10:33 +0300 Subject: [PATCH] [#140] sdk: Define Signature type Signed-off-by: Leonard Lyubich --- pkg/signature.go | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 pkg/signature.go diff --git a/pkg/signature.go b/pkg/signature.go new file mode 100644 index 0000000..7322c50 --- /dev/null +++ b/pkg/signature.go @@ -0,0 +1,44 @@ +package pkg + +import ( + "github.com/nspcc-dev/neofs-api-go/v2/refs" +) + +// Signature represents v2-compatible signature. +type Signature refs.Signature + +// NewSignatureFromV2 wraps v2 Signature message to Signature. +func NewSignatureFromV2(sV2 *refs.Signature) *Signature { + return (*Signature)(sV2) +} + +// NewSignature creates and initializes blank Signature. +// +// Works similar as NewSignatureFromV2(new(Signature)). +func NewSignature() *Signature { + return NewSignatureFromV2(new(refs.Signature)) +} + +// GetKey sets binary public key. +func (s *Signature) GetKey() []byte { + return (*refs.Signature)(s).GetKey() +} + +// SetKey returns binary public key. +func (s *Signature) SetKey(v []byte) { + (*refs.Signature)(s).SetKey(v) +} + +// GetSign return signature value. +func (s *Signature) GetSign() []byte { + return (*refs.Signature)(s).GetSign() +} + +// SetSign sets signature value. +func (s *Signature) SetSign(v []byte) { + (*refs.Signature)(s).SetSign(v) +} + +func (s *Signature) ToV2() *refs.Signature { + return (*refs.Signature)(s) +}