Struct miden_core::crypto::merkle::Mmr
source · pub struct Mmr { /* private fields */ }
Expand description
A fully materialized Merkle Mountain Range, with every tree in the forest and all their elements.
Since this is a full representation of the MMR, elements are never removed and the MMR will
grow roughly O(2n)
in number of leaf elements.
Implementations§
source§impl Mmr
impl Mmr
sourcepub const fn forest(&self) -> usize
pub const fn forest(&self) -> usize
Returns the MMR forest representation.
The forest value has the following interpretations:
- its value is the number of elements in the forest
- bit count corresponds to the number of trees in the forest
- each true bit position determines the depth of a tree in the forest
sourcepub fn open(&self, pos: usize) -> Result<MmrProof, MmrError>
pub fn open(&self, pos: usize) -> Result<MmrProof, MmrError>
Given a leaf position, returns the Merkle path to its corresponding peak. If the position is greater-or-equal than the tree size an error is returned.
Note: The leaf position is the 0-indexed number corresponding to the order the leaves were added, this corresponds to the MMR size prior to adding the element. So the 1st element has position 0, the second position 1, and so on.
sourcepub fn get(&self, pos: usize) -> Result<RpoDigest, MmrError>
pub fn get(&self, pos: usize) -> Result<RpoDigest, MmrError>
Returns the leaf value at position pos
.
Note: The leaf position is the 0-indexed number corresponding to the order the leaves were added, this corresponds to the MMR size prior to adding the element. So the 1st element has position 0, the second position 1, and so on.
sourcepub fn accumulator(&self) -> MmrPeaks
pub fn accumulator(&self) -> MmrPeaks
Returns an accumulator representing the current state of the MMR.
sourcepub fn inner_nodes(&self) -> MmrNodes<'_>
pub fn inner_nodes(&self) -> MmrNodes<'_>
An iterator over inner nodes in the MMR. The order of iteration is unspecified.