ics23

package module
v0.0.0-...-6b337ec Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

* This implements the client side functions as specified in https://github.com/cosmos/ics/tree/master/spec/ics-023-vector-commitments

In particular:

// Assumes ExistenceProof
type verifyMembership = (root: CommitmentRoot, proof: CommitmentProof, key: Key, value: Value) => boolean

// Assumes NonExistenceProof
type verifyNonMembership = (root: CommitmentRoot, proof: CommitmentProof, key: Key) => boolean

// Assumes BatchProof - required ExistenceProofs may be a subset of all items proven
type batchVerifyMembership = (root: CommitmentRoot, proof: CommitmentProof, items: Map<Key, Value>) => boolean

// Assumes BatchProof - required NonExistenceProofs may be a subset of all items proven
type batchVerifyNonMembership = (root: CommitmentRoot, proof: CommitmentProof, keys: Set<Key>) => boolean

We make an adjustment to accept a Spec to ensure the provided proof is in the format of the expected merkle store. This can avoid an range of attacks on fake preimages, as we need to be careful on how to map key, value -> leaf and determine neighbors

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthProofs        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowProofs          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupProofs = fmt.Errorf("proto: unexpected end of group")
)
View Source
var HashOp_name = map[int32]string{
	0: "NO_HASH",
	1: "SHA256",
	2: "SHA512",
	3: "KECCAK",
	4: "RIPEMD160",
	5: "BITCOIN",
	6: "SHA512_256",
}
View Source
var HashOp_value = map[string]int32{
	"NO_HASH":    0,
	"SHA256":     1,
	"SHA512":     2,
	"KECCAK":     3,
	"RIPEMD160":  4,
	"BITCOIN":    5,
	"SHA512_256": 6,
}
View Source
var IavlSpec = &ProofSpec{
	LeafSpec: &LeafOp{
		Prefix:       []byte{0},
		Hash:         HashOp_SHA256,
		PrehashValue: HashOp_SHA256,
		Length:       LengthOp_VAR_PROTO,
	},
	InnerSpec: &InnerSpec{
		ChildOrder:      []int32{0, 1},
		MinPrefixLength: 4,
		MaxPrefixLength: 12,
		ChildSize:       33,
		Hash:            HashOp_SHA256,
	},
}

IavlSpec constrains the format from proofs-iavl (iavl merkle proofs)

View Source
var LengthOp_name = map[int32]string{
	0: "NO_PREFIX",
	1: "VAR_PROTO",
	2: "VAR_RLP",
	3: "FIXED32_BIG",
	4: "FIXED32_LITTLE",
	5: "FIXED64_BIG",
	6: "FIXED64_LITTLE",
	7: "REQUIRE_32_BYTES",
	8: "REQUIRE_64_BYTES",
}
View Source
var LengthOp_value = map[string]int32{
	"NO_PREFIX":        0,
	"VAR_PROTO":        1,
	"VAR_RLP":          2,
	"FIXED32_BIG":      3,
	"FIXED32_LITTLE":   4,
	"FIXED64_BIG":      5,
	"FIXED64_LITTLE":   6,
	"REQUIRE_32_BYTES": 7,
	"REQUIRE_64_BYTES": 8,
}
View Source
var SmtSpec = &ProofSpec{
	LeafSpec: &LeafOp{
		Hash:         HashOp_SHA256,
		PrehashKey:   HashOp_NO_HASH,
		PrehashValue: HashOp_SHA256,
		Length:       LengthOp_NO_PREFIX,
		Prefix:       []byte{0},
	},
	InnerSpec: &InnerSpec{
		ChildOrder:      []int32{0, 1},
		ChildSize:       32,
		MinPrefixLength: 1,
		MaxPrefixLength: 1,
		EmptyChild:      make([]byte, 32),
		Hash:            HashOp_SHA256,
	},
	MaxDepth: 256,
}

SmtSpec constrains the format for SMT proofs (as implemented by github.com/celestiaorg/smt)

View Source
var TendermintSpec = &ProofSpec{
	LeafSpec: &LeafOp{
		Prefix:       []byte{0},
		Hash:         HashOp_SHA256,
		PrehashValue: HashOp_SHA256,
		Length:       LengthOp_VAR_PROTO,
	},
	InnerSpec: &InnerSpec{
		ChildOrder:      []int32{0, 1},
		MinPrefixLength: 1,
		MaxPrefixLength: 1,
		ChildSize:       32,
		Hash:            HashOp_SHA256,
	},
}

TendermintSpec constrains the format from proofs-tendermint (crypto/merkle SimpleProof)

Functions

func BatchVerifyMembership

func BatchVerifyMembership(spec *ProofSpec, root CommitmentRoot, proof *CommitmentProof, items map[string][]byte) bool

BatchVerifyMembership will ensure all items are also proven by the CommitmentProof (which should be a BatchProof, unless there is one item, when a ExistenceProof may work)

func BatchVerifyNonMembership

func BatchVerifyNonMembership(spec *ProofSpec, root CommitmentRoot, proof *CommitmentProof, keys [][]byte) bool

BatchVerifyNonMembership will ensure all items are also proven to not be in the Commitment by the CommitmentProof (which should be a BatchProof, unless there is one item, when a NonExistenceProof may work)

func IsCompressed

func IsCompressed(proof *CommitmentProof) bool

IsCompressed returns true if the proof was compressed

func IsLeftMost

func IsLeftMost(spec *InnerSpec, path []*InnerOp) bool

IsLeftMost returns true if this is the left-most path in the tree, excluding placeholder (empty child) nodes

func IsLeftNeighbor

func IsLeftNeighbor(spec *InnerSpec, left []*InnerOp, right []*InnerOp) bool

IsLeftNeighbor returns true if `right` is the next possible path right of `left`

Find the common suffix from the Left.Path and Right.Path and remove it. We have LPath and RPath now, which must be neighbors.
Validate that LPath[len-1] is the left neighbor of RPath[len-1]
For step in LPath[0..len-1], validate step is right-most node
For step in RPath[0..len-1], validate step is left-most node

func IsRightMost

func IsRightMost(spec *InnerSpec, path []*InnerOp) bool

IsRightMost returns true if this is the left-most path in the tree, excluding placeholder (empty child) nodes

func VerifyMembership

func VerifyMembership(spec *ProofSpec, root CommitmentRoot, proof *CommitmentProof, key []byte, value []byte) bool

