public class MerkleTreePrimitives
extends java.lang.Object
All algorithms are expressed against the MerkleTreeHash operator,
which the caller supplies; there are no direct org.bouncycastle.crypto.*
or java.security.* dependencies in this class.
| Modifier and Type | Class and Description |
|---|---|
static class |
MerkleTreePrimitives.SubtreeInfo
Simple container for a subtree interval (start inclusive, end exclusive).
|
| Constructor and Description |
|---|
MerkleTreePrimitives() |
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
evaluateSubtreeInclusionProof(long index,
long start,
long end,
byte[] entryHash,
java.util.List<byte[]> proof,
MerkleTreeHash hash)
Evaluates a subtree inclusion proof, returning the expected subtree hash.
|
static java.util.List<long[]> |
findCoveringSubtrees(long start,
long end)
Finds the minimal set of subtrees that efficiently cover the interval [start, end).
|
static boolean |
isValidSubtree(long start,
long end)
Checks whether
[start, end) is a valid subtree interval per
Section 4.1:
0 <= start < end, and start is a multiple of BIT_CEIL(end - start). |
static boolean |
verifySubtreeConsistencyProof(long start,
long end,
long n,
byte[] subtreeHash,
byte[] rootHash,
java.util.List<byte[]> proof,
MerkleTreeHash hash)
Verifies a subtree consistency proof.
|
static boolean |
verifySubtreeInclusionProof(long index,
long start,
long end,
byte[] entryHash,
byte[] subtreeHash,
java.util.List<byte[]> proof,
MerkleTreeHash hash)
Verifies a subtree inclusion proof by comparing the evaluated hash with the given subtree hash.
|
public static byte[] evaluateSubtreeInclusionProof(long index,
long start,
long end,
byte[] entryHash,
java.util.List<byte[]> proof,
MerkleTreeHash hash)
throws InvalidProofException
index - absolute index of the entry in the logstart - subtree start index (inclusive)end - subtree end index (exclusive)entryHash - hash of the entry (MTH({entry}))proof - list of node hashes forming the inclusion proofhash - the Merkle tree hash implementationInvalidProofException - if the proof is malformed or cannot be evaluatedpublic static boolean verifySubtreeInclusionProof(long index,
long start,
long end,
byte[] entryHash,
byte[] subtreeHash,
java.util.List<byte[]> proof,
MerkleTreeHash hash)
index - absolute index of the entrystart - subtree startend - subtree endentryHash - hash of the entrysubtreeHash - claimed subtree hashproof - inclusion proofhash - hash implementationpublic static boolean verifySubtreeConsistencyProof(long start,
long end,
long n,
byte[] subtreeHash,
byte[] rootHash,
java.util.List<byte[]> proof,
MerkleTreeHash hash)
start - subtree start indexend - subtree end index (exclusive)n - full tree size (number of entries)subtreeHash - hash of the subtree (MTH(D[start:end]))rootHash - hash of the full tree (MTH(D[0:n]))proof - list of node hashes forming the consistency proofhash - hash implementationpublic static boolean isValidSubtree(long start,
long end)
[start, end) is a valid subtree interval per
Section 4.1:
0 <= start < end, and start is a multiple of BIT_CEIL(end - start).start - subtree start (inclusive)end - subtree end (exclusive)public static java.util.List<long[]> findCoveringSubtrees(long start,
long end)
start - start index of the interval (inclusive)end - end index of the interval (exclusive)