public interface MerkleTreeNodeSource
MerkleTreePrimitives, backed by whatever a log or CA keeps its tree in.
The generators walk the tree in the recursive form of RFC 9162 Section 2.1 and
the draft's Section 4.4.1, and every hash they need is either a full
subtree - a range [start, end) whose size is a power of two and
whose start is a multiple of that size, MTH(D[start:end]) being one
node of the tree - or a right-hand range that
MerkleTreePrimitives.computeMerkleTreeHash(MerkleTreeNodeSource, long, long, MerkleTreeHash)
combines from at most one full subtree per level. So a production log, which
cannot hold its entries in memory, only has to answer for the nodes it would
store or cache anyway; an in-memory tree of entry hashes can be adapted with
ListMerkleTreeNodeSource.
A proof over a tree of size n makes O(log n) requests per
proof element for a range that is not itself full, O(log^2 n) in all.
Requests are never made outside the ranges the caller passed to the generator,
so an implementation may treat any other request as an error.
| Modifier and Type | Method and Description |
|---|---|
byte[] |
getFullSubtreeHash(long start,
long end)
Returns the hash
MTH(D[start:end]) of a full subtree. |
byte[] getFullSubtreeHash(long start,
long end)
MTH(D[start:end]) of a full subtree.start - subtree start index (inclusive), a multiple of end - startend - subtree end index (exclusive); end - start is a power of twoend == start + 1 this is the entry hash
MTH({entry}), i.e. MerkleTreeHash.hashLeaf(byte[]) of the entryjava.lang.IllegalArgumentException - if the node is not available, for instance because
end is beyond the tree's current size