Struct jmt::proof::SparseMerkleProof
source · pub struct SparseMerkleProof<H: SimpleHasher> { /* private fields */ }
Expand description
A proof that can be used to authenticate an element in a Sparse Merkle Tree given trusted root
hash. For example, TransactionInfoToAccountProof
can be constructed on top of this structure.
Implementations§
source§impl<H: SimpleHasher> SparseMerkleProof<H>
impl<H: SimpleHasher> SparseMerkleProof<H>
sourcepub fn leaf(&self) -> Option<SparseMerkleLeafNode>
pub fn leaf(&self) -> Option<SparseMerkleLeafNode>
Returns the leaf node in this proof.
sourcepub fn verify_existence<V: AsRef<[u8]>>(
&self,
expected_root_hash: RootHash,
element_key: KeyHash,
element_value: V
) -> Result<()>
pub fn verify_existence<V: AsRef<[u8]>>( &self, expected_root_hash: RootHash, element_key: KeyHash, element_value: V ) -> Result<()>
Verifies an element whose key is element_key
and value is
element_value
exists in the Sparse Merkle Tree using the provided proof.
sourcepub fn verify_nonexistence(
&self,
expected_root_hash: RootHash,
element_key: KeyHash
) -> Result<()>
pub fn verify_nonexistence( &self, expected_root_hash: RootHash, element_key: KeyHash ) -> Result<()>
Verifies the proof is a valid non-inclusion proof that shows this key doesn’t exist in the tree.
sourcepub fn verify<V: AsRef<[u8]>>(
&self,
expected_root_hash: RootHash,
element_key: KeyHash,
element_value: Option<V>
) -> Result<()>
pub fn verify<V: AsRef<[u8]>>( &self, expected_root_hash: RootHash, element_key: KeyHash, element_value: Option<V> ) -> Result<()>
If element_value
is present, verifies an element whose key is element_key
and value is
element_value
exists in the Sparse Merkle Tree using the provided proof. Otherwise
verifies the proof is a valid non-inclusion proof that shows this key doesn’t exist in the
tree.
pub fn root_hash(&self) -> RootHash
Trait Implementations§
source§impl<H: SimpleHasher> BorshDeserialize for SparseMerkleProof<H>
impl<H: SimpleHasher> BorshDeserialize for SparseMerkleProof<H>
fn deserialize_reader<R: Read>(reader: &mut R) -> Result<Self, Error>
§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
Deserializes this instance from a given slice of bytes.
Updates the buffer to point at the remaining bytes.
§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
Deserialize this instance from a slice of bytes.
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
source§impl<H: SimpleHasher> BorshSerialize for SparseMerkleProof<H>
impl<H: SimpleHasher> BorshSerialize for SparseMerkleProof<H>
source§impl<H: SimpleHasher> Clone for SparseMerkleProof<H>
impl<H: SimpleHasher> Clone for SparseMerkleProof<H>
source§impl<H: SimpleHasher> Debug for SparseMerkleProof<H>
impl<H: SimpleHasher> Debug for SparseMerkleProof<H>
source§impl<'de, H: SimpleHasher> Deserialize<'de> for SparseMerkleProof<H>
impl<'de, H: SimpleHasher> Deserialize<'de> for SparseMerkleProof<H>
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<H: SimpleHasher> PartialEq for SparseMerkleProof<H>
impl<H: SimpleHasher> PartialEq for SparseMerkleProof<H>
source§impl<H: SimpleHasher> Serialize for SparseMerkleProof<H>
impl<H: SimpleHasher> Serialize for SparseMerkleProof<H>
Auto Trait Implementations§
impl<H> Freeze for SparseMerkleProof<H>
impl<H> RefUnwindSafe for SparseMerkleProof<H>where
H: RefUnwindSafe,
impl<H> Send for SparseMerkleProof<H>where
H: Send,
impl<H> Sync for SparseMerkleProof<H>where
H: Sync,
impl<H> Unpin for SparseMerkleProof<H>where
H: Unpin,
impl<H> UnwindSafe for SparseMerkleProof<H>where
H: UnwindSafe,
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
Mutably borrows from an owned value. Read more