VerifyMembership returns true iff proof is (contains) an ExistenceProof for the given key and value AND calculating the root for the ExistenceProof matches the provided CommitmentRoot

func VerifyNonMembership

func VerifyNonMembership(spec *ProofSpec, root CommitmentRoot, proof *CommitmentProof, key []byte) bool

VerifyNonMembership returns true iff proof is (contains) a NonExistenceProof both left and right sub-proofs are valid existence proofs (see above) or nil left and right proofs are neighbors (or left/right most if one is nil) provided key is between the keys of the two proofs

Types

type BatchEntry

type BatchEntry struct {
	// Types that are valid to be assigned to Proof:
	//	*BatchEntry_Exist
	//	*BatchEntry_Nonexist
	Proof isBatchEntry_Proof `protobuf_oneof:"proof"`
}

Use BatchEntry not CommitmentProof, to avoid recursion

func (*BatchEntry) Descriptor

func (*BatchEntry) Descriptor() ([]byte, []int)

func (*BatchEntry) GetExist

func (m *BatchEntry) GetExist() *ExistenceProof

func (*BatchEntry) GetNonexist

func (m *BatchEntry) GetNonexist() *NonExistenceProof

func (*BatchEntry) GetProof

func (m *BatchEntry) GetProof() isBatchEntry_Proof

func (*BatchEntry) Marshal

func (m *BatchEntry) Marshal() (dAtA []byte, err error)

func (*BatchEntry) MarshalTo

func (m *BatchEntry) MarshalTo(dAtA []byte) (int, error)

func (*BatchEntry) MarshalToSizedBuffer

func (m *BatchEntry) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*BatchEntry) ProtoMessage

func (*BatchEntry) ProtoMessage()

func (*BatchEntry) Reset

func (m *BatchEntry) Reset()

func (*BatchEntry) Size

func (m *BatchEntry) Size() (n int)

func (*BatchEntry) String

func (m *BatchEntry) String() string

func (*BatchEntry) Unmarshal

func (m *BatchEntry) Unmarshal(dAtA []byte) error

func (*BatchEntry) XXX_DiscardUnknown

func (m *BatchEntry) XXX_DiscardUnknown()

func (*BatchEntry) XXX_Marshal

func (m *BatchEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*BatchEntry) XXX_Merge

func (m *BatchEntry) XXX_Merge(src proto.Message)

func (*BatchEntry) XXX_OneofWrappers

func (*BatchEntry) XXX_OneofWrappers() []interface{}

XXX_OneofWrappers is for the internal use of the proto package.

func (*BatchEntry) XXX_Size

func (m *BatchEntry) XXX_Size() int

func (*BatchEntry) XXX_Unmarshal

func (m *BatchEntry) XXX_Unmarshal(b []byte) error

type BatchEntry_Exist

type BatchEntry_Exist struct {
	Exist *ExistenceProof `protobuf:"bytes,1,opt,name=exist,proto3,oneof" json:"exist,omitempty"`
}

func (*BatchEntry_Exist) MarshalTo

func (m *BatchEntry_Exist) MarshalTo(dAtA []byte) (int, error)

func (*BatchEntry_Exist) MarshalToSizedBuffer

func (m *BatchEntry_Exist) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*BatchEntry_Exist) Size

func (m *BatchEntry_Exist) Size() (n int)

type BatchEntry_Nonexist

type BatchEntry_Nonexist struct {
	Nonexist *NonExistenceProof `protobuf:"bytes,2,opt,name=nonexist,proto3,oneof" json:"nonexist,omitempty"`
}

func (*BatchEntry_Nonexist) MarshalTo

func (m *BatchEntry_Nonexist) MarshalTo(dAtA []byte) (int, error)

func (*BatchEntry_Nonexist) MarshalToSizedBuffer

func (m *BatchEntry_Nonexist) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*BatchEntry_Nonexist) Size

func (m *BatchEntry_Nonexist) Size() (n int)

type BatchProof

type BatchProof struct {
	Entries []*BatchEntry `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"`
}

BatchProof is a group of multiple proof types than can be compressed

func (*BatchProof) Descriptor

func (*BatchProof) Descriptor() ([]byte, []int)

func (*BatchProof) GetEntries

func (m *BatchProof) GetEntries() []*BatchEntry

func (*BatchProof) Marshal

func (m *BatchProof) Marshal() (dAtA []byte, err error)

func (*BatchProof) MarshalTo

func (m *BatchProof) MarshalTo(dAtA []byte) (int, error)

func (*BatchProof) MarshalToSizedBuffer

func (m *BatchProof) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*BatchProof) ProtoMessage

func (*BatchProof) ProtoMessage()

func (*BatchProof) Reset

func (m *BatchProof) Reset()

func (*BatchProof) Size

func (m *BatchProof) Size() (n int)

func (*BatchProof) String

func (m *BatchProof) String() string

func (*BatchProof) Unmarshal

func (m *BatchProof) Unmarshal(dAtA []byte) error

func (*BatchProof) XXX_DiscardUnknown

func (m *BatchProof) XXX_DiscardUnknown()

func (*BatchProof) XXX_Marshal

func (m *BatchProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*BatchProof) XXX_Merge

func (m *BatchProof) XXX_Merge(src proto.Message)

func (*BatchProof) XXX_Size

func (m *BatchProof) XXX_Size() int

func (*BatchProof) XXX_Unmarshal

func (m *BatchProof) XXX_Unmarshal(b []byte) error

type CommitmentProof

type CommitmentProof struct {
	// Types that are valid to be assigned to Proof:
	//	*CommitmentProof_Exist
	//	*CommitmentProof_Nonexist
	//	*CommitmentProof_Batch
	//	*CommitmentProof_Compressed
	Proof isCommitmentProof_Proof `protobuf_oneof:"proof"`
}

CommitmentProof is either an ExistenceProof or a NonExistenceProof, or a Batch of such messages

func CombineProofs

func CombineProofs(proofs []*CommitmentProof) (*CommitmentProof, error)

CombineProofs takes a number of commitment proofs (simple or batch) and converts them into a batch and compresses them.

This is designed for proof generation libraries to create efficient batches

func Compress

func Compress(proof *CommitmentProof) *CommitmentProof

Compress will return a CompressedBatchProof if the input is BatchProof Otherwise it will return the input. This is safe to call multiple times (idempotent)

func Decompress

