/
signable_stub.go
45 lines (36 loc) · 1.01 KB
/
signable_stub.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright © 2020-2022 The EVEN Solutions Developers Team
package crypto
import (
"github.com/evenlab/go-kit/errors"
)
type (
// SignableStub implements Signable interface.
SignableStub struct {
Blob []byte
Sign Signature
PbKey PublicKey
}
)
// NewSignable constructs Signable interface over given bytes.
func NewSignable(blob []byte) Signable {
return &SignableStub{Blob: blob}
}
// GetSignature implements Signable.GetSignature method of interface.
func (c *SignableStub) GetSignature() Signature {
return c.Sign
}
// Hash implements Hasher.Hash method of interface.
func (c *SignableStub) Hash() (Hash256, error) {
if c.Blob == nil {
return Hash256{}, errors.ErrNilPointerValue()
}
return NewHash256(c.Blob), nil
}
// SetPublicKey implements Signable.SetPublicKey method of interface.
func (c *SignableStub) SetPublicKey(pbKey PublicKey) {
c.PbKey = pbKey
}
// SetSignature implements Signable.SetSignature method of interface.
func (c *SignableStub) SetSignature(sign Signature) {
c.Sign = sign
}