pub struct TileHashReader<S: TileStore> { /* private fields */ }Expand description
Reads the tiles a root or a proof needs, and no tile that has not been checked against the trusted root: the partial tiles together through the root they fold to, each full tile through its hash in the level above.
Implementations§
Source§impl<S: TileStore> TileHashReader<S>
impl<S: TileStore> TileHashReader<S>
Sourcepub fn new(store: S, size: u64, root: Hash) -> Self
pub fn new(store: S, size: u64, root: Hash) -> Self
A reader over store that trusts root to be the root at size.
Sourcepub fn trusted_root(&self) -> Hash
pub fn trusted_root(&self) -> Hash
The trusted root.
Sourcepub fn root(&self) -> Result<Hash>
pub fn root(&self) -> Result<Hash>
The root recomputed from the partial tiles in the store; an error when it is not the trusted one.
Sourcepub fn tile(&self, level: u8, index: u64) -> Result<Rc<Vec<Hash>>>
pub fn tile(&self, level: u8, index: u64) -> Result<Rc<Vec<Hash>>>
The hashes of the tile at level and index, checked against the
tree. A tile the tree of this size does not have is out of range.
Sourcepub fn hash(&self, level: u8, index: u64) -> Result<Hash>
pub fn hash(&self, level: u8, index: u64) -> Result<Hash>
Stored hash index at level: the root over leaves
[index * 256^level, (index + 1) * 256^level).
Sourcepub fn perfect(&self, start: u64, height: u32) -> Result<Hash>
pub fn perfect(&self, start: u64, height: u32) -> Result<Hash>
The root of the perfect subtree over leaves [start, start + 2^height),
which must be aligned and inside the tree.
Sourcepub fn range_root(&self, lo: u64, hi: u64) -> Result<Hash>
pub fn range_root(&self, lo: u64, hi: u64) -> Result<Hash>
The RFC 9162 root over leaves [lo, hi) of this tree, the same bytes
rfc9162::root gives over that slice of leaf hashes.
Sourcepub fn inclusion_proof(&self, index: u64) -> Result<Option<Vec<Hash>>>
pub fn inclusion_proof(&self, index: u64) -> Result<Option<Vec<Hash>>>
The audit path for the leaf at index, RFC 9162 section 2.1.3,
assembled from tiles: the bytes rfc9162::inclusion_proof gives over
the flat leaf slice. Nothing for an index past the size.
Sourcepub fn consistency_proof(&self, old: u64) -> Result<Option<Vec<Hash>>>
pub fn consistency_proof(&self, old: u64) -> Result<Option<Vec<Hash>>>
The consistency proof that the tree of old leaves is a prefix of
this one, RFC 9162 section 2.1.4, assembled from tiles: the bytes
rfc9162::consistency_proof gives over the flat leaf slice. Nothing
when old is zero or past the size.