Skip to content

Add SmtProof::authenticated_nodes #516

@PhilippGackstatter

Description

@PhilippGackstatter

In miden-base, we have AssetWitness (which wraps an SmtProof) define the following method:

/// Returns an iterator over every inner node of this witness' merkle path.
pub fn authenticated_nodes(&self) -> impl Iterator<Item = InnerNodeInfo> + '_ {
    self.0
        .path()
        .authenticated_nodes(self.0.leaf().index().value(), self.0.leaf().hash())
        .expect("leaf index is u64 and should be less than 2^SMT_DEPTH")
}

and similarly, AccountWitness (which conceptually wraps an SmtProof) define the following method:

/// Returns an iterator over every inner node of this witness' merkle path.
pub fn authenticated_nodes(&self) -> impl Iterator<Item = InnerNodeInfo> + '_ {
    let leaf = self.leaf();
    self.path()
        .authenticated_nodes(leaf.index().value(), leaf.hash())
        .expect("leaf index is u64 and should be less than 2^SMT_DEPTH")
}

It would be great to have this be available on SmtProof directly, e.g. SmtProof::authenticated_nodes.

This came up in 0xMiden/miden-base#1848.

Metadata

Metadata

Assignees

No one assigned

    Labels

    merkleRelated to Merkle trees or MMRs

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions