pub struct MerkleProof {
pub tree_size: usize,
pub leaf_index: usize,
pub audit_path: Vec<Hash>,
}Expand description
Merkle inclusion proof.
Fields§
§tree_size: usizeTotal number of leaves in the tree.
leaf_index: usizeIndex of the leaf being proved.
audit_path: Vec<Hash>Audit path (sibling hashes from leaf to root).
Implementations§
Source§impl MerkleProof
impl MerkleProof
Sourcepub fn compute_root(&self, leaf_bytes: &[u8]) -> Result<Hash, Error>
pub fn compute_root(&self, leaf_bytes: &[u8]) -> Result<Hash, Error>
Compute the root from leaf bytes and the proof.
Sourcepub fn compute_root_from_hash(&self, lh: Hash) -> Result<Hash, Error>
pub fn compute_root_from_hash(&self, lh: Hash) -> Result<Hash, Error>
Compute the root from a pre-hashed leaf and the proof.
Sourcepub fn verify(&self, leaf_bytes: &[u8], expected_root: &Hash) -> bool
pub fn verify(&self, leaf_bytes: &[u8], expected_root: &Hash) -> bool
Verify the proof against an expected root.
Sourcepub fn verify_hash(&self, lh: Hash, expected_root: &Hash) -> bool
pub fn verify_hash(&self, lh: Hash, expected_root: &Hash) -> bool
Verify the proof from a pre-hashed leaf.
Trait Implementations§
Source§impl Clone for MerkleProof
impl Clone for MerkleProof
Source§fn clone(&self) -> MerkleProof
fn clone(&self) -> MerkleProof
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MerkleProof
impl Debug for MerkleProof
Source§impl<'de> Deserialize<'de> for MerkleProof
impl<'de> Deserialize<'de> for MerkleProof
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<MerkleProof, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<MerkleProof, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for MerkleProof
impl Serialize for MerkleProof
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for MerkleProof
impl RefUnwindSafe for MerkleProof
impl Send for MerkleProof
impl Sync for MerkleProof
impl Unpin for MerkleProof
impl UnsafeUnpin for MerkleProof
impl UnwindSafe for MerkleProof
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