/** * Minimum surface a hash function must expose to drive RFC 9162 * (Certificate Transparency Version 2.0) §2.1.1, Merkle Hash Trees. * * Implementations are `const` objects (no instantiation); each call site * acquires the underlying WASM module fresh, runs the operation, and * disposes. There is no long-lived state on a Hasher; concurrent users * are serialised by the per-module exclusivity guard at the WASM layer. */ export interface Hasher { /** Display name, used in error messages and the export catalog. */ readonly name: string; /** Bytes per hash output. */ readonly outputSize: number; /** WASM module ids this Hasher exercises during `init()`. */ readonly wasmModules: readonly string[]; /** RFC 9162 §2.1.1: MTH({}) = HASH(), the hash of the empty input. */ hashEmpty(): Uint8Array; /** RFC 9162 §2.1.1: leaf domain separator `0x00` prefix. */ hashLeaf(leaf: Uint8Array): Uint8Array; /** RFC 9162 §2.1.1: internal-node domain separator `0x01` prefix. */ hashInternal(left: Uint8Array, right: Uint8Array): Uint8Array; } /** * Stateful Merkle tree with pluggable storage. Append a leaf, query * size + root, build inclusion and consistency proofs. The tree owns * the hash function via `hasher`; consumers do not pass it per call. */ export interface MerkleTree { readonly hasher: Hasher; size(): number; rootHash(): Uint8Array; append(leafBytes: Uint8Array): { leafIndex: number; leafHash: Uint8Array; }; getInclusionProof(leafIndex: number, treeSize?: number): Uint8Array[]; getConsistencyProof(oldSize: number, newSize: number): Uint8Array[]; } /** * RFC 9162 §2.1.4, Consistency Proof Verification: "k is the largest * power of two smaller than n". The split point at which an n-leaf * tree decomposes into a perfect left subtree of size k and a right * subtree of size n - k. Defined for n >= 2. * * Invariant for n >= 2: k < n <= 2*k. */ export declare function splitPoint(n: number): number; /** * `bits.Len64(x)` analogue: position of the most-significant set bit * of x, with `bitLen(0) = 0`. Used by the §2.1.3 / §2.1.4 inclusion * and consistency verifiers to split a proof into inner and border * segments. */ export declare function bitLen(x: number): number; /** * Popcount of a non-negative integer (`bits.OnesCount64` analogue). * Used to compute the "border" length of an inclusion proof per the * RFC 9162 §2.1.3 decomposition. */ export declare function popcount(x: number): number; /** * Number of trailing zero bits in a positive integer * (`bits.TrailingZeros64` analogue). Used by RFC 9162 §2.1.4 to step * the consistency verifier past the levels covered by the size1 * subtree. Defined for x >= 1. */ export declare function trailingZeros(x: number): number;