/** * Client-Side ZK Prover * * Generates Groth16 proofs using snarkjs in the browser. * Circuit artifacts are cached in IndexedDB after first download. * * Ported from backend: utils/railgun-core/proof/prover.ts */ import type { PrivateInputsRailgun, PublicInputsRailgun } from './proof-inputs'; import type { CommitmentCiphertext } from './note-encryption'; export interface Proof { pi_a: [string, string]; pi_b: [[string, string], [string, string]]; pi_c: [string, string]; } export interface GenerateProofParams { privateInputs: PrivateInputsRailgun; publicInputs: PublicInputsRailgun; spendingPrivateKey: Uint8Array; chainId: number; treeNumber: number; /** Number of outputs: 1 for full unshield (01x01), 2 for partial unshield with change (01x02) */ outputCount?: 1 | 2; /** Commitment ciphertext for change notes (required for partial unshield with outputCount=2) */ commitmentCiphertext?: CommitmentCiphertext[]; /** If true, this is a pure transact (no unshield) - sets unshield=0 in boundParams */ isTransact?: boolean; /** Adapt contract address for cross-contract calls via RelayAdapt (default: ZeroAddress) */ adaptContract?: string; /** Adapt parameters hash for cross-contract calls (default: ZeroHash) */ adaptParams?: string; onProgress?: (progress: number, status: string) => void; } export interface ProofResult { proof: Proof; publicInputs: PublicInputsRailgun; /** The bound params used for proof generation (includes commitmentCiphertext) */ boundParams: BoundParamsV2; } /** * Bound parameters structure for V2 transactions * This is included in the ZK proof and verified by the contract */ export interface BoundParamsV2 { treeNumber: number; minGasPrice: number; unshield: number; chainID: string; adaptContract: string; adaptParams: string; commitmentCiphertext: CommitmentCiphertext[]; } /** * Generate ZK proof client-side */ export declare function generateProofClientSide(params: GenerateProofParams): Promise;