func Decompress(proof *CommitmentProof) *CommitmentProof

Decompress will return a BatchProof if the input is CompressedBatchProof Otherwise it will return the input. This is safe to call multiple times (idempotent)

func (*CommitmentProof) Calculate

func (p *CommitmentProof) Calculate() (CommitmentRoot, error)

Calculate determines the root hash that matches a given Commitment proof by type switching and calculating root based on proof type NOTE: Calculate will return the first calculated root in the proof, you must validate that all other embedded ExistenceProofs commit to the same root. This can be done with the Verify method

func (*CommitmentProof) Descriptor

func (*CommitmentProof) Descriptor() ([]byte, []int)

func (*CommitmentProof) GetBatch

func (m *CommitmentProof) GetBatch() *BatchProof

func (*CommitmentProof) GetCompressed

func (m *CommitmentProof) GetCompressed() *CompressedBatchProof

func (*CommitmentProof) GetExist

func (m *CommitmentProof) GetExist() *ExistenceProof

func (*CommitmentProof) GetNonexist

func (m *CommitmentProof) GetNonexist() *NonExistenceProof

func (*CommitmentProof) GetProof

func (m *CommitmentProof) GetProof() isCommitmentProof_Proof

func (*CommitmentProof) Marshal

func (m *CommitmentProof) Marshal() (dAtA []byte, err error)

func (*CommitmentProof) MarshalTo

func (m *CommitmentProof) MarshalTo(dAtA []byte) (int, error)

func (*CommitmentProof) MarshalToSizedBuffer

func (m *CommitmentProof) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*CommitmentProof) ProtoMessage

func (*CommitmentProof) ProtoMessage()

func (*CommitmentProof) Reset

func (m *CommitmentProof) Reset()

func (*CommitmentProof) Size

func (m *CommitmentProof) Size() (n int)

func (*CommitmentProof) String

func (m *CommitmentProof) String() string

func (*CommitmentProof) Unmarshal

func (m *CommitmentProof) Unmarshal(dAtA []byte) error

func (*CommitmentProof) XXX_DiscardUnknown

func (m *CommitmentProof) XXX_DiscardUnknown()

func (*CommitmentProof) XXX_Marshal

func (m *CommitmentProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CommitmentProof) XXX_Merge

func (m *CommitmentProof) XXX_Merge(src proto.Message)

func (*CommitmentProof) XXX_OneofWrappers

func (*CommitmentProof) XXX_OneofWrappers() []interface{}

XXX_OneofWrappers is for the internal use of the proto package.

func (*CommitmentProof) XXX_Size

func (m *CommitmentProof) XXX_Size() int

func (*CommitmentProof) XXX_Unmarshal

func (m *CommitmentProof) XXX_Unmarshal(b []byte) error

type CommitmentProof_Batch

type CommitmentProof_Batch struct {
	Batch *BatchProof `protobuf:"bytes,3,opt,name=batch,proto3,oneof" json:"batch,omitempty"`
}

func (*CommitmentProof_Batch) MarshalTo

func (m *CommitmentProof_Batch) MarshalTo(dAtA []byte) (int, error)

func (*CommitmentProof_Batch) MarshalToSizedBuffer

func (m *CommitmentProof_Batch) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*CommitmentProof_Batch) Size

func (m *CommitmentProof_Batch) Size() (n int)

type CommitmentProof_Compressed

type CommitmentProof_Compressed struct {
	Compressed *CompressedBatchProof `protobuf:"bytes,4,opt,name=compressed,proto3,oneof" json:"compressed,omitempty"`
}

func (*CommitmentProof_Compressed) MarshalTo

func (m *CommitmentProof_Compressed) MarshalTo(dAtA []byte) (int, error)

func (*CommitmentProof_Compressed) MarshalToSizedBuffer

func (m *CommitmentProof_Compressed) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*CommitmentProof_Compressed) Size

func (m *CommitmentProof_Compressed) Size() (n int)

type CommitmentProof_Exist

type CommitmentProof_Exist struct {
	Exist *ExistenceProof `protobuf:"bytes,1,opt,name=exist,proto3,oneof" json:"exist,omitempty"`
}

func (*CommitmentProof_Exist) MarshalTo

func (m *CommitmentProof_Exist) MarshalTo(dAtA []byte) (int, error)

func (*CommitmentProof_Exist) MarshalToSizedBuffer

func (m *CommitmentProof_Exist) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*CommitmentProof_Exist) Size

func (m *CommitmentProof_Exist) Size() (n int)

type CommitmentProof_Nonexist

type CommitmentProof_Nonexist struct {
	Nonexist *NonExistenceProof `protobuf:"bytes,2,opt,name=nonexist,proto3,oneof" json:"nonexist,omitempty"`
}

func (*CommitmentProof_Nonexist) MarshalTo

func (m *CommitmentProof_Nonexist) MarshalTo(dAtA []byte) (int, error)

func (*CommitmentProof_Nonexist) MarshalToSizedBuffer

func (m *CommitmentProof_Nonexist) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*CommitmentProof_Nonexist) Size

func (m *CommitmentProof_Nonexist) Size() (n int)

type CommitmentRoot

type CommitmentRoot []byte

CommitmentRoot is a byte slice that represents the merkle root of a tree that can be used to validate proofs

type CompressedBatchEntry

type CompressedBatchEntry struct {
	// Types that are valid to be assigned to Proof:
	//	*CompressedBatchEntry_Exist
	//	*CompressedBatchEntry_Nonexist
	Proof isCompressedBatchEntry_Proof `protobuf_oneof:"proof"`
}

Use BatchEntry not CommitmentProof, to avoid recursion

func (*CompressedBatchEntry) Descriptor

func (*CompressedBatchEntry) Descriptor() ([]byte, []int)

func (*CompressedBatchEntry) GetExist

func (*CompressedBatchEntry) GetNonexist

func (*CompressedBatchEntry) GetProof

func (m *CompressedBatchEntry) GetProof() isCompressedBatchEntry_Proof

func (*CompressedBatchEntry) Marshal

func (m *CompressedBatchEntry) Marshal() (dAtA []byte, err error)

func (*CompressedBatchEntry) MarshalTo

func (m *CompressedBatchEntry) MarshalTo(dAtA []byte) (int, error)

func (*CompressedBatchEntry) MarshalToSizedBuffer

func (m *CompressedBatchEntry) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*CompressedBatchEntry) ProtoMessage

