Package org.bouncycastle.cert.plants
Class ListMerkleTreeNodeSource
- java.lang.Object
-
- org.bouncycastle.cert.plants.ListMerkleTreeNodeSource
-
- All Implemented Interfaces:
MerkleTreeNodeSource
public class ListMerkleTreeNodeSource extends java.lang.Object implements MerkleTreeNodeSource
MerkleTreeNodeSourceover an in-memory list of entry hashes, computing each requested node from the entries beneath it (RFC 9162 Section 2.1.1).This is what the
List<byte[]>overloads of theMerkleTreePrimitivesgenerators use, and it suits the tree sizes a test, a prototype or a standalone-certificate subtree handles in memory. A production log should implementMerkleTreeNodeSourceover its own storage instead - or extend this class and overridegetFullSubtreeHash(long, long)to serve cached nodes, falling back tosuperfor the rest.
-
-
Constructor Summary
Constructors Constructor Description ListMerkleTreeNodeSource(java.util.List<byte[]> entryHashes, MerkleTreeHash hash)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]getFullSubtreeHash(long start, long end)ReturnsMTH(D[start:end])computed from the entry hashes.longsize()
-
-
-
Constructor Detail
-
ListMerkleTreeNodeSource
public ListMerkleTreeNodeSource(java.util.List<byte[]> entryHashes, MerkleTreeHash hash)- Parameters:
entryHashes- hashes of the tree's entries, entryiat positioni(eachMTH({entry}), i.e.MerkleTreeHash.hashLeaf(byte[]))hash- the Merkle tree hash implementation
-
-
Method Detail
-
size
public long size()
- Returns:
- the number of entries in the tree
-
getFullSubtreeHash
public byte[] getFullSubtreeHash(long start, long end)ReturnsMTH(D[start:end])computed from the entry hashes. Any non-empty range covered by the list is accepted, not only full subtrees.- Specified by:
getFullSubtreeHashin interfaceMerkleTreeNodeSource- Parameters:
start- subtree start index (inclusive), a multiple ofend - startend- subtree end index (exclusive);end - startis a power of two- Returns:
- the node hash; for
end == start + 1this is the entry hashMTH({entry}), i.e.MerkleTreeHash.hashLeaf(byte[])of the entry - Throws:
java.lang.IllegalArgumentException- if the range is empty or not covered by the list
-
-