miden_crypto::merkle

Struct 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

source

pub fn new(path: MerklePath, leaf: SmtLeaf) -> Result<Self, SmtProofError>

Returns a new instance of SmtProof instantiated from the specified path and leaf.

§Errors

Returns an error if the path length is not SMT_DEPTH.

source

pub fn verify_membership( &self, key: &RpoDigest, value: &Word, 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.

source

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.

source

pub fn compute_root(&self) -> RpoDigest

Computes the root of a super::Smt to which this proof resolves.

source

pub fn path(&self) -> &MerklePath

Returns the proof’s Merkle path.

source

pub fn leaf(&self) -> &SmtLeaf

Returns the leaf associated with the proof.

source

pub fn into_parts(self) -> (MerklePath, SmtLeaf)

Consume the proof and returns its parts.

Trait Implementations§

source§

impl Clone for SmtProof

source§

fn clone(&self) -> SmtProof

Returns a copy of the value. Read more
1.6.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for SmtProof

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Deserializable for SmtProof

source§

fn read_from<R: ByteReader>( source: &mut R, ) -> Result<Self, DeserializationError>

Reads a sequence of bytes from the provided source, attempts to deserialize these bytes into Self, and returns the result. Read more
source§

fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>

Attempts to deserialize the provided bytes into Self and returns the result. Read more
source§

impl PartialEq for SmtProof

source§

fn eq(&self, other: &SmtProof) -> bool

Tests for self and other values to be equal, and is used by ==.
1.6.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serializable for SmtProof

source§

fn write_into<W: ByteWriter>(&self, target: &mut W)

Serializes self into bytes and writes these bytes into the target.
source§

fn to_bytes(&self) -> Vec<u8>

Serializes self into a vector of bytes.
source§

fn get_size_hint(&self) -> usize

Returns an estimate of how many bytes are needed to represent self. Read more
source§

impl Eq for SmtProof

source§

impl StructuralPartialEq for SmtProof

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V