Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func VerifyMerklePath ¶
VerifyMerklePath verifies a Merkle tree path against the expected root hash.
Types ¶
type MerkleNode ¶
type MerkleNode struct { Left *MerkleNode // Left child of the current node. Right *MerkleNode // Right child of the current node. Data *big.Int // Hash of the current node. }
MerkleNode represents an individual node in the Merkle Tree.
type MerklePathItem ¶
type MerklePathItem struct { SiblingHash *big.Int // Hash of the sibling in the Merkle Path. IsRight bool // Indicates whether this sibling node is a right child. }
MerklePathItem represents an item in the Merkle tree path.
type SparseMerkleTree ¶
type SparseMerkleTree struct { Root *MerkleNode // The root node of the Sparse Merkle Tree. Depth int // The depth of the Sparse Merkle Tree. Leaves map[string]*big.Int // The leaves of the Sparse Merkle Tree, where keys are the binary representation of the index. ZeroLeaf *big.Int // Hash of the zero leaf. }
SparseMerkleTree represents a sparse Merkle tree.
func NewDeterministicSparseMerkleTree ¶
func NewDeterministicSparseMerkleTree(depth int, zeroLeaf *big.Int) *SparseMerkleTree
NewDeterministicSparseMerkleTree creates a new deterministic sparse Merkle tree with non-null leaves.
func NewSparseMerkleTree ¶
func NewSparseMerkleTree(depth int, zeroLeaf *big.Int) *SparseMerkleTree
NewSparseMerkleTree creates a new sparse Merkle tree with empty leaves.
func (*SparseMerkleTree) GenerateMerklePath ¶
func (smt *SparseMerkleTree) GenerateMerklePath(index int) ([]*MerklePathItem, error)
GenerateMerklePath generates a Merkle tree path for the leaf with the given index.
Click to show internal directories.
Click to hide internal directories.