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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more