Class MerkleProof
RFC 6962 Merkle tree helpers for Rekor-compatible transparency logs. Inclusion proof verification follows the decomposed inner/border walk used by transparency-dev/merkle, which implements the proof semantics described in RFC 6962 (Merkle audit paths).
public static class MerkleProof
- Inheritance
-
MerkleProof
- Inherited Members
Methods
HashChildren(ReadOnlySpan<byte>, ReadOnlySpan<byte>)
RFC 6962 §2.1 — hash an internal node from child hashes (prefix 0x01).
public static byte[] HashChildren(ReadOnlySpan<byte> left, ReadOnlySpan<byte> right)
Parameters
leftReadOnlySpan<byte>rightReadOnlySpan<byte>
Returns
- byte[]
HashLeaf(ReadOnlySpan<byte>)
RFC 6962 — leaf hash with domain separation prefix 0x00 over the serialized MerkleTreeLeaf.
public static byte[] HashLeaf(ReadOnlySpan<byte> merkleTreeLeafBytes)
Parameters
merkleTreeLeafBytesReadOnlySpan<byte>
Returns
- byte[]
RootFromInclusionProof(byte[], ulong, ulong, IReadOnlyList<byte[]>)
Computes the tree head from an inclusion proof (transparency-dev/merkle RootFromInclusionProof).
public static byte[] RootFromInclusionProof(byte[] leafHash, ulong leafIndex, ulong treeSize, IReadOnlyList<byte[]> proof)
Parameters
leafHashbyte[]32-byte leaf hash.
leafIndexulongLeaf index.
treeSizeulongTree size.
proofIReadOnlyList<byte[]>Proof elements.
Returns
- byte[]
Computed 32-byte root.
VerifyInclusion(ReadOnlySpan<byte>, long, long, IReadOnlyList<byte[]>, ReadOnlySpan<byte>)
Verifies that leafHash is included at leafIndex in a tree of
treeSize leaves, yielding rootHash for the supplied
inclusionPath.
public static void VerifyInclusion(ReadOnlySpan<byte> leafHash, long leafIndex, long treeSize, IReadOnlyList<byte[]> inclusionPath, ReadOnlySpan<byte> rootHash)
Parameters
leafHashReadOnlySpan<byte>RFC 6962 leaf hash (32 bytes).
leafIndexlongZero-based leaf index.
treeSizelongNumber of leaves in the tree.
inclusionPathIReadOnlyList<byte[]>Inclusion proof hashes (inner segment then border segment).
rootHashReadOnlySpan<byte>Expected tree head (32 bytes).
Exceptions
- InclusionProofException
When inputs are malformed or the proof does not verify.