func (*CompressedBatchEntry) ProtoMessage()

func (*CompressedBatchEntry) Reset

func (m *CompressedBatchEntry) Reset()

func (*CompressedBatchEntry) Size

func (m *CompressedBatchEntry) Size() (n int)

func (*CompressedBatchEntry) String

func (m *CompressedBatchEntry) String() string

func (*CompressedBatchEntry) Unmarshal

func (m *CompressedBatchEntry) Unmarshal(dAtA []byte) error

func (*CompressedBatchEntry) XXX_DiscardUnknown

func (m *CompressedBatchEntry) XXX_DiscardUnknown()

func (*CompressedBatchEntry) XXX_Marshal

func (m *CompressedBatchEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CompressedBatchEntry) XXX_Merge

func (m *CompressedBatchEntry) XXX_Merge(src proto.Message)

func (*CompressedBatchEntry) XXX_OneofWrappers

func (*CompressedBatchEntry) XXX_OneofWrappers() []interface{}

XXX_OneofWrappers is for the internal use of the proto package.

func (*CompressedBatchEntry) XXX_Size

func (m *CompressedBatchEntry) XXX_Size() int

func (*CompressedBatchEntry) XXX_Unmarshal

func (m *CompressedBatchEntry) XXX_Unmarshal(b []byte) error

type CompressedBatchEntry_Exist

type CompressedBatchEntry_Exist struct {
	Exist *CompressedExistenceProof `protobuf:"bytes,1,opt,name=exist,proto3,oneof" json:"exist,omitempty"`
}

func (*CompressedBatchEntry_Exist) MarshalTo

func (m *CompressedBatchEntry_Exist) MarshalTo(dAtA []byte) (int, error)

func (*CompressedBatchEntry_Exist) MarshalToSizedBuffer

func (m *CompressedBatchEntry_Exist) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*CompressedBatchEntry_Exist) Size

func (m *CompressedBatchEntry_Exist) Size() (n int)

type CompressedBatchEntry_Nonexist

type CompressedBatchEntry_Nonexist struct {
	Nonexist *CompressedNonExistenceProof `protobuf:"bytes,2,opt,name=nonexist,proto3,oneof" json:"nonexist,omitempty"`
}

func (*CompressedBatchEntry_Nonexist) MarshalTo

func (m *CompressedBatchEntry_Nonexist) MarshalTo(dAtA []byte) (int, error)

func (*CompressedBatchEntry_Nonexist) MarshalToSizedBuffer

func (m *CompressedBatchEntry_Nonexist) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*CompressedBatchEntry_Nonexist) Size

func (m *CompressedBatchEntry_Nonexist) Size() (n int)

type CompressedBatchProof

type CompressedBatchProof struct {
	Entries      []*CompressedBatchEntry `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"`
	LookupInners []*InnerOp              `protobuf:"bytes,2,rep,name=lookup_inners,json=lookupInners,proto3" json:"lookup_inners,omitempty"`
}

func (*CompressedBatchProof) Descriptor

func (*CompressedBatchProof) Descriptor() ([]byte, []int)

func (*CompressedBatchProof) GetEntries

func (m *CompressedBatchProof) GetEntries() []*CompressedBatchEntry

func (*CompressedBatchProof) GetLookupInners

func (m *CompressedBatchProof) GetLookupInners() []*InnerOp

func (*CompressedBatchProof) Marshal

func (m *CompressedBatchProof) Marshal() (dAtA []byte, err error)

func (*CompressedBatchProof) MarshalTo

func (m *CompressedBatchProof) MarshalTo(dAtA []byte) (int, error)

func (*CompressedBatchProof) MarshalToSizedBuffer

func (m *CompressedBatchProof) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*CompressedBatchProof) ProtoMessage

func (*CompressedBatchProof) ProtoMessage()

func (*CompressedBatchProof) Reset

func (m *CompressedBatchProof) Reset()

func (*CompressedBatchProof) Size

func (m *CompressedBatchProof) Size() (n int)

func (*CompressedBatchProof) String

func (m *CompressedBatchProof) String() string

func (*CompressedBatchProof) Unmarshal

func (m *CompressedBatchProof) Unmarshal(dAtA []byte) error

func (*CompressedBatchProof) XXX_DiscardUnknown

func (m *CompressedBatchProof) XXX_DiscardUnknown()

func (*CompressedBatchProof) XXX_Marshal

func (m *CompressedBatchProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CompressedBatchProof) XXX_Merge

func (m *CompressedBatchProof) XXX_Merge(src proto.Message)

func (*CompressedBatchProof) XXX_Size

func (m *CompressedBatchProof) XXX_Size() int

func (*CompressedBatchProof) XXX_Unmarshal

func (m *CompressedBatchProof) XXX_Unmarshal(b []byte) error

type CompressedExistenceProof

type CompressedExistenceProof struct {
	Key   []byte  `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	Value []byte  `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
	Leaf  *LeafOp `protobuf:"bytes,3,opt,name=leaf,proto3" json:"leaf,omitempty"`
	// these are indexes into the lookup_inners table in CompressedBatchProof
	Path []int32 `protobuf:"varint,4,rep,packed,name=path,proto3" json:"path,omitempty"`
}

func (*CompressedExistenceProof) Descriptor

func (*CompressedExistenceProof) Descriptor() ([]byte, []int)

func (*CompressedExistenceProof) GetKey

func (m *CompressedExistenceProof) GetKey() []byte

func (*CompressedExistenceProof) GetLeaf

func (m *CompressedExistenceProof) GetLeaf() *LeafOp

func (*CompressedExistenceProof) GetPath

func (m *CompressedExistenceProof) GetPath() []int32

func (*CompressedExistenceProof) GetValue

func (m *CompressedExistenceProof) GetValue() []byte

func (*CompressedExistenceProof) Marshal

func (m *CompressedExistenceProof) Marshal() (dAtA []byte, err error)

func (*CompressedExistenceProof) MarshalTo

func (m *CompressedExistenceProof) MarshalTo(dAtA []byte) (int, error)

func (*CompressedExistenceProof) MarshalToSizedBuffer

func (m *CompressedExistenceProof) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*CompressedExistenceProof) ProtoMessage

func (*CompressedExistenceProof) ProtoMessage()

func (*CompressedExistenceProof) Reset

func (m *CompressedExistenceProof) Reset()

