merkle

package
v1.7.4 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 2 Imported by: 0

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

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.

Jump to

Keyboard shortcuts

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