pub struct RootHash { /* private fields */ }Expand description
Root hash of an AppendOnlyTree at a particular size.
Wraps ct_merkle::RootHash<Sha256>, which carries both the 32-byte
SHA-256 Merkle Tree Hash and the number of leaves. The leaf count is part
of the root because ct-merkle’s verifier uses it to size proofs — a bare
32-byte hash without the count cannot drive verification.
Implementations§
Source§impl RootHash
impl RootHash
Sourcepub fn from_parts(root_hash: [u8; 32], num_leaves: u64) -> Self
pub fn from_parts(root_hash: [u8; 32], num_leaves: u64) -> Self
Reconstructs a root hash from its published parts: the 32-byte SHA-256 Merkle Tree Hash and the leaf count at which that root was computed.
This is the entry point for external verifiers. A transparency
log publishes (root bytes, leaf count) — obtained from
Self::to_parts — alongside proof bytes; a third party that holds
only those published primitives reconstructs the root with this
constructor and then verifies proofs via verify_inclusion /
verify_consistency without ever having access to the tree
itself.
No validation is possible at construction time — a root hash is an opaque commitment. Supplying bytes or a leaf count that do not match the tree that produced the proofs causes verification to fail, which is exercised by this module’s tests.
Sourcepub fn to_parts(&self) -> ([u8; 32], u64)
pub fn to_parts(&self) -> ([u8; 32], u64)
Returns the published parts of this root: the 32-byte SHA-256 Merkle Tree Hash and the leaf count at which it was computed.
The returned pair is exactly what Self::from_parts accepts, so a
log operator publishes these two values and an external verifier
reconstructs an equal RootHash from them.
Sourcepub fn num_leaves(&self) -> u64
pub fn num_leaves(&self) -> u64
Returns the number of leaves in the tree at the time this root was computed.