func (*CompressedExistenceProof) Size

func (m *CompressedExistenceProof) Size() (n int)

func (*CompressedExistenceProof) String

func (m *CompressedExistenceProof) String() string

func (*CompressedExistenceProof) Unmarshal

func (m *CompressedExistenceProof) Unmarshal(dAtA []byte) error

func (*CompressedExistenceProof) XXX_DiscardUnknown

func (m *CompressedExistenceProof) XXX_DiscardUnknown()

func (*CompressedExistenceProof) XXX_Marshal

func (m *CompressedExistenceProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CompressedExistenceProof) XXX_Merge

func (m *CompressedExistenceProof) XXX_Merge(src proto.Message)

func (*CompressedExistenceProof) XXX_Size

func (m *CompressedExistenceProof) XXX_Size() int

func (*CompressedExistenceProof) XXX_Unmarshal

func (m *CompressedExistenceProof) XXX_Unmarshal(b []byte) error

type CompressedNonExistenceProof

type CompressedNonExistenceProof struct {
	Key   []byte                    `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	Left  *CompressedExistenceProof `protobuf:"bytes,2,opt,name=left,proto3" json:"left,omitempty"`
	Right *CompressedExistenceProof `protobuf:"bytes,3,opt,name=right,proto3" json:"right,omitempty"`
}

func (*CompressedNonExistenceProof) Descriptor

func (*CompressedNonExistenceProof) Descriptor() ([]byte, []int)

func (*CompressedNonExistenceProof) GetKey

func (m *CompressedNonExistenceProof) GetKey() []byte

func (*CompressedNonExistenceProof) GetLeft

func (*CompressedNonExistenceProof) GetRight

func (*CompressedNonExistenceProof) Marshal

func (m *CompressedNonExistenceProof) Marshal() (dAtA []byte, err error)

func (*CompressedNonExistenceProof) MarshalTo

func (m *CompressedNonExistenceProof) MarshalTo(dAtA []byte) (int, error)

func (*CompressedNonExistenceProof) MarshalToSizedBuffer

func (m *CompressedNonExistenceProof) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*CompressedNonExistenceProof) ProtoMessage

func (*CompressedNonExistenceProof) ProtoMessage()

func (*CompressedNonExistenceProof) Reset

func (m *CompressedNonExistenceProof) Reset()

func (*CompressedNonExistenceProof) Size

func (m *CompressedNonExistenceProof) Size() (n int)

func (*CompressedNonExistenceProof) String

func (m *CompressedNonExistenceProof) String() string

func (*CompressedNonExistenceProof) Unmarshal

func (m *CompressedNonExistenceProof) Unmarshal(dAtA []byte) error

func (*CompressedNonExistenceProof) XXX_DiscardUnknown

func (m *CompressedNonExistenceProof) XXX_DiscardUnknown()

func (*CompressedNonExistenceProof) XXX_Marshal

func (m *CompressedNonExistenceProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CompressedNonExistenceProof) XXX_Merge

func (m *CompressedNonExistenceProof) XXX_Merge(src proto.Message)

func (*CompressedNonExistenceProof) XXX_Size

func (m *CompressedNonExistenceProof) XXX_Size() int

func (*CompressedNonExistenceProof) XXX_Unmarshal

func (m *CompressedNonExistenceProof) XXX_Unmarshal(b []byte) error

type ExistenceProof

type ExistenceProof struct {
	Key   []byte     `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	Value []byte     `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
	Leaf  *LeafOp    `protobuf:"bytes,3,opt,name=leaf,proto3" json:"leaf,omitempty"`
	Path  []*InnerOp `protobuf:"bytes,4,rep,name=path,proto3" json:"path,omitempty"`
}

* ExistenceProof takes a key and a value and a set of steps to perform on it. The result of peforming all these steps will provide a "root hash", which can be compared to the value in a header.

Since it is computationally infeasible to produce a hash collission for any of the used cryptographic hash functions, if someone can provide a series of operations to transform a given key and value into a root hash that matches some trusted root, these key and values must be in the referenced merkle tree.

The only possible issue is maliablity in LeafOp, such as providing extra prefix data, which should be controlled by a spec. Eg. with lengthOp as NONE, prefix = FOO, key = BAR, value = CHOICE and prefix = F, key = OOBAR, value = CHOICE would produce the same value.

With LengthOp this is tricker but not impossible. Which is why the "leafPrefixEqual" field in the ProofSpec is valuable to prevent this mutability. And why all trees should length-prefix the data before hashing it.

func (*ExistenceProof) Calculate

func (p *ExistenceProof) Calculate() (CommitmentRoot, error)

Calculate determines the root hash that matches the given proof. You must validate the result is what you have in a header. Returns error if the calculations cannot be performed.

func (*ExistenceProof) CheckAgainstSpec

func (p *ExistenceProof) CheckAgainstSpec(spec *ProofSpec) error

CheckAgainstSpec will verify the leaf and all path steps are in the format defined in spec

func (*ExistenceProof) Descriptor

func (*ExistenceProof) Descriptor() ([]byte, []int)

func (*ExistenceProof) GetKey

func (m *ExistenceProof) GetKey() []byte

func (*ExistenceProof) GetLeaf

func (m *ExistenceProof) GetLeaf() *LeafOp

func (*ExistenceProof) GetPath

func (m *ExistenceProof) GetPath() []*InnerOp

func (*ExistenceProof) GetValue

func (m *ExistenceProof) GetValue() []byte

func (*ExistenceProof) Marshal

func (m *ExistenceProof) Marshal() (dAtA []byte, err error)

func (*ExistenceProof) MarshalTo

func (m *ExistenceProof) MarshalTo(dAtA []byte) (int, error)

func (*ExistenceProof) MarshalToSizedBuffer

func (m *ExistenceProof) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*ExistenceProof) ProtoMessage

func (*ExistenceProof) ProtoMessage()

func (*ExistenceProof) Reset

func (m *ExistenceProof) Reset()

func (*ExistenceProof) Size

func (m *ExistenceProof) Size() (n int)

func (*ExistenceProof) String

func (m *ExistenceProof) String() string

func (*ExistenceProof) Unmarshal

func (m *ExistenceProof) Unmarshal(dAtA []byte) error

func (*ExistenceProof) Verify

func (p *ExistenceProof) Verify(spec *ProofSpec, root CommitmentRoot, key []byte, value []byte) error

Verify does all checks to ensure this proof proves this key, value -> root and matches the spec.

func (*ExistenceProof) XXX_DiscardUnknown

func (m *ExistenceProof) XXX_DiscardUnknown()

func (*ExistenceProof) XXX_Marshal

func (m *ExistenceProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ExistenceProof) XXX_Merge

func (m *ExistenceProof) XXX_Merge(src proto.Message)

func (*ExistenceProof) XXX_Size

func (m *ExistenceProof) XXX_Size() int

func (*ExistenceProof) XXX_Unmarshal

func (m *ExistenceProof) XXX_Unmarshal(b []byte) error

type HashOp

type HashOp int32
const (
	// NO_HASH is the default if no data passed. Note this is an illegal argument some places.
	HashOp_NO_HASH    HashOp = 0
	HashOp_SHA256     HashOp = 1
	HashOp_SHA512     HashOp = 2
	HashOp_KECCAK     HashOp = 3
	HashOp_RIPEMD160  HashOp = 4
	HashOp_BITCOIN    HashOp = 5
	HashOp_SHA512_256 HashOp = 6
)

func (HashOp) EnumDescriptor

func (HashOp) EnumDescriptor() ([]byte, []int)

func (HashOp) String

func (x HashOp) String() string

type InnerOp

type InnerOp struct {
	Hash   HashOp `protobuf:"varint,1,opt,name=hash,proto3,enum=ics23.HashOp" json:"hash,omitempty"`
	Prefix []byte `protobuf:"bytes,2,opt,name=prefix,proto3" json:"prefix,omitempty"`
	Suffix []byte `protobuf:"bytes,3,opt,name=suffix,proto3" json:"suffix,omitempty"`
}

* InnerOp represents a merkle-proof step that is not a leaf. It represents concatenating two children and hashing them to provide the next result.

The result of the previous step is passed in, so the signature of this op is: innerOp(child) -> output

The result of applying InnerOp should be: output = op.hash(op.prefix || child || op.suffix)

where the || operator is concatenation of binary data, and child is the result of hashing all the tree below this step.

Any special data, like prepending child with the length, or prepending the entire operation with some value to differentiate from leaf nodes, should be included in prefix and suffix. If either of prefix or suffix is empty, we just treat it as an empty string

func (*InnerOp) Apply

func (op *InnerOp) Apply(child []byte) ([]byte, error)

Apply will calculate the hash of the next step, given the hash of the previous step

func (*InnerOp) CheckAgainstSpec

func (op *InnerOp) CheckAgainstSpec(spec *ProofSpec) error

CheckAgainstSpec will verify the InnerOp is in the format defined in spec

func (*InnerOp) Descriptor

func (*InnerOp) Descriptor() ([]byte, []int)

func (*InnerOp) GetHash

func (m *InnerOp) GetHash() HashOp

func (*InnerOp) GetPrefix

func (m *InnerOp) GetPrefix() []byte

func (*InnerOp) GetSuffix

func (m *InnerOp) GetSuffix() []byte

func (*InnerOp) Marshal

func (m *InnerOp) Marshal() (dAtA []byte, err error)

func (*InnerOp) MarshalTo

func (m *InnerOp) MarshalTo(dAtA []byte) (int, error)

func (*InnerOp) MarshalToSizedBuffer

func (m *InnerOp) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*InnerOp) ProtoMessage

func (*InnerOp) ProtoMessage()

func (*InnerOp) Reset

func (m *InnerOp) Reset()

func (*InnerOp) Size

func (m *InnerOp) Size() (n int)

func (*InnerOp) String

func (m *InnerOp) String() string

func (*InnerOp) Unmarshal

func (m *InnerOp) Unmarshal(dAtA []byte) error

func (*InnerOp) XXX_DiscardUnknown

func (m *InnerOp) XXX_DiscardUnknown()

func (*InnerOp) XXX_Marshal

func (m *InnerOp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*InnerOp) XXX_Merge

func (m *InnerOp) XXX_Merge(src proto.Message)

func (*InnerOp) XXX_Size

func (m *InnerOp) XXX_Size() int

func (*InnerOp) XXX_Unmarshal

func (m *InnerOp) XXX_Unmarshal(b []byte) error

type InnerSpec

type InnerSpec struct {
	// Child order is the ordering of the children node, must count from 0
	// iavl tree is [0, 1] (left then right)
	// merk is [0, 2, 1] (left, right, here)
	ChildOrder      []int32 `protobuf:"varint,1,rep,packed,name=child_order,json=childOrder,proto3" json:"child_order,omitempty"`
	ChildSize       int32   `protobuf:"varint,2,opt,name=child_size,json=childSize,proto3" json:"child_size,omitempty"`
	MinPrefixLength int32   `protobuf:"varint,3,opt,name=min_prefix_length,json=minPrefixLength,proto3" json:"min_prefix_length,omitempty"`
	MaxPrefixLength int32   `protobuf:"varint,4,opt,name=max_prefix_length,json=maxPrefixLength,proto3" json:"max_prefix_length,omitempty"`
	// empty child is the prehash image that is used when one child is nil (eg. 20 bytes of 0)
	EmptyChild []byte `protobuf:"bytes,5,opt,name=empty_child,json=emptyChild,proto3" json:"empty_child,omitempty"`
	// hash is the algorithm that must be used for each InnerOp
	Hash HashOp `protobuf:"varint,6,opt,name=hash,proto3,enum=ics23.HashOp" json:"hash,omitempty"`
}

InnerSpec contains all store-specific structure info to determine if two proofs from a given store are neighbors.

This enables:

isLeftMost(spec: InnerSpec, op: InnerOp) isRightMost(spec: InnerSpec, op: InnerOp) isLeftNeighbor(spec: InnerSpec, left: InnerOp, right: InnerOp)

func (*InnerSpec) Descriptor

func (*InnerSpec) Descriptor() ([]byte, []int)

func (*InnerSpec) GetChildOrder

func (m *InnerSpec) GetChildOrder() []int32

func (*InnerSpec) GetChildSize

func (m *InnerSpec) GetChildSize() int32

func (*InnerSpec) GetEmptyChild

func (m *InnerSpec) GetEmptyChild() []byte

func (*InnerSpec) GetHash

func (m *InnerSpec) GetHash() HashOp

func (*InnerSpec) GetMaxPrefixLength

func (m *InnerSpec) GetMaxPrefixLength() int32

func (*InnerSpec) GetMinPrefixLength

func (m *InnerSpec) GetMinPrefixLength() int32

func (*InnerSpec) Marshal

func (m *InnerSpec) Marshal() (dAtA []byte, err error)

func (*InnerSpec) MarshalTo

func (m *InnerSpec) MarshalTo(dAtA []byte) (int, error)

func (*InnerSpec) MarshalToSizedBuffer

func (m *InnerSpec) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*InnerSpec) ProtoMessage

func (*InnerSpec) ProtoMessage()

func (*InnerSpec) Reset

func (m *InnerSpec) Reset()

func (*InnerSpec) Size

func (m *InnerSpec) Size() (n int)

func (*InnerSpec) String

func (m *InnerSpec) String() string

func (*InnerSpec) Unmarshal

func (m *InnerSpec) Unmarshal(dAtA []byte) error

func (*InnerSpec) XXX_DiscardUnknown

func (m *InnerSpec) XXX_DiscardUnknown()

func (*InnerSpec) XXX_Marshal

func (m *InnerSpec) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*InnerSpec) XXX_Merge

func (m *InnerSpec) XXX_Merge(src proto.Message)

func (*InnerSpec) XXX_Size

func (m *InnerSpec) XXX_Size() int

func (*InnerSpec) XXX_Unmarshal

func (m *InnerSpec) XXX_Unmarshal(b []byte) error

type LeafOp

type LeafOp struct {
	Hash         HashOp   `protobuf:"varint,1,opt,name=hash,proto3,enum=ics23.HashOp" json:"hash,omitempty"`
	PrehashKey   HashOp   `protobuf:"varint,2,opt,name=prehash_key,json=prehashKey,proto3,enum=ics23.HashOp" json:"prehash_key,omitempty"`
	PrehashValue HashOp   `protobuf:"varint,3,opt,name=prehash_value,json=prehashValue,proto3,enum=ics23.HashOp" json:"prehash_value,omitempty"`
	Length       LengthOp `protobuf:"varint,4,opt,name=length,proto3,enum=ics23.LengthOp" json:"length,omitempty"`
	// prefix is a fixed bytes that may optionally be included at the beginning to differentiate
	// a leaf node from an inner node.
	Prefix []byte `protobuf:"bytes,5,opt,name=prefix,proto3" json:"prefix,omitempty"`
}

* LeafOp represents the raw key-value data we wish to prove, and must be flexible to represent the internal transformation from the original key-value pairs into the basis hash, for many existing merkle trees.

key and value are passed in. So that the signature of this operation is: leafOp(key, value) -> output

To process this, first prehash the keys and values if needed (ANY means no hash in this case): hkey = prehashKey(key) hvalue = prehashValue(value)

Then combine the bytes, and hash it output = hash(prefix || length(hkey) || hkey || length(hvalue) || hvalue)

func (*LeafOp) Apply

func (op *LeafOp) Apply(key []byte, value []byte) ([]byte, error)

Apply will calculate the leaf hash given the key and value being proven

func (*LeafOp) CheckAgainstSpec

func (op *LeafOp) CheckAgainstSpec(spec *ProofSpec) error

CheckAgainstSpec will verify the LeafOp is in the format defined in spec

func (*LeafOp) Descriptor

func (*LeafOp) Descriptor() ([]byte, []int)

func (*LeafOp) GetHash

func (m *LeafOp) GetHash() HashOp

func (*LeafOp) GetLength

func (m *LeafOp) GetLength() LengthOp

func (*LeafOp) GetPrefix

func (m *LeafOp) GetPrefix() []byte

func (*LeafOp) GetPrehashKey

func (m *LeafOp) GetPrehashKey() HashOp

func (*LeafOp) GetPrehashValue

func (m *LeafOp) GetPrehashValue() HashOp

func (*LeafOp) Marshal

func (m *LeafOp) Marshal() (dAtA []byte, err error)

func (*LeafOp) MarshalTo

func (m *LeafOp) MarshalTo(dAtA []byte) (int, error)

func (*LeafOp) MarshalToSizedBuffer

func (m *LeafOp) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*LeafOp) ProtoMessage

func (*LeafOp) ProtoMessage()

func (*LeafOp) Reset

func (m *LeafOp) Reset()

func (*LeafOp) Size

func (m *LeafOp) Size() (n int)

func (*LeafOp) String

func (m *LeafOp) String() string

func (*LeafOp) Unmarshal

func (m *LeafOp) Unmarshal(dAtA []byte) error

func (*LeafOp) XXX_DiscardUnknown

func (m *LeafOp) XXX_DiscardUnknown()

func (*LeafOp) XXX_Marshal

func (m *LeafOp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*LeafOp) XXX_Merge

func (m *LeafOp) XXX_Merge(src proto.Message)

func (*LeafOp) XXX_Size

func (m *LeafOp) XXX_Size() int

func (*LeafOp) XXX_Unmarshal

func (m *LeafOp) XXX_Unmarshal(b []byte) error

type LengthOp

type LengthOp int32

* LengthOp defines how to process the key and value of the LeafOp to include length information. After encoding the length with the given algorithm, the length will be prepended to the key and value bytes. (Each one with it's own encoded length)

const (
	// NO_PREFIX don't include any length info
	LengthOp_NO_PREFIX LengthOp = 0
	// VAR_PROTO uses protobuf (and go-amino) varint encoding of the length
	LengthOp_VAR_PROTO LengthOp = 1
	// VAR_RLP uses rlp int encoding of the length
	LengthOp_VAR_RLP LengthOp = 2
	// FIXED32_BIG uses big-endian encoding of the length as a 32 bit integer
	LengthOp_FIXED32_BIG LengthOp = 3
	// FIXED32_LITTLE uses little-endian encoding of the length as a 32 bit integer
	LengthOp_FIXED32_LITTLE LengthOp = 4
	// FIXED64_BIG uses big-endian encoding of the length as a 64 bit integer
	LengthOp_FIXED64_BIG LengthOp = 5
	// FIXED64_LITTLE uses little-endian encoding of the length as a 64 bit integer
	LengthOp_FIXED64_LITTLE LengthOp = 6
	// REQUIRE_32_BYTES is like NONE, but will fail if the input is not exactly 32 bytes (sha256 output)
	LengthOp_REQUIRE_32_BYTES LengthOp = 7
	// REQUIRE_64_BYTES is like NONE, but will fail if the input is not exactly 64 bytes (sha512 output)
	LengthOp_REQUIRE_64_BYTES LengthOp = 8
)

func (LengthOp) EnumDescriptor

func (LengthOp) EnumDescriptor() ([]byte, []int)

func (LengthOp) String

func (x LengthOp) String() string

type NonExistenceProof

type NonExistenceProof struct {
	Key   []byte          `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	Left  *ExistenceProof `protobuf:"bytes,2,opt,name=left,proto3" json:"left,omitempty"`
	Right *ExistenceProof `protobuf:"bytes,3,opt,name=right,proto3" json:"right,omitempty"`
}

