-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
exported.go
71 lines (59 loc) · 1.68 KB
/
exported.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
package exported
// ICS 023 Types Implementation
//
// This file includes types defined under
// https://github.com/cosmos/ics/tree/master/spec/ics-023-vector-commitments
// spec:Path and spec:Value are defined as bytestring
// Root implements spec:CommitmentRoot.
// A root is constructed from a set of key-value pairs,
// and the inclusion or non-inclusion of an arbitrary key-value pair
// can be proven with the proof.
type Root interface {
GetCommitmentType() Type
GetHash() []byte
IsEmpty() bool
}
// Prefix implements spec:CommitmentPrefix.
// Prefix represents the common "prefix" that a set of keys shares.
type Prefix interface {
GetCommitmentType() Type
Bytes() []byte
IsEmpty() bool
}
// Path implements spec:CommitmentPath.
// A path is the additional information provided to the verification function.
type Path interface {
GetCommitmentType() Type
String() string
IsEmpty() bool
}
// Proof implements spec:CommitmentProof.
// Proof can prove whether the key-value pair is a part of the Root or not.
// Each proof has designated key-value pair it is able to prove.
// Proofs includes key but value is provided dynamically at the verification time.
type Proof interface {
GetCommitmentType() Type
VerifyMembership(Root, Path, []byte) error
VerifyNonMembership(Root, Path) error
IsEmpty() bool
ValidateBasic() error
}
// Type defines the type of the commitment
type Type byte
// Registered commitment types
const (
Merkle Type = iota + 1 // 1
)
// string representation of the commitment types
const (
TypeMerkle string = "merkle"
)
// String implements the Stringer interface
func (ct Type) String() string {
switch ct {
case Merkle:
return TypeMerkle
default:
return ""
}
}