Module mmr

Source
Expand description

MMR (Merkle Mountain Range) proof verification

Functions for verifying that headers are committed in MMRs using inclusion proofs.

Structsยง

KeccakHasher ๐Ÿ”’
Keccak-based hasher using B256 as the word type.
MmrVerifier
PoseidonHasher ๐Ÿ”’
Poseidon-based hasher using Felt as the word type.

Traitsยง

MmrHasher ๐Ÿ”’

Functionsยง

assert_mmr_size_is_valid ๐Ÿ”’
Validates that an MMR size can be decomposed into distinct peaks of the form (2^k - 1).
bit_length ๐Ÿ”’
Returns the number of bits required to represent n (0 => 0, 1.. => floor(log2(n)) + 1).
compute_expected_peaks_len ๐Ÿ”’
Computes how many peaks an MMR of mmr_size elements should have.
compute_height ๐Ÿ”’
Computes the height in the implicit binary tree for a 1-indexed position x.
get_peak_info ๐Ÿ”’
Returns (peak_index, peak_height) for the 1-indexed element_index in an MMR with elements_count total elements. The height is the number of edges from the leaf to the peak.
hash_subtree_path_iter ๐Ÿ”’
Iterative subtree path hashing generic over the hasher.
verify_with_hasher ๐Ÿ”’
Generic verification with a concrete MmrHasher implementation.