import type { TransactionProofBuilder, RawProof } from "./proofs/types.js"; import { type SwapProofBuilder } from "./proofs/swap.js"; /** * Circuit artifact paths required by snarkjs. * * These files are large (10-100 MB) and are NOT bundled in the npm package — * `files` ships `dist/` only. Optional: omit them and the prover resolves a * local copy (see `resolveCircuitArtifacts`). Supply them explicitly whenever * the defaults cannot apply, which includes every browser build. * * For Node.js: pass file system paths (e.g. "./circuits/transaction.wasm"). * For browsers: pass Uint8Array buffers or URLs that fetch returns as ArrayBuffer. */ export interface CircuitArtifacts { /** Path or buffer for the compiled WASM witness generator */ wasmPath: string | Uint8Array; /** Path or buffer for the Groth16 proving key (.zkey) */ zkeyPath: string | Uint8Array; } /** The circuits this package can resolve artifacts for. */ export type CircuitName = "transaction" | "swap"; /** * Resolve circuit artifacts from disk when the caller did not supply them. * * Search order, first hit wins: * * 1. $VEILO_CIRCUITS_DIR explicit override * 2. /circuits populated by `npm run copy:circuits` * 3. /circuits * 4. /node_modules/@veilo/sdk-core/circuits * * NODE ONLY, AND DELIBERATELY LAZY. `node:fs` is imported inside the call, not * at module scope: this module is reachable from the package root export, and a * top-level `node:fs` import throws at bundle time in browser builds with no * Node polyfill — the same reason `random.ts` avoids `node:crypto`. Browsers * must pass `CircuitArtifacts` explicitly; there is nothing to resolve there. * * @throws when no candidate directory holds both files, listing what it tried */ export declare function resolveCircuitArtifacts(circuit: CircuitName): Promise; /** * Create a proof builder function for the transaction circuit. * * Uses dynamic `import("snarkjs")` so the dependency is only loaded when * proof generation is actually called. Install snarkjs as a peer dependency: * * ``` * npm install snarkjs * ``` * * @param artifacts Paths or buffers to the circuit WASM and zkey files * @returns A `TransactionProofBuilder` callback compatible with the SDK's client functions * * @example * ```ts * import { createTransactionProver } from "@veilo/sdk-core"; * * const prover = createTransactionProver({ * wasmPath: "./circuits/transaction.wasm", * zkeyPath: "./circuits/transaction_final.zkey", * }); * * // Pass to SDK functions that accept a TransactionProofBuilder * const proof = await prover(circuitInputs); * ``` */ export declare function createTransactionProver(artifacts?: CircuitArtifacts): TransactionProofBuilder; /** Create a proof builder for the current `swap.circom` witness shape. */ export declare function createSwapProver(artifacts?: CircuitArtifacts): SwapProofBuilder; /** * Verify a Groth16 proof against public signals and a verification key. * * Useful for local verification before submitting to the relayer. * * @param proof The raw snarkjs proof * @param publicSignals Array of public signal strings * @param vkeyPath Path to the verification key JSON file, or the parsed JSON object * @returns true if the proof is valid */ export declare function verifyProof(proof: RawProof, publicSignals: string[], vkey: string | object): Promise;