Struct miden_objects::crypto::merkle::SmtProof
source · pub struct SmtProof { /* private fields */ }Expand description
A proof which can be used to assert membership (or non-membership) of key-value pairs in a
super::Smt.
The proof consists of a Merkle path and leaf which describes the node located at the base of the path.
Implementations§
source§impl SmtProof
impl SmtProof
sourcepub fn new(path: MerklePath, leaf: SmtLeaf) -> Result<SmtProof, SmtProofError>
pub fn new(path: MerklePath, leaf: SmtLeaf) -> Result<SmtProof, SmtProofError>
sourcepub fn verify_membership(
&self,
key: &RpoDigest,
value: &[BaseElement; 4],
root: &RpoDigest
) -> bool
pub fn verify_membership( &self, key: &RpoDigest, value: &[BaseElement; 4], root: &RpoDigest ) -> bool
Returns true if a super::Smt 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<[BaseElement; 4]>
pub fn get(&self, key: &RpoDigest) -> Option<[BaseElement; 4]>
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 super::Smt to which this proof resolves.
sourcepub fn path(&self) -> &MerklePath
pub fn path(&self) -> &MerklePath
Returns the proof’s Merkle path.
sourcepub fn into_parts(self) -> (MerklePath, SmtLeaf)
pub fn into_parts(self) -> (MerklePath, SmtLeaf)
Consume the proof and returns its parts.
Trait Implementations§
source§impl Deserializable for SmtProof
impl Deserializable for SmtProof
source§fn read_from<R>(source: &mut R) -> Result<SmtProof, DeserializationError>where
R: ByteReader,
fn read_from<R>(source: &mut R) -> Result<SmtProof, DeserializationError>where
R: ByteReader,
source, attempts to deserialize these bytes
into Self, and returns the result. Read moresource§fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
source§impl PartialEq for SmtProof
impl PartialEq for SmtProof
source§impl Serializable for SmtProof
impl Serializable for SmtProof
source§fn write_into<W>(&self, target: &mut W)where
W: ByteWriter,
fn write_into<W>(&self, target: &mut W)where
W: ByteWriter,
self into bytes and writes these bytes into the target.