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

source

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.
source

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.

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 Tiered Sparse Merkle tree to which this proof resolve.

source

pub fn into_parts(self) -> (MerklePath, Vec<(RpoDigest, Word)>)

Consume the proof and returns its parts.

Trait Implementations§

source§

impl Debug for TieredSmtProof

source§

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

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

impl PartialEq for TieredSmtProof

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

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

impl Eq for TieredSmtProof

source§

impl StructuralEq for TieredSmtProof

source§

impl StructuralPartialEq for TieredSmtProof

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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

§

type Output = T

Should always be Self
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.