NonExistenceProof takes a proof of two neighbors, one left of the desired key, one right of the desired key. If both proofs are valid AND they are neighbors, then there is no valid proof for the given key.

func (*NonExistenceProof) Calculate

func (p *NonExistenceProof) Calculate() (CommitmentRoot, error)

Calculate determines the root hash that matches the given nonexistence rpoog. You must validate the result is what you have in a header. Returns error if the calculations cannot be performed.

func (*NonExistenceProof) Descriptor

func (*NonExistenceProof) Descriptor() ([]byte, []int)

func (*NonExistenceProof) GetKey

func (m *NonExistenceProof) GetKey() []byte

func (*NonExistenceProof) GetLeft

func (m *NonExistenceProof) GetLeft() *ExistenceProof

func (*NonExistenceProof) GetRight

func (m *NonExistenceProof) GetRight() *ExistenceProof

func (*NonExistenceProof) Marshal

func (m *NonExistenceProof) Marshal() (dAtA []byte, err error)

func (*NonExistenceProof) MarshalTo

func (m *NonExistenceProof) MarshalTo(dAtA []byte) (int, error)

func (*NonExistenceProof) MarshalToSizedBuffer

func (m *NonExistenceProof) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*NonExistenceProof) ProtoMessage

func (*NonExistenceProof) ProtoMessage()

