/**
 * Merkle Tree Implementation
 *
 * Binary Merkle tree with SHA-256 for proof aggregation.
 * Supports batch proof creation, membership proofs, and verification.
 *
 * @packageDocumentation
 */
/**
 * Merkle proof for a leaf in the tree
 */
export interface MerkleProof {
    /** Index of the leaf in the tree (0-based) */
    leafIndex: number;
    /** Hash of the leaf */
    leafHash: string;
    /** Sibling hashes needed to reconstruct the root (from leaf to root) */
    siblingHashes: string[];
    /** Direction indicators: true = sibling is on the right, false = sibling is on the left */
    siblingDirections: boolean[];
    /** Root hash of the tree */
    root: string;
    /** Total number of leaves in the tree */
    leafCount: number;
}
/**
 * Result of building a Merkle tree
 */
export interface MerkleTreeResult {
    /** Root hash of the tree */
    root: string;
    /** Number of leaves in the tree */
    leafCount: number;
    /** All tree levels (leaves at index 0, root at last index) */
    levels: string[][];
}
/**
 * Calculate SHA-256 hash of input data
 */
export declare function sha256(data: string | Uint8Array): Promise<string>;
/**
 * Calculate hash of two concatenated hashes (for internal nodes)
 * Always orders hashes consistently: smaller hash first, then larger hash
 * This makes the tree order-independent for the same set of leaves
 */
export declare function hashPair(left: string, right: string): Promise<string>;
/**
 * Build a Merkle tree from an array of leaf hashes
 *
 * @param leaves - Array of leaf hashes (pre-hashed data)
 * @returns The tree result including root and all levels
 *
 * Algorithm:
 * 1. If odd number of leaves, duplicate the last leaf
 * 2. Build tree bottom-up by hashing pairs
 * 3. Continue until a single root hash remains
 */
export declare function buildMerkleTree(leaves: string[]): Promise<MerkleTreeResult>;
/**
 * Generate a Merkle proof for a specific leaf
 *
 * @param leafIndex - Index of the leaf to prove (0-based)
 * @param tree - The Merkle tree result
 * @returns The Merkle proof for the leaf
 */
export declare function generateMerkleProof(leafIndex: number, tree: MerkleTreeResult): MerkleProof;
/**
 * Verify a Merkle proof against a root hash
 *
 * @param proof - The Merkle proof to verify
 * @param expectedRoot - Optional expected root hash (defaults to proof.root)
 * @returns True if the proof is valid
 */
export declare function verifyMerkleProof(proof: MerkleProof, expectedRoot?: string): Promise<boolean>;
/**
 * Hash proof data into a leaf hash for inclusion in Merkle tree
 *
 * @param proofId - The proof ID
 * @param proofHash - The proof's hash from the proof chain
 * @returns The leaf hash for the Merkle tree
 */
export declare function hashProofToLeaf(proofId: string, proofHash: string): Promise<string>;
/**
 * Verify that a proof (by ID and hash) is included in a Merkle root
 *
 * @param proofId - The proof ID
 * @param proofHash - The proof's hash
 * @param proof - The Merkle proof
 * @param expectedRoot - The expected Merkle root
 * @returns True if the proof is included in the tree
 */
export declare function verifyProofInclusion(proofId: string, proofHash: string, proof: MerkleProof, expectedRoot?: string): Promise<boolean>;
/**
 * Batch aggregate proof hashes into a Merkle root
 *
 * @param proofs - Array of proof records with id and hash
 * @returns The Merkle tree result
 */
export declare function aggregateProofs(proofs: Array<{
    id: string;
    hash: string;
}>): Promise<MerkleTreeResult>;
/**
 * Get proofs for all leaves in a tree (batch generation)
 *
 * @param tree - The Merkle tree
 * @returns Array of Merkle proofs, one for each leaf
 */
export declare function generateAllProofs(tree: MerkleTreeResult): MerkleProof[];
/**
 * Serialize a Merkle proof to a compact JSON-compatible format
 */
export declare function serializeMerkleProof(proof: MerkleProof): string;
/**
 * Deserialize a Merkle proof from compact JSON format
 */
export declare function deserializeMerkleProof(serialized: string): MerkleProof;
//# sourceMappingURL=merkle.d.ts.map