pub struct RootHash<H: Digest> { /* private fields */ }Expand description
The root hash of a Merkle tree. This uniquely represents the tree.
Implementations§
Source§impl<H: Digest> RootHash<H>
impl<H: Digest> RootHash<H>
Sourcepub fn verify_consistency(
&self,
old_root: &RootHash<H>,
proof: &ConsistencyProof<H>,
) -> Result<(), ConsistencyVerifError>
pub fn verify_consistency( &self, old_root: &RootHash<H>, proof: &ConsistencyProof<H>, ) -> Result<(), ConsistencyVerifError>
Verifies a proof that the tree described by old_root is a prefix of the tree described by
self. This does not panic.
§Note
Verification success does NOT imply that the size of the tree that produced the proof equals
self.num_leaves(), or that the old tree size was old_root.num_leaves(). For any given
proof, there are multiple tree size combinations that could have produced it.
Source§impl<H: Digest> RootHash<H>
impl<H: Digest> RootHash<H>
Sourcepub fn verify_inclusion<T: HashableLeaf>(
&self,
val: &T,
idx: u64,
proof: &InclusionProof<H>,
) -> Result<(), InclusionVerifError>
pub fn verify_inclusion<T: HashableLeaf>( &self, val: &T, idx: u64, proof: &InclusionProof<H>, ) -> Result<(), InclusionVerifError>
Verifies that val occurs at index idx in the tree described by this RootHash. This
does not panic.
§Note
Verification success does NOT imply that the size of the tree that produced the proof equals
self.num_leaves(). For any given proof, there are multiple tree sizes that could have
produced it.
Source§impl<H: Digest> RootHash<H>
impl<H: Digest> RootHash<H>
Sourcepub fn new(digest: Output<H>, num_leaves: u64) -> RootHash<H>
pub fn new(digest: Output<H>, num_leaves: u64) -> RootHash<H>
Constructs a RootHash from the given hash digest and the number of leaves in the tree
that created it.
Sourcepub fn as_bytes(&self) -> &Output<H>
pub fn as_bytes(&self) -> &Output<H>
Returns the Merkle Tree Hash of the tree that created this RootHash.
This is precisely the Merkle Tree Hash (MTH) of the tree that created it, as defined in RFC 6962 §2.1.
Sourcepub fn num_leaves(&self) -> u64
pub fn num_leaves(&self) -> u64
Returns the number of leaves in the tree that created this RootHash.