Documentation ¶
Overview ¶
Updated for Herdius Requirements Original Copyright (c) Tendermint Core. https://github.com/tendermint/tendermint/blob/master/LICENSE
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SimpleHashFromByteSlices ¶
SimpleHashFromByteSlices computes a Merkle tree where the leaves are the byte slice, in the provided order.
func SimpleHashFromMap ¶
SimpleHashFromMap computes a Merkle tree from sorted map. Like calling SimpleHashFromHashers with `item = []byte(Hash(key) | Hash(value))`, sorted by `item`.
func SimpleProofsFromMap ¶
func SimpleProofsFromMap(m map[string][]byte) (rootHash []byte, proofs map[string]*SimpleProof, keys []string)
SimpleProofsFromMap generates proofs from a map. The keys/values of the map will be used as the keys/values in the underlying key-value pairs. The keys are sorted before the proofs are computed.
Types ¶
type KVPair ¶
A local extension to KVPair that can be hashed. Key and value are length prefixed and concatenated, then hashed.
type SimpleProof ¶
type SimpleProof struct { Total int `json:"total"` // Total number of items. Index int `json:"index"` // Index of item to prove. LeafHash []byte `json:"leaf_hash"` // Hash of item value. Aunts [][]byte `json:"aunts"` // Hashes from leaf's sibling to a root's child. }
SimpleProof represents a simple Merkle proof.
func SimpleProofsFromByteSlices ¶
func SimpleProofsFromByteSlices(items [][]byte) (rootHash []byte, proofs []*SimpleProof)
SimpleProofsFromByteSlices computes inclusion proof for given items. proofs[0] is the proof for items[0].
func (*SimpleProof) ComputeRootHash ¶
func (sp *SimpleProof) ComputeRootHash() []byte
Compute the root hash given a leaf hash. Does not verify the result.
func (*SimpleProof) String ¶
func (sp *SimpleProof) String() string
String implements the stringer interface for SimpleProof. It is a wrapper around StringIndented.
func (*SimpleProof) StringIndented ¶
func (sp *SimpleProof) StringIndented(indent string) string
StringIndented generates a canonical string representation of a SimpleProof.
type SimpleProofNode ¶
type SimpleProofNode struct { Hash []byte Parent *SimpleProofNode Left *SimpleProofNode // Left sibling (only one of Left,Right is set) Right *SimpleProofNode // Right sibling (only one of Left,Right is set) }
SimpleProofNode is a helper structure to construct merkle proof. The node and the tree is thrown away afterwards. Exactly one of node.Left and node.Right is nil, unless node is the root, in which case both are nil. node.Parent.Hash = hash(node.Hash, node.Right.Hash) or hash(node.Left.Hash, node.Hash), depending on whether node is a left/right child.
func (*SimpleProofNode) FlattenAunts ¶
func (spn *SimpleProofNode) FlattenAunts() [][]byte
FlattenAunts will return the inner hashes for the item corresponding to the leaf, starting from a leaf SimpleProofNode.