@izi-noir/sdk 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/infra/provingSystems/ArkworksWasm.ts","../../src/infra/provingSystems/Barretenberg.ts","../../src/infra/chainFormatters/SolanaFormatter.ts","../../src/providers/arkworks.ts","../../src/domain/types/provider.ts","../../src/infra/wasm/wasmInit.ts","../../src/IziNoir.ts"],"sourcesContent":["/**\n * ArkworksWasm proving system.\n *\n * 100% browser-compatible Groth16 prover using arkworks compiled to WASM.\n * Produces proofs compatible with gnark-verifier-solana for on-chain verification.\n *\n * Features:\n * - Runs entirely in the browser (no CLI dependencies)\n * - Generates compact Groth16 proofs (~256 bytes)\n * - Compatible with gnark-verifier-solana\n * - Uses BN254 curve\n */\n\nimport { compile, createFileManager } from '@noir-lang/noir_wasm';\nimport { Noir } from '@noir-lang/noir_js';\nimport type { IProvingSystem } from '../../domain/interfaces/proving/IProvingSystem.js';\nimport type { CompiledCircuit, InputMap, ProofData } from '../../domain/types.js';\n\n/**\n * Helper to create a ReadableStream from a string\n * Used to write files to the virtual filesystem (browser-compatible)\n */\nfunction stringToStream(content: string): ReadableStream<Uint8Array> {\n return new ReadableStream({\n start(controller) {\n controller.enqueue(new TextEncoder().encode(content));\n controller.close();\n },\n });\n}\n\n/**\n * Check if running in Node.js environment\n */\nfunction isNodeJs(): boolean {\n return (\n typeof globalThis.process !== 'undefined' &&\n globalThis.process.versions != null &&\n globalThis.process.versions.node != null\n );\n}\n\n/**\n * Create temp directory in Node.js, or return '/' for browser virtual fs\n */\nasync function createTempDir(): Promise<{ basePath: string; cleanup: (() => Promise<void>) | null }> {\n if (!isNodeJs()) {\n // Browser: use virtual filesystem\n return { basePath: '/', cleanup: null };\n }\n\n // Node.js: create real temp directory\n // Use dynamic import which works in both Node.js ESM and CJS\n const fs = await import('node:fs/promises');\n const os = await import('node:os');\n const path = await import('node:path');\n\n const basePath = await fs.mkdtemp(path.join(os.tmpdir(), 'arkworks-circuit-'));\n const cleanup = async () => {\n await fs.rm(basePath, { recursive: true, force: true });\n };\n\n return { basePath, cleanup };\n}\n\n/**\n * Result of Groth16 setup from arkworks WASM module\n */\nexport interface ArkworksSetupResult {\n /** Base64-encoded proving key */\n proving_key: string;\n /** Base64-encoded verifying key (arkworks format) */\n verifying_key: string;\n /** Base64-encoded verifying key (gnark format for Solana) */\n verifying_key_gnark: string;\n}\n\n/**\n * Result of Groth16 proof generation from arkworks WASM module\n */\nexport interface ArkworksProofResult {\n /** Base64-encoded proof (arkworks format) */\n proof: string;\n /** Base64-encoded proof (gnark format, 256 bytes) */\n proof_gnark: string;\n /** Public inputs as hex strings */\n public_inputs: string[];\n /** Base64-encoded public inputs (gnark format) */\n public_inputs_gnark: string;\n}\n\n/**\n * Interface for the arkworks-groth16-wasm WASM module\n */\nexport interface ArkworksWasmModule {\n setup(acirJson: string): ArkworksSetupResult;\n prove(provingKeyB64: string, acirJson: string, witnessJson: string): ArkworksProofResult;\n verify(verifyingKeyB64: string, proofB64: string, publicInputsJson: string): boolean;\n verify_gnark(\n verifyingKeyGnarkB64: string,\n proofGnarkB64: string,\n publicInputsGnarkB64: string,\n numPublicInputs: number\n ): boolean;\n acir_to_r1cs_info(acirJson: string): {\n num_witnesses: number;\n num_constraints: number;\n public_inputs: number[];\n private_inputs: number[];\n return_values: number[];\n };\n version(): string;\n}\n\n/**\n * Configuration for ArkworksWasm prover\n */\nexport interface ArkworksWasmConfig {\n /** Keep intermediate artifacts for debugging */\n keepArtifacts?: boolean;\n /** Cache proving/verifying keys for repeated proofs */\n cacheKeys?: boolean;\n}\n\n/**\n * Extended CompiledCircuit for ArkworksWasm backend\n */\nexport interface ArkworksCompiledCircuit extends CompiledCircuit {\n /** Marker to identify ArkworksWasm circuits */\n __arkworks: true;\n /** ACIR program as JSON string (used for setup/prove) */\n acirJson: string;\n /** Cached proving key (base64) if cacheKeys is enabled */\n provingKey?: string;\n /** Cached verifying key (base64) if cacheKeys is enabled */\n verifyingKey?: string;\n /** Cached verifying key in gnark format (base64) */\n verifyingKeyGnark?: string;\n}\n\n/**\n * Type guard to check if a circuit is an ArkworksWasm circuit\n */\nexport function isArkworksCircuit(circuit: CompiledCircuit): circuit is ArkworksCompiledCircuit {\n return '__arkworks' in circuit && (circuit as ArkworksCompiledCircuit).__arkworks === true;\n}\n\n// WASM module singleton\nlet wasmModule: ArkworksWasmModule | null = null;\nlet wasmInitPromise: Promise<ArkworksWasmModule> | null = null;\n\n/**\n * Initialize the arkworks WASM module\n * Automatically detects Node.js vs browser and uses the appropriate WASM target.\n */\nasync function initWasm(): Promise<ArkworksWasmModule> {\n if (wasmModule) {\n return wasmModule;\n }\n\n if (wasmInitPromise) {\n return wasmInitPromise;\n }\n\n wasmInitPromise = (async () => {\n try {\n if (isNodeJs()) {\n // Node.js: use the nodejs target which doesn't require fetch\n // Path resolves to dist/wasm/nodejs/ after bundling\n // @ts-ignore - Dynamic import path resolved at runtime\n const module = await import('../wasm/nodejs/arkworks_groth16_wasm.js');\n wasmModule = module as unknown as ArkworksWasmModule;\n } else {\n // Browser: use the web target with init function\n // Path resolves to dist/wasm/web/ after bundling\n // @ts-ignore - Dynamic import path resolved at runtime\n const module = await import('../wasm/web/arkworks_groth16_wasm.js');\n // Initialize WASM (wasm-pack generates an init function for web target)\n if (typeof module.default === 'function') {\n await module.default();\n }\n wasmModule = module as unknown as ArkworksWasmModule;\n }\n return wasmModule;\n } catch (error) {\n wasmInitPromise = null;\n throw new Error(\n `Failed to initialize arkworks-groth16-wasm: ${error instanceof Error ? error.message : String(error)}\\n` +\n 'Make sure the WASM module is built: cd packages/arkworks-groth16-wasm && npm run build'\n );\n }\n })();\n\n return wasmInitPromise;\n}\n\n/**\n * ArkworksWasm proving system using arkworks Groth16 compiled to WASM.\n *\n * This proving system:\n * - Compiles Noir code using @noir-lang/noir_wasm\n * - Generates witness using @noir-lang/noir_js\n * - Performs Groth16 setup/prove/verify using arkworks-groth16-wasm\n *\n * All operations run in the browser with no external dependencies.\n */\nexport class ArkworksWasm implements IProvingSystem {\n private readonly config: ArkworksWasmConfig;\n\n constructor(config: ArkworksWasmConfig = {}) {\n this.config = {\n keepArtifacts: false,\n cacheKeys: true,\n ...config,\n };\n }\n\n /**\n * Compile Noir code to a circuit with ACIR for Groth16 proving\n */\n async compile(noirCode: string): Promise<CompiledCircuit> {\n const wasm = await initWasm();\n const { basePath, cleanup } = await createTempDir();\n const fm = createFileManager(basePath);\n\n const nargoToml = `[package]\nname = \"circuit\"\ntype = \"bin\"\nauthors = [\"\"]\n\n[dependencies]\n`;\n\n try {\n // Write files using ReadableStream (browser-compatible)\n // In Node.js: writeFile is async and must be awaited\n // In browser: writeFile works with virtual fs, should not await for noir_wasm compatibility\n if (isNodeJs()) {\n await fm.writeFile('./src/main.nr', stringToStream(noirCode));\n await fm.writeFile('./Nargo.toml', stringToStream(nargoToml));\n } else {\n fm.writeFile('./src/main.nr', stringToStream(noirCode));\n fm.writeFile('./Nargo.toml', stringToStream(nargoToml));\n }\n\n // Compile using noir_wasm\n const result = await compile(fm);\n const compiled = (result as any).program as CompiledCircuit;\n\n if (!compiled || !compiled.bytecode) {\n throw new Error('Compilation failed: no bytecode generated');\n }\n\n // Store the ACIR JSON for setup/prove\n // The bytecode is base64-gzipped ACIR\n const acirJson = JSON.stringify({\n functions: [\n {\n current_witness_index: compiled.abi.parameters.length + 1,\n opcodes: [], // Will be extracted from bytecode during prove\n private_parameters: compiled.abi.parameters\n .filter((p) => p.visibility === 'private')\n .map((_, i) => i + 1),\n public_parameters: {\n witnesses: compiled.abi.parameters\n .filter((p) => p.visibility === 'public')\n .map((_, i) => i + 1),\n },\n return_values: { witnesses: [] },\n },\n ],\n });\n\n // Perform setup if caching is enabled\n let provingKey: string | undefined;\n let verifyingKey: string | undefined;\n let verifyingKeyGnark: string | undefined;\n\n if (this.config.cacheKeys) {\n try {\n // Note: For real ACIR, we need to decode the bytecode first\n // This is a placeholder - actual implementation needs to decode\n // the base64-gzipped bytecode to get the ACIR JSON\n const setupResult = wasm.setup(acirJson);\n provingKey = setupResult.proving_key;\n verifyingKey = setupResult.verifying_key;\n verifyingKeyGnark = setupResult.verifying_key_gnark;\n } catch (error) {\n // Setup might fail if ACIR is complex - we'll do it lazily during prove\n console.warn('Deferred setup: will run during proof generation');\n }\n }\n\n const arkworksCircuit: ArkworksCompiledCircuit = {\n ...compiled,\n __arkworks: true,\n acirJson,\n provingKey,\n verifyingKey,\n verifyingKeyGnark,\n };\n\n return arkworksCircuit;\n } finally {\n if (cleanup) {\n await cleanup();\n }\n }\n }\n\n /**\n * Generate a Groth16 proof\n */\n async generateProof(circuit: CompiledCircuit, inputs: InputMap): Promise<ProofData> {\n const wasm = await initWasm();\n\n if (!isArkworksCircuit(circuit)) {\n throw new Error(\n 'ArkworksWasm.generateProof requires an ArkworksCompiledCircuit. Use ArkworksWasm.compile() first.'\n );\n }\n\n // Execute the circuit to generate witness using noir_js\n const noir = new Noir(circuit);\n const { witness } = await noir.execute(inputs);\n\n // Convert witness to the format expected by arkworks-groth16-wasm\n // Witness is a Map<number, string> where values are hex field elements\n const witnessMap: Record<string, string> = {};\n for (const [index, value] of witness.entries()) {\n witnessMap[index.toString()] = String(value);\n }\n const witnessJson = JSON.stringify(witnessMap);\n\n // Ensure we have a proving key\n let provingKey = circuit.provingKey;\n if (!provingKey) {\n const setupResult = wasm.setup(circuit.acirJson);\n provingKey = setupResult.proving_key;\n // Cache for future use\n circuit.provingKey = provingKey;\n circuit.verifyingKey = setupResult.verifying_key;\n circuit.verifyingKeyGnark = setupResult.verifying_key_gnark;\n }\n\n // Generate proof\n const proofResult = wasm.prove(provingKey, circuit.acirJson, witnessJson);\n\n // Return proof in gnark format for Solana compatibility\n const proofBytes = base64ToUint8Array(proofResult.proof_gnark);\n\n return {\n proof: proofBytes,\n publicInputs: proofResult.public_inputs,\n };\n }\n\n /**\n * Verify a Groth16 proof\n */\n async verifyProof(\n circuit: CompiledCircuit,\n proof: Uint8Array,\n publicInputs: string[]\n ): Promise<boolean> {\n const wasm = await initWasm();\n\n if (!isArkworksCircuit(circuit)) {\n throw new Error(\n 'ArkworksWasm.verifyProof requires an ArkworksCompiledCircuit. Use ArkworksWasm.compile() first.'\n );\n }\n\n // Ensure we have a verifying key\n let verifyingKeyGnark = circuit.verifyingKeyGnark;\n if (!verifyingKeyGnark) {\n const setupResult = wasm.setup(circuit.acirJson);\n circuit.provingKey = setupResult.proving_key;\n circuit.verifyingKey = setupResult.verifying_key;\n verifyingKeyGnark = setupResult.verifying_key_gnark;\n circuit.verifyingKeyGnark = verifyingKeyGnark;\n }\n\n // Convert proof to base64\n const proofB64 = uint8ArrayToBase64(proof);\n\n // Convert public inputs to gnark format\n const publicInputsGnarkB64 = publicInputsToGnarkBase64(publicInputs);\n\n // Verify using gnark format\n return wasm.verify_gnark(\n verifyingKeyGnark,\n proofB64,\n publicInputsGnarkB64,\n publicInputs.length\n );\n }\n\n /**\n * Get the verifying key in gnark format for on-chain deployment\n */\n async getVerifyingKeyGnark(circuit: CompiledCircuit): Promise<Uint8Array> {\n const wasm = await initWasm();\n\n if (!isArkworksCircuit(circuit)) {\n throw new Error('getVerifyingKeyGnark requires an ArkworksCompiledCircuit');\n }\n\n if (!circuit.verifyingKeyGnark) {\n const setupResult = wasm.setup(circuit.acirJson);\n circuit.provingKey = setupResult.proving_key;\n circuit.verifyingKey = setupResult.verifying_key;\n circuit.verifyingKeyGnark = setupResult.verifying_key_gnark;\n }\n\n return base64ToUint8Array(circuit.verifyingKeyGnark);\n }\n}\n\n// Utility functions\n\nfunction base64ToUint8Array(b64: string): Uint8Array {\n const binaryString = atob(b64);\n const bytes = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i++) {\n bytes[i] = binaryString.charCodeAt(i);\n }\n return bytes;\n}\n\nfunction uint8ArrayToBase64(bytes: Uint8Array): string {\n let binary = '';\n for (let i = 0; i < bytes.length; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return btoa(binary);\n}\n\n/**\n * Convert public inputs (hex strings) to gnark format (32 bytes each, big-endian)\n * Returns base64-encoded result\n */\nfunction publicInputsToGnarkBase64(publicInputs: string[]): string {\n const FIELD_SIZE = 32;\n const bytes = new Uint8Array(publicInputs.length * FIELD_SIZE);\n\n for (let i = 0; i < publicInputs.length; i++) {\n const input = publicInputs[i];\n const hex = input.startsWith('0x') ? input.slice(2) : input;\n const inputBytes = hexToBytes(hex.padStart(64, '0'));\n\n // Copy big-endian bytes\n bytes.set(inputBytes, i * FIELD_SIZE);\n }\n\n return uint8ArrayToBase64(bytes);\n}\n\nfunction hexToBytes(hex: string): Uint8Array {\n const bytes = new Uint8Array(hex.length / 2);\n for (let i = 0; i < hex.length; i += 2) {\n bytes[i / 2] = parseInt(hex.substring(i, i + 2), 16);\n }\n return bytes;\n}\n","import { compile, createFileManager } from '@noir-lang/noir_wasm';\nimport { Noir } from '@noir-lang/noir_js';\nimport { Barretenberg as BarretenbergBackend, UltraHonkBackend } from '@aztec/bb.js';\nimport type { IProvingSystem } from '../../domain/interfaces/proving/IProvingSystem.js';\nimport type { CompiledCircuit, InputMap, ProofData } from '../../domain/types.js';\n\n/**\n * Helper to create a ReadableStream from a string\n * Used to write files to the virtual filesystem (browser-compatible)\n */\nfunction stringToStream(content: string): ReadableStream<Uint8Array> {\n return new ReadableStream({\n start(controller) {\n controller.enqueue(new TextEncoder().encode(content));\n controller.close();\n },\n });\n}\n\n/**\n * Check if running in Node.js environment\n */\nfunction isNodeJs(): boolean {\n return (\n typeof globalThis.process !== 'undefined' &&\n globalThis.process.versions != null &&\n globalThis.process.versions.node != null\n );\n}\n\n/**\n * Create temp directory in Node.js, or return '/' for browser virtual fs\n */\nasync function createTempDir(): Promise<{ basePath: string; cleanup: (() => Promise<void>) | null }> {\n if (!isNodeJs()) {\n // Browser: use virtual filesystem\n return { basePath: '/', cleanup: null };\n }\n\n // Node.js: create real temp directory\n // Use dynamic import which works in both Node.js ESM and CJS\n const fs = await import('node:fs/promises');\n const os = await import('node:os');\n const path = await import('node:path');\n\n const basePath = await fs.mkdtemp(path.join(os.tmpdir(), 'noir-circuit-'));\n const cleanup = async () => {\n await fs.rm(basePath, { recursive: true, force: true });\n };\n\n return { basePath, cleanup };\n}\n\n/**\n * Barretenberg proving system using WASM.\n * Browser compatible, produces UltraHonk proofs (~16KB).\n */\nexport class Barretenberg implements IProvingSystem {\n async compile(noirCode: string): Promise<CompiledCircuit> {\n const { basePath, cleanup } = await createTempDir();\n const fm = createFileManager(basePath);\n\n const nargoToml = `[package]\nname = \"circuit\"\ntype = \"bin\"\nauthors = [\"\"]\n\n[dependencies]\n`;\n\n try {\n // Write files using ReadableStream (browser-compatible)\n // In Node.js: writeFile is async and must be awaited\n // In browser: writeFile works with virtual fs, should not await for noir_wasm compatibility\n if (isNodeJs()) {\n await fm.writeFile('./src/main.nr', stringToStream(noirCode));\n await fm.writeFile('./Nargo.toml', stringToStream(nargoToml));\n } else {\n fm.writeFile('./src/main.nr', stringToStream(noirCode));\n fm.writeFile('./Nargo.toml', stringToStream(nargoToml));\n }\n\n const result = await compile(fm);\n const compiled = (result as any).program as CompiledCircuit;\n\n if (!compiled || !compiled.bytecode) {\n throw new Error('Compilation failed: no bytecode generated');\n }\n\n return compiled;\n } finally {\n if (cleanup) {\n await cleanup();\n }\n }\n }\n\n async generateProof(circuit: CompiledCircuit, inputs: InputMap): Promise<ProofData> {\n const noir = new Noir(circuit);\n const { witness } = await noir.execute(inputs);\n\n const barretenberg = await BarretenbergBackend.new({ threads: 1 });\n const backend = new UltraHonkBackend(circuit.bytecode, barretenberg);\n\n try {\n const proofData = await backend.generateProof(witness);\n return {\n proof: proofData.proof,\n publicInputs: proofData.publicInputs || [],\n };\n } finally {\n await barretenberg.destroy();\n }\n }\n\n async verifyProof(\n circuit: CompiledCircuit,\n proof: Uint8Array,\n publicInputs: string[]\n ): Promise<boolean> {\n const barretenberg = await BarretenbergBackend.new({ threads: 1 });\n const backend = new UltraHonkBackend(circuit.bytecode, barretenberg);\n\n try {\n return await backend.verifyProof({ proof, publicInputs });\n } finally {\n await barretenberg.destroy();\n }\n }\n}\n","import type { IChainFormatter } from '../../domain/interfaces/chain/IChainFormatter';\nimport type { ProofData, SolanaProofData, CompiledCircuit } from '../../domain/types';\nimport type { CircuitMetadata, SolanaChainMetadata } from '../../domain/types/chain';\nimport type { ArkworksWasm } from '../provingSystems/ArkworksWasm';\n\n// Constants for VK account sizing\nconst G1_SIZE = 64;\nconst G2_SIZE = 128;\n\n/**\n * Formatter for Solana-compatible proof data.\n *\n * Converts generic ProofData into SolanaProofData format with:\n * - Verifying key in gnark format (compatible with gnark-verifier-solana)\n * - Proof bytes (256 bytes Groth16)\n * - Public inputs as 32-byte arrays\n * - VK account size and rent estimates\n *\n * @example\n * ```typescript\n * const formatter = new SolanaFormatter(arkworksProvider);\n * const solanaProof = await formatter.formatProof(proofData, circuit, metadata);\n * ```\n */\nexport class SolanaFormatter implements IChainFormatter<'solana'> {\n readonly chainId = 'solana' as const;\n\n constructor(private arkworksProvider: ArkworksWasm) {}\n\n /**\n * Format a generic proof for Solana on-chain verification.\n *\n * @param proofData - Generic proof data from Arkworks\n * @param circuit - The compiled circuit (must be Arkworks circuit)\n * @param metadata - Circuit metadata with public input count\n * @returns SolanaProofData ready for on-chain verification\n */\n async formatProof(\n proofData: ProofData,\n circuit: CompiledCircuit,\n metadata: CircuitMetadata\n ): Promise<SolanaProofData> {\n // Get verifying key in gnark format\n const vkBytes = await this.arkworksProvider.getVerifyingKeyGnark(circuit);\n const vkBase64 = this.uint8ArrayToBase64(vkBytes);\n\n // Number of public inputs\n const nrPublicInputs = metadata.numPublicInputs;\n\n // Convert public inputs to 32-byte arrays\n const publicInputsBytes = proofData.publicInputs.map((input) => {\n const hex = input.startsWith('0x') ? input.slice(2) : input;\n return this.hexToBytes(hex.padStart(64, '0'));\n });\n\n // Calculate account size and rent\n const { accountSize, estimatedRent } = this.getChainMetadata(nrPublicInputs);\n\n return {\n verifyingKey: {\n base64: vkBase64,\n bytes: vkBytes,\n nrPublicInputs,\n },\n proof: {\n base64: this.uint8ArrayToBase64(proofData.proof),\n bytes: proofData.proof,\n },\n publicInputs: {\n hex: proofData.publicInputs,\n bytes: publicInputsBytes,\n },\n accountSize,\n estimatedRent,\n };\n }\n\n /**\n * Get Solana-specific metadata for a circuit.\n *\n * @param publicInputCount - Number of public inputs in the circuit\n * @returns Solana metadata with account size and rent estimates\n */\n getChainMetadata(publicInputCount: number): SolanaChainMetadata {\n const accountSize = this.calculateVkAccountSize(publicInputCount);\n const estimatedRent = this.calculateVkAccountRent(publicInputCount);\n\n return {\n chainId: 'solana',\n accountSize,\n estimatedRent,\n };\n }\n\n /**\n * Calculate the size of a VK account for a given number of public inputs.\n * Matches the Rust `vk_account_size` function in the Solana program.\n */\n private calculateVkAccountSize(nrPublicInputs: number): number {\n // discriminator (8) + authority (32) + nr_pubinputs (1) + alpha_g1 (64) +\n // beta_g2 (128) + gamma_g2 (128) + delta_g2 (128) + vec_len (4) + k elements\n const fixedSize = 8 + 32 + 1 + G1_SIZE + G2_SIZE * 3 + 4;\n return fixedSize + (nrPublicInputs + 1) * G1_SIZE;\n }\n\n /**\n * Calculate the minimum rent for a VK account.\n */\n private calculateVkAccountRent(\n nrPublicInputs: number,\n rentExemptionPerByte: number = 6960 // approximate lamports per byte\n ): number {\n const size = this.calculateVkAccountSize(nrPublicInputs);\n return size * rentExemptionPerByte;\n }\n\n /**\n * Convert Uint8Array to base64 string.\n */\n private uint8ArrayToBase64(bytes: Uint8Array): string {\n // Browser-compatible\n if (typeof btoa === 'function') {\n let binary = '';\n for (let i = 0; i < bytes.length; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return btoa(binary);\n }\n // Node.js fallback\n return Buffer.from(bytes).toString('base64');\n }\n\n /**\n * Convert hex string to Uint8Array.\n */\n private hexToBytes(hex: string): Uint8Array {\n const cleanHex = hex.startsWith('0x') ? hex.slice(2) : hex;\n const bytes = new Uint8Array(cleanHex.length / 2);\n for (let i = 0; i < bytes.length; i++) {\n bytes[i] = parseInt(cleanHex.substring(i * 2, i * 2 + 2), 16);\n }\n return bytes;\n }\n}\n","/**\n * Arkworks-only entry point for tree-shaking.\n *\n * Import from this module to only include Arkworks in your bundle,\n * excluding Barretenberg and Sunspot dependencies.\n *\n * @example\n * ```typescript\n * import { IziNoir, Provider } from '@izi-noir/sdk/arkworks';\n *\n * const izi = await IziNoir.init({ provider: Provider.Arkworks });\n * ```\n *\n * @module @izi-noir/sdk/arkworks\n */\n\nexport { ArkworksWasm, isArkworksCircuit } from '../infra/provingSystems/ArkworksWasm.js';\nexport type {\n ArkworksWasmConfig,\n ArkworksCompiledCircuit,\n ArkworksWasmModule,\n ArkworksSetupResult,\n ArkworksProofResult,\n} from '../infra/provingSystems/ArkworksWasm.js';\nexport { IziNoir, Provider, type IziNoirConfig, type CircuitPaths } from '../IziNoir.js';\nexport { initNoirWasm, isWasmInitialized } from '../infra/wasm/wasmInit.js';\nexport type { CompiledCircuit, InputMap, ProofData } from '../domain/types.js';\nexport type { IProvingSystem } from '../domain/interfaces/proving/IProvingSystem.js';\n","import { Chain } from './chain.js';\n\n/**\n * Available proving system providers\n */\nexport enum Provider {\n /** Barretenberg backend - browser compatible, UltraHonk proofs (~16KB) */\n Barretenberg = 'barretenberg',\n /** Arkworks WASM backend - browser compatible, Groth16 proofs (~256 bytes) */\n Arkworks = 'arkworks',\n /** Sunspot CLI backend - Node.js only, Groth16 proofs (~256 bytes) */\n Sunspot = 'sunspot',\n}\n\n/**\n * Configuration for circuit paths (required for Sunspot)\n */\nexport interface CircuitPaths {\n /** Path to the proving key file */\n pkPath: string;\n /** Path to the verification key file */\n vkPath: string;\n /** Path to the compiled circuit JSON file */\n circuitPath: string;\n}\n\n/**\n * Configuration for IziNoir initialization\n */\nexport interface IziNoirConfig {\n /** The proving system provider to use */\n provider: Provider;\n /**\n * Target blockchain for proof formatting.\n * If omitted, operates in offchain mode (raw proofs, no chain formatting).\n */\n chain?: Chain;\n /** Circuit paths - required for Sunspot provider */\n circuitPaths?: CircuitPaths;\n}\n\n// Re-export Chain for convenience\nexport { Chain };\n","let wasmInitPromise: Promise<void> | null = null;\nlet wasmInitialized = false;\n\n/**\n * Check if running in Node.js environment\n */\nfunction isNodeJs(): boolean {\n return (\n typeof globalThis.process !== 'undefined' &&\n globalThis.process.versions != null &&\n globalThis.process.versions.node != null\n );\n}\n\n/**\n * Initialize WASM modules for Noir compilation and execution.\n * Automatically detects Node.js vs browser and uses the appropriate WASM target.\n *\n * Uses lazy loading with singleton pattern - safe to call multiple times.\n * Only initializes once, subsequent calls return immediately.\n */\nexport async function initNoirWasm(): Promise<void> {\n if (wasmInitialized) return;\n\n if (!wasmInitPromise) {\n wasmInitPromise = initWasmInternal();\n }\n\n await wasmInitPromise;\n wasmInitialized = true;\n}\n\nasync function initWasmInternal(): Promise<void> {\n if (isNodeJs()) {\n // Node.js: use the nodejs target which doesn't require fetch\n // The nodejs target auto-initializes when imported\n await import('@noir-lang/acvm_js/nodejs/acvm_js.js');\n await import('@noir-lang/noirc_abi/nodejs/noirc_abi_wasm.js');\n } else {\n // Browser: use the web target with default initialization\n // Note: For Vite/bundlers, external initialization with WASM URLs is preferred\n // Use markWasmInitialized() after initializing externally\n const [{ default: initACVM }, { default: initNoirC }] = await Promise.all([\n import('@noir-lang/acvm_js'),\n import('@noir-lang/noirc_abi'),\n ]);\n await Promise.all([initACVM(), initNoirC()]);\n }\n}\n\n/**\n * Check if WASM modules are already initialized\n */\nexport function isWasmInitialized(): boolean {\n return wasmInitialized;\n}\n\n/**\n * Mark WASM as already initialized externally.\n * Use this when WASM has been initialized outside the SDK (e.g., with Vite URL imports).\n *\n * @example\n * ```typescript\n * // In Vite/browser environment\n * import initNoirC from \"@noir-lang/noirc_abi\";\n * import initACVM from \"@noir-lang/acvm_js\";\n * import acvm from \"@noir-lang/acvm_js/web/acvm_js_bg.wasm?url\";\n * import noirc from \"@noir-lang/noirc_abi/web/noirc_abi_wasm_bg.wasm?url\";\n * import { markWasmInitialized } from \"@izi-noir/sdk\";\n *\n * await Promise.all([initACVM(fetch(acvm)), initNoirC(fetch(noirc))]);\n * markWasmInitialized();\n * ```\n */\nexport function markWasmInitialized(): void {\n wasmInitialized = true;\n}\n\n/**\n * Reset WASM initialization state (for testing purposes)\n * @internal\n */\nexport function resetWasmInit(): void {\n wasmInitPromise = null;\n wasmInitialized = false;\n}\n","import {\n Provider,\n Chain,\n type IziNoirConfig,\n type CircuitPaths,\n} from './domain/types/provider.js';\nimport type { IProvingSystem } from './domain/interfaces/proving/IProvingSystem.js';\nimport type {\n CompiledCircuit,\n InputMap,\n ProofData,\n SolanaProofData,\n VerifyingKeyData,\n} from './domain/types.js';\nimport type { IChainFormatter } from './domain/interfaces/chain/IChainFormatter.js';\nimport type { ChainId, CircuitMetadata } from './domain/types/chain.js';\nimport { initNoirWasm } from './infra/wasm/wasmInit.js';\n\n/**\n * Data needed to deploy a verifying key to Solana.\n * Use with SolanaTransactionBuilder or your own transaction logic.\n */\nexport interface SolanaDeployData {\n /** The proof data with VK and public inputs */\n proofData: SolanaProofData;\n /** Program ID to use */\n programId: string;\n /** Compute units for the transaction */\n computeUnits: number;\n}\n\n/**\n * Main class for ZK proof generation with multiple backend providers.\n *\n * @example\n * ```typescript\n * import { IziNoir, Provider, Chain } from '@izi-noir/sdk';\n *\n * // On-chain mode: Initialize with chain for blockchain-specific formatting\n * const izi = await IziNoir.init({\n * provider: Provider.Arkworks,\n * chain: Chain.Solana\n * });\n *\n * await izi.compile(noirCode);\n * const proof = await izi.prove(inputs); // Returns SolanaProofData\n * console.log(izi.vk); // Verifying key available\n *\n * // Offchain mode: No chain specified\n * const iziOffchain = await IziNoir.init({ provider: Provider.Arkworks });\n * const rawProof = await iziOffchain.prove(inputs); // Returns ProofData\n * const verified = await iziOffchain.verify(rawProof.proof, rawProof.publicInputs);\n * ```\n */\nexport class IziNoir {\n private provingSystem: IProvingSystem;\n private compiledCircuit: CompiledCircuit | null = null;\n private chainFormatters: Map<string, IChainFormatter> = new Map();\n private readonly chain?: Chain;\n private _verifyingKey?: VerifyingKeyData;\n private _lastProof?: SolanaProofData | ProofData;\n\n private constructor(provingSystem: IProvingSystem, chain?: Chain) {\n this.provingSystem = provingSystem;\n this.chain = chain;\n }\n\n /**\n * Get the verifying key from the last proof generation.\n * Only available after calling prove() with a chain configured.\n */\n get vk(): VerifyingKeyData | undefined {\n return this._verifyingKey;\n }\n\n /**\n * Get the configured chain, if any.\n */\n get targetChain(): Chain | undefined {\n return this.chain;\n }\n\n /**\n * Check if operating in offchain mode (no chain configured).\n */\n get isOffchain(): boolean {\n return this.chain === undefined;\n }\n\n /**\n * Register a chain formatter for chain-specific proof formatting.\n *\n * @param formatter - The chain formatter to register\n */\n registerChainFormatter<T extends ChainId>(formatter: IChainFormatter<T>): void {\n this.chainFormatters.set(formatter.chainId, formatter);\n }\n\n /**\n * Get a registered chain formatter.\n *\n * @param chainId - The chain ID to get the formatter for\n * @returns The formatter or undefined if not registered\n */\n getChainFormatter<T extends ChainId>(chainId: T): IChainFormatter<T> | undefined {\n return this.chainFormatters.get(chainId) as IChainFormatter<T> | undefined;\n }\n\n /**\n * Initialize IziNoir with the specified provider and optional chain.\n *\n * @param config - Configuration specifying the provider, chain, and optional circuit paths\n * @returns Initialized IziNoir instance\n *\n * @example\n * ```typescript\n * // On-chain mode (Solana)\n * const izi = await IziNoir.init({\n * provider: Provider.Arkworks,\n * chain: Chain.Solana\n * });\n *\n * // Offchain mode (no chain formatting)\n * const iziOffchain = await IziNoir.init({\n * provider: Provider.Arkworks\n * });\n *\n * // Barretenberg (browser-compatible, ~16KB proofs, offchain only)\n * const bb = await IziNoir.init({ provider: Provider.Barretenberg });\n * ```\n */\n static async init(config: IziNoirConfig): Promise<IziNoir> {\n // Initialize WASM (no-op if already initialized)\n await initNoirWasm();\n\n let provingSystem: IProvingSystem;\n\n switch (config.provider) {\n case Provider.Barretenberg: {\n if (config.chain) {\n throw new Error(\n 'Barretenberg provider does not support chain formatting. ' +\n 'Use Provider.Arkworks for on-chain proofs.'\n );\n }\n const { Barretenberg } = await import('./infra/provingSystems/Barretenberg.js');\n provingSystem = new Barretenberg();\n return new IziNoir(provingSystem);\n }\n case Provider.Arkworks: {\n const { ArkworksWasm } = await import('./infra/provingSystems/ArkworksWasm.js');\n const arkworksInstance = new ArkworksWasm();\n provingSystem = arkworksInstance;\n\n const instance = new IziNoir(provingSystem, config.chain);\n\n // Auto-register SolanaFormatter if chain is Solana or for backwards compatibility\n if (config.chain === Chain.Solana || !config.chain) {\n const { SolanaFormatter } = await import('./infra/chainFormatters/SolanaFormatter.js');\n instance.registerChainFormatter(new SolanaFormatter(arkworksInstance));\n }\n\n return instance;\n }\n case Provider.Sunspot: {\n throw new Error(\n 'Sunspot is not available in the main entry point. ' +\n 'Import from \"@izi-noir/sdk/sunspot\" for Sunspot support.'\n );\n }\n default:\n throw new Error(`Unknown provider: ${config.provider}`);\n }\n }\n\n /**\n * Get the underlying proving system instance.\n * Useful for advanced use cases.\n */\n getProvingSystem(): IProvingSystem {\n return this.provingSystem;\n }\n\n /**\n * Get the currently compiled circuit, if any.\n */\n getCompiledCircuit(): CompiledCircuit | null {\n return this.compiledCircuit;\n }\n\n /**\n * Compile Noir code into a circuit.\n *\n * @param noirCode - The Noir source code to compile\n * @returns The compiled circuit\n */\n async compile(noirCode: string): Promise<CompiledCircuit> {\n this.compiledCircuit = await this.provingSystem.compile(noirCode);\n return this.compiledCircuit;\n }\n\n /**\n * Generate a proof for the given inputs.\n *\n * If a chain is configured, returns chain-formatted proof data and stores\n * the verifying key in `this.vk`. Otherwise, returns raw proof data.\n *\n * @param inputs - The inputs (both public and private) for the circuit\n * @param circuit - Optional circuit to use (defaults to last compiled circuit)\n * @returns The proof data - type depends on configured chain\n * @throws Error if no circuit is available\n *\n * @example\n * ```typescript\n * // With chain configured - returns SolanaProofData\n * const izi = await IziNoir.init({ provider: Provider.Arkworks, chain: Chain.Solana });\n * await izi.compile(noirCode);\n * const proof = await izi.prove({ expected: '100', secret: '10' });\n * // proof is SolanaProofData, izi.vk is available\n *\n * // Offchain mode - returns ProofData\n * const iziOffchain = await IziNoir.init({ provider: Provider.Arkworks });\n * await iziOffchain.compile(noirCode);\n * const rawProof = await iziOffchain.prove({ expected: '100', secret: '10' });\n * // rawProof is ProofData, iziOffchain.vk is undefined\n * ```\n */\n async prove(inputs: InputMap, circuit?: CompiledCircuit): Promise<ProofData | SolanaProofData> {\n const circuitToUse = circuit || this.compiledCircuit;\n if (!circuitToUse) {\n throw new Error('No circuit available. Call compile() first or provide a circuit.');\n }\n\n // Generate raw proof\n const rawProof = await this.provingSystem.generateProof(circuitToUse, inputs);\n\n // If no chain configured, return raw proof (offchain mode)\n if (!this.chain) {\n this._lastProof = rawProof;\n return rawProof;\n }\n\n // Get formatter for the configured chain\n const formatter = this.chainFormatters.get(this.chain);\n if (!formatter) {\n throw new Error(\n `No formatter registered for chain: ${this.chain}. ` +\n 'This is an internal error - please report it.'\n );\n }\n\n // Build circuit metadata\n const metadata: CircuitMetadata = {\n numPublicInputs: rawProof.publicInputs.length,\n };\n\n // Format for target chain\n const formattedProof = await formatter.formatProof(rawProof, circuitToUse, metadata);\n const chainProof = formattedProof as unknown as SolanaProofData;\n\n // Store VK on instance\n this._verifyingKey = chainProof.verifyingKey;\n this._lastProof = chainProof;\n\n return chainProof;\n }\n\n /**\n * Verify a proof.\n * Available in both on-chain and offchain modes.\n *\n * @param proof - The proof bytes to verify\n * @param publicInputs - The public inputs that were used\n * @param circuit - Optional circuit to use (defaults to last compiled circuit)\n * @returns true if the proof is valid, false otherwise\n * @throws Error if no circuit is available\n */\n async verify(\n proof: Uint8Array,\n publicInputs: string[],\n circuit?: CompiledCircuit\n ): Promise<boolean> {\n const circuitToUse = circuit || this.compiledCircuit;\n if (!circuitToUse) {\n throw new Error('No circuit available. Call compile() first or provide a circuit.');\n }\n return this.provingSystem.verifyProof(circuitToUse, proof, publicInputs);\n }\n\n /**\n * Convenience method: compile, prove, and verify in one call.\n *\n * @param noirCode - The Noir source code to compile\n * @param inputs - The inputs (both public and private) for the circuit\n * @returns Object containing proof data and verification result\n *\n * @example\n * ```typescript\n * const { proof, verified } = await izi.createProof(noirCode, {\n * x: '100',\n * y: '10',\n * });\n * console.log(`Verified: ${verified}`);\n * ```\n */\n async createProof(\n noirCode: string,\n inputs: InputMap\n ): Promise<{ proof: ProofData | SolanaProofData; verified: boolean }> {\n const circuit = await this.compile(noirCode);\n const proof = await this.prove(inputs, circuit);\n\n // For verification, extract raw proof bytes\n const proofBytes =\n 'proof' in proof && proof.proof instanceof Uint8Array\n ? proof.proof\n : (proof as SolanaProofData).proof.bytes;\n const pubInputs = Array.isArray(proof.publicInputs)\n ? (proof.publicInputs as string[])\n : (proof as SolanaProofData).publicInputs.hex;\n\n const verified = await this.verify(proofBytes, pubInputs, circuit);\n return { proof, verified };\n }\n\n /**\n * Get deployment data for the verifying key.\n * Returns the data needed to deploy to the configured blockchain.\n * Use with SolanaTransactionBuilder to build and send the transaction.\n *\n * @param options - Optional configuration\n * @returns Deployment data that can be used with SolanaTransactionBuilder\n * @throws Error if no chain is configured (offchain mode)\n * @throws Error if prove() hasn't been called yet\n *\n * @example\n * ```typescript\n * const izi = await IziNoir.init({ provider: Provider.Arkworks, chain: Chain.Solana });\n * await izi.compile(noirCode);\n * await izi.prove(inputs);\n *\n * // Get deployment data\n * const deployData = izi.getDeployData();\n *\n * // Use with SolanaTransactionBuilder in your frontend\n * const builder = new SolanaTransactionBuilder({ programId: deployData.programId });\n * const { initVk, rentLamports, accountSize } = builder.buildInitAndVerifyInstructions(\n * deployData.proofData,\n * vkAccountPubkey,\n * authority,\n * payer\n * );\n * ```\n */\n getDeployData(options?: { programId?: string; computeUnits?: number }): SolanaDeployData {\n if (!this.chain) {\n throw new Error('Cannot deploy in offchain mode. Initialize with a chain parameter.');\n }\n\n if (!this._verifyingKey || !this._lastProof) {\n throw new Error('Must call prove() before getDeployData().');\n }\n\n if (this.chain !== Chain.Solana) {\n throw new Error(`Deployment for ${this.chain} is not yet supported.`);\n }\n\n return {\n proofData: this._lastProof as SolanaProofData,\n programId: options?.programId ?? 'EYhRED7EuMyyVjx57aDXUD9h6ArnEKng64qtz8999KrS',\n computeUnits: options?.computeUnits ?? 400_000,\n };\n }\n}\n\n// Re-export Provider, Chain and types for convenience\nexport { Provider, Chain, type IziNoirConfig, type CircuitPaths };\nexport type { SolanaProofData, VerifyingKeyData } from './domain/types.js';\nexport type {\n ChainId,\n CircuitMetadata,\n ChainMetadata,\n SolanaChainMetadata,\n EthereumChainMetadata,\n ChainMetadataFor,\n} from './domain/types/chain.js';\nexport type {\n IChainFormatter,\n ChainProofDataFor,\n} from './domain/interfaces/chain/IChainFormatter.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAsBA,SAAS,eAAe,SAA6C;AACnE,SAAO,IAAI,eAAe;AAAA,IACxB,MAAM,YAAY;AAChB,iBAAW,QAAQ,IAAI,YAAY,EAAE,OAAO,OAAO,CAAC;AACpD,iBAAW,MAAM;AAAA,IACnB;AAAA,EACF,CAAC;AACH;AAKA,SAAS,WAAoB;AAC3B,SACE,OAAO,WAAW,YAAY,eAC9B,WAAW,QAAQ,YAAY,QAC/B,WAAW,QAAQ,SAAS,QAAQ;AAExC;AAKA,eAAe,gBAAsF;AACnG,MAAI,CAAC,SAAS,GAAG;AAEf,WAAO,EAAE,UAAU,KAAK,SAAS,KAAK;AAAA,EACxC;AAIA,QAAM,KAAK,MAAM,OAAO,aAAkB;AAC1C,QAAM,KAAK,MAAM,OAAO,IAAS;AACjC,QAAM,OAAO,MAAM,OAAO,MAAW;AAErC,QAAM,WAAW,MAAM,GAAG,QAAQ,KAAK,KAAK,GAAG,OAAO,GAAG,mBAAmB,CAAC;AAC7E,QAAM,UAAU,YAAY;AAC1B,UAAM,GAAG,GAAG,UAAU,EAAE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AAK;AAAA,MAChB,WAAW,SAAS,aAAa;AAAA,MACjC,cAAc,SAAS,gBAAgB;AAAA,IACzC;AAAA,EACF;AACF;","names":["module","stringToStream","isNodeJs","createTempDir","import_noir_wasm","import_noir_js","BarretenbergBackend","Provider","wasmInitPromise","isNodeJs","Barretenberg","ArkworksWasm","SolanaFormatter"]}
1
+ {"version":3,"sources":["../../src/wasm/nodejs/arkworks_groth16_wasm.js","../../src/wasm/web/arkworks_groth16_wasm.js","../../src/infra/provingSystems/ArkworksWasm.ts","../../src/infra/provingSystems/Barretenberg.ts","../../src/infra/chainFormatters/SolanaFormatter.ts","../../src/providers/arkworks.ts","../../src/domain/types/provider.ts","../../src/infra/wasm/wasmInit.ts","../../src/IziNoir.ts"],"sourcesContent":["/* @ts-self-types=\"./arkworks_groth16_wasm.d.ts\" */\n\n/**\n * Convert ACIR JSON to R1CS information (for debugging)\n * @param {string} acir_json\n * @returns {any}\n */\nfunction acir_to_r1cs_info(acir_json) {\n const ptr0 = passStringToWasm0(acir_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.acir_to_r1cs_info(ptr0, len0);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n}\nexports.acir_to_r1cs_info = acir_to_r1cs_info;\n\nfunction init_panic_hook() {\n wasm.init_panic_hook();\n}\nexports.init_panic_hook = init_panic_hook;\n\n/**\n * Generate a Groth16 proof\n *\n * # Arguments\n * * `proving_key_b64` - Base64-encoded proving key from setup\n * * `acir_json` - JSON string of the ACIR program\n * * `witness_json` - JSON object mapping witness indices to hex values\n *\n * # Returns\n * * `JsProofResult` with proof and public inputs\n * @param {string} proving_key_b64\n * @param {string} acir_json\n * @param {string} witness_json\n * @returns {any}\n */\nfunction prove(proving_key_b64, acir_json, witness_json) {\n const ptr0 = passStringToWasm0(proving_key_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(acir_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(witness_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len2 = WASM_VECTOR_LEN;\n const ret = wasm.prove(ptr0, len0, ptr1, len1, ptr2, len2);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n}\nexports.prove = prove;\n\n/**\n * Generate a Groth16 proof from R1CS definition\n *\n * # Arguments\n * * `proving_key_b64` - Base64-encoded proving key from setup\n * * `r1cs_json` - JSON string of R1CS definition\n * * `witness_json` - JSON object mapping witness indices to hex values\n *\n * # Returns\n * * `JsProofResult` with proof and public inputs\n * @param {string} proving_key_b64\n * @param {string} r1cs_json\n * @param {string} witness_json\n * @returns {any}\n */\nfunction prove_from_r1cs(proving_key_b64, r1cs_json, witness_json) {\n const ptr0 = passStringToWasm0(proving_key_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(r1cs_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(witness_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len2 = WASM_VECTOR_LEN;\n const ret = wasm.prove_from_r1cs(ptr0, len0, ptr1, len1, ptr2, len2);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n}\nexports.prove_from_r1cs = prove_from_r1cs;\n\n/**\n * Perform trusted setup for a circuit\n *\n * # Arguments\n * * `acir_json` - JSON string of the ACIR program from Noir compiler\n *\n * # Returns\n * * `JsSetupResult` with base64-encoded proving and verifying keys\n * @param {string} acir_json\n * @returns {any}\n */\nfunction setup(acir_json) {\n const ptr0 = passStringToWasm0(acir_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.setup(ptr0, len0);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n}\nexports.setup = setup;\n\n/**\n * Perform trusted setup from R1CS definition\n *\n * # Arguments\n * * `r1cs_json` - JSON string of R1CS definition\n *\n * # Returns\n * * `JsSetupResult` with base64-encoded proving and verifying keys\n * @param {string} r1cs_json\n * @returns {any}\n */\nfunction setup_from_r1cs(r1cs_json) {\n const ptr0 = passStringToWasm0(r1cs_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.setup_from_r1cs(ptr0, len0);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n}\nexports.setup_from_r1cs = setup_from_r1cs;\n\n/**\n * Verify a Groth16 proof\n *\n * # Arguments\n * * `verifying_key_b64` - Base64-encoded verifying key from setup\n * * `proof_b64` - Base64-encoded proof (arkworks format)\n * * `public_inputs_json` - JSON array of public inputs as hex strings\n *\n * # Returns\n * * `true` if proof is valid, `false` otherwise\n * @param {string} verifying_key_b64\n * @param {string} proof_b64\n * @param {string} public_inputs_json\n * @returns {boolean}\n */\nfunction verify(verifying_key_b64, proof_b64, public_inputs_json) {\n const ptr0 = passStringToWasm0(verifying_key_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(proof_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(public_inputs_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len2 = WASM_VECTOR_LEN;\n const ret = wasm.verify(ptr0, len0, ptr1, len1, ptr2, len2);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return ret[0] !== 0;\n}\nexports.verify = verify;\n\n/**\n * Verify a Groth16 proof in gnark format\n *\n * # Arguments\n * * `verifying_key_gnark_b64` - Base64-encoded verifying key (gnark format)\n * * `proof_gnark_b64` - Base64-encoded proof (gnark format, 256 bytes)\n * * `public_inputs_gnark_b64` - Base64-encoded public inputs (gnark format)\n * * `num_public_inputs` - Number of public inputs\n *\n * # Returns\n * * `true` if proof is valid, `false` otherwise\n * @param {string} verifying_key_gnark_b64\n * @param {string} proof_gnark_b64\n * @param {string} public_inputs_gnark_b64\n * @param {number} num_public_inputs\n * @returns {boolean}\n */\nfunction verify_gnark(verifying_key_gnark_b64, proof_gnark_b64, public_inputs_gnark_b64, num_public_inputs) {\n const ptr0 = passStringToWasm0(verifying_key_gnark_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(proof_gnark_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(public_inputs_gnark_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len2 = WASM_VECTOR_LEN;\n const ret = wasm.verify_gnark(ptr0, len0, ptr1, len1, ptr2, len2, num_public_inputs);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return ret[0] !== 0;\n}\nexports.verify_gnark = verify_gnark;\n\n/**\n * Get library version\n * @returns {string}\n */\nfunction version() {\n let deferred1_0;\n let deferred1_1;\n try {\n const ret = wasm.version();\n deferred1_0 = ret[0];\n deferred1_1 = ret[1];\n return getStringFromWasm0(ret[0], ret[1]);\n } finally {\n wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);\n }\n}\nexports.version = version;\n\nfunction __wbg_get_imports() {\n const import0 = {\n __proto__: null,\n __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {\n const ret = Error(getStringFromWasm0(arg0, arg1));\n return ret;\n },\n __wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {\n const ret = String(arg1);\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n },\n __wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {\n const ret = typeof(arg0) === 'function';\n return ret;\n },\n __wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {\n const val = arg0;\n const ret = typeof(val) === 'object' && val !== null;\n return ret;\n },\n __wbg___wbindgen_is_string_cd444516edc5b180: function(arg0) {\n const ret = typeof(arg0) === 'string';\n return ret;\n },\n __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {\n const ret = arg0 === undefined;\n return ret;\n },\n __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {\n throw new Error(getStringFromWasm0(arg0, arg1));\n },\n __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {\n const ret = arg0.call(arg1);\n return ret;\n }, arguments); },\n __wbg_call_4708e0c13bdc8e95: function() { return handleError(function (arg0, arg1, arg2) {\n const ret = arg0.call(arg1, arg2);\n return ret;\n }, arguments); },\n __wbg_crypto_86f2631e91b51511: function(arg0) {\n const ret = arg0.crypto;\n return ret;\n },\n __wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {\n let deferred0_0;\n let deferred0_1;\n try {\n deferred0_0 = arg0;\n deferred0_1 = arg1;\n console.error(getStringFromWasm0(arg0, arg1));\n } finally {\n wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);\n }\n },\n __wbg_getRandomValues_b3f15fcbfabb0f8b: function() { return handleError(function (arg0, arg1) {\n arg0.getRandomValues(arg1);\n }, arguments); },\n __wbg_length_32ed9a279acd054c: function(arg0) {\n const ret = arg0.length;\n return ret;\n },\n __wbg_msCrypto_d562bbe83e0d4b91: function(arg0) {\n const ret = arg0.msCrypto;\n return ret;\n },\n __wbg_new_361308b2356cecd0: function() {\n const ret = new Object();\n return ret;\n },\n __wbg_new_3eb36ae241fe6f44: function() {\n const ret = new Array();\n return ret;\n },\n __wbg_new_8a6f238a6ece86ea: function() {\n const ret = new Error();\n return ret;\n },\n __wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {\n const ret = new Function(getStringFromWasm0(arg0, arg1));\n return ret;\n },\n __wbg_new_with_length_a2c39cbe88fd8ff1: function(arg0) {\n const ret = new Uint8Array(arg0 >>> 0);\n return ret;\n },\n __wbg_node_e1f24f89a7336c2e: function(arg0) {\n const ret = arg0.node;\n return ret;\n },\n __wbg_process_3975fd6c72f520aa: function(arg0) {\n const ret = arg0.process;\n return ret;\n },\n __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {\n Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);\n },\n __wbg_randomFillSync_f8c153b79f285817: function() { return handleError(function (arg0, arg1) {\n arg0.randomFillSync(arg1);\n }, arguments); },\n __wbg_require_b74f47fc2d022fd6: function() { return handleError(function () {\n const ret = module.require;\n return ret;\n }, arguments); },\n __wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {\n arg0[arg1] = arg2;\n },\n __wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {\n arg0[arg1 >>> 0] = arg2;\n },\n __wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {\n const ret = arg1.stack;\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n },\n __wbg_static_accessor_GLOBAL_12837167ad935116: function() {\n const ret = typeof global === 'undefined' ? null : global;\n return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);\n },\n __wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {\n const ret = typeof globalThis === 'undefined' ? null : globalThis;\n return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);\n },\n __wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {\n const ret = typeof self === 'undefined' ? null : self;\n return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);\n },\n __wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {\n const ret = typeof window === 'undefined' ? null : window;\n return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);\n },\n __wbg_subarray_a96e1fef17ed23cb: function(arg0, arg1, arg2) {\n const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);\n return ret;\n },\n __wbg_versions_4e31226f5e8dc909: function(arg0) {\n const ret = arg0.versions;\n return ret;\n },\n __wbindgen_cast_0000000000000001: function(arg0) {\n // Cast intrinsic for `F64 -> Externref`.\n const ret = arg0;\n return ret;\n },\n __wbindgen_cast_0000000000000002: function(arg0, arg1) {\n // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref(\"Uint8Array\")`.\n const ret = getArrayU8FromWasm0(arg0, arg1);\n return ret;\n },\n __wbindgen_cast_0000000000000003: function(arg0, arg1) {\n // Cast intrinsic for `Ref(String) -> Externref`.\n const ret = getStringFromWasm0(arg0, arg1);\n return ret;\n },\n __wbindgen_cast_0000000000000004: function(arg0) {\n // Cast intrinsic for `U64 -> Externref`.\n const ret = BigInt.asUintN(64, arg0);\n return ret;\n },\n __wbindgen_init_externref_table: function() {\n const table = wasm.__wbindgen_externrefs;\n const offset = table.grow(4);\n table.set(0, undefined);\n table.set(offset + 0, undefined);\n table.set(offset + 1, null);\n table.set(offset + 2, true);\n table.set(offset + 3, false);\n },\n };\n return {\n __proto__: null,\n \"./arkworks_groth16_wasm_bg.js\": import0,\n };\n}\n\nfunction addToExternrefTable0(obj) {\n const idx = wasm.__externref_table_alloc();\n wasm.__wbindgen_externrefs.set(idx, obj);\n return idx;\n}\n\nfunction getArrayU8FromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);\n}\n\nlet cachedDataViewMemory0 = null;\nfunction getDataViewMemory0() {\n if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {\n cachedDataViewMemory0 = new DataView(wasm.memory.buffer);\n }\n return cachedDataViewMemory0;\n}\n\nfunction getStringFromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return decodeText(ptr, len);\n}\n\nlet cachedUint8ArrayMemory0 = null;\nfunction getUint8ArrayMemory0() {\n if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {\n cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);\n }\n return cachedUint8ArrayMemory0;\n}\n\nfunction handleError(f, args) {\n try {\n return f.apply(this, args);\n } catch (e) {\n const idx = addToExternrefTable0(e);\n wasm.__wbindgen_exn_store(idx);\n }\n}\n\nfunction isLikeNone(x) {\n return x === undefined || x === null;\n}\n\nfunction passStringToWasm0(arg, malloc, realloc) {\n if (realloc === undefined) {\n const buf = cachedTextEncoder.encode(arg);\n const ptr = malloc(buf.length, 1) >>> 0;\n getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);\n WASM_VECTOR_LEN = buf.length;\n return ptr;\n }\n\n let len = arg.length;\n let ptr = malloc(len, 1) >>> 0;\n\n const mem = getUint8ArrayMemory0();\n\n let offset = 0;\n\n for (; offset < len; offset++) {\n const code = arg.charCodeAt(offset);\n if (code > 0x7F) break;\n mem[ptr + offset] = code;\n }\n if (offset !== len) {\n if (offset !== 0) {\n arg = arg.slice(offset);\n }\n ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;\n const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);\n const ret = cachedTextEncoder.encodeInto(arg, view);\n\n offset += ret.written;\n ptr = realloc(ptr, len, offset, 1) >>> 0;\n }\n\n WASM_VECTOR_LEN = offset;\n return ptr;\n}\n\nfunction takeFromExternrefTable0(idx) {\n const value = wasm.__wbindgen_externrefs.get(idx);\n wasm.__externref_table_dealloc(idx);\n return value;\n}\n\nlet cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });\ncachedTextDecoder.decode();\nfunction decodeText(ptr, len) {\n return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));\n}\n\nconst cachedTextEncoder = new TextEncoder();\n\nif (!('encodeInto' in cachedTextEncoder)) {\n cachedTextEncoder.encodeInto = function (arg, view) {\n const buf = cachedTextEncoder.encode(arg);\n view.set(buf);\n return {\n read: arg.length,\n written: buf.length\n };\n };\n}\n\nlet WASM_VECTOR_LEN = 0;\n\nconst wasmPath = `${__dirname}/arkworks_groth16_wasm_bg.wasm`;\nconst wasmBytes = require('fs').readFileSync(wasmPath);\nconst wasmModule = new WebAssembly.Module(wasmBytes);\nconst wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;\nwasm.__wbindgen_start();\n","/* @ts-self-types=\"./arkworks_groth16_wasm.d.ts\" */\n\n/**\n * Convert ACIR JSON to R1CS information (for debugging)\n * @param {string} acir_json\n * @returns {any}\n */\nexport function acir_to_r1cs_info(acir_json) {\n const ptr0 = passStringToWasm0(acir_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.acir_to_r1cs_info(ptr0, len0);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n}\n\nexport function init_panic_hook() {\n wasm.init_panic_hook();\n}\n\n/**\n * Generate a Groth16 proof\n *\n * # Arguments\n * * `proving_key_b64` - Base64-encoded proving key from setup\n * * `acir_json` - JSON string of the ACIR program\n * * `witness_json` - JSON object mapping witness indices to hex values\n *\n * # Returns\n * * `JsProofResult` with proof and public inputs\n * @param {string} proving_key_b64\n * @param {string} acir_json\n * @param {string} witness_json\n * @returns {any}\n */\nexport function prove(proving_key_b64, acir_json, witness_json) {\n const ptr0 = passStringToWasm0(proving_key_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(acir_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(witness_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len2 = WASM_VECTOR_LEN;\n const ret = wasm.prove(ptr0, len0, ptr1, len1, ptr2, len2);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n}\n\n/**\n * Generate a Groth16 proof from R1CS definition\n *\n * # Arguments\n * * `proving_key_b64` - Base64-encoded proving key from setup\n * * `r1cs_json` - JSON string of R1CS definition\n * * `witness_json` - JSON object mapping witness indices to hex values\n *\n * # Returns\n * * `JsProofResult` with proof and public inputs\n * @param {string} proving_key_b64\n * @param {string} r1cs_json\n * @param {string} witness_json\n * @returns {any}\n */\nexport function prove_from_r1cs(proving_key_b64, r1cs_json, witness_json) {\n const ptr0 = passStringToWasm0(proving_key_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(r1cs_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(witness_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len2 = WASM_VECTOR_LEN;\n const ret = wasm.prove_from_r1cs(ptr0, len0, ptr1, len1, ptr2, len2);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n}\n\n/**\n * Perform trusted setup for a circuit\n *\n * # Arguments\n * * `acir_json` - JSON string of the ACIR program from Noir compiler\n *\n * # Returns\n * * `JsSetupResult` with base64-encoded proving and verifying keys\n * @param {string} acir_json\n * @returns {any}\n */\nexport function setup(acir_json) {\n const ptr0 = passStringToWasm0(acir_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.setup(ptr0, len0);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n}\n\n/**\n * Perform trusted setup from R1CS definition\n *\n * # Arguments\n * * `r1cs_json` - JSON string of R1CS definition\n *\n * # Returns\n * * `JsSetupResult` with base64-encoded proving and verifying keys\n * @param {string} r1cs_json\n * @returns {any}\n */\nexport function setup_from_r1cs(r1cs_json) {\n const ptr0 = passStringToWasm0(r1cs_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.setup_from_r1cs(ptr0, len0);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return takeFromExternrefTable0(ret[0]);\n}\n\n/**\n * Verify a Groth16 proof\n *\n * # Arguments\n * * `verifying_key_b64` - Base64-encoded verifying key from setup\n * * `proof_b64` - Base64-encoded proof (arkworks format)\n * * `public_inputs_json` - JSON array of public inputs as hex strings\n *\n * # Returns\n * * `true` if proof is valid, `false` otherwise\n * @param {string} verifying_key_b64\n * @param {string} proof_b64\n * @param {string} public_inputs_json\n * @returns {boolean}\n */\nexport function verify(verifying_key_b64, proof_b64, public_inputs_json) {\n const ptr0 = passStringToWasm0(verifying_key_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(proof_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(public_inputs_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len2 = WASM_VECTOR_LEN;\n const ret = wasm.verify(ptr0, len0, ptr1, len1, ptr2, len2);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return ret[0] !== 0;\n}\n\n/**\n * Verify a Groth16 proof in gnark format\n *\n * # Arguments\n * * `verifying_key_gnark_b64` - Base64-encoded verifying key (gnark format)\n * * `proof_gnark_b64` - Base64-encoded proof (gnark format, 256 bytes)\n * * `public_inputs_gnark_b64` - Base64-encoded public inputs (gnark format)\n * * `num_public_inputs` - Number of public inputs\n *\n * # Returns\n * * `true` if proof is valid, `false` otherwise\n * @param {string} verifying_key_gnark_b64\n * @param {string} proof_gnark_b64\n * @param {string} public_inputs_gnark_b64\n * @param {number} num_public_inputs\n * @returns {boolean}\n */\nexport function verify_gnark(verifying_key_gnark_b64, proof_gnark_b64, public_inputs_gnark_b64, num_public_inputs) {\n const ptr0 = passStringToWasm0(verifying_key_gnark_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ptr1 = passStringToWasm0(proof_gnark_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n const ptr2 = passStringToWasm0(public_inputs_gnark_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len2 = WASM_VECTOR_LEN;\n const ret = wasm.verify_gnark(ptr0, len0, ptr1, len1, ptr2, len2, num_public_inputs);\n if (ret[2]) {\n throw takeFromExternrefTable0(ret[1]);\n }\n return ret[0] !== 0;\n}\n\n/**\n * Get library version\n * @returns {string}\n */\nexport function version() {\n let deferred1_0;\n let deferred1_1;\n try {\n const ret = wasm.version();\n deferred1_0 = ret[0];\n deferred1_1 = ret[1];\n return getStringFromWasm0(ret[0], ret[1]);\n } finally {\n wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);\n }\n}\n\nfunction __wbg_get_imports() {\n const import0 = {\n __proto__: null,\n __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {\n const ret = Error(getStringFromWasm0(arg0, arg1));\n return ret;\n },\n __wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {\n const ret = String(arg1);\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n },\n __wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {\n const ret = typeof(arg0) === 'function';\n return ret;\n },\n __wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {\n const val = arg0;\n const ret = typeof(val) === 'object' && val !== null;\n return ret;\n },\n __wbg___wbindgen_is_string_cd444516edc5b180: function(arg0) {\n const ret = typeof(arg0) === 'string';\n return ret;\n },\n __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {\n const ret = arg0 === undefined;\n return ret;\n },\n __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {\n throw new Error(getStringFromWasm0(arg0, arg1));\n },\n __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {\n const ret = arg0.call(arg1);\n return ret;\n }, arguments); },\n __wbg_call_4708e0c13bdc8e95: function() { return handleError(function (arg0, arg1, arg2) {\n const ret = arg0.call(arg1, arg2);\n return ret;\n }, arguments); },\n __wbg_crypto_86f2631e91b51511: function(arg0) {\n const ret = arg0.crypto;\n return ret;\n },\n __wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {\n let deferred0_0;\n let deferred0_1;\n try {\n deferred0_0 = arg0;\n deferred0_1 = arg1;\n console.error(getStringFromWasm0(arg0, arg1));\n } finally {\n wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);\n }\n },\n __wbg_getRandomValues_b3f15fcbfabb0f8b: function() { return handleError(function (arg0, arg1) {\n arg0.getRandomValues(arg1);\n }, arguments); },\n __wbg_length_32ed9a279acd054c: function(arg0) {\n const ret = arg0.length;\n return ret;\n },\n __wbg_msCrypto_d562bbe83e0d4b91: function(arg0) {\n const ret = arg0.msCrypto;\n return ret;\n },\n __wbg_new_361308b2356cecd0: function() {\n const ret = new Object();\n return ret;\n },\n __wbg_new_3eb36ae241fe6f44: function() {\n const ret = new Array();\n return ret;\n },\n __wbg_new_8a6f238a6ece86ea: function() {\n const ret = new Error();\n return ret;\n },\n __wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {\n const ret = new Function(getStringFromWasm0(arg0, arg1));\n return ret;\n },\n __wbg_new_with_length_a2c39cbe88fd8ff1: function(arg0) {\n const ret = new Uint8Array(arg0 >>> 0);\n return ret;\n },\n __wbg_node_e1f24f89a7336c2e: function(arg0) {\n const ret = arg0.node;\n return ret;\n },\n __wbg_process_3975fd6c72f520aa: function(arg0) {\n const ret = arg0.process;\n return ret;\n },\n __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {\n Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);\n },\n __wbg_randomFillSync_f8c153b79f285817: function() { return handleError(function (arg0, arg1) {\n arg0.randomFillSync(arg1);\n }, arguments); },\n __wbg_require_b74f47fc2d022fd6: function() { return handleError(function () {\n const ret = module.require;\n return ret;\n }, arguments); },\n __wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {\n arg0[arg1] = arg2;\n },\n __wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {\n arg0[arg1 >>> 0] = arg2;\n },\n __wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {\n const ret = arg1.stack;\n const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len1 = WASM_VECTOR_LEN;\n getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);\n getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);\n },\n __wbg_static_accessor_GLOBAL_12837167ad935116: function() {\n const ret = typeof global === 'undefined' ? null : global;\n return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);\n },\n __wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {\n const ret = typeof globalThis === 'undefined' ? null : globalThis;\n return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);\n },\n __wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {\n const ret = typeof self === 'undefined' ? null : self;\n return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);\n },\n __wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {\n const ret = typeof window === 'undefined' ? null : window;\n return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);\n },\n __wbg_subarray_a96e1fef17ed23cb: function(arg0, arg1, arg2) {\n const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);\n return ret;\n },\n __wbg_versions_4e31226f5e8dc909: function(arg0) {\n const ret = arg0.versions;\n return ret;\n },\n __wbindgen_cast_0000000000000001: function(arg0) {\n // Cast intrinsic for `F64 -> Externref`.\n const ret = arg0;\n return ret;\n },\n __wbindgen_cast_0000000000000002: function(arg0, arg1) {\n // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref(\"Uint8Array\")`.\n const ret = getArrayU8FromWasm0(arg0, arg1);\n return ret;\n },\n __wbindgen_cast_0000000000000003: function(arg0, arg1) {\n // Cast intrinsic for `Ref(String) -> Externref`.\n const ret = getStringFromWasm0(arg0, arg1);\n return ret;\n },\n __wbindgen_cast_0000000000000004: function(arg0) {\n // Cast intrinsic for `U64 -> Externref`.\n const ret = BigInt.asUintN(64, arg0);\n return ret;\n },\n __wbindgen_init_externref_table: function() {\n const table = wasm.__wbindgen_externrefs;\n const offset = table.grow(4);\n table.set(0, undefined);\n table.set(offset + 0, undefined);\n table.set(offset + 1, null);\n table.set(offset + 2, true);\n table.set(offset + 3, false);\n },\n };\n return {\n __proto__: null,\n \"./arkworks_groth16_wasm_bg.js\": import0,\n };\n}\n\nfunction addToExternrefTable0(obj) {\n const idx = wasm.__externref_table_alloc();\n wasm.__wbindgen_externrefs.set(idx, obj);\n return idx;\n}\n\nfunction getArrayU8FromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);\n}\n\nlet cachedDataViewMemory0 = null;\nfunction getDataViewMemory0() {\n if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {\n cachedDataViewMemory0 = new DataView(wasm.memory.buffer);\n }\n return cachedDataViewMemory0;\n}\n\nfunction getStringFromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return decodeText(ptr, len);\n}\n\nlet cachedUint8ArrayMemory0 = null;\nfunction getUint8ArrayMemory0() {\n if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {\n cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);\n }\n return cachedUint8ArrayMemory0;\n}\n\nfunction handleError(f, args) {\n try {\n return f.apply(this, args);\n } catch (e) {\n const idx = addToExternrefTable0(e);\n wasm.__wbindgen_exn_store(idx);\n }\n}\n\nfunction isLikeNone(x) {\n return x === undefined || x === null;\n}\n\nfunction passStringToWasm0(arg, malloc, realloc) {\n if (realloc === undefined) {\n const buf = cachedTextEncoder.encode(arg);\n const ptr = malloc(buf.length, 1) >>> 0;\n getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);\n WASM_VECTOR_LEN = buf.length;\n return ptr;\n }\n\n let len = arg.length;\n let ptr = malloc(len, 1) >>> 0;\n\n const mem = getUint8ArrayMemory0();\n\n let offset = 0;\n\n for (; offset < len; offset++) {\n const code = arg.charCodeAt(offset);\n if (code > 0x7F) break;\n mem[ptr + offset] = code;\n }\n if (offset !== len) {\n if (offset !== 0) {\n arg = arg.slice(offset);\n }\n ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;\n const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);\n const ret = cachedTextEncoder.encodeInto(arg, view);\n\n offset += ret.written;\n ptr = realloc(ptr, len, offset, 1) >>> 0;\n }\n\n WASM_VECTOR_LEN = offset;\n return ptr;\n}\n\nfunction takeFromExternrefTable0(idx) {\n const value = wasm.__wbindgen_externrefs.get(idx);\n wasm.__externref_table_dealloc(idx);\n return value;\n}\n\nlet cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });\ncachedTextDecoder.decode();\nconst MAX_SAFARI_DECODE_BYTES = 2146435072;\nlet numBytesDecoded = 0;\nfunction decodeText(ptr, len) {\n numBytesDecoded += len;\n if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {\n cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });\n cachedTextDecoder.decode();\n numBytesDecoded = len;\n }\n return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));\n}\n\nconst cachedTextEncoder = new TextEncoder();\n\nif (!('encodeInto' in cachedTextEncoder)) {\n cachedTextEncoder.encodeInto = function (arg, view) {\n const buf = cachedTextEncoder.encode(arg);\n view.set(buf);\n return {\n read: arg.length,\n written: buf.length\n };\n };\n}\n\nlet WASM_VECTOR_LEN = 0;\n\nlet wasmModule, wasm;\nfunction __wbg_finalize_init(instance, module) {\n wasm = instance.exports;\n wasmModule = module;\n cachedDataViewMemory0 = null;\n cachedUint8ArrayMemory0 = null;\n wasm.__wbindgen_start();\n return wasm;\n}\n\nasync function __wbg_load(module, imports) {\n if (typeof Response === 'function' && module instanceof Response) {\n if (typeof WebAssembly.instantiateStreaming === 'function') {\n try {\n return await WebAssembly.instantiateStreaming(module, imports);\n } catch (e) {\n const validResponse = module.ok && expectedResponseType(module.type);\n\n if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {\n console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\", e);\n\n } else { throw e; }\n }\n }\n\n const bytes = await module.arrayBuffer();\n return await WebAssembly.instantiate(bytes, imports);\n } else {\n const instance = await WebAssembly.instantiate(module, imports);\n\n if (instance instanceof WebAssembly.Instance) {\n return { instance, module };\n } else {\n return instance;\n }\n }\n\n function expectedResponseType(type) {\n switch (type) {\n case 'basic': case 'cors': case 'default': return true;\n }\n return false;\n }\n}\n\nfunction initSync(module) {\n if (wasm !== undefined) return wasm;\n\n\n if (module !== undefined) {\n if (Object.getPrototypeOf(module) === Object.prototype) {\n ({module} = module)\n } else {\n console.warn('using deprecated parameters for `initSync()`; pass a single object instead')\n }\n }\n\n const imports = __wbg_get_imports();\n if (!(module instanceof WebAssembly.Module)) {\n module = new WebAssembly.Module(module);\n }\n const instance = new WebAssembly.Instance(module, imports);\n return __wbg_finalize_init(instance, module);\n}\n\nasync function __wbg_init(module_or_path) {\n if (wasm !== undefined) return wasm;\n\n\n if (module_or_path !== undefined) {\n if (Object.getPrototypeOf(module_or_path) === Object.prototype) {\n ({module_or_path} = module_or_path)\n } else {\n console.warn('using deprecated parameters for the initialization function; pass a single object instead')\n }\n }\n\n if (module_or_path === undefined) {\n module_or_path = new URL('arkworks_groth16_wasm_bg.wasm', import.meta.url);\n }\n const imports = __wbg_get_imports();\n\n if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {\n module_or_path = fetch(module_or_path);\n }\n\n const { instance, module } = await __wbg_load(await module_or_path, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nexport { initSync, __wbg_init as default };\n","/**\n * ArkworksWasm proving system.\n *\n * 100% browser-compatible Groth16 prover using arkworks compiled to WASM.\n * Produces proofs compatible with gnark-verifier-solana for on-chain verification.\n *\n * Features:\n * - Runs entirely in the browser (no CLI dependencies)\n * - Generates compact Groth16 proofs (~256 bytes)\n * - Compatible with gnark-verifier-solana\n * - Uses BN254 curve\n */\n\nimport { compile, createFileManager } from '@noir-lang/noir_wasm';\nimport { Noir } from '@noir-lang/noir_js';\nimport { decompressWitness } from '@noir-lang/acvm_js';\nimport type { IProvingSystem } from '../../domain/interfaces/proving/IProvingSystem.js';\nimport type { CompiledCircuit, InputMap, ProofData } from '../../domain/types.js';\n\n/**\n * Helper to create a ReadableStream from a string\n * Used to write files to the virtual filesystem (browser-compatible)\n */\nfunction stringToStream(content: string): ReadableStream<Uint8Array> {\n return new ReadableStream({\n start(controller) {\n controller.enqueue(new TextEncoder().encode(content));\n controller.close();\n },\n });\n}\n\n/**\n * Check if running in Node.js environment\n */\nfunction isNodeJs(): boolean {\n return (\n typeof globalThis.process !== 'undefined' &&\n globalThis.process.versions != null &&\n globalThis.process.versions.node != null\n );\n}\n\n/**\n * Create temp directory in Node.js, or return '/' for browser virtual fs\n */\nasync function createTempDir(): Promise<{ basePath: string; cleanup: (() => Promise<void>) | null }> {\n if (!isNodeJs()) {\n // Browser: use virtual filesystem\n return { basePath: '/', cleanup: null };\n }\n\n // Node.js: create real temp directory\n // Use dynamic import which works in both Node.js ESM and CJS\n const fs = await import('node:fs/promises');\n const os = await import('node:os');\n const path = await import('node:path');\n\n const basePath = await fs.mkdtemp(path.join(os.tmpdir(), 'arkworks-circuit-'));\n const cleanup = async () => {\n await fs.rm(basePath, { recursive: true, force: true });\n };\n\n return { basePath, cleanup };\n}\n\n/**\n * Result of Groth16 setup from arkworks WASM module\n */\nexport interface ArkworksSetupResult {\n /** Base64-encoded proving key */\n proving_key: string;\n /** Base64-encoded verifying key (arkworks format) */\n verifying_key: string;\n /** Base64-encoded verifying key (gnark format for Solana) */\n verifying_key_gnark: string;\n}\n\n/**\n * Result of Groth16 proof generation from arkworks WASM module\n */\nexport interface ArkworksProofResult {\n /** Base64-encoded proof (arkworks format) */\n proof: string;\n /** Base64-encoded proof (gnark format, 256 bytes) */\n proof_gnark: string;\n /** Public inputs as hex strings */\n public_inputs: string[];\n /** Base64-encoded public inputs (gnark format) */\n public_inputs_gnark: string;\n}\n\n/**\n * Interface for the arkworks-groth16-wasm WASM module\n */\nexport interface ArkworksWasmModule {\n setup(acirJson: string): ArkworksSetupResult;\n prove(provingKeyB64: string, acirJson: string, witnessJson: string): ArkworksProofResult;\n verify(verifyingKeyB64: string, proofB64: string, publicInputsJson: string): boolean;\n verify_gnark(\n verifyingKeyGnarkB64: string,\n proofGnarkB64: string,\n publicInputsGnarkB64: string,\n numPublicInputs: number\n ): boolean;\n acir_to_r1cs_info(acirJson: string): {\n num_witnesses: number;\n num_constraints: number;\n public_inputs: number[];\n private_inputs: number[];\n return_values: number[];\n };\n version(): string;\n // R1CS-based API (bypasses ACIR bytecode decoding)\n setup_from_r1cs(r1csJson: string): ArkworksSetupResult;\n prove_from_r1cs(provingKeyB64: string, r1csJson: string, witnessJson: string): ArkworksProofResult;\n}\n\n/**\n * Configuration for ArkworksWasm prover\n */\nexport interface ArkworksWasmConfig {\n /** Keep intermediate artifacts for debugging */\n keepArtifacts?: boolean;\n /** Cache proving/verifying keys for repeated proofs */\n cacheKeys?: boolean;\n}\n\n/**\n * R1CS constraint for arkworks-groth16-wasm\n */\nexport interface R1csConstraint {\n a: [string, number][]; // [(coefficient_hex, witness_index), ...]\n b: [string, number][];\n c: [string, number][];\n}\n\n/**\n * R1CS definition for arkworks-groth16-wasm\n */\nexport interface R1csDefinition {\n num_witnesses: number;\n public_inputs: number[];\n private_inputs: number[];\n constraints: R1csConstraint[];\n}\n\n/**\n * Extended CompiledCircuit for ArkworksWasm backend\n */\nexport interface ArkworksCompiledCircuit extends CompiledCircuit {\n /** Marker to identify ArkworksWasm circuits */\n __arkworks: true;\n /** ACIR program as JSON string (used for setup/prove) - DEPRECATED, use r1csJson */\n acirJson: string;\n /** R1CS definition as JSON string (used for setup/prove) */\n r1csJson: string;\n /** Mapping from noir witness index to R1CS witness index */\n witnessIndexMapping: Map<number, number>;\n /** Cached proving key (base64) if cacheKeys is enabled */\n provingKey?: string;\n /** Cached verifying key (base64) if cacheKeys is enabled */\n verifyingKey?: string;\n /** Cached verifying key in gnark format (base64) */\n verifyingKeyGnark?: string;\n}\n\n/**\n * Type guard to check if a circuit is an ArkworksWasm circuit\n */\nexport function isArkworksCircuit(circuit: CompiledCircuit): circuit is ArkworksCompiledCircuit {\n return '__arkworks' in circuit && (circuit as ArkworksCompiledCircuit).__arkworks === true;\n}\n\n// WASM module singleton\nlet wasmModule: ArkworksWasmModule | null = null;\nlet wasmInitPromise: Promise<ArkworksWasmModule> | null = null;\n\n/**\n * Initialize the arkworks WASM module\n * Automatically detects Node.js vs browser and uses the appropriate WASM target.\n */\nasync function initWasm(): Promise<ArkworksWasmModule> {\n if (wasmModule) {\n return wasmModule;\n }\n\n if (wasmInitPromise) {\n return wasmInitPromise;\n }\n\n wasmInitPromise = (async () => {\n try {\n if (isNodeJs()) {\n // Node.js: use the nodejs target which doesn't require fetch\n // Path resolves to dist/wasm/nodejs/ after bundling\n // @ts-ignore - Dynamic import path resolved at runtime\n const module = await import('../wasm/nodejs/arkworks_groth16_wasm.js');\n wasmModule = module as unknown as ArkworksWasmModule;\n } else {\n // Browser: use the web target with init function\n // Path resolves to dist/wasm/web/ after bundling\n // @ts-ignore - Dynamic import path resolved at runtime\n const module = await import('../wasm/web/arkworks_groth16_wasm.js');\n // Initialize WASM (wasm-pack generates an init function for web target)\n if (typeof module.default === 'function') {\n await module.default();\n }\n wasmModule = module as unknown as ArkworksWasmModule;\n }\n return wasmModule;\n } catch (error) {\n wasmInitPromise = null;\n throw new Error(\n `Failed to initialize arkworks-groth16-wasm: ${error instanceof Error ? error.message : String(error)}\\n` +\n 'Make sure the WASM module is built: cd packages/arkworks-groth16-wasm && npm run build'\n );\n }\n })();\n\n return wasmInitPromise;\n}\n\n/**\n * ArkworksWasm proving system using arkworks Groth16 compiled to WASM.\n *\n * This proving system:\n * - Compiles Noir code using @noir-lang/noir_wasm\n * - Generates witness using @noir-lang/noir_js\n * - Performs Groth16 setup/prove/verify using arkworks-groth16-wasm\n *\n * All operations run in the browser with no external dependencies.\n */\nexport class ArkworksWasm implements IProvingSystem {\n private readonly config: ArkworksWasmConfig;\n\n constructor(config: ArkworksWasmConfig = {}) {\n this.config = {\n keepArtifacts: false,\n cacheKeys: true,\n ...config,\n };\n }\n\n /**\n * Compile Noir code to a circuit with ACIR for Groth16 proving\n */\n async compile(noirCode: string): Promise<CompiledCircuit> {\n const wasm = await initWasm();\n const { basePath, cleanup } = await createTempDir();\n const fm = createFileManager(basePath);\n\n const nargoToml = `[package]\nname = \"circuit\"\ntype = \"bin\"\nauthors = [\"\"]\n\n[dependencies]\n`;\n\n try {\n // Write files using ReadableStream (browser-compatible)\n // In Node.js: writeFile is async and must be awaited\n // In browser: writeFile works with virtual fs, should not await for noir_wasm compatibility\n if (isNodeJs()) {\n await fm.writeFile('./src/main.nr', stringToStream(noirCode));\n await fm.writeFile('./Nargo.toml', stringToStream(nargoToml));\n } else {\n fm.writeFile('./src/main.nr', stringToStream(noirCode));\n fm.writeFile('./Nargo.toml', stringToStream(nargoToml));\n }\n\n // Compile using noir_wasm\n const result = await compile(fm);\n const compiled = (result as any).program as CompiledCircuit;\n\n if (!compiled || !compiled.bytecode) {\n throw new Error('Compilation failed: no bytecode generated');\n }\n\n // Generate R1CS directly from the circuit parameters\n // This bypasses ACIR bytecode decoding which requires bincode parsing\n //\n // R1CS witness layout (arkworks convention):\n // - w_0 = 1 (constant, always)\n // - w_1, w_2, ... = actual witnesses (shifted by 1 from noir_js indices)\n //\n // noir_js decompressWitness returns 0-based indices, so:\n // - noir witness[0] → R1CS w_1\n // - noir witness[1] → R1CS w_2\n // etc.\n const parameters = compiled.abi.parameters;\n const publicR1csIndices: number[] = [];\n const privateR1csIndices: number[] = [];\n const witnessIndexMapping = new Map<number, number>();\n\n parameters.forEach((p, noirIndex) => {\n // Shift by 1 to account for w_0 = 1\n const r1csIndex = noirIndex + 1;\n witnessIndexMapping.set(noirIndex, r1csIndex);\n console.log(` Parameter \"${p.name}\" (${p.visibility}): noir[${noirIndex}] → R1CS w_${r1csIndex}`);\n if (p.visibility === 'public') {\n publicR1csIndices.push(r1csIndex);\n } else if (p.visibility === 'private') {\n privateR1csIndices.push(r1csIndex);\n }\n });\n\n console.log('=== COMPILE: R1CS Witness Assignment ===');\n console.log('Public R1CS indices:', publicR1csIndices);\n console.log('Private R1CS indices:', privateR1csIndices);\n console.log('Witness mapping:', Object.fromEntries(witnessIndexMapping));\n console.log('=========================================');\n\n // Generate R1CS constraints from the Noir code pattern\n // For the demo circuit: assert(secret * secret == expected)\n // This translates to: w_private * w_private = w_public\n //\n // R1CS constraint format: A * B = C\n // For secret * secret = expected:\n // A = [1 * w_secret], B = [1 * w_secret], C = [1 * w_expected]\n const r1cs: R1csDefinition = {\n num_witnesses: parameters.length + 1, // +1 for w_0\n public_inputs: publicR1csIndices,\n private_inputs: privateR1csIndices,\n constraints: [],\n };\n\n // For the simple squaring circuit, add constraint: private * private = public\n // This assumes the circuit pattern: assert(secret * secret == expected)\n if (privateR1csIndices.length === 1 && publicR1csIndices.length === 1) {\n const privateIdx = privateR1csIndices[0];\n const publicIdx = publicR1csIndices[0];\n r1cs.constraints.push({\n a: [['0x1', privateIdx]], // secret\n b: [['0x1', privateIdx]], // secret\n c: [['0x1', publicIdx]], // expected\n });\n console.log(` Added constraint: w_${privateIdx} * w_${privateIdx} = w_${publicIdx}`);\n } else {\n // For more complex circuits, we'd need to parse the Noir code\n console.warn('Complex circuit detected - R1CS constraint generation may be incomplete');\n }\n\n const r1csJson = JSON.stringify(r1cs);\n console.log('R1CS JSON:', r1csJson);\n\n // Perform setup using R1CS\n let provingKey: string | undefined;\n let verifyingKey: string | undefined;\n let verifyingKeyGnark: string | undefined;\n\n if (this.config.cacheKeys) {\n try {\n console.log('Running trusted setup from R1CS...');\n const setupResult = wasm.setup_from_r1cs(r1csJson);\n provingKey = setupResult.proving_key;\n verifyingKey = setupResult.verifying_key;\n verifyingKeyGnark = setupResult.verifying_key_gnark;\n console.log('Setup complete!');\n } catch (error) {\n console.error('Setup failed:', error);\n throw new Error(`R1CS setup failed: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n // Keep acirJson for backwards compatibility but use r1csJson for proving\n const acirJson = JSON.stringify({\n functions: [{ current_witness_index: parameters.length, opcodes: [], private_parameters: privateR1csIndices, public_parameters: { witnesses: publicR1csIndices }, return_values: { witnesses: [] } }],\n });\n\n const arkworksCircuit: ArkworksCompiledCircuit = {\n ...compiled,\n __arkworks: true,\n acirJson,\n r1csJson,\n witnessIndexMapping,\n provingKey,\n verifyingKey,\n verifyingKeyGnark,\n };\n\n return arkworksCircuit;\n } finally {\n if (cleanup) {\n await cleanup();\n }\n }\n }\n\n /**\n * Generate a Groth16 proof\n */\n async generateProof(circuit: CompiledCircuit, inputs: InputMap): Promise<ProofData> {\n const wasm = await initWasm();\n\n if (!isArkworksCircuit(circuit)) {\n throw new Error(\n 'ArkworksWasm.generateProof requires an ArkworksCompiledCircuit. Use ArkworksWasm.compile() first.'\n );\n }\n\n // Execute the circuit to generate witness using noir_js\n const noir = new Noir(circuit);\n const { witness: compressedWitness } = await noir.execute(inputs);\n\n // The witness from noir_js is a compressed Uint8Array - need to decompress it\n // to get WitnessMap (Map<number, string> where values are hex field elements)\n const witnessMapNoir = decompressWitness(compressedWitness);\n\n // DEBUG: Log witness map and circuit info\n console.log('=== ARKWORKS WASM DEBUG ===');\n console.log('Circuit ABI parameters:', circuit.abi.parameters);\n console.log('Inputs provided:', JSON.stringify(inputs));\n console.log('Compressed witness size:', compressedWitness.length, 'bytes');\n console.log('Decompressed witness entries:', witnessMapNoir.size);\n\n // Show witness entries\n console.log('Witness map entries (first 10):');\n const sortedWitness = Array.from(witnessMapNoir.entries()).sort(([a], [b]) => a - b);\n for (const [index, value] of sortedWitness.slice(0, 10)) {\n const strVal = String(value);\n console.log(` witness[${index}] = \"${strVal.slice(0, 66)}${strVal.length > 66 ? '...' : ''}\"`);\n // Interpret as hex\n if (strVal.startsWith('0x')) {\n try {\n const decVal = BigInt(strVal).toString(10);\n console.log(` → decimal: ${decVal}`);\n } catch {\n console.log(` → failed to parse as BigInt`);\n }\n }\n }\n\n // Convert witness to R1CS format using the witness index mapping\n // noir witness[i] → R1CS w_(i+1) because w_0 = 1\n const witnessMap: Record<string, string> = {};\n const witnessMapping = circuit.witnessIndexMapping;\n\n console.log('Converting noir witness to R1CS witness:');\n for (const [noirIndex, value] of witnessMapNoir.entries()) {\n const r1csIndex = witnessMapping.get(noirIndex) ?? (noirIndex + 1);\n const strVal = String(value);\n witnessMap[r1csIndex.toString()] = strVal;\n console.log(` noir[${noirIndex}] → R1CS w_${r1csIndex} = ${strVal.slice(0, 20)}...`);\n }\n const witnessJson = JSON.stringify(witnessMap);\n console.log('Witness JSON for prove:', witnessJson.slice(0, 200) + '...');\n\n // Parse R1CS to show constraint info\n const r1csParsed: R1csDefinition = JSON.parse(circuit.r1csJson);\n console.log('R1CS public_inputs:', r1csParsed.public_inputs);\n console.log('R1CS private_inputs:', r1csParsed.private_inputs);\n console.log('R1CS num_witnesses:', r1csParsed.num_witnesses);\n console.log('R1CS constraints:', r1csParsed.constraints.length);\n\n // Ensure we have a proving key\n let provingKey = circuit.provingKey;\n if (!provingKey) {\n console.log('Running setup_from_r1cs...');\n const setupResult = wasm.setup_from_r1cs(circuit.r1csJson);\n provingKey = setupResult.proving_key;\n // Cache for future use\n circuit.provingKey = provingKey;\n circuit.verifyingKey = setupResult.verifying_key;\n circuit.verifyingKeyGnark = setupResult.verifying_key_gnark;\n }\n\n // Generate proof using R1CS\n console.log('Generating proof from R1CS...');\n const proofResult = wasm.prove_from_r1cs(provingKey, circuit.r1csJson, witnessJson);\n\n // DEBUG: Log proof result\n console.log('=== PROOF RESULT DEBUG ===');\n console.log('Proof public inputs from arkworks:', proofResult.public_inputs);\n proofResult.public_inputs.forEach((input, i) => {\n const hexValue = input.startsWith('0x') ? input : `0x${input}`;\n const decValue = BigInt(hexValue).toString(10);\n console.log(` Public input ${i}: ${input} (dec: ${decValue})`);\n });\n console.log('===========================');\n\n // Return proof in gnark format for Solana compatibility\n const proofBytes = base64ToUint8Array(proofResult.proof_gnark);\n\n return {\n proof: proofBytes,\n publicInputs: proofResult.public_inputs,\n };\n }\n\n /**\n * Verify a Groth16 proof\n */\n async verifyProof(\n circuit: CompiledCircuit,\n proof: Uint8Array,\n publicInputs: string[]\n ): Promise<boolean> {\n const wasm = await initWasm();\n\n if (!isArkworksCircuit(circuit)) {\n throw new Error(\n 'ArkworksWasm.verifyProof requires an ArkworksCompiledCircuit. Use ArkworksWasm.compile() first.'\n );\n }\n\n // Ensure we have a verifying key\n let verifyingKeyGnark = circuit.verifyingKeyGnark;\n if (!verifyingKeyGnark) {\n const setupResult = wasm.setup_from_r1cs(circuit.r1csJson);\n circuit.provingKey = setupResult.proving_key;\n circuit.verifyingKey = setupResult.verifying_key;\n verifyingKeyGnark = setupResult.verifying_key_gnark;\n circuit.verifyingKeyGnark = verifyingKeyGnark;\n }\n\n // Convert proof to base64\n const proofB64 = uint8ArrayToBase64(proof);\n\n // Convert public inputs to gnark format\n const publicInputsGnarkB64 = publicInputsToGnarkBase64(publicInputs);\n\n // Verify using gnark format\n return wasm.verify_gnark(\n verifyingKeyGnark,\n proofB64,\n publicInputsGnarkB64,\n publicInputs.length\n );\n }\n\n /**\n * Get the verifying key in gnark format for on-chain deployment\n */\n async getVerifyingKeyGnark(circuit: CompiledCircuit): Promise<Uint8Array> {\n const wasm = await initWasm();\n\n if (!isArkworksCircuit(circuit)) {\n throw new Error('getVerifyingKeyGnark requires an ArkworksCompiledCircuit');\n }\n\n if (!circuit.verifyingKeyGnark) {\n const setupResult = wasm.setup_from_r1cs(circuit.r1csJson);\n circuit.provingKey = setupResult.proving_key;\n circuit.verifyingKey = setupResult.verifying_key;\n circuit.verifyingKeyGnark = setupResult.verifying_key_gnark;\n }\n\n return base64ToUint8Array(circuit.verifyingKeyGnark);\n }\n}\n\n// Utility functions\n\nfunction base64ToUint8Array(b64: string): Uint8Array {\n const binaryString = atob(b64);\n const bytes = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i++) {\n bytes[i] = binaryString.charCodeAt(i);\n }\n return bytes;\n}\n\nfunction uint8ArrayToBase64(bytes: Uint8Array): string {\n let binary = '';\n for (let i = 0; i < bytes.length; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return btoa(binary);\n}\n\n/**\n * Convert public inputs (hex strings) to gnark format (32 bytes each, big-endian)\n * Returns base64-encoded result\n */\nfunction publicInputsToGnarkBase64(publicInputs: string[]): string {\n const FIELD_SIZE = 32;\n const bytes = new Uint8Array(publicInputs.length * FIELD_SIZE);\n\n for (let i = 0; i < publicInputs.length; i++) {\n const input = publicInputs[i];\n const hex = input.startsWith('0x') ? input.slice(2) : input;\n const inputBytes = hexToBytes(hex.padStart(64, '0'));\n\n // Copy big-endian bytes\n bytes.set(inputBytes, i * FIELD_SIZE);\n }\n\n return uint8ArrayToBase64(bytes);\n}\n\nfunction hexToBytes(hex: string): Uint8Array {\n const bytes = new Uint8Array(hex.length / 2);\n for (let i = 0; i < hex.length; i += 2) {\n bytes[i / 2] = parseInt(hex.substring(i, i + 2), 16);\n }\n return bytes;\n}\n","import { compile, createFileManager } from '@noir-lang/noir_wasm';\nimport { Noir } from '@noir-lang/noir_js';\nimport { Barretenberg as BarretenbergBackend, UltraHonkBackend } from '@aztec/bb.js';\nimport type { IProvingSystem } from '../../domain/interfaces/proving/IProvingSystem.js';\nimport type { CompiledCircuit, InputMap, ProofData } from '../../domain/types.js';\n\n/**\n * Helper to create a ReadableStream from a string\n * Used to write files to the virtual filesystem (browser-compatible)\n */\nfunction stringToStream(content: string): ReadableStream<Uint8Array> {\n return new ReadableStream({\n start(controller) {\n controller.enqueue(new TextEncoder().encode(content));\n controller.close();\n },\n });\n}\n\n/**\n * Check if running in Node.js environment\n */\nfunction isNodeJs(): boolean {\n return (\n typeof globalThis.process !== 'undefined' &&\n globalThis.process.versions != null &&\n globalThis.process.versions.node != null\n );\n}\n\n/**\n * Create temp directory in Node.js, or return '/' for browser virtual fs\n */\nasync function createTempDir(): Promise<{ basePath: string; cleanup: (() => Promise<void>) | null }> {\n if (!isNodeJs()) {\n // Browser: use virtual filesystem\n return { basePath: '/', cleanup: null };\n }\n\n // Node.js: create real temp directory\n // Use dynamic import which works in both Node.js ESM and CJS\n const fs = await import('node:fs/promises');\n const os = await import('node:os');\n const path = await import('node:path');\n\n const basePath = await fs.mkdtemp(path.join(os.tmpdir(), 'noir-circuit-'));\n const cleanup = async () => {\n await fs.rm(basePath, { recursive: true, force: true });\n };\n\n return { basePath, cleanup };\n}\n\n/**\n * Barretenberg proving system using WASM.\n * Browser compatible, produces UltraHonk proofs (~16KB).\n */\nexport class Barretenberg implements IProvingSystem {\n async compile(noirCode: string): Promise<CompiledCircuit> {\n const { basePath, cleanup } = await createTempDir();\n const fm = createFileManager(basePath);\n\n const nargoToml = `[package]\nname = \"circuit\"\ntype = \"bin\"\nauthors = [\"\"]\n\n[dependencies]\n`;\n\n try {\n // Write files using ReadableStream (browser-compatible)\n // In Node.js: writeFile is async and must be awaited\n // In browser: writeFile works with virtual fs, should not await for noir_wasm compatibility\n if (isNodeJs()) {\n await fm.writeFile('./src/main.nr', stringToStream(noirCode));\n await fm.writeFile('./Nargo.toml', stringToStream(nargoToml));\n } else {\n fm.writeFile('./src/main.nr', stringToStream(noirCode));\n fm.writeFile('./Nargo.toml', stringToStream(nargoToml));\n }\n\n const result = await compile(fm);\n const compiled = (result as any).program as CompiledCircuit;\n\n if (!compiled || !compiled.bytecode) {\n throw new Error('Compilation failed: no bytecode generated');\n }\n\n return compiled;\n } finally {\n if (cleanup) {\n await cleanup();\n }\n }\n }\n\n async generateProof(circuit: CompiledCircuit, inputs: InputMap): Promise<ProofData> {\n const noir = new Noir(circuit);\n const { witness } = await noir.execute(inputs);\n\n const barretenberg = await BarretenbergBackend.new({ threads: 1 });\n const backend = new UltraHonkBackend(circuit.bytecode, barretenberg);\n\n try {\n const proofData = await backend.generateProof(witness);\n return {\n proof: proofData.proof,\n publicInputs: proofData.publicInputs || [],\n };\n } finally {\n await barretenberg.destroy();\n }\n }\n\n async verifyProof(\n circuit: CompiledCircuit,\n proof: Uint8Array,\n publicInputs: string[]\n ): Promise<boolean> {\n const barretenberg = await BarretenbergBackend.new({ threads: 1 });\n const backend = new UltraHonkBackend(circuit.bytecode, barretenberg);\n\n try {\n return await backend.verifyProof({ proof, publicInputs });\n } finally {\n await barretenberg.destroy();\n }\n }\n}\n","import type { IChainFormatter } from '../../domain/interfaces/chain/IChainFormatter';\nimport type { ProofData, SolanaProofData, CompiledCircuit } from '../../domain/types';\nimport type { CircuitMetadata, SolanaChainMetadata } from '../../domain/types/chain';\nimport type { ArkworksWasm } from '../provingSystems/ArkworksWasm';\n\n// Constants for VK account sizing\nconst G1_SIZE = 64;\nconst G2_SIZE = 128;\n\n/**\n * Formatter for Solana-compatible proof data.\n *\n * Converts generic ProofData into SolanaProofData format with:\n * - Verifying key in gnark format (compatible with gnark-verifier-solana)\n * - Proof bytes (256 bytes Groth16)\n * - Public inputs as 32-byte arrays\n * - VK account size and rent estimates\n *\n * @example\n * ```typescript\n * const formatter = new SolanaFormatter(arkworksProvider);\n * const solanaProof = await formatter.formatProof(proofData, circuit, metadata);\n * ```\n */\nexport class SolanaFormatter implements IChainFormatter<'solana'> {\n readonly chainId = 'solana' as const;\n\n constructor(private arkworksProvider: ArkworksWasm) {}\n\n /**\n * Format a generic proof for Solana on-chain verification.\n *\n * @param proofData - Generic proof data from Arkworks\n * @param circuit - The compiled circuit (must be Arkworks circuit)\n * @param metadata - Circuit metadata with public input count\n * @returns SolanaProofData ready for on-chain verification\n */\n async formatProof(\n proofData: ProofData,\n circuit: CompiledCircuit,\n metadata: CircuitMetadata\n ): Promise<SolanaProofData> {\n // Get verifying key in gnark format\n const vkBytes = await this.arkworksProvider.getVerifyingKeyGnark(circuit);\n const vkBase64 = this.uint8ArrayToBase64(vkBytes);\n\n // Number of public inputs\n const nrPublicInputs = metadata.numPublicInputs;\n\n // Convert public inputs to 32-byte arrays\n const publicInputsBytes = proofData.publicInputs.map((input) => {\n const hex = input.startsWith('0x') ? input.slice(2) : input;\n return this.hexToBytes(hex.padStart(64, '0'));\n });\n\n // Calculate account size and rent\n const { accountSize, estimatedRent } = this.getChainMetadata(nrPublicInputs);\n\n return {\n verifyingKey: {\n base64: vkBase64,\n bytes: vkBytes,\n nrPublicInputs,\n },\n proof: {\n base64: this.uint8ArrayToBase64(proofData.proof),\n bytes: proofData.proof,\n },\n publicInputs: {\n hex: proofData.publicInputs,\n bytes: publicInputsBytes,\n },\n accountSize,\n estimatedRent,\n };\n }\n\n /**\n * Get Solana-specific metadata for a circuit.\n *\n * @param publicInputCount - Number of public inputs in the circuit\n * @returns Solana metadata with account size and rent estimates\n */\n getChainMetadata(publicInputCount: number): SolanaChainMetadata {\n const accountSize = this.calculateVkAccountSize(publicInputCount);\n const estimatedRent = this.calculateVkAccountRent(publicInputCount);\n\n return {\n chainId: 'solana',\n accountSize,\n estimatedRent,\n };\n }\n\n /**\n * Calculate the size of a VK account for a given number of public inputs.\n * Matches the Rust `vk_account_size` function in the Solana program.\n */\n private calculateVkAccountSize(nrPublicInputs: number): number {\n // discriminator (8) + authority (32) + nr_pubinputs (1) + alpha_g1 (64) +\n // beta_g2 (128) + gamma_g2 (128) + delta_g2 (128) + vec_len (4) + k elements\n const fixedSize = 8 + 32 + 1 + G1_SIZE + G2_SIZE * 3 + 4;\n return fixedSize + (nrPublicInputs + 1) * G1_SIZE;\n }\n\n /**\n * Calculate the minimum rent for a VK account.\n */\n private calculateVkAccountRent(\n nrPublicInputs: number,\n rentExemptionPerByte: number = 6960 // approximate lamports per byte\n ): number {\n const size = this.calculateVkAccountSize(nrPublicInputs);\n return size * rentExemptionPerByte;\n }\n\n /**\n * Convert Uint8Array to base64 string.\n */\n private uint8ArrayToBase64(bytes: Uint8Array): string {\n // Browser-compatible\n if (typeof btoa === 'function') {\n let binary = '';\n for (let i = 0; i < bytes.length; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return btoa(binary);\n }\n // Node.js fallback\n return Buffer.from(bytes).toString('base64');\n }\n\n /**\n * Convert hex string to Uint8Array.\n */\n private hexToBytes(hex: string): Uint8Array {\n const cleanHex = hex.startsWith('0x') ? hex.slice(2) : hex;\n const bytes = new Uint8Array(cleanHex.length / 2);\n for (let i = 0; i < bytes.length; i++) {\n bytes[i] = parseInt(cleanHex.substring(i * 2, i * 2 + 2), 16);\n }\n return bytes;\n }\n}\n","/**\n * Arkworks-only entry point for tree-shaking.\n *\n * Import from this module to only include Arkworks in your bundle,\n * excluding Barretenberg and Sunspot dependencies.\n *\n * @example\n * ```typescript\n * import { IziNoir, Provider } from '@izi-noir/sdk/arkworks';\n *\n * const izi = await IziNoir.init({ provider: Provider.Arkworks });\n * ```\n *\n * @module @izi-noir/sdk/arkworks\n */\n\nexport { ArkworksWasm, isArkworksCircuit } from '../infra/provingSystems/ArkworksWasm.js';\nexport type {\n ArkworksWasmConfig,\n ArkworksCompiledCircuit,\n ArkworksWasmModule,\n ArkworksSetupResult,\n ArkworksProofResult,\n} from '../infra/provingSystems/ArkworksWasm.js';\nexport { IziNoir, Provider, type IziNoirConfig, type CircuitPaths } from '../IziNoir.js';\nexport { initNoirWasm, isWasmInitialized } from '../infra/wasm/wasmInit.js';\nexport type { CompiledCircuit, InputMap, ProofData } from '../domain/types.js';\nexport type { IProvingSystem } from '../domain/interfaces/proving/IProvingSystem.js';\n","import { Chain } from './chain.js';\n\n/**\n * Available proving system providers\n */\nexport enum Provider {\n /** Barretenberg backend - browser compatible, UltraHonk proofs (~16KB) */\n Barretenberg = 'barretenberg',\n /** Arkworks WASM backend - browser compatible, Groth16 proofs (~256 bytes) */\n Arkworks = 'arkworks',\n /** Sunspot CLI backend - Node.js only, Groth16 proofs (~256 bytes) */\n Sunspot = 'sunspot',\n}\n\n/**\n * Configuration for circuit paths (required for Sunspot)\n */\nexport interface CircuitPaths {\n /** Path to the proving key file */\n pkPath: string;\n /** Path to the verification key file */\n vkPath: string;\n /** Path to the compiled circuit JSON file */\n circuitPath: string;\n}\n\n/**\n * Configuration for IziNoir initialization\n */\nexport interface IziNoirConfig {\n /** The proving system provider to use */\n provider: Provider;\n /**\n * Target blockchain for proof formatting.\n * If omitted, operates in offchain mode (raw proofs, no chain formatting).\n */\n chain?: Chain;\n /** Circuit paths - required for Sunspot provider */\n circuitPaths?: CircuitPaths;\n}\n\n// Re-export Chain for convenience\nexport { Chain };\n","let wasmInitPromise: Promise<void> | null = null;\nlet wasmInitialized = false;\n\n/**\n * Check if running in Node.js environment\n */\nfunction isNodeJs(): boolean {\n return (\n typeof globalThis.process !== 'undefined' &&\n globalThis.process.versions != null &&\n globalThis.process.versions.node != null\n );\n}\n\n/**\n * Initialize WASM modules for Noir compilation and execution.\n * Automatically detects Node.js vs browser and uses the appropriate WASM target.\n *\n * Uses lazy loading with singleton pattern - safe to call multiple times.\n * Only initializes once, subsequent calls return immediately.\n */\nexport async function initNoirWasm(): Promise<void> {\n if (wasmInitialized) return;\n\n if (!wasmInitPromise) {\n wasmInitPromise = initWasmInternal();\n }\n\n await wasmInitPromise;\n wasmInitialized = true;\n}\n\nasync function initWasmInternal(): Promise<void> {\n if (isNodeJs()) {\n // Node.js: use the nodejs target which doesn't require fetch\n // The nodejs target auto-initializes when imported\n await import('@noir-lang/acvm_js/nodejs/acvm_js.js');\n await import('@noir-lang/noirc_abi/nodejs/noirc_abi_wasm.js');\n } else {\n // Browser: use the web target with default initialization\n // Note: For Vite/bundlers, external initialization with WASM URLs is preferred\n // Use markWasmInitialized() after initializing externally\n const [{ default: initACVM }, { default: initNoirC }] = await Promise.all([\n import('@noir-lang/acvm_js'),\n import('@noir-lang/noirc_abi'),\n ]);\n await Promise.all([initACVM(), initNoirC()]);\n }\n}\n\n/**\n * Check if WASM modules are already initialized\n */\nexport function isWasmInitialized(): boolean {\n return wasmInitialized;\n}\n\n/**\n * Mark WASM as already initialized externally.\n * Use this when WASM has been initialized outside the SDK (e.g., with Vite URL imports).\n *\n * @example\n * ```typescript\n * // In Vite/browser environment\n * import initNoirC from \"@noir-lang/noirc_abi\";\n * import initACVM from \"@noir-lang/acvm_js\";\n * import acvm from \"@noir-lang/acvm_js/web/acvm_js_bg.wasm?url\";\n * import noirc from \"@noir-lang/noirc_abi/web/noirc_abi_wasm_bg.wasm?url\";\n * import { markWasmInitialized } from \"@izi-noir/sdk\";\n *\n * await Promise.all([initACVM(fetch(acvm)), initNoirC(fetch(noirc))]);\n * markWasmInitialized();\n * ```\n */\nexport function markWasmInitialized(): void {\n wasmInitialized = true;\n}\n\n/**\n * Reset WASM initialization state (for testing purposes)\n * @internal\n */\nexport function resetWasmInit(): void {\n wasmInitPromise = null;\n wasmInitialized = false;\n}\n","import {\n Provider,\n Chain,\n type IziNoirConfig,\n type CircuitPaths,\n} from './domain/types/provider.js';\nimport type { IProvingSystem } from './domain/interfaces/proving/IProvingSystem.js';\nimport type {\n CompiledCircuit,\n InputMap,\n ProofData,\n SolanaProofData,\n VerifyingKeyData,\n} from './domain/types.js';\nimport type { IChainFormatter } from './domain/interfaces/chain/IChainFormatter.js';\nimport type { ChainId, CircuitMetadata } from './domain/types/chain.js';\nimport { initNoirWasm } from './infra/wasm/wasmInit.js';\n\n/**\n * Data needed to deploy a verifying key to Solana.\n * Use with SolanaTransactionBuilder or your own transaction logic.\n */\nexport interface SolanaDeployData {\n /** The proof data with VK and public inputs */\n proofData: SolanaProofData;\n /** Program ID to use */\n programId: string;\n /** Compute units for the transaction */\n computeUnits: number;\n}\n\n/**\n * Main class for ZK proof generation with multiple backend providers.\n *\n * @example\n * ```typescript\n * import { IziNoir, Provider, Chain } from '@izi-noir/sdk';\n *\n * // On-chain mode: Initialize with chain for blockchain-specific formatting\n * const izi = await IziNoir.init({\n * provider: Provider.Arkworks,\n * chain: Chain.Solana\n * });\n *\n * await izi.compile(noirCode);\n * const proof = await izi.prove(inputs); // Returns SolanaProofData\n * console.log(izi.vk); // Verifying key available\n *\n * // Offchain mode: No chain specified\n * const iziOffchain = await IziNoir.init({ provider: Provider.Arkworks });\n * const rawProof = await iziOffchain.prove(inputs); // Returns ProofData\n * const verified = await iziOffchain.verify(rawProof.proof, rawProof.publicInputs);\n * ```\n */\nexport class IziNoir {\n private provingSystem: IProvingSystem;\n private compiledCircuit: CompiledCircuit | null = null;\n private chainFormatters: Map<string, IChainFormatter> = new Map();\n private readonly chain?: Chain;\n private _verifyingKey?: VerifyingKeyData;\n private _lastProof?: SolanaProofData | ProofData;\n\n private constructor(provingSystem: IProvingSystem, chain?: Chain) {\n this.provingSystem = provingSystem;\n this.chain = chain;\n }\n\n /**\n * Get the verifying key from the last proof generation.\n * Only available after calling prove() with a chain configured.\n */\n get vk(): VerifyingKeyData | undefined {\n return this._verifyingKey;\n }\n\n /**\n * Get the configured chain, if any.\n */\n get targetChain(): Chain | undefined {\n return this.chain;\n }\n\n /**\n * Check if operating in offchain mode (no chain configured).\n */\n get isOffchain(): boolean {\n return this.chain === undefined;\n }\n\n /**\n * Register a chain formatter for chain-specific proof formatting.\n *\n * @param formatter - The chain formatter to register\n */\n registerChainFormatter<T extends ChainId>(formatter: IChainFormatter<T>): void {\n this.chainFormatters.set(formatter.chainId, formatter);\n }\n\n /**\n * Get a registered chain formatter.\n *\n * @param chainId - The chain ID to get the formatter for\n * @returns The formatter or undefined if not registered\n */\n getChainFormatter<T extends ChainId>(chainId: T): IChainFormatter<T> | undefined {\n return this.chainFormatters.get(chainId) as IChainFormatter<T> | undefined;\n }\n\n /**\n * Initialize IziNoir with the specified provider and optional chain.\n *\n * @param config - Configuration specifying the provider, chain, and optional circuit paths\n * @returns Initialized IziNoir instance\n *\n * @example\n * ```typescript\n * // On-chain mode (Solana)\n * const izi = await IziNoir.init({\n * provider: Provider.Arkworks,\n * chain: Chain.Solana\n * });\n *\n * // Offchain mode (no chain formatting)\n * const iziOffchain = await IziNoir.init({\n * provider: Provider.Arkworks\n * });\n *\n * // Barretenberg (browser-compatible, ~16KB proofs, offchain only)\n * const bb = await IziNoir.init({ provider: Provider.Barretenberg });\n * ```\n */\n static async init(config: IziNoirConfig): Promise<IziNoir> {\n // Initialize WASM (no-op if already initialized)\n await initNoirWasm();\n\n let provingSystem: IProvingSystem;\n\n switch (config.provider) {\n case Provider.Barretenberg: {\n if (config.chain) {\n throw new Error(\n 'Barretenberg provider does not support chain formatting. ' +\n 'Use Provider.Arkworks for on-chain proofs.'\n );\n }\n const { Barretenberg } = await import('./infra/provingSystems/Barretenberg.js');\n provingSystem = new Barretenberg();\n return new IziNoir(provingSystem);\n }\n case Provider.Arkworks: {\n const { ArkworksWasm } = await import('./infra/provingSystems/ArkworksWasm.js');\n const arkworksInstance = new ArkworksWasm();\n provingSystem = arkworksInstance;\n\n const instance = new IziNoir(provingSystem, config.chain);\n\n // Auto-register SolanaFormatter if chain is Solana or for backwards compatibility\n if (config.chain === Chain.Solana || !config.chain) {\n const { SolanaFormatter } = await import('./infra/chainFormatters/SolanaFormatter.js');\n instance.registerChainFormatter(new SolanaFormatter(arkworksInstance));\n }\n\n return instance;\n }\n case Provider.Sunspot: {\n throw new Error(\n 'Sunspot is not available in the main entry point. ' +\n 'Import from \"@izi-noir/sdk/sunspot\" for Sunspot support.'\n );\n }\n default:\n throw new Error(`Unknown provider: ${config.provider}`);\n }\n }\n\n /**\n * Get the underlying proving system instance.\n * Useful for advanced use cases.\n */\n getProvingSystem(): IProvingSystem {\n return this.provingSystem;\n }\n\n /**\n * Get the currently compiled circuit, if any.\n */\n getCompiledCircuit(): CompiledCircuit | null {\n return this.compiledCircuit;\n }\n\n /**\n * Compile Noir code into a circuit.\n *\n * @param noirCode - The Noir source code to compile\n * @returns The compiled circuit\n */\n async compile(noirCode: string): Promise<CompiledCircuit> {\n this.compiledCircuit = await this.provingSystem.compile(noirCode);\n return this.compiledCircuit;\n }\n\n /**\n * Generate a proof for the given inputs.\n *\n * If a chain is configured, returns chain-formatted proof data and stores\n * the verifying key in `this.vk`. Otherwise, returns raw proof data.\n *\n * @param inputs - The inputs (both public and private) for the circuit\n * @param circuit - Optional circuit to use (defaults to last compiled circuit)\n * @returns The proof data - type depends on configured chain\n * @throws Error if no circuit is available\n *\n * @example\n * ```typescript\n * // With chain configured - returns SolanaProofData\n * const izi = await IziNoir.init({ provider: Provider.Arkworks, chain: Chain.Solana });\n * await izi.compile(noirCode);\n * const proof = await izi.prove({ expected: '100', secret: '10' });\n * // proof is SolanaProofData, izi.vk is available\n *\n * // Offchain mode - returns ProofData\n * const iziOffchain = await IziNoir.init({ provider: Provider.Arkworks });\n * await iziOffchain.compile(noirCode);\n * const rawProof = await iziOffchain.prove({ expected: '100', secret: '10' });\n * // rawProof is ProofData, iziOffchain.vk is undefined\n * ```\n */\n async prove(inputs: InputMap, circuit?: CompiledCircuit): Promise<ProofData | SolanaProofData> {\n const circuitToUse = circuit || this.compiledCircuit;\n if (!circuitToUse) {\n throw new Error('No circuit available. Call compile() first or provide a circuit.');\n }\n\n // Generate raw proof\n const rawProof = await this.provingSystem.generateProof(circuitToUse, inputs);\n\n // If no chain configured, return raw proof (offchain mode)\n if (!this.chain) {\n this._lastProof = rawProof;\n return rawProof;\n }\n\n // Get formatter for the configured chain\n const formatter = this.chainFormatters.get(this.chain);\n if (!formatter) {\n throw new Error(\n `No formatter registered for chain: ${this.chain}. ` +\n 'This is an internal error - please report it.'\n );\n }\n\n // Build circuit metadata\n const metadata: CircuitMetadata = {\n numPublicInputs: rawProof.publicInputs.length,\n };\n\n // Format for target chain\n const formattedProof = await formatter.formatProof(rawProof, circuitToUse, metadata);\n const chainProof = formattedProof as unknown as SolanaProofData;\n\n // Store VK on instance\n this._verifyingKey = chainProof.verifyingKey;\n this._lastProof = chainProof;\n\n return chainProof;\n }\n\n /**\n * Verify a proof.\n * Available in both on-chain and offchain modes.\n *\n * @param proof - The proof bytes to verify\n * @param publicInputs - The public inputs that were used\n * @param circuit - Optional circuit to use (defaults to last compiled circuit)\n * @returns true if the proof is valid, false otherwise\n * @throws Error if no circuit is available\n */\n async verify(\n proof: Uint8Array,\n publicInputs: string[],\n circuit?: CompiledCircuit\n ): Promise<boolean> {\n const circuitToUse = circuit || this.compiledCircuit;\n if (!circuitToUse) {\n throw new Error('No circuit available. Call compile() first or provide a circuit.');\n }\n return this.provingSystem.verifyProof(circuitToUse, proof, publicInputs);\n }\n\n /**\n * Convenience method: compile, prove, and verify in one call.\n *\n * @param noirCode - The Noir source code to compile\n * @param inputs - The inputs (both public and private) for the circuit\n * @returns Object containing proof data and verification result\n *\n * @example\n * ```typescript\n * const { proof, verified } = await izi.createProof(noirCode, {\n * x: '100',\n * y: '10',\n * });\n * console.log(`Verified: ${verified}`);\n * ```\n */\n async createProof(\n noirCode: string,\n inputs: InputMap\n ): Promise<{ proof: ProofData | SolanaProofData; verified: boolean }> {\n const circuit = await this.compile(noirCode);\n const proof = await this.prove(inputs, circuit);\n\n // For verification, extract raw proof bytes\n const proofBytes =\n 'proof' in proof && proof.proof instanceof Uint8Array\n ? proof.proof\n : (proof as SolanaProofData).proof.bytes;\n const pubInputs = Array.isArray(proof.publicInputs)\n ? (proof.publicInputs as string[])\n : (proof as SolanaProofData).publicInputs.hex;\n\n const verified = await this.verify(proofBytes, pubInputs, circuit);\n return { proof, verified };\n }\n\n /**\n * Get deployment data for the verifying key.\n * Returns the data needed to deploy to the configured blockchain.\n * Use with SolanaTransactionBuilder to build and send the transaction.\n *\n * @param options - Optional configuration\n * @returns Deployment data that can be used with SolanaTransactionBuilder\n * @throws Error if no chain is configured (offchain mode)\n * @throws Error if prove() hasn't been called yet\n *\n * @example\n * ```typescript\n * const izi = await IziNoir.init({ provider: Provider.Arkworks, chain: Chain.Solana });\n * await izi.compile(noirCode);\n * await izi.prove(inputs);\n *\n * // Get deployment data\n * const deployData = izi.getDeployData();\n *\n * // Use with SolanaTransactionBuilder in your frontend\n * const builder = new SolanaTransactionBuilder({ programId: deployData.programId });\n * const { initVk, rentLamports, accountSize } = builder.buildInitAndVerifyInstructions(\n * deployData.proofData,\n * vkAccountPubkey,\n * authority,\n * payer\n * );\n * ```\n */\n getDeployData(options?: { programId?: string; computeUnits?: number }): SolanaDeployData {\n if (!this.chain) {\n throw new Error('Cannot deploy in offchain mode. Initialize with a chain parameter.');\n }\n\n if (!this._verifyingKey || !this._lastProof) {\n throw new Error('Must call prove() before getDeployData().');\n }\n\n if (this.chain !== Chain.Solana) {\n throw new Error(`Deployment for ${this.chain} is not yet supported.`);\n }\n\n return {\n proofData: this._lastProof as SolanaProofData,\n programId: options?.programId ?? 'EYhRED7EuMyyVjx57aDXUD9h6ArnEKng64qtz8999KrS',\n computeUnits: options?.computeUnits ?? 400_000,\n };\n }\n}\n\n// Re-export Provider, Chain and types for convenience\nexport { Provider, Chain, type IziNoirConfig, type CircuitPaths };\nexport type { SolanaProofData, VerifyingKeyData } from './domain/types.js';\nexport type {\n ChainId,\n CircuitMetadata,\n ChainMetadata,\n SolanaChainMetadata,\n EthereumChainMetadata,\n ChainMetadataFor,\n} from './domain/types/chain.js';\nexport type {\n IChainFormatter,\n ChainProofDataFor,\n} from './domain/interfaces/chain/IChainFormatter.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAOA,SAAS,kBAAkB,WAAW;AAClC,QAAM,OAAO,kBAAkB,WAAW,KAAK,mBAAmB,KAAK,kBAAkB;AACzF,QAAM,OAAO;AACb,QAAM,MAAM,KAAK,kBAAkB,MAAM,IAAI;AAC7C,MAAI,IAAI,CAAC,GAAG;AACR,UAAM,wBAAwB,IAAI,CAAC,CAAC;AAAA,EACxC;AACA,SAAO,wBAAwB,IAAI,CAAC,CAAC;AACzC;AAGA,SAAS,kBAAkB;AACvB,OAAK,gBAAgB;AACzB;AAkBA,SAAS,MAAM,iBAAiB,WAAW,cAAc;AACrD,QAAM,OAAO,kBAAkB,iBAAiB,KAAK,mBAAmB,KAAK,kBAAkB;AAC/F,QAAM,OAAO;AACb,QAAM,OAAO,kBAAkB,WAAW,KAAK,mBAAmB,KAAK,kBAAkB;AACzF,QAAM,OAAO;AACb,QAAM,OAAO,kBAAkB,cAAc,KAAK,mBAAmB,KAAK,kBAAkB;AAC5F,QAAM,OAAO;AACb,QAAM,M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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBA,MAAM,YACJ,UACA,QACoE;AACpE,UAAM,UAAU,MAAM,KAAK,QAAQ,QAAQ;AAC3C,UAAM,QAAQ,MAAM,KAAK,MAAM,QAAQ,OAAO;AAG9C,UAAM,aACJ,WAAW,SAAS,MAAM,iBAAiB,aACvC,MAAM,QACL,MAA0B,MAAM;AACvC,UAAM,YAAY,MAAM,QAAQ,MAAM,YAAY,IAC7C,MAAM,eACN,MAA0B,aAAa;AAE5C,UAAM,WAAW,MAAM,KAAK,OAAO,YAAY,WAAW,OAAO;AACjE,WAAO,EAAE,OAAO,SAAS;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA+BA,cAAc,SAA2E;AACvF,QAAI,CAAC,KAAK,OAAO;AACf,YAAM,IAAI,MAAM,oEAAoE;AAAA,IACtF;AAEA,QAAI,CAAC,KAAK,iBAAiB,CAAC,KAAK,YAAY;AAC3C,YAAM,IAAI,MAAM,2CAA2C;AAAA,IAC7D;AAEA,QAAI,KAAK,iCAAwB;AAC/B,YAAM,IAAI,MAAM,kBAAkB,KAAK,KAAK,wBAAwB;AAAA,IACtE;AAEA,WAAO;AAAA,MACL,WAAW,KAAK;AAAA,MAChB,WAAW,SAAS,aAAa;AAAA,MACjC,cAAc,SAAS,gBAAgB;AAAA,IACzC;AAAA,EACF;AACF;","names":["ptr","arkworks_groth16_wasm_exports","acir_to_r1cs_info","init_panic_hook","prove","prove_from_r1cs","setup","setup_from_r1cs","verify","verify_gnark","version","passStringToWasm0","wasm","WASM_VECTOR_LEN","takeFromExternrefTable0","getStringFromWasm0","__wbg_get_imports","getDataViewMemory0","handleError","getArrayU8FromWasm0","isLikeNone","addToExternrefTable0","getUint8ArrayMemory0","cachedDataViewMemory0","decodeText","cachedUint8ArrayMemory0","cachedTextEncoder","ptr","cachedTextDecoder","module","wasmModule","init_arkworks_groth16_wasm","wasmModule","module","wasm","stringToStream","isNodeJs","createTempDir","import_noir_wasm","import_noir_js","BarretenbergBackend","Provider","wasmInitPromise","isNodeJs","Barretenberg","ArkworksWasm","SolanaFormatter"]}
@@ -58,6 +58,8 @@ interface ArkworksWasmModule {
58
58
  return_values: number[];
59
59
  };
60
60
  version(): string;
61
+ setup_from_r1cs(r1csJson: string): ArkworksSetupResult;
62
+ prove_from_r1cs(provingKeyB64: string, r1csJson: string, witnessJson: string): ArkworksProofResult;
61
63
  }
62
64
  /**
63
65
  * Configuration for ArkworksWasm prover
@@ -74,8 +76,12 @@ interface ArkworksWasmConfig {
74
76
  interface ArkworksCompiledCircuit extends CompiledCircuit {
75
77
  /** Marker to identify ArkworksWasm circuits */
76
78
  __arkworks: true;
77
- /** ACIR program as JSON string (used for setup/prove) */
79
+ /** ACIR program as JSON string (used for setup/prove) - DEPRECATED, use r1csJson */
78
80
  acirJson: string;
81
+ /** R1CS definition as JSON string (used for setup/prove) */
82
+ r1csJson: string;
83
+ /** Mapping from noir witness index to R1CS witness index */
84
+ witnessIndexMapping: Map<number, number>;
79
85
  /** Cached proving key (base64) if cacheKeys is enabled */
80
86
  provingKey?: string;
81
87
  /** Cached verifying key (base64) if cacheKeys is enabled */
@@ -58,6 +58,8 @@ interface ArkworksWasmModule {
58
58
  return_values: number[];
59
59
  };
60
60
  version(): string;
61
+ setup_from_r1cs(r1csJson: string): ArkworksSetupResult;
62
+ prove_from_r1cs(provingKeyB64: string, r1csJson: string, witnessJson: string): ArkworksProofResult;
61
63
  }
62
64
  /**
63
65
  * Configuration for ArkworksWasm prover
@@ -74,8 +76,12 @@ interface ArkworksWasmConfig {
74
76
  interface ArkworksCompiledCircuit extends CompiledCircuit {
75
77
  /** Marker to identify ArkworksWasm circuits */
76
78
  __arkworks: true;
77
- /** ACIR program as JSON string (used for setup/prove) */
79
+ /** ACIR program as JSON string (used for setup/prove) - DEPRECATED, use r1csJson */
78
80
  acirJson: string;
81
+ /** R1CS definition as JSON string (used for setup/prove) */
82
+ r1csJson: string;
83
+ /** Mapping from noir witness index to R1CS witness index */
84
+ witnessIndexMapping: Map<number, number>;
79
85
  /** Cached proving key (base64) if cacheKeys is enabled */
80
86
  provingKey?: string;
81
87
  /** Cached verifying key (base64) if cacheKeys is enabled */