import type { Hasher } from './tree.js'; export interface VerifyInclusionInput { hasher: Hasher; leafHash: Uint8Array; leafIndex: number; treeSize: number; proof: readonly Uint8Array[]; rootHash: Uint8Array; } /** * RFC 9162 §2.1.3, Inclusion Proof Verification. Returns true if the * proof reconstructs `rootHash` from `leafHash` at position * (leafIndex, treeSize). Wrong proof length, wrong leaf-hash size, or * a reconstructed root that differs from `rootHash` all return false. * Contract violations (negative or out-of-range index, treeSize <= 0, * wrong-sized rootHash) throw RangeError. * * `leafHash` is the leaf's MTH ({d_m} hashed under the leaf prefix), not * the raw leaf bytes. Thin verifiers receiving a leaf over the wire * should compute `hasher.hashLeaf(bytes)` before calling. */ export declare function verifyInclusionProof(input: VerifyInclusionInput): boolean; export interface VerifyConsistencyInput { hasher: Hasher; oldSize: number; newSize: number; oldRoot: Uint8Array; newRoot: Uint8Array; proof: readonly Uint8Array[]; } /** * RFC 9162 §2.1.4, Consistency Proof Verification. Returns true if * `proof` proves that the size-`oldSize` tree with root `oldRoot` is a * prefix of the size-`newSize` tree with root `newRoot`. * * Malformed-proof conditions (wrong proof length, non-empty proof when * one is forbidden, mismatched old/new root reconstruction) return * false. Contract violations (`oldSize > newSize`, wrong-sized root) * throw RangeError; the special "consistency from empty tree" form is * not part of the wire format and returns false. */ export declare function verifyConsistencyProof(input: VerifyConsistencyInput): boolean; /** Callback the builders use to read the tree without knowing how it is stored. */ export type GetNode = (level: number, index: number) => Uint8Array; export interface BuildInclusionInput { hasher: Hasher; leafIndex: number; treeSize: number; getNode: GetNode; } /** * RFC 9162 §2.1.3: build the inclusion proof for leaf `leafIndex` in * a tree of size `treeSize`. The returned bytes are ordered from the * lowest level upward (leaf sibling first, root-adjacent last), the * order `verifyInclusionProof` consumes. */ export declare function buildInclusionProof(input: BuildInclusionInput): Uint8Array[]; export interface BuildConsistencyInput { hasher: Hasher; oldSize: number; newSize: number; getNode: GetNode; } /** * RFC 9162 §2.1.4: build the consistency proof between two tree * sizes. Returns an empty array when oldSize equals newSize or * oldSize is zero (the verifier rejects the latter, but the builder * is symmetric for inspection-time use). */ export declare function buildConsistencyProof(input: BuildConsistencyInput): Uint8Array[];