func (*NonExistenceProof) Reset

func (m *NonExistenceProof) Reset()

func (*NonExistenceProof) Size

func (m *NonExistenceProof) Size() (n int)

func (*NonExistenceProof) String

func (m *NonExistenceProof) String() string

func (*NonExistenceProof) Unmarshal

func (m *NonExistenceProof) Unmarshal(dAtA []byte) error

func (*NonExistenceProof) Verify

func (p *NonExistenceProof) Verify(spec *ProofSpec, root CommitmentRoot, key []byte) error

Verify does all checks to ensure the proof has valid non-existence proofs, and they ensure the given key is not in the CommitmentState

func (*NonExistenceProof) XXX_DiscardUnknown

func (m *NonExistenceProof) XXX_DiscardUnknown()

func (*NonExistenceProof) XXX_Marshal

func (m *NonExistenceProof) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*NonExistenceProof) XXX_Merge

func (m *NonExistenceProof) XXX_Merge(src proto.Message)

func (*NonExistenceProof) XXX_Size

func (m *NonExistenceProof) XXX_Size() int

func (*NonExistenceProof) XXX_Unmarshal

func (m *NonExistenceProof) XXX_Unmarshal(b []byte) error

type ProofSpec

type ProofSpec struct {
	// any field in the ExistenceProof must be the same as in this spec.
	// except Prefix, which is just the first bytes of prefix (spec can be longer)
	LeafSpec  *LeafOp    `protobuf:"bytes,1,opt,name=leaf_spec,json=leafSpec,proto3" json:"leaf_spec,omitempty"`
	InnerSpec *InnerSpec `protobuf:"bytes,2,opt,name=inner_spec,json=innerSpec,proto3" json:"inner_spec,omitempty"`
	// max_depth (if > 0) is the maximum number of InnerOps allowed (mainly for fixed-depth tries)
	MaxDepth int32 `protobuf:"varint,3,opt,name=max_depth,json=maxDepth,proto3" json:"max_depth,omitempty"`
	// min_depth (if > 0) is the minimum number of InnerOps allowed (mainly for fixed-depth tries)
	MinDepth int32 `protobuf:"varint,4,opt,name=min_depth,json=minDepth,proto3" json:"min_depth,omitempty"`
}

