forked from FactomProject/factomd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
signature.go
76 lines (64 loc) · 1.8 KB
/
signature.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright 2017 Factom Foundation
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
package interfaces
/**************************************
* ISign
*
* Interface for RCB Signatures
*
* Data structure to support signatures, including multisig.
**************************************/
// Verifier objects can Verify signed messages
type Verifier interface {
Verify(msg []byte, sig *[64]byte) bool
String() string
}
// Signer object can Sign msg
type Signer interface {
Sign(msg []byte) IFullSignature
}
type ISignature interface {
BinaryMarshallable
SetSignature(sig []byte) error // Set or update the signature
GetSignature() *[64]byte
CustomMarshalText() ([]byte, error)
Bytes() []byte
IsSameAs(ISignature) bool
}
type IFullSignature interface {
BinaryMarshallable
SetSignature(sig []byte) error // Set or update the signature
GetSignature() *[64]byte
CustomMarshalText() ([]byte, error)
Bytes() []byte
SetPub(publicKey []byte)
// Get the public key
GetKey() []byte
// Validate data against this signature
Verify(data []byte) bool
IsSameAs(IFullSignature) bool
}
/**************************************
* ISign
*
* Interface for RCB Signatures
*
* The signature block holds the signatures that validate one of the RCBs.
* Each signature has an index, so if the RCD is a multisig, you can know
* how to apply the signatures to the addresses in the RCD.
**************************************/
type ISignatureBlock interface {
BinaryMarshallable
Printable
AddSignature(sig ISignature)
CustomMarshalText() ([]byte, error)
GetSignature(int) ISignature
GetSignatures() []ISignature
IsSameAs(ISignatureBlock) bool
}
type ISignable interface {
Sign(privateKey []byte) error
MarshalBinarySig() ([]byte, error)
ValidateSignatures() error
}