mt

package
v0.0.0-...-c101335 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

In-memory Merkle Tree which implements an authenticated list.

Index

Constants

This section is empty.

Variables

View Source
var InternalSeparator = []byte("MT::InternalNode")
View Source
var LeafSeparator = []byte("MT::LeafNode")
View Source
var MerklePlaceholderDigest = Digest([]byte("MERKLE_PLACEHOLDER_HASH_________"))

Functions

func MaxProofLength

func MaxProofLength(leafCount int) int

MaxProofLength returns the maximum possible length of a Merkle proof (i.e. number of sibling digests) for a tree with the given number of leaves. This is an upper bound on the proof length, not necessarily the exact length of all proofs for a given leaf count.

func Verify

func Verify(expectedRootDigest Digest, index uint64, leafPreimage []byte, proof []Digest) error

Verify verifies that leafPreimage is preimage of the index-th leaf in the Merkle tree rooted at expectedRootDigest.

Types

type Digest

type Digest = [sha256.Size]byte

func Prove

func Prove(leafPreimages [][]byte, index uint64) ([]Digest, error)

Prove generates a Merkle inclusion proof that the leafPreimage at index is included in the tree rooted at Root(leafPreimages).

func Root

func Root(leafPreimages [][]byte) Digest

Root computes the Merkle tree root from leaf preimages.

Jump to

Keyboard shortcuts

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