Struct miden_crypto::merkle::TieredSmtProof
source · pub struct TieredSmtProof { /* private fields */ }
Expand description
A proof which can be used to assert membership (or non-membership) of key-value pairs in a Tiered Sparse Merkle tree.
The proof consists of a Merkle path and one or more key-value entries which describe the node located at the base of the path. If the node at the base of the path resolves to [ZERO; 4], the entries will contain a single item with value set to [ZERO; 4].
Implementations§
source§impl TieredSmtProof
impl TieredSmtProof
sourcepub fn new<I>(path: MerklePath, entries: I) -> Result<Self, TieredSmtProofError>where
I: IntoIterator<Item = (RpoDigest, Word)>,
pub fn new<I>(path: MerklePath, entries: I) -> Result<Self, TieredSmtProofError>where I: IntoIterator<Item = (RpoDigest, Word)>,
Returns a new instance of TieredSmtProof instantiated from the specified path and entries.
Panics
Panics if:
- The length of the path is greater than 64.
- Entries is an empty vector.
- Entries contains more than 1 item, but the length of the path is not 64.
- Entries contains more than 1 item, and one of the items has value set to [ZERO; 4].
- Entries contains multiple items with keys which don’t share the same 64-bit prefix.
sourcepub fn verify_membership(
&self,
key: &RpoDigest,
value: &Word,
root: &RpoDigest
) -> bool
pub fn verify_membership( &self, key: &RpoDigest, value: &Word, root: &RpoDigest ) -> bool
Returns true if a Tiered Sparse Merkle tree with the specified root contains the provided key-value pair.
Note: this method cannot be used to assert non-membership. That is, if false is returned, it does not mean that the provided key-value pair is not in the tree.
sourcepub fn get(&self, key: &RpoDigest) -> Option<Word>
pub fn get(&self, key: &RpoDigest) -> Option<Word>
Returns the value associated with the specific key according to this proof, or None if this proof does not contain a value for the specified key.
A key-value pair generated by using this method should pass the verify_membership()
check.
sourcepub fn compute_root(&self) -> RpoDigest
pub fn compute_root(&self) -> RpoDigest
Computes the root of a Tiered Sparse Merkle tree to which this proof resolve.
sourcepub fn into_parts(self) -> (MerklePath, Vec<(RpoDigest, Word)>)
pub fn into_parts(self) -> (MerklePath, Vec<(RpoDigest, Word)>)
Consume the proof and returns its parts.
Trait Implementations§
source§impl Debug for TieredSmtProof
impl Debug for TieredSmtProof
source§impl PartialEq for TieredSmtProof
impl PartialEq for TieredSmtProof
source§fn eq(&self, other: &TieredSmtProof) -> bool
fn eq(&self, other: &TieredSmtProof) -> bool
self
and other
values to be equal, and is used
by ==
.