/** * Proof Inputs Builder * * Builds the private and public inputs for the ZK circuit. */ import type { SpendableUTXO } from './utxo-fetcher'; import type { SpendingKeyPair } from './key-derivation'; import type { MerkleProofResponse } from './types'; export interface PrivateInputsRailgun { tokenAddress: bigint; publicKey: bigint[]; randomIn: bigint[]; valueIn: bigint[]; pathElements: bigint[][]; leavesIndices: bigint[]; nullifyingKey: bigint; npkOut: bigint[]; valueOut: bigint[]; } export interface PublicInputsRailgun { merkleRoot: bigint; boundParamsHash: bigint; nullifiers: bigint[]; commitmentsOut: bigint[]; } export interface UnshieldProofInputsParams { utxo: SpendableUTXO; nullifyingKey: bigint; spendingKeyPair: SpendingKeyPair; unshieldAmount: bigint; recipientAddress: string; tokenAddress: string; } /** * Parameters for partial unshield with change (01x02 circuit) */ export interface PartialUnshieldProofInputsParams { utxo: SpendableUTXO; nullifyingKey: bigint; spendingKeyPair: SpendingKeyPair; unshieldAmount: bigint; changeAmount: bigint; recipientAddress: string; changeMasterPublicKey: bigint; changeRandom: bigint; tokenAddress: string; } /** * Information about the change note created during partial unshield */ export interface ChangeNoteInfo { commitment: string; value: bigint; random: bigint; npk: bigint; tokenAddress: string; } /** * Build proof inputs for unshield transaction */ export declare function buildUnshieldProofInputs(params: UnshieldProofInputsParams): { privateInputs: PrivateInputsRailgun; publicInputs: PublicInputsRailgun; }; /** * Build proof inputs for partial unshield transaction (01x02 circuit) * * This creates 2 outputs: * 1. Unshield output: tokens sent to recipient address * 2. Change output: remaining tokens as a new shielded UTXO back to self * * @returns Proof inputs + change note info for tracking */ export declare function buildPartialUnshieldProofInputs(params: PartialUnshieldProofInputsParams): { privateInputs: PrivateInputsRailgun; publicInputs: PublicInputsRailgun; changeNote: ChangeNoteInfo; }; /** * Parameters for transact (internal transfer) with 01x02 circuit * * This creates 2 shielded outputs (NO unshield): * - Output 0: Fee note to b402's zk-address * - Output 1: User's change note back to self * * Key difference from partial unshield: * - Both outputs stay shielded (no unshieldPreimage.npk set) * - Both npkOut values are derived from master public keys */ export interface TransactProofInputsParams { utxo: SpendableUTXO; nullifyingKey: bigint; spendingKeyPair: SpendingKeyPair; feeAmount: bigint; feeRecipientMasterPublicKey: bigint; feeRandom: bigint; changeAmount: bigint; userMasterPublicKey: bigint; changeRandom: bigint; tokenAddress: string; } /** * Build proof inputs for transact (internal transfer, NO unshield) * * Uses 01x02 circuit with 2 shielded outputs: * - Output 0: Fee note to b402 * - Output 1: User's change note * * Unlike partial unshield, NEITHER output leaves Railgun. * Both outputs are encrypted notes that go into the merkle tree. * * @returns Proof inputs + both note infos for tracking */ export declare function buildTransactProofInputs(params: TransactProofInputsParams): { privateInputs: PrivateInputsRailgun; publicInputs: PublicInputsRailgun; feeNote: ChangeNoteInfo; changeNote: ChangeNoteInfo; }; /** * Verify merkle proof locally before generating ZK proof * This catches issues early and saves proof generation time */ export declare function verifyMerkleProof(commitment: bigint, merkleProof: MerkleProofResponse): boolean;