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<Self, SmtProofError>
pub fn new(path: MerklePath, leaf: SmtLeaf) -> Result<Self, SmtProofError>
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 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<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 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: ByteReader>(
source: &mut R,
) -> Result<Self, DeserializationError>
fn read_from<R: ByteReader>( source: &mut R, ) -> Result<Self, DeserializationError>
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 Serializable for SmtProof
impl Serializable for SmtProof
source§fn write_into<W: ByteWriter>(&self, target: &mut W)
fn write_into<W: ByteWriter>(&self, target: &mut W)
self
into bytes and writes these bytes into the target
.source§fn get_size_hint(&self) -> usize
fn get_size_hint(&self) -> usize
impl Eq for SmtProof
impl StructuralPartialEq for SmtProof
Auto Trait Implementations§
impl Freeze for SmtProof
impl RefUnwindSafe for SmtProof
impl Send for SmtProof
impl Sync for SmtProof
impl Unpin for SmtProof
impl UnwindSafe for SmtProof
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)