Documentation ¶
Index ¶
Constants ¶
View Source
const BinaryMerkleTreeDepth = 16
BinaryMerkleTreeDepth is the depth of the merkle tree.
Variables ¶
View Source
var ( // MaxLeafCount is the maximum number of leaves in the merkle tree. MaxLeafCount = 1<<BinaryMerkleTreeDepth - 1 // 2^16 - 1 )
Functions ¶
This section is empty.
Types ¶
type BinaryMerkleTree ¶
type BinaryMerkleTree struct { Root *merkleNode LeafCount uint64 }
BinaryMerkleTree is a binary hash tree that uses the keccak256 hash function. It is an append-only tree, where leaves are added from left to right.
func NewBinaryMerkleTree ¶
func NewBinaryMerkleTree() *BinaryMerkleTree
func (*BinaryMerkleTree) AddLeaf ¶
func (m *BinaryMerkleTree) AddLeaf(hash common.Hash)
AddLeaf adds a leaf to the binary merkle tree.
func (*BinaryMerkleTree) ProofAtIndex ¶
func (m *BinaryMerkleTree) ProofAtIndex(index uint64) (proof Proof)
ProofAtIndex returns a merkle proof at the given leaf node index.
func (*BinaryMerkleTree) RootHash ¶
func (m *BinaryMerkleTree) RootHash() (rootHash common.Hash)
RootHash returns the root hash of the binary merkle tree.
type Proof ¶
type Proof [BinaryMerkleTreeDepth]common.Hash
Proof is a list of [common.Hash]s that prove the merkle inclusion of a leaf. These are the sibling hashes of the leaf's path from the root to the leaf.
Click to show internal directories.
Click to hide internal directories.