* ProofSpec defines what the expected parameters are for a given proof type. This can be stored in the client and used to validate any incoming proofs.

verify(ProofSpec, Proof) -> Proof | Error

As demonstrated in tests, if we don't fix the algorithm used to calculate the LeafHash for a given tree, there are many possible key-value pairs that can generate a given hash (by interpretting the preimage differently). We need this for proper security, requires client knows a priori what tree format server uses. But not in code, rather a configuration object.

func (*ProofSpec) Descriptor

func (*ProofSpec) Descriptor() ([]byte, []int)

func (*ProofSpec) GetInnerSpec

func (m *ProofSpec) GetInnerSpec() *InnerSpec

func (*ProofSpec) GetLeafSpec

func (m *ProofSpec) GetLeafSpec() *LeafOp

func (*ProofSpec) GetMaxDepth

func (m *ProofSpec) GetMaxDepth() int32

func (*ProofSpec) GetMinDepth

func (m *ProofSpec) GetMinDepth() int32

func (*ProofSpec) Marshal

func (m *ProofSpec) Marshal() (dAtA []byte, err error)

func (*ProofSpec) MarshalTo

func (m *ProofSpec) MarshalTo(dAtA []byte) (int, error)

func (*ProofSpec) MarshalToSizedBuffer

func (m *ProofSpec) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*ProofSpec) ProtoMessage

func (*ProofSpec) ProtoMessage()

func (*ProofSpec) Reset

func (m *ProofSpec) Reset()

func (*ProofSpec) Size

func (m *ProofSpec) Size() (n int)

func (*ProofSpec) String

func (m *ProofSpec) String() string

func (*ProofSpec) Unmarshal

func (m *ProofSpec) Unmarshal(dAtA []byte) error

func (*ProofSpec) XXX_DiscardUnknown

func (m *ProofSpec) XXX_DiscardUnknown()

func (*ProofSpec) XXX_Marshal

func (m *ProofSpec) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ProofSpec) XXX_Merge

func (m *ProofSpec) XXX_Merge(src proto.Message)

func (*ProofSpec) XXX_Size

func (m *ProofSpec) XXX_Size() int

func (*ProofSpec) XXX_Unmarshal

func (m *ProofSpec) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL