@izi-noir/sdk 0.1.0 → 0.1.2

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.
Files changed (39) hide show
  1. package/dist/{IProvingSystem-TKNofoo8.d.cts → IProvingSystem-BpI0rmve.d.cts} +32 -2
  2. package/dist/{IProvingSystem-D9TnEig0.d.ts → IProvingSystem-D0X9Rp3W.d.ts} +32 -2
  3. package/dist/index.cjs +29968 -1358
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.cts +47 -7
  6. package/dist/index.d.ts +47 -7
  7. package/dist/index.js +29948 -1317
  8. package/dist/index.js.map +1 -1
  9. package/dist/providers/arkworks.cjs +29061 -173
  10. package/dist/providers/arkworks.cjs.map +1 -1
  11. package/dist/providers/arkworks.d.cts +11 -5
  12. package/dist/providers/arkworks.d.ts +11 -5
  13. package/dist/providers/arkworks.js +29081 -167
  14. package/dist/providers/arkworks.js.map +1 -1
  15. package/dist/providers/barretenberg.cjs +29061 -173
  16. package/dist/providers/barretenberg.cjs.map +1 -1
  17. package/dist/providers/barretenberg.d.cts +4 -4
  18. package/dist/providers/barretenberg.d.ts +4 -4
  19. package/dist/providers/barretenberg.js +29081 -167
  20. package/dist/providers/barretenberg.js.map +1 -1
  21. package/dist/providers/solana.cjs +2 -20
  22. package/dist/providers/solana.cjs.map +1 -1
  23. package/dist/providers/solana.d.cts +1 -1
  24. package/dist/providers/solana.d.ts +1 -1
  25. package/dist/providers/solana.js +2 -20
  26. package/dist/providers/solana.js.map +1 -1
  27. package/dist/providers/sunspot.cjs.map +1 -1
  28. package/dist/providers/sunspot.d.cts +3 -3
  29. package/dist/providers/sunspot.d.ts +3 -3
  30. package/dist/providers/sunspot.js.map +1 -1
  31. package/dist/{types-CaaigonG.d.cts → types-CxkI04bP.d.cts} +14 -2
  32. package/dist/{types-CaaigonG.d.ts → types-CxkI04bP.d.ts} +14 -2
  33. package/dist/wasm/nodejs/arkworks_groth16_wasm.js +52 -0
  34. package/dist/wasm/nodejs/arkworks_groth16_wasm_bg.wasm +0 -0
  35. package/dist/wasm/web/arkworks_groth16_wasm.js +50 -0
  36. package/dist/wasm/web/arkworks_groth16_wasm_bg.wasm +0 -0
  37. package/dist/{wasmInit-iEYiiB8M.d.cts → wasmInit-D615cpte.d.cts} +147 -12
  38. package/dist/{wasmInit-KV6DTj4J.d.ts → wasmInit-oOZwkgo_.d.ts} +147 -12
  39. package/package.json +6 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/infra/provingSystems/Sunspot.ts","../../src/infra/sunspot/types.ts","../../src/infra/sunspot/SunspotCliExecutor.ts","../../src/domain/types/provider.ts","../../src/providers/sunspot.ts"],"sourcesContent":["import { readFile, writeFile, rm, mkdtemp, mkdir } from 'node:fs/promises';\nimport { join, dirname } from 'node:path';\nimport { tmpdir } from 'node:os';\nimport type { IProvingSystem } from '../../domain/interfaces/proving/IProvingSystem.js';\nimport type { CompiledCircuit, InputMap, ProofData } from '../../domain/types.js';\nimport type { SunspotConfig, SunspotCircuitPaths, SunspotCompiledCircuit } from '../sunspot/types.js';\nimport { DEFAULT_SUNSPOT_CONFIG, isSunspotCircuit, SunspotCliError } from '../sunspot/types.js';\nimport { SunspotCliExecutor } from '../sunspot/SunspotCliExecutor.js';\nimport type { CircuitPaths } from '../../domain/types/provider.js';\n\n/**\n * Configuration for Sunspot constructor\n */\nexport interface SunspotInitConfig extends Partial<SunspotConfig> {\n /** Pre-compiled circuit paths (if provided, compile() is disabled) */\n precompiledPaths?: CircuitPaths;\n}\n\n/**\n * Sunspot proving system using CLI tools.\n * Node.js only (requires nargo and sunspot binaries).\n * Produces Groth16 proofs (~324 bytes) for Solana on-chain verification.\n *\n * Can be used in two modes:\n * 1. Full compilation: Call compile() with Noir code (requires nargo + sunspot CLI)\n * 2. Pre-compiled: Provide circuitPaths in constructor, then only prove/verify\n *\n * @example Full compilation\n * ```typescript\n * const sunspot = new Sunspot();\n * const circuit = await sunspot.compile(noirCode);\n * const proof = await sunspot.generateProof(circuit, inputs);\n * ```\n *\n * @example Pre-compiled (via IziNoir)\n * ```typescript\n * const izi = await IziNoir.init({\n * provider: Provider.Sunspot,\n * circuitPaths: { pkPath: '...', vkPath: '...', circuitPath: '...' }\n * });\n * ```\n */\nexport class Sunspot implements IProvingSystem {\n private readonly config: SunspotConfig;\n private readonly executor: SunspotCliExecutor;\n private readonly precompiledPaths?: CircuitPaths;\n private precompiledCircuit?: SunspotCompiledCircuit;\n\n /**\n * Create a new Sunspot proving system\n * @param config - Configuration options or pre-compiled circuit paths\n */\n constructor(config: SunspotInitConfig | CircuitPaths = {}) {\n // Check if config is CircuitPaths (has pkPath, vkPath, circuitPath)\n if ('pkPath' in config && 'vkPath' in config && 'circuitPath' in config) {\n this.config = { ...DEFAULT_SUNSPOT_CONFIG };\n this.precompiledPaths = config as CircuitPaths;\n } else {\n const initConfig = config as SunspotInitConfig;\n this.config = { ...DEFAULT_SUNSPOT_CONFIG, ...initConfig };\n this.precompiledPaths = initConfig.precompiledPaths;\n }\n\n this.executor = new SunspotCliExecutor(this.config);\n\n // If pre-compiled paths provided, create a dummy circuit object\n if (this.precompiledPaths) {\n this.precompiledCircuit = this.createPrecompiledCircuit(this.precompiledPaths);\n }\n }\n\n /**\n * Create a SunspotCompiledCircuit from pre-compiled paths\n */\n private createPrecompiledCircuit(paths: CircuitPaths): SunspotCompiledCircuit {\n const baseDir = dirname(paths.circuitPath);\n return {\n bytecode: '', // Not needed for prove/verify with pre-compiled\n abi: { parameters: [], return_type: null, error_types: {} },\n debug_symbols: '',\n file_map: {},\n __sunspot: true,\n paths: {\n workDir: baseDir,\n noirProjectDir: baseDir,\n circuitJsonPath: paths.circuitPath,\n witnessPath: join(baseDir, 'circuit.gz'),\n ccsPath: join(baseDir, 'circuit.ccs'),\n pkPath: paths.pkPath,\n vkPath: paths.vkPath,\n proofPath: join(baseDir, 'circuit.proof'),\n publicWitnessPath: join(baseDir, 'circuit.pw'),\n proverTomlPath: join(baseDir, 'Prover.toml'),\n },\n };\n }\n\n /**\n * Create a temporary Noir project for compilation\n */\n private async createNoirProject(noirCode: string, packageName: string): Promise<{ rootDir: string }> {\n const rootDir = await mkdtemp(join(tmpdir(), 'sunspot-circuit-'));\n const srcDir = join(rootDir, 'src');\n await mkdir(srcDir, { recursive: true });\n\n const nargoToml = `[package]\nname = \"${packageName}\"\ntype = \"bin\"\nauthors = [\"\"]\n\n[dependencies]\n`;\n\n await writeFile(join(rootDir, 'Nargo.toml'), nargoToml);\n await writeFile(join(srcDir, 'main.nr'), noirCode);\n\n return { rootDir };\n }\n\n async compile(noirCode: string): Promise<CompiledCircuit> {\n if (this.precompiledPaths) {\n throw new Error(\n 'Sunspot was initialized with pre-compiled circuit paths. ' +\n 'compile() is not available. Use generateProof() and verifyProof() directly.'\n );\n }\n\n // 1. Create temp Noir project\n const project = await this.createNoirProject(noirCode, 'circuit');\n const targetDir = join(project.rootDir, 'target');\n\n // 2. Run nargo compile → circuit.json\n await this.executor.nargoCompile(project.rootDir);\n const circuitJsonPath = join(targetDir, 'circuit.json');\n\n // 3. Run sunspot compile → circuit.ccs\n await this.executor.sunspotCompile(circuitJsonPath);\n const ccsPath = join(dirname(circuitJsonPath), 'circuit.ccs');\n\n // 4. Run sunspot setup → circuit.pk + circuit.vk\n await this.executor.sunspotSetup(ccsPath);\n const pkPath = join(dirname(ccsPath), 'circuit.pk');\n const vkPath = join(dirname(ccsPath), 'circuit.vk');\n\n // 5. Read circuit.json to extract ABI\n const circuitJson = JSON.parse(await readFile(circuitJsonPath, 'utf-8'));\n\n // 6. Build paths object\n const paths: SunspotCircuitPaths = {\n workDir: project.rootDir,\n noirProjectDir: project.rootDir,\n circuitJsonPath,\n witnessPath: join(targetDir, 'circuit.gz'),\n ccsPath,\n pkPath,\n vkPath,\n proofPath: join(dirname(ccsPath), 'circuit.proof'),\n publicWitnessPath: join(dirname(ccsPath), 'circuit.pw'),\n proverTomlPath: join(project.rootDir, 'Prover.toml'),\n };\n\n // 7. Return SunspotCompiledCircuit (don't cleanup - prover needs the files)\n const sunspotCircuit: SunspotCompiledCircuit = {\n bytecode: circuitJson.bytecode || '',\n abi: circuitJson.abi || {\n parameters: [],\n return_type: null,\n error_types: {},\n },\n debug_symbols: circuitJson.debug_symbols || '',\n file_map: circuitJson.file_map || {},\n __sunspot: true,\n paths,\n };\n\n return sunspotCircuit;\n }\n\n async generateProof(circuit: CompiledCircuit, inputs: InputMap): Promise<ProofData> {\n // Use precompiled circuit if available and circuit is empty/default\n const circuitToUse = this.resolveCircuit(circuit);\n\n if (!isSunspotCircuit(circuitToUse)) {\n throw new Error(\n 'Sunspot.generateProof requires a SunspotCompiledCircuit. Use Sunspot.compile() first.'\n );\n }\n\n const paths = circuitToUse.paths;\n\n try {\n // 1. Write Prover.toml with inputs\n const proverToml = this.generateProverToml(inputs);\n await writeFile(paths.proverTomlPath, proverToml);\n\n // 2. Run nargo execute to generate witness\n await this.executor.nargoExecute(paths.noirProjectDir);\n\n // 3. Run sunspot prove to generate proof\n await this.executor.sunspotProve(\n paths.circuitJsonPath,\n paths.witnessPath,\n paths.ccsPath,\n paths.pkPath\n );\n\n // 4. Read proof and public witness files\n const proofBytes = new Uint8Array(await readFile(paths.proofPath));\n const publicWitnessBytes = new Uint8Array(await readFile(paths.publicWitnessPath));\n\n // 5. Parse public inputs from public witness\n const publicInputs = this.parsePublicWitness(publicWitnessBytes);\n\n return {\n proof: proofBytes,\n publicInputs,\n };\n } catch (error) {\n if (!this.config.keepArtifacts) {\n await rm(paths.workDir, { recursive: true, force: true }).catch(() => {});\n }\n throw error;\n }\n }\n\n async verifyProof(\n circuit: CompiledCircuit,\n proof: Uint8Array,\n publicInputs: string[]\n ): Promise<boolean> {\n // Use precompiled circuit if available and circuit is empty/default\n const circuitToUse = this.resolveCircuit(circuit);\n\n if (!isSunspotCircuit(circuitToUse)) {\n throw new Error(\n 'Sunspot.verifyProof requires a SunspotCompiledCircuit. Use Sunspot.compile() first.'\n );\n }\n\n const paths = circuitToUse.paths;\n\n try {\n // Use existing .proof and .pw files from generateProof\n const existingProof = await readFile(paths.proofPath).catch(() => null);\n if (!existingProof || !this.bytesEqual(existingProof, proof)) {\n await writeFile(paths.proofPath, proof);\n }\n\n await this.executor.sunspotVerify(\n paths.vkPath,\n paths.proofPath,\n paths.publicWitnessPath\n );\n\n return true;\n } catch (error) {\n if (error instanceof SunspotCliError) {\n if (error.stderr.toLowerCase().includes('verification failed') ||\n error.stderr.toLowerCase().includes('invalid proof')) {\n return false;\n }\n }\n throw error;\n } finally {\n if (!this.config.keepArtifacts) {\n await rm(paths.workDir, { recursive: true, force: true }).catch(() => {});\n }\n }\n }\n\n /**\n * Resolve which circuit to use - precompiled or provided\n */\n private resolveCircuit(circuit: CompiledCircuit): CompiledCircuit {\n // If circuit is a proper SunspotCompiledCircuit, use it\n if (isSunspotCircuit(circuit)) {\n return circuit;\n }\n\n // If we have precompiled paths, use those\n if (this.precompiledCircuit) {\n return this.precompiledCircuit;\n }\n\n // Otherwise, return the provided circuit (will fail validation)\n return circuit;\n }\n\n private generateProverToml(inputs: InputMap): string {\n const lines: string[] = [];\n for (const [key, value] of Object.entries(inputs)) {\n lines.push(`${key} = ${this.formatTomlValue(value)}`);\n }\n return lines.join('\\n') + '\\n';\n }\n\n private formatTomlValue(value: unknown): string {\n if (typeof value === 'string') {\n if (value.startsWith('0x')) return `\"${value}\"`;\n if (/^\\d+$/.test(value)) return value;\n return `\"${value}\"`;\n }\n if (typeof value === 'number' || typeof value === 'bigint') {\n return value.toString();\n }\n if (Array.isArray(value)) {\n return `[${value.map(v => this.formatTomlValue(v)).join(', ')}]`;\n }\n return String(value);\n }\n\n private parsePublicWitness(bytes: Uint8Array): string[] {\n const publicInputs: string[] = [];\n const FIELD_SIZE = 32;\n\n for (let i = 0; i < bytes.length; i += FIELD_SIZE) {\n const fieldBytes = bytes.slice(i, Math.min(i + FIELD_SIZE, bytes.length));\n if (fieldBytes.length === FIELD_SIZE) {\n const hex = '0x' + Array.from(fieldBytes)\n .map(b => b.toString(16).padStart(2, '0'))\n .join('');\n publicInputs.push(hex);\n }\n }\n\n return publicInputs;\n }\n\n private bytesEqual(a: Buffer | Uint8Array, b: Uint8Array): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n }\n}\n","import type { CompiledCircuit } from '@noir-lang/types';\n\n/**\n * Configuration for Sunspot CLI execution\n */\nexport interface SunspotConfig {\n /** Path to nargo binary (default: 'nargo') */\n nargoBinaryPath: string;\n /** Path to sunspot binary (default: 'sunspot') */\n sunspotBinaryPath: string;\n /** Keep temp artifacts for debugging (default: false) */\n keepArtifacts: boolean;\n /** Timeout for CLI commands in ms (default: 120000) */\n timeoutMs: number;\n}\n\nexport const DEFAULT_SUNSPOT_CONFIG: SunspotConfig = {\n nargoBinaryPath: process.env.NARGO_PATH || 'nargo',\n sunspotBinaryPath: process.env.SUNSPOT_PATH || 'sunspot',\n keepArtifacts: process.env.SUNSPOT_KEEP_ARTIFACTS === 'true',\n timeoutMs: 120000,\n};\n\n/**\n * Paths to all Sunspot artifacts in the temp directory\n */\nexport interface SunspotCircuitPaths {\n /** Base temp directory */\n workDir: string;\n /** Noir project directory with Nargo.toml */\n noirProjectDir: string;\n /** Path to compiled circuit.json (ACIR) */\n circuitJsonPath: string;\n /** Path to witness.gz */\n witnessPath: string;\n /** Path to circuit.ccs */\n ccsPath: string;\n /** Path to proving key */\n pkPath: string;\n /** Path to verification key */\n vkPath: string;\n /** Path to proof file */\n proofPath: string;\n /** Path to public witness file */\n publicWitnessPath: string;\n /** Path to Prover.toml */\n proverTomlPath: string;\n}\n\n/**\n * Extended CompiledCircuit for Sunspot backend\n */\nexport interface SunspotCompiledCircuit extends CompiledCircuit {\n /** Marker to identify Sunspot circuits */\n __sunspot: true;\n /** Paths to all artifacts */\n paths: SunspotCircuitPaths;\n}\n\n/**\n * Type guard to check if a circuit is a Sunspot circuit\n */\nexport function isSunspotCircuit(circuit: CompiledCircuit): circuit is SunspotCompiledCircuit {\n return '__sunspot' in circuit && (circuit as SunspotCompiledCircuit).__sunspot === true;\n}\n\n/**\n * Result of CLI command execution\n */\nexport interface CliResult {\n stdout: string;\n stderr: string;\n exitCode: number;\n}\n\n/**\n * Error thrown when CLI command fails\n */\nexport class SunspotCliError extends Error {\n constructor(\n message: string,\n public readonly command: string,\n public readonly exitCode: number,\n public readonly stderr: string\n ) {\n super(message);\n this.name = 'SunspotCliError';\n }\n}\n","import { spawn } from 'node:child_process';\nimport type { SunspotConfig, CliResult } from './types.js';\nimport { SunspotCliError } from './types.js';\n\n/**\n * Executes Sunspot and Nargo CLI commands\n */\nexport class SunspotCliExecutor {\n constructor(private readonly config: SunspotConfig) {}\n\n /**\n * Execute a CLI command and return the result\n */\n private async execute(command: string, args: string[], cwd?: string): Promise<CliResult> {\n return new Promise((resolve, reject) => {\n const proc = spawn(command, args, {\n cwd,\n timeout: this.config.timeoutMs,\n env: { ...process.env },\n });\n\n let stdout = '';\n let stderr = '';\n\n proc.stdout.on('data', (data) => {\n stdout += data.toString();\n });\n\n proc.stderr.on('data', (data) => {\n stderr += data.toString();\n });\n\n proc.on('close', (exitCode) => {\n const result: CliResult = {\n stdout,\n stderr,\n exitCode: exitCode ?? 1,\n };\n\n if (exitCode !== 0) {\n reject(new SunspotCliError(\n `Command failed: ${command} ${args.join(' ')}\\n${stderr || stdout}`,\n `${command} ${args.join(' ')}`,\n exitCode ?? 1,\n stderr || stdout\n ));\n } else {\n resolve(result);\n }\n });\n\n proc.on('error', (error) => {\n const message = error.message.includes('ENOENT')\n ? `Binary not found: ${command}. Ensure it is installed and in PATH.`\n : `Failed to execute ${command}: ${error.message}`;\n\n reject(new SunspotCliError(\n message,\n `${command} ${args.join(' ')}`,\n 1,\n error.message\n ));\n });\n });\n }\n\n /**\n * Run nargo compile in the project directory\n * Output: target/circuit.json\n */\n async nargoCompile(projectDir: string): Promise<CliResult> {\n return this.execute(this.config.nargoBinaryPath, ['compile'], projectDir);\n }\n\n /**\n * Run nargo execute to generate witness\n * Output: target/circuit.gz\n */\n async nargoExecute(projectDir: string): Promise<CliResult> {\n return this.execute(this.config.nargoBinaryPath, ['execute'], projectDir);\n }\n\n /**\n * Run sunspot compile to generate CCS\n * Input: circuit.json\n * Output: circuit.ccs (in same directory as input)\n */\n async sunspotCompile(circuitJsonPath: string): Promise<CliResult> {\n return this.execute(this.config.sunspotBinaryPath, ['compile', circuitJsonPath]);\n }\n\n /**\n * Run sunspot setup to generate proving and verification keys\n * Input: circuit.ccs\n * Output: circuit.pk, circuit.vk (in same directory as input)\n */\n async sunspotSetup(ccsPath: string): Promise<CliResult> {\n return this.execute(this.config.sunspotBinaryPath, ['setup', ccsPath]);\n }\n\n /**\n * Run sunspot prove to generate proof\n * Inputs: circuit.json, witness.gz, circuit.ccs, circuit.pk\n * Outputs: circuit.proof, circuit.pw (in same directory as ccs)\n */\n async sunspotProve(\n circuitJsonPath: string,\n witnessPath: string,\n ccsPath: string,\n pkPath: string\n ): Promise<CliResult> {\n return this.execute(this.config.sunspotBinaryPath, [\n 'prove',\n circuitJsonPath,\n witnessPath,\n ccsPath,\n pkPath,\n ]);\n }\n\n /**\n * Run sunspot verify to verify a proof\n * Inputs: circuit.vk, circuit.proof, circuit.pw\n * Returns: true if verification succeeds\n */\n async sunspotVerify(\n vkPath: string,\n proofPath: string,\n publicWitnessPath: string\n ): Promise<CliResult> {\n return this.execute(this.config.sunspotBinaryPath, [\n 'verify',\n vkPath,\n proofPath,\n publicWitnessPath,\n ]);\n }\n}\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","/**\n * Sunspot entry point for Node.js.\n *\n * This module provides Sunspot support which is NOT available in the main\n * `@izi-noir/sdk` entry point due to Node.js-only dependencies.\n *\n * Note: Sunspot requires nargo and sunspot CLI tools to be installed.\n *\n * @example Using Sunspot directly\n * ```typescript\n * import { Sunspot } from '@izi-noir/sdk/sunspot';\n *\n * // Full compilation mode\n * const sunspot = new Sunspot();\n * const circuit = await sunspot.compile(noirCode);\n * const proof = await sunspot.generateProof(circuit, inputs);\n * const verified = await sunspot.verifyProof(circuit, proof.proof, proof.publicInputs);\n *\n * // Pre-compiled mode\n * const sunspot = new Sunspot({\n * pkPath: './circuit/circuit.pk',\n * vkPath: './circuit/circuit.vk',\n * circuitPath: './circuit/circuit.json',\n * });\n * ```\n *\n * @example Using initSunspotIziNoir helper\n * ```typescript\n * import { initSunspotIziNoir } from '@izi-noir/sdk/sunspot';\n *\n * const izi = await initSunspotIziNoir({\n * pkPath: './circuit/circuit.pk',\n * vkPath: './circuit/circuit.vk',\n * circuitPath: './circuit/circuit.json',\n * });\n *\n * // Use like regular IziNoir (but only prove/verify, not compile)\n * const proof = await izi.prove(inputs);\n * const verified = await izi.verify(proof.proof, proof.publicInputs);\n * ```\n *\n * @module @izi-noir/sdk/sunspot\n */\n\nimport type { IProvingSystem } from '../domain/interfaces/proving/IProvingSystem.js';\nimport type { CompiledCircuit, InputMap, ProofData } from '../domain/types.js';\nimport type { CircuitPaths } from '../domain/types/provider.js';\nimport { Sunspot } from '../infra/provingSystems/Sunspot.js';\n\nexport { Sunspot } from '../infra/provingSystems/Sunspot.js';\nexport type { SunspotInitConfig } from '../infra/provingSystems/Sunspot.js';\nexport type {\n SunspotConfig,\n SunspotCircuitPaths,\n SunspotCompiledCircuit,\n} from '../infra/sunspot/types.js';\nexport { isSunspotCircuit, SunspotCliError } from '../infra/sunspot/types.js';\n\n// Re-export common types\nexport { Provider, type IziNoirConfig, type CircuitPaths } from '../domain/types/provider.js';\nexport type { CompiledCircuit, InputMap, ProofData } from '../domain/types.js';\nexport type { IProvingSystem } from '../domain/interfaces/proving/IProvingSystem.js';\n\n/**\n * IziNoir-like wrapper for Sunspot.\n * Provides a similar API to IziNoir but backed by the Sunspot proving system.\n */\nexport class IziNoirSunspot {\n private provingSystem: IProvingSystem;\n private compiledCircuit: CompiledCircuit | null = null;\n\n private constructor(provingSystem: IProvingSystem) {\n this.provingSystem = provingSystem;\n }\n\n /**\n * Initialize IziNoirSunspot with pre-compiled circuit paths.\n * Note: Sunspot requires pre-compiled circuits for prove/verify operations.\n *\n * @param circuitPaths - Paths to the pre-compiled circuit files\n */\n static async init(circuitPaths: CircuitPaths): Promise<IziNoirSunspot> {\n const sunspot = new Sunspot(circuitPaths);\n return new IziNoirSunspot(sunspot);\n }\n\n /**\n * Initialize IziNoirSunspot for full compilation mode.\n * Requires nargo and sunspot CLI tools to be installed.\n */\n static async initForCompilation(): Promise<IziNoirSunspot> {\n const sunspot = new Sunspot();\n return new IziNoirSunspot(sunspot);\n }\n\n getProvingSystem(): IProvingSystem {\n return this.provingSystem;\n }\n\n getCompiledCircuit(): CompiledCircuit | null {\n return this.compiledCircuit;\n }\n\n async compile(noirCode: string): Promise<CompiledCircuit> {\n this.compiledCircuit = await this.provingSystem.compile(noirCode);\n return this.compiledCircuit;\n }\n\n async prove(inputs: InputMap, circuit?: CompiledCircuit): Promise<ProofData> {\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.generateProof(circuitToUse, inputs);\n }\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 async createProof(\n noirCode: string,\n inputs: InputMap\n ): Promise<{ proof: ProofData; verified: boolean }> {\n const circuit = await this.compile(noirCode);\n const proof = await this.prove(inputs, circuit);\n const verified = await this.verify(proof.proof, proof.publicInputs, circuit);\n return { proof, verified };\n }\n}\n\n/**\n * Helper function to create an IziNoirSunspot instance with pre-compiled circuit paths.\n * @deprecated Use `IziNoirSunspot.init(circuitPaths)` instead.\n */\nexport async function initSunspotIziNoir(circuitPaths: CircuitPaths): Promise<IziNoirSunspot> {\n return IziNoirSunspot.init(circuitPaths);\n}\n"],"mappings":";AAAA,SAAS,UAAU,WAAW,IAAI,SAAS,aAAa;AACxD,SAAS,MAAM,eAAe;AAC9B,SAAS,cAAc;;;ACchB,IAAM,yBAAwC;AAAA,EACnD,iBAAiB,QAAQ,IAAI,cAAc;AAAA,EAC3C,mBAAmB,QAAQ,IAAI,gBAAgB;AAAA,EAC/C,eAAe,QAAQ,IAAI,2BAA2B;AAAA,EACtD,WAAW;AACb;AAyCO,SAAS,iBAAiB,SAA6D;AAC5F,SAAO,eAAe,WAAY,QAAmC,cAAc;AACrF;AAcO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC,YACE,SACgB,SACA,UACA,QAChB;AACA,UAAM,OAAO;AAJG;AACA;AACA;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;;;ACxFA,SAAS,aAAa;AAOf,IAAM,qBAAN,MAAyB;AAAA,EAC9B,YAA6B,QAAuB;AAAvB;AAAA,EAAwB;AAAA;AAAA;AAAA;AAAA,EAKrD,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EA,mBAAmC;AACjC,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,qBAA6C;AAC3C,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAM,QAAQ,UAA4C;AACxD,SAAK,kBAAkB,MAAM,KAAK,cAAc,QAAQ,QAAQ;AAChE,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAM,MAAM,QAAkB,SAA+C;AAC3E,UAAM,eAAe,WAAW,KAAK;AACrC,QAAI,CAAC,cAAc;AACjB,YAAM,IAAI,MAAM,kEAAkE;AAAA,IACpF;AACA,WAAO,KAAK,cAAc,cAAc,cAAc,MAAM;AAAA,EAC9D;AAAA,EAEA,MAAM,OACJ,OACA,cACA,SACkB;AAClB,UAAM,eAAe,WAAW,KAAK;AACrC,QAAI,CAAC,cAAc;AACjB,YAAM,IAAI,MAAM,kEAAkE;AAAA,IACpF;AACA,WAAO,KAAK,cAAc,YAAY,cAAc,OAAO,YAAY;AAAA,EACzE;AAAA,EAEA,MAAM,YACJ,UACA,QACkD;AAClD,UAAM,UAAU,MAAM,KAAK,QAAQ,QAAQ;AAC3C,UAAM,QAAQ,MAAM,KAAK,MAAM,QAAQ,OAAO;AAC9C,UAAM,WAAW,MAAM,KAAK,OAAO,MAAM,OAAO,MAAM,cAAc,OAAO;AAC3E,WAAO,EAAE,OAAO,SAAS;AAAA,EAC3B;AACF;AAMA,eAAsB,mBAAmB,cAAqD;AAC5F,SAAO,eAAe,KAAK,YAAY;AACzC;","names":["Provider"]}
1
+ {"version":3,"sources":["../../src/infra/provingSystems/Sunspot.ts","../../src/infra/sunspot/types.ts","../../src/infra/sunspot/SunspotCliExecutor.ts","../../src/domain/types/provider.ts","../../src/providers/sunspot.ts"],"sourcesContent":["import { readFile, writeFile, rm, mkdtemp, mkdir } from 'node:fs/promises';\nimport { join, dirname } from 'node:path';\nimport { tmpdir } from 'node:os';\nimport type { IProvingSystem } from '../../domain/interfaces/proving/IProvingSystem.js';\nimport type { CompiledCircuit, InputMap, ProofData } from '../../domain/types.js';\nimport type { SunspotConfig, SunspotCircuitPaths, SunspotCompiledCircuit } from '../sunspot/types.js';\nimport { DEFAULT_SUNSPOT_CONFIG, isSunspotCircuit, SunspotCliError } from '../sunspot/types.js';\nimport { SunspotCliExecutor } from '../sunspot/SunspotCliExecutor.js';\nimport type { CircuitPaths } from '../../domain/types/provider.js';\n\n/**\n * Configuration for Sunspot constructor\n */\nexport interface SunspotInitConfig extends Partial<SunspotConfig> {\n /** Pre-compiled circuit paths (if provided, compile() is disabled) */\n precompiledPaths?: CircuitPaths;\n}\n\n/**\n * Sunspot proving system using CLI tools.\n * Node.js only (requires nargo and sunspot binaries).\n * Produces Groth16 proofs (~324 bytes) for Solana on-chain verification.\n *\n * Can be used in two modes:\n * 1. Full compilation: Call compile() with Noir code (requires nargo + sunspot CLI)\n * 2. Pre-compiled: Provide circuitPaths in constructor, then only prove/verify\n *\n * @example Full compilation\n * ```typescript\n * const sunspot = new Sunspot();\n * const circuit = await sunspot.compile(noirCode);\n * const proof = await sunspot.generateProof(circuit, inputs);\n * ```\n *\n * @example Pre-compiled (via IziNoir)\n * ```typescript\n * const izi = await IziNoir.init({\n * provider: Provider.Sunspot,\n * circuitPaths: { pkPath: '...', vkPath: '...', circuitPath: '...' }\n * });\n * ```\n */\nexport class Sunspot implements IProvingSystem {\n private readonly config: SunspotConfig;\n private readonly executor: SunspotCliExecutor;\n private readonly precompiledPaths?: CircuitPaths;\n private precompiledCircuit?: SunspotCompiledCircuit;\n\n /**\n * Create a new Sunspot proving system\n * @param config - Configuration options or pre-compiled circuit paths\n */\n constructor(config: SunspotInitConfig | CircuitPaths = {}) {\n // Check if config is CircuitPaths (has pkPath, vkPath, circuitPath)\n if ('pkPath' in config && 'vkPath' in config && 'circuitPath' in config) {\n this.config = { ...DEFAULT_SUNSPOT_CONFIG };\n this.precompiledPaths = config as CircuitPaths;\n } else {\n const initConfig = config as SunspotInitConfig;\n this.config = { ...DEFAULT_SUNSPOT_CONFIG, ...initConfig };\n this.precompiledPaths = initConfig.precompiledPaths;\n }\n\n this.executor = new SunspotCliExecutor(this.config);\n\n // If pre-compiled paths provided, create a dummy circuit object\n if (this.precompiledPaths) {\n this.precompiledCircuit = this.createPrecompiledCircuit(this.precompiledPaths);\n }\n }\n\n /**\n * Create a SunspotCompiledCircuit from pre-compiled paths\n */\n private createPrecompiledCircuit(paths: CircuitPaths): SunspotCompiledCircuit {\n const baseDir = dirname(paths.circuitPath);\n return {\n bytecode: '', // Not needed for prove/verify with pre-compiled\n abi: { parameters: [], return_type: null, error_types: {} },\n debug_symbols: '',\n file_map: {},\n __sunspot: true,\n paths: {\n workDir: baseDir,\n noirProjectDir: baseDir,\n circuitJsonPath: paths.circuitPath,\n witnessPath: join(baseDir, 'circuit.gz'),\n ccsPath: join(baseDir, 'circuit.ccs'),\n pkPath: paths.pkPath,\n vkPath: paths.vkPath,\n proofPath: join(baseDir, 'circuit.proof'),\n publicWitnessPath: join(baseDir, 'circuit.pw'),\n proverTomlPath: join(baseDir, 'Prover.toml'),\n },\n };\n }\n\n /**\n * Create a temporary Noir project for compilation\n */\n private async createNoirProject(noirCode: string, packageName: string): Promise<{ rootDir: string }> {\n const rootDir = await mkdtemp(join(tmpdir(), 'sunspot-circuit-'));\n const srcDir = join(rootDir, 'src');\n await mkdir(srcDir, { recursive: true });\n\n const nargoToml = `[package]\nname = \"${packageName}\"\ntype = \"bin\"\nauthors = [\"\"]\n\n[dependencies]\n`;\n\n await writeFile(join(rootDir, 'Nargo.toml'), nargoToml);\n await writeFile(join(srcDir, 'main.nr'), noirCode);\n\n return { rootDir };\n }\n\n async compile(noirCode: string): Promise<CompiledCircuit> {\n if (this.precompiledPaths) {\n throw new Error(\n 'Sunspot was initialized with pre-compiled circuit paths. ' +\n 'compile() is not available. Use generateProof() and verifyProof() directly.'\n );\n }\n\n // 1. Create temp Noir project\n const project = await this.createNoirProject(noirCode, 'circuit');\n const targetDir = join(project.rootDir, 'target');\n\n // 2. Run nargo compile → circuit.json\n await this.executor.nargoCompile(project.rootDir);\n const circuitJsonPath = join(targetDir, 'circuit.json');\n\n // 3. Run sunspot compile → circuit.ccs\n await this.executor.sunspotCompile(circuitJsonPath);\n const ccsPath = join(dirname(circuitJsonPath), 'circuit.ccs');\n\n // 4. Run sunspot setup → circuit.pk + circuit.vk\n await this.executor.sunspotSetup(ccsPath);\n const pkPath = join(dirname(ccsPath), 'circuit.pk');\n const vkPath = join(dirname(ccsPath), 'circuit.vk');\n\n // 5. Read circuit.json to extract ABI\n const circuitJson = JSON.parse(await readFile(circuitJsonPath, 'utf-8'));\n\n // 6. Build paths object\n const paths: SunspotCircuitPaths = {\n workDir: project.rootDir,\n noirProjectDir: project.rootDir,\n circuitJsonPath,\n witnessPath: join(targetDir, 'circuit.gz'),\n ccsPath,\n pkPath,\n vkPath,\n proofPath: join(dirname(ccsPath), 'circuit.proof'),\n publicWitnessPath: join(dirname(ccsPath), 'circuit.pw'),\n proverTomlPath: join(project.rootDir, 'Prover.toml'),\n };\n\n // 7. Return SunspotCompiledCircuit (don't cleanup - prover needs the files)\n const sunspotCircuit: SunspotCompiledCircuit = {\n bytecode: circuitJson.bytecode || '',\n abi: circuitJson.abi || {\n parameters: [],\n return_type: null,\n error_types: {},\n },\n debug_symbols: circuitJson.debug_symbols || '',\n file_map: circuitJson.file_map || {},\n __sunspot: true,\n paths,\n };\n\n return sunspotCircuit;\n }\n\n async generateProof(circuit: CompiledCircuit, inputs: InputMap): Promise<ProofData> {\n // Use precompiled circuit if available and circuit is empty/default\n const circuitToUse = this.resolveCircuit(circuit);\n\n if (!isSunspotCircuit(circuitToUse)) {\n throw new Error(\n 'Sunspot.generateProof requires a SunspotCompiledCircuit. Use Sunspot.compile() first.'\n );\n }\n\n const paths = circuitToUse.paths;\n\n try {\n // 1. Write Prover.toml with inputs\n const proverToml = this.generateProverToml(inputs);\n await writeFile(paths.proverTomlPath, proverToml);\n\n // 2. Run nargo execute to generate witness\n await this.executor.nargoExecute(paths.noirProjectDir);\n\n // 3. Run sunspot prove to generate proof\n await this.executor.sunspotProve(\n paths.circuitJsonPath,\n paths.witnessPath,\n paths.ccsPath,\n paths.pkPath\n );\n\n // 4. Read proof and public witness files\n const proofBytes = new Uint8Array(await readFile(paths.proofPath));\n const publicWitnessBytes = new Uint8Array(await readFile(paths.publicWitnessPath));\n\n // 5. Parse public inputs from public witness\n const publicInputs = this.parsePublicWitness(publicWitnessBytes);\n\n return {\n proof: proofBytes,\n publicInputs,\n };\n } catch (error) {\n if (!this.config.keepArtifacts) {\n await rm(paths.workDir, { recursive: true, force: true }).catch(() => {});\n }\n throw error;\n }\n }\n\n async verifyProof(\n circuit: CompiledCircuit,\n proof: Uint8Array,\n publicInputs: string[]\n ): Promise<boolean> {\n // Use precompiled circuit if available and circuit is empty/default\n const circuitToUse = this.resolveCircuit(circuit);\n\n if (!isSunspotCircuit(circuitToUse)) {\n throw new Error(\n 'Sunspot.verifyProof requires a SunspotCompiledCircuit. Use Sunspot.compile() first.'\n );\n }\n\n const paths = circuitToUse.paths;\n\n try {\n // Use existing .proof and .pw files from generateProof\n const existingProof = await readFile(paths.proofPath).catch(() => null);\n if (!existingProof || !this.bytesEqual(existingProof, proof)) {\n await writeFile(paths.proofPath, proof);\n }\n\n await this.executor.sunspotVerify(\n paths.vkPath,\n paths.proofPath,\n paths.publicWitnessPath\n );\n\n return true;\n } catch (error) {\n if (error instanceof SunspotCliError) {\n if (error.stderr.toLowerCase().includes('verification failed') ||\n error.stderr.toLowerCase().includes('invalid proof')) {\n return false;\n }\n }\n throw error;\n } finally {\n if (!this.config.keepArtifacts) {\n await rm(paths.workDir, { recursive: true, force: true }).catch(() => {});\n }\n }\n }\n\n /**\n * Resolve which circuit to use - precompiled or provided\n */\n private resolveCircuit(circuit: CompiledCircuit): CompiledCircuit {\n // If circuit is a proper SunspotCompiledCircuit, use it\n if (isSunspotCircuit(circuit)) {\n return circuit;\n }\n\n // If we have precompiled paths, use those\n if (this.precompiledCircuit) {\n return this.precompiledCircuit;\n }\n\n // Otherwise, return the provided circuit (will fail validation)\n return circuit;\n }\n\n private generateProverToml(inputs: InputMap): string {\n const lines: string[] = [];\n for (const [key, value] of Object.entries(inputs)) {\n lines.push(`${key} = ${this.formatTomlValue(value)}`);\n }\n return lines.join('\\n') + '\\n';\n }\n\n private formatTomlValue(value: unknown): string {\n if (typeof value === 'string') {\n if (value.startsWith('0x')) return `\"${value}\"`;\n if (/^\\d+$/.test(value)) return value;\n return `\"${value}\"`;\n }\n if (typeof value === 'number' || typeof value === 'bigint') {\n return value.toString();\n }\n if (Array.isArray(value)) {\n return `[${value.map(v => this.formatTomlValue(v)).join(', ')}]`;\n }\n return String(value);\n }\n\n private parsePublicWitness(bytes: Uint8Array): string[] {\n const publicInputs: string[] = [];\n const FIELD_SIZE = 32;\n\n for (let i = 0; i < bytes.length; i += FIELD_SIZE) {\n const fieldBytes = bytes.slice(i, Math.min(i + FIELD_SIZE, bytes.length));\n if (fieldBytes.length === FIELD_SIZE) {\n const hex = '0x' + Array.from(fieldBytes)\n .map(b => b.toString(16).padStart(2, '0'))\n .join('');\n publicInputs.push(hex);\n }\n }\n\n return publicInputs;\n }\n\n private bytesEqual(a: Buffer | Uint8Array, b: Uint8Array): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n }\n}\n","import type { CompiledCircuit } from '@noir-lang/types';\n\n/**\n * Configuration for Sunspot CLI execution\n */\nexport interface SunspotConfig {\n /** Path to nargo binary (default: 'nargo') */\n nargoBinaryPath: string;\n /** Path to sunspot binary (default: 'sunspot') */\n sunspotBinaryPath: string;\n /** Keep temp artifacts for debugging (default: false) */\n keepArtifacts: boolean;\n /** Timeout for CLI commands in ms (default: 120000) */\n timeoutMs: number;\n}\n\nexport const DEFAULT_SUNSPOT_CONFIG: SunspotConfig = {\n nargoBinaryPath: process.env.NARGO_PATH || 'nargo',\n sunspotBinaryPath: process.env.SUNSPOT_PATH || 'sunspot',\n keepArtifacts: process.env.SUNSPOT_KEEP_ARTIFACTS === 'true',\n timeoutMs: 120000,\n};\n\n/**\n * Paths to all Sunspot artifacts in the temp directory\n */\nexport interface SunspotCircuitPaths {\n /** Base temp directory */\n workDir: string;\n /** Noir project directory with Nargo.toml */\n noirProjectDir: string;\n /** Path to compiled circuit.json (ACIR) */\n circuitJsonPath: string;\n /** Path to witness.gz */\n witnessPath: string;\n /** Path to circuit.ccs */\n ccsPath: string;\n /** Path to proving key */\n pkPath: string;\n /** Path to verification key */\n vkPath: string;\n /** Path to proof file */\n proofPath: string;\n /** Path to public witness file */\n publicWitnessPath: string;\n /** Path to Prover.toml */\n proverTomlPath: string;\n}\n\n/**\n * Extended CompiledCircuit for Sunspot backend\n */\nexport interface SunspotCompiledCircuit extends CompiledCircuit {\n /** Marker to identify Sunspot circuits */\n __sunspot: true;\n /** Paths to all artifacts */\n paths: SunspotCircuitPaths;\n}\n\n/**\n * Type guard to check if a circuit is a Sunspot circuit\n */\nexport function isSunspotCircuit(circuit: CompiledCircuit): circuit is SunspotCompiledCircuit {\n return '__sunspot' in circuit && (circuit as SunspotCompiledCircuit).__sunspot === true;\n}\n\n/**\n * Result of CLI command execution\n */\nexport interface CliResult {\n stdout: string;\n stderr: string;\n exitCode: number;\n}\n\n/**\n * Error thrown when CLI command fails\n */\nexport class SunspotCliError extends Error {\n constructor(\n message: string,\n public readonly command: string,\n public readonly exitCode: number,\n public readonly stderr: string\n ) {\n super(message);\n this.name = 'SunspotCliError';\n }\n}\n","import { spawn } from 'node:child_process';\nimport type { SunspotConfig, CliResult } from './types.js';\nimport { SunspotCliError } from './types.js';\n\n/**\n * Executes Sunspot and Nargo CLI commands\n */\nexport class SunspotCliExecutor {\n constructor(private readonly config: SunspotConfig) {}\n\n /**\n * Execute a CLI command and return the result\n */\n private async execute(command: string, args: string[], cwd?: string): Promise<CliResult> {\n return new Promise((resolve, reject) => {\n const proc = spawn(command, args, {\n cwd,\n timeout: this.config.timeoutMs,\n env: { ...process.env },\n });\n\n let stdout = '';\n let stderr = '';\n\n proc.stdout.on('data', (data) => {\n stdout += data.toString();\n });\n\n proc.stderr.on('data', (data) => {\n stderr += data.toString();\n });\n\n proc.on('close', (exitCode) => {\n const result: CliResult = {\n stdout,\n stderr,\n exitCode: exitCode ?? 1,\n };\n\n if (exitCode !== 0) {\n reject(new SunspotCliError(\n `Command failed: ${command} ${args.join(' ')}\\n${stderr || stdout}`,\n `${command} ${args.join(' ')}`,\n exitCode ?? 1,\n stderr || stdout\n ));\n } else {\n resolve(result);\n }\n });\n\n proc.on('error', (error) => {\n const message = error.message.includes('ENOENT')\n ? `Binary not found: ${command}. Ensure it is installed and in PATH.`\n : `Failed to execute ${command}: ${error.message}`;\n\n reject(new SunspotCliError(\n message,\n `${command} ${args.join(' ')}`,\n 1,\n error.message\n ));\n });\n });\n }\n\n /**\n * Run nargo compile in the project directory\n * Output: target/circuit.json\n */\n async nargoCompile(projectDir: string): Promise<CliResult> {\n return this.execute(this.config.nargoBinaryPath, ['compile'], projectDir);\n }\n\n /**\n * Run nargo execute to generate witness\n * Output: target/circuit.gz\n */\n async nargoExecute(projectDir: string): Promise<CliResult> {\n return this.execute(this.config.nargoBinaryPath, ['execute'], projectDir);\n }\n\n /**\n * Run sunspot compile to generate CCS\n * Input: circuit.json\n * Output: circuit.ccs (in same directory as input)\n */\n async sunspotCompile(circuitJsonPath: string): Promise<CliResult> {\n return this.execute(this.config.sunspotBinaryPath, ['compile', circuitJsonPath]);\n }\n\n /**\n * Run sunspot setup to generate proving and verification keys\n * Input: circuit.ccs\n * Output: circuit.pk, circuit.vk (in same directory as input)\n */\n async sunspotSetup(ccsPath: string): Promise<CliResult> {\n return this.execute(this.config.sunspotBinaryPath, ['setup', ccsPath]);\n }\n\n /**\n * Run sunspot prove to generate proof\n * Inputs: circuit.json, witness.gz, circuit.ccs, circuit.pk\n * Outputs: circuit.proof, circuit.pw (in same directory as ccs)\n */\n async sunspotProve(\n circuitJsonPath: string,\n witnessPath: string,\n ccsPath: string,\n pkPath: string\n ): Promise<CliResult> {\n return this.execute(this.config.sunspotBinaryPath, [\n 'prove',\n circuitJsonPath,\n witnessPath,\n ccsPath,\n pkPath,\n ]);\n }\n\n /**\n * Run sunspot verify to verify a proof\n * Inputs: circuit.vk, circuit.proof, circuit.pw\n * Returns: true if verification succeeds\n */\n async sunspotVerify(\n vkPath: string,\n proofPath: string,\n publicWitnessPath: string\n ): Promise<CliResult> {\n return this.execute(this.config.sunspotBinaryPath, [\n 'verify',\n vkPath,\n proofPath,\n publicWitnessPath,\n ]);\n }\n}\n","import { Chain } from './chain.js';\nimport { Network } from '../../solana/config.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 /**\n * Solana network for deploy/verify operations.\n * Only used when chain is Chain.Solana.\n * Default: Network.Devnet\n */\n network?: Network;\n /** Circuit paths - required for Sunspot provider */\n circuitPaths?: CircuitPaths;\n}\n\n// Re-export Chain and Network for convenience\nexport { Chain };\nexport { Network };\n","/**\n * Sunspot entry point for Node.js.\n *\n * This module provides Sunspot support which is NOT available in the main\n * `@izi-noir/sdk` entry point due to Node.js-only dependencies.\n *\n * Note: Sunspot requires nargo and sunspot CLI tools to be installed.\n *\n * @example Using Sunspot directly\n * ```typescript\n * import { Sunspot } from '@izi-noir/sdk/sunspot';\n *\n * // Full compilation mode\n * const sunspot = new Sunspot();\n * const circuit = await sunspot.compile(noirCode);\n * const proof = await sunspot.generateProof(circuit, inputs);\n * const verified = await sunspot.verifyProof(circuit, proof.proof, proof.publicInputs);\n *\n * // Pre-compiled mode\n * const sunspot = new Sunspot({\n * pkPath: './circuit/circuit.pk',\n * vkPath: './circuit/circuit.vk',\n * circuitPath: './circuit/circuit.json',\n * });\n * ```\n *\n * @example Using initSunspotIziNoir helper\n * ```typescript\n * import { initSunspotIziNoir } from '@izi-noir/sdk/sunspot';\n *\n * const izi = await initSunspotIziNoir({\n * pkPath: './circuit/circuit.pk',\n * vkPath: './circuit/circuit.vk',\n * circuitPath: './circuit/circuit.json',\n * });\n *\n * // Use like regular IziNoir (but only prove/verify, not compile)\n * const proof = await izi.prove(inputs);\n * const verified = await izi.verify(proof.proof, proof.publicInputs);\n * ```\n *\n * @module @izi-noir/sdk/sunspot\n */\n\nimport type { IProvingSystem } from '../domain/interfaces/proving/IProvingSystem.js';\nimport type { CompiledCircuit, InputMap, ProofData } from '../domain/types.js';\nimport type { CircuitPaths } from '../domain/types/provider.js';\nimport { Sunspot } from '../infra/provingSystems/Sunspot.js';\n\nexport { Sunspot } from '../infra/provingSystems/Sunspot.js';\nexport type { SunspotInitConfig } from '../infra/provingSystems/Sunspot.js';\nexport type {\n SunspotConfig,\n SunspotCircuitPaths,\n SunspotCompiledCircuit,\n} from '../infra/sunspot/types.js';\nexport { isSunspotCircuit, SunspotCliError } from '../infra/sunspot/types.js';\n\n// Re-export common types\nexport { Provider, type IziNoirConfig, type CircuitPaths } from '../domain/types/provider.js';\nexport type { CompiledCircuit, InputMap, ProofData } from '../domain/types.js';\nexport type { IProvingSystem } from '../domain/interfaces/proving/IProvingSystem.js';\n\n/**\n * IziNoir-like wrapper for Sunspot.\n * Provides a similar API to IziNoir but backed by the Sunspot proving system.\n */\nexport class IziNoirSunspot {\n private provingSystem: IProvingSystem;\n private compiledCircuit: CompiledCircuit | null = null;\n\n private constructor(provingSystem: IProvingSystem) {\n this.provingSystem = provingSystem;\n }\n\n /**\n * Initialize IziNoirSunspot with pre-compiled circuit paths.\n * Note: Sunspot requires pre-compiled circuits for prove/verify operations.\n *\n * @param circuitPaths - Paths to the pre-compiled circuit files\n */\n static async init(circuitPaths: CircuitPaths): Promise<IziNoirSunspot> {\n const sunspot = new Sunspot(circuitPaths);\n return new IziNoirSunspot(sunspot);\n }\n\n /**\n * Initialize IziNoirSunspot for full compilation mode.\n * Requires nargo and sunspot CLI tools to be installed.\n */\n static async initForCompilation(): Promise<IziNoirSunspot> {\n const sunspot = new Sunspot();\n return new IziNoirSunspot(sunspot);\n }\n\n getProvingSystem(): IProvingSystem {\n return this.provingSystem;\n }\n\n getCompiledCircuit(): CompiledCircuit | null {\n return this.compiledCircuit;\n }\n\n async compile(noirCode: string): Promise<CompiledCircuit> {\n this.compiledCircuit = await this.provingSystem.compile(noirCode);\n return this.compiledCircuit;\n }\n\n async prove(inputs: InputMap, circuit?: CompiledCircuit): Promise<ProofData> {\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.generateProof(circuitToUse, inputs);\n }\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 async createProof(\n noirCode: string,\n inputs: InputMap\n ): Promise<{ proof: ProofData; verified: boolean }> {\n const circuit = await this.compile(noirCode);\n const proof = await this.prove(inputs, circuit);\n const verified = await this.verify(proof.proof, proof.publicInputs, circuit);\n return { proof, verified };\n }\n}\n\n/**\n * Helper function to create an IziNoirSunspot instance with pre-compiled circuit paths.\n * @deprecated Use `IziNoirSunspot.init(circuitPaths)` instead.\n */\nexport async function initSunspotIziNoir(circuitPaths: CircuitPaths): Promise<IziNoirSunspot> {\n return IziNoirSunspot.init(circuitPaths);\n}\n"],"mappings":";AAAA,SAAS,UAAU,WAAW,IAAI,SAAS,aAAa;AACxD,SAAS,MAAM,eAAe;AAC9B,SAAS,cAAc;;;ACchB,IAAM,yBAAwC;AAAA,EACnD,iBAAiB,QAAQ,IAAI,cAAc;AAAA,EAC3C,mBAAmB,QAAQ,IAAI,gBAAgB;AAAA,EAC/C,eAAe,QAAQ,IAAI,2BAA2B;AAAA,EACtD,WAAW;AACb;AAyCO,SAAS,iBAAiB,SAA6D;AAC5F,SAAO,eAAe,WAAY,QAAmC,cAAc;AACrF;AAcO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC,YACE,SACgB,SACA,UACA,QAChB;AACA,UAAM,OAAO;AAJG;AACA;AACA;AAGhB,SAAK,OAAO;AAAA,EACd;AACF;;;ACxFA,SAAS,aAAa;AAOf,IAAM,qBAAN,MAAyB;AAAA,EAC9B,YAA6B,QAAuB;AAAvB;AAAA,EAAwB;AAAA;AAAA;AAAA;AAAA,EAKrD,MAAc,QAAQ,SAAiB,MAAgB,KAAkC;AACvF,WAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,YAAM,OAAO,MAAM,SAAS,MAAM;AAAA,QAChC;AAAA,QACA,SAAS,KAAK,OAAO;AAAA,QACrB,KAAK,EAAE,GAAG,QAAQ,IAAI;AAAA,MACxB,CAAC;AAED,UAAI,SAAS;AACb,UAAI,SAAS;AAEb,WAAK,OAAO,GAAG,QAAQ,CAAC,SAAS;AAC/B,kBAAU,KAAK,SAAS;AAAA,MAC1B,CAAC;AAED,WAAK,OAAO,GAAG,QAAQ,CAAC,SAAS;AAC/B,kBAAU,KAAK,SAAS;AAAA,MAC1B,CAAC;AAED,WAAK,GAAG,SAAS,CAAC,aAAa;AAC7B,cAAM,SAAoB;AAAA,UACxB;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jB,YAAM,IAAI,MAAM,kEAAkE;AAAA,IACpF;AACA,WAAO,KAAK,cAAc,YAAY,cAAc,OAAO,YAAY;AAAA,EACzE;AAAA,EAEA,MAAM,YACJ,UACA,QACkD;AAClD,UAAM,UAAU,MAAM,KAAK,QAAQ,QAAQ;AAC3C,UAAM,QAAQ,MAAM,KAAK,MAAM,QAAQ,OAAO;AAC9C,UAAM,WAAW,MAAM,KAAK,OAAO,MAAM,OAAO,MAAM,cAAc,OAAO;AAC3E,WAAO,EAAE,OAAO,SAAS;AAAA,EAC3B;AACF;AAMA,eAAsB,mBAAmB,cAAqD;AAC5F,SAAO,eAAe,KAAK,YAAY;AACzC;","names":["Provider"]}
@@ -1,3 +1,5 @@
1
+ import { CompiledCircuit } from '@noir-lang/types';
2
+
1
3
  type InputValue = number | string | bigint;
2
4
  interface ProofTimings {
3
5
  parseMs: number;
@@ -27,9 +29,19 @@ interface ProverOptions {
27
29
  interface VerifierOptions {
28
30
  verbose?: boolean;
29
31
  }
32
+ /**
33
+ * Result of compiling a circuit.
34
+ * Contains the compiled circuit and verifying key generated during trusted setup.
35
+ */
36
+ interface CompileResult {
37
+ /** The compiled circuit (includes cached PK/VK) */
38
+ circuit: CompiledCircuit;
39
+ /** Verifying key generated during trusted setup */
40
+ verifyingKey: VerifyingKeyData;
41
+ }
30
42
  /**
31
43
  * Verifying key data for on-chain verification.
32
- * Stored on the IziNoir instance after prove() is called.
44
+ * Stored on the IziNoir instance after compile() is called.
33
45
  */
34
46
  interface VerifyingKeyData {
35
47
  /** Base64-encoded VK in gnark format */
@@ -90,4 +102,4 @@ interface SolanaProofData {
90
102
  estimatedRent: number;
91
103
  }
92
104
 
93
- export type { CircuitFunction as C, InputValue as I, ProofData as P, SolanaProofData as S, VerifyingKeyData as V, ProofResult as a, ProofTimings as b, ProverOptions as c, VerifierOptions as d };
105
+ export type { CompileResult as C, InputValue as I, ProofData as P, SolanaProofData as S, VerifyingKeyData as V, CircuitFunction as a, ProofResult as b, ProofTimings as c, ProverOptions as d, VerifierOptions as e };
@@ -1,3 +1,5 @@
1
+ import { CompiledCircuit } from '@noir-lang/types';
2
+
1
3
  type InputValue = number | string | bigint;
2
4
  interface ProofTimings {
3
5
  parseMs: number;
@@ -27,9 +29,19 @@ interface ProverOptions {
27
29
  interface VerifierOptions {
28
30
  verbose?: boolean;
29
31
  }
32
+ /**
33
+ * Result of compiling a circuit.
34
+ * Contains the compiled circuit and verifying key generated during trusted setup.
35
+ */
36
+ interface CompileResult {
37
+ /** The compiled circuit (includes cached PK/VK) */
38
+ circuit: CompiledCircuit;
39
+ /** Verifying key generated during trusted setup */
40
+ verifyingKey: VerifyingKeyData;
41
+ }
30
42
  /**
31
43
  * Verifying key data for on-chain verification.
32
- * Stored on the IziNoir instance after prove() is called.
44
+ * Stored on the IziNoir instance after compile() is called.
33
45
  */
34
46
  interface VerifyingKeyData {
35
47
  /** Base64-encoded VK in gnark format */
@@ -90,4 +102,4 @@ interface SolanaProofData {
90
102
  estimatedRent: number;
91
103
  }
92
104
 
93
- export type { CircuitFunction as C, InputValue as I, ProofData as P, SolanaProofData as S, VerifyingKeyData as V, ProofResult as a, ProofTimings as b, ProverOptions as c, VerifierOptions as d };
105
+ export type { CompileResult as C, InputValue as I, ProofData as P, SolanaProofData as S, VerifyingKeyData as V, CircuitFunction as a, ProofResult as b, ProofTimings as c, ProverOptions as d, VerifierOptions as e };
@@ -51,6 +51,36 @@ function prove(proving_key_b64, acir_json, witness_json) {
51
51
  }
52
52
  exports.prove = prove;
53
53
 
54
+ /**
55
+ * Generate a Groth16 proof from R1CS definition
56
+ *
57
+ * # Arguments
58
+ * * `proving_key_b64` - Base64-encoded proving key from setup
59
+ * * `r1cs_json` - JSON string of R1CS definition
60
+ * * `witness_json` - JSON object mapping witness indices to hex values
61
+ *
62
+ * # Returns
63
+ * * `JsProofResult` with proof and public inputs
64
+ * @param {string} proving_key_b64
65
+ * @param {string} r1cs_json
66
+ * @param {string} witness_json
67
+ * @returns {any}
68
+ */
69
+ function prove_from_r1cs(proving_key_b64, r1cs_json, witness_json) {
70
+ const ptr0 = passStringToWasm0(proving_key_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
71
+ const len0 = WASM_VECTOR_LEN;
72
+ const ptr1 = passStringToWasm0(r1cs_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
73
+ const len1 = WASM_VECTOR_LEN;
74
+ const ptr2 = passStringToWasm0(witness_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
75
+ const len2 = WASM_VECTOR_LEN;
76
+ const ret = wasm.prove_from_r1cs(ptr0, len0, ptr1, len1, ptr2, len2);
77
+ if (ret[2]) {
78
+ throw takeFromExternrefTable0(ret[1]);
79
+ }
80
+ return takeFromExternrefTable0(ret[0]);
81
+ }
82
+ exports.prove_from_r1cs = prove_from_r1cs;
83
+
54
84
  /**
55
85
  * Perform trusted setup for a circuit
56
86
  *
@@ -73,6 +103,28 @@ function setup(acir_json) {
73
103
  }
74
104
  exports.setup = setup;
75
105
 
106
+ /**
107
+ * Perform trusted setup from R1CS definition
108
+ *
109
+ * # Arguments
110
+ * * `r1cs_json` - JSON string of R1CS definition
111
+ *
112
+ * # Returns
113
+ * * `JsSetupResult` with base64-encoded proving and verifying keys
114
+ * @param {string} r1cs_json
115
+ * @returns {any}
116
+ */
117
+ function setup_from_r1cs(r1cs_json) {
118
+ const ptr0 = passStringToWasm0(r1cs_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
119
+ const len0 = WASM_VECTOR_LEN;
120
+ const ret = wasm.setup_from_r1cs(ptr0, len0);
121
+ if (ret[2]) {
122
+ throw takeFromExternrefTable0(ret[1]);
123
+ }
124
+ return takeFromExternrefTable0(ret[0]);
125
+ }
126
+ exports.setup_from_r1cs = setup_from_r1cs;
127
+
76
128
  /**
77
129
  * Verify a Groth16 proof
78
130
  *
@@ -48,6 +48,35 @@ export function prove(proving_key_b64, acir_json, witness_json) {
48
48
  return takeFromExternrefTable0(ret[0]);
49
49
  }
50
50
 
51
+ /**
52
+ * Generate a Groth16 proof from R1CS definition
53
+ *
54
+ * # Arguments
55
+ * * `proving_key_b64` - Base64-encoded proving key from setup
56
+ * * `r1cs_json` - JSON string of R1CS definition
57
+ * * `witness_json` - JSON object mapping witness indices to hex values
58
+ *
59
+ * # Returns
60
+ * * `JsProofResult` with proof and public inputs
61
+ * @param {string} proving_key_b64
62
+ * @param {string} r1cs_json
63
+ * @param {string} witness_json
64
+ * @returns {any}
65
+ */
66
+ export function prove_from_r1cs(proving_key_b64, r1cs_json, witness_json) {
67
+ const ptr0 = passStringToWasm0(proving_key_b64, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
68
+ const len0 = WASM_VECTOR_LEN;
69
+ const ptr1 = passStringToWasm0(r1cs_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
70
+ const len1 = WASM_VECTOR_LEN;
71
+ const ptr2 = passStringToWasm0(witness_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
72
+ const len2 = WASM_VECTOR_LEN;
73
+ const ret = wasm.prove_from_r1cs(ptr0, len0, ptr1, len1, ptr2, len2);
74
+ if (ret[2]) {
75
+ throw takeFromExternrefTable0(ret[1]);
76
+ }
77
+ return takeFromExternrefTable0(ret[0]);
78
+ }
79
+
51
80
  /**
52
81
  * Perform trusted setup for a circuit
53
82
  *
@@ -69,6 +98,27 @@ export function setup(acir_json) {
69
98
  return takeFromExternrefTable0(ret[0]);
70
99
  }
71
100
 
101
+ /**
102
+ * Perform trusted setup from R1CS definition
103
+ *
104
+ * # Arguments
105
+ * * `r1cs_json` - JSON string of R1CS definition
106
+ *
107
+ * # Returns
108
+ * * `JsSetupResult` with base64-encoded proving and verifying keys
109
+ * @param {string} r1cs_json
110
+ * @returns {any}
111
+ */
112
+ export function setup_from_r1cs(r1cs_json) {
113
+ const ptr0 = passStringToWasm0(r1cs_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
114
+ const len0 = WASM_VECTOR_LEN;
115
+ const ret = wasm.setup_from_r1cs(ptr0, len0);
116
+ if (ret[2]) {
117
+ throw takeFromExternrefTable0(ret[1]);
118
+ }
119
+ return takeFromExternrefTable0(ret[0]);
120
+ }
121
+
72
122
  /**
73
123
  * Verify a Groth16 proof
74
124
  *
@@ -1,5 +1,5 @@
1
- import { C as ChainId, a as CircuitMetadata, b as ChainMetadataFor, c as Chain, I as IziNoirConfig, d as IProvingSystem } from './IProvingSystem-TKNofoo8.cjs';
2
- import { P as ProofData, S as SolanaProofData, V as VerifyingKeyData } from './types-CaaigonG.cjs';
1
+ import { b as ChainId, c as CircuitMetadata, d as ChainMetadataFor, N as Network, e as Chain, a as IziNoirConfig, I as IProvingSystem } from './IProvingSystem-BpI0rmve.cjs';
2
+ import { P as ProofData, S as SolanaProofData, V as VerifyingKeyData, C as CompileResult } from './types-CxkI04bP.cjs';
3
3
  import { CompiledCircuit, InputMap } from '@noir-lang/types';
4
4
 
5
5
  /**
@@ -46,6 +46,70 @@ interface IChainFormatter<TChain extends ChainId = ChainId> {
46
46
  */
47
47
  type ChainProofDataFor<T extends ChainId> = T extends 'solana' ? SolanaProofData : ProofData;
48
48
 
49
+ /**
50
+ * Solana types for IZI-NOIR SDK.
51
+ */
52
+ /**
53
+ * Minimal wallet adapter interface compatible with @solana/wallet-adapter-react.
54
+ *
55
+ * This interface requires only the essential methods for deploying and verifying
56
+ * proofs on Solana, making it compatible with any wallet adapter implementation.
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * // Works with @solana/wallet-adapter-react
61
+ * const { publicKey, sendTransaction } = useWallet();
62
+ *
63
+ * await izi.deploy({ publicKey, sendTransaction });
64
+ * ```
65
+ */
66
+ interface WalletAdapter {
67
+ /**
68
+ * The wallet's public key.
69
+ */
70
+ publicKey: {
71
+ toBase58(): string;
72
+ toBytes(): Uint8Array;
73
+ } | null;
74
+ /**
75
+ * Send a transaction to the network.
76
+ * This signature is compatible with @solana/wallet-adapter-react's sendTransaction.
77
+ *
78
+ * @param transaction - The transaction to send (web3.js Transaction type)
79
+ * @param connection - The Solana connection
80
+ * @param options - Optional send options
81
+ * @returns The transaction signature
82
+ */
83
+ sendTransaction: SendTransactionFunction;
84
+ }
85
+ /**
86
+ * Function type for sending transactions.
87
+ * Compatible with @solana/wallet-adapter-react.
88
+ */
89
+ type SendTransactionFunction = (transaction: any, connection: any, options?: any) => Promise<string>;
90
+ /**
91
+ * Result of a deploy operation.
92
+ */
93
+ interface DeployResult {
94
+ /** The VK account address (base58) */
95
+ vkAccount: string;
96
+ /** Transaction signature */
97
+ signature: string;
98
+ /** Explorer URL for the transaction */
99
+ explorerUrl: string;
100
+ }
101
+ /**
102
+ * Result of an on-chain verification.
103
+ */
104
+ interface VerifyOnChainResult {
105
+ /** Whether the proof was verified successfully */
106
+ verified: boolean;
107
+ /** Transaction signature */
108
+ signature: string;
109
+ /** Explorer URL for the transaction */
110
+ explorerUrl: string;
111
+ }
112
+
49
113
  /**
50
114
  * Data needed to deploy a verifying key to Solana.
51
115
  * Use with SolanaTransactionBuilder or your own transaction logic.
@@ -88,12 +152,23 @@ declare class IziNoir {
88
152
  private readonly chain?;
89
153
  private _verifyingKey?;
90
154
  private _lastProof?;
155
+ private readonly _network;
156
+ private _vkAccount?;
91
157
  private constructor();
92
158
  /**
93
- * Get the verifying key from the last proof generation.
94
- * Only available after calling prove() with a chain configured.
159
+ * Get the verifying key.
160
+ * Available after calling compile() (for Arkworks/Sunspot providers with chain configured).
95
161
  */
96
162
  get vk(): VerifyingKeyData | undefined;
163
+ /**
164
+ * Get the deployed VK account address.
165
+ * Only available after calling deploy().
166
+ */
167
+ get vkAccount(): string | undefined;
168
+ /**
169
+ * Get the configured network.
170
+ */
171
+ get network(): Network;
97
172
  /**
98
173
  * Get the configured chain, if any.
99
174
  */
@@ -150,16 +225,30 @@ declare class IziNoir {
150
225
  getCompiledCircuit(): CompiledCircuit | null;
151
226
  /**
152
227
  * Compile Noir code into a circuit.
228
+ * Performs trusted setup (generates PK and VK) during compilation.
229
+ * After compile(), the verifying key is available via `this.vk`.
153
230
  *
154
231
  * @param noirCode - The Noir source code to compile
155
- * @returns The compiled circuit
232
+ * @returns CompileResult with circuit and verifying key
233
+ *
234
+ * @example
235
+ * ```typescript
236
+ * const { circuit, verifyingKey } = await izi.compile(noirCode);
237
+ * console.log('VK:', izi.vk); // Available immediately after compile
238
+ * ```
239
+ */
240
+ compile(noirCode: string): Promise<CompileResult>;
241
+ /**
242
+ * Extract verifying key from compiled circuit.
243
+ * Works for Arkworks circuits that have VK cached after setup.
156
244
  */
157
- compile(noirCode: string): Promise<CompiledCircuit>;
245
+ private extractVerifyingKey;
158
246
  /**
159
247
  * Generate a proof for the given inputs.
248
+ * Uses the cached proving key from compile() for fast proof generation.
160
249
  *
161
- * If a chain is configured, returns chain-formatted proof data and stores
162
- * the verifying key in `this.vk`. Otherwise, returns raw proof data.
250
+ * If a chain is configured, returns chain-formatted proof data.
251
+ * Otherwise, returns raw proof data.
163
252
  *
164
253
  * @param inputs - The inputs (both public and private) for the circuit
165
254
  * @param circuit - Optional circuit to use (defaults to last compiled circuit)
@@ -170,15 +259,13 @@ declare class IziNoir {
170
259
  * ```typescript
171
260
  * // With chain configured - returns SolanaProofData
172
261
  * const izi = await IziNoir.init({ provider: Provider.Arkworks, chain: Chain.Solana });
173
- * await izi.compile(noirCode);
262
+ * await izi.compile(noirCode); // VK available after compile
174
263
  * const proof = await izi.prove({ expected: '100', secret: '10' });
175
- * // proof is SolanaProofData, izi.vk is available
176
264
  *
177
265
  * // Offchain mode - returns ProofData
178
266
  * const iziOffchain = await IziNoir.init({ provider: Provider.Arkworks });
179
267
  * await iziOffchain.compile(noirCode);
180
268
  * const rawProof = await iziOffchain.prove({ expected: '100', secret: '10' });
181
- * // rawProof is ProofData, iziOffchain.vk is undefined
182
269
  * ```
183
270
  */
184
271
  prove(inputs: InputMap, circuit?: CompiledCircuit): Promise<ProofData | SolanaProofData>;
@@ -246,6 +333,54 @@ declare class IziNoir {
246
333
  programId?: string;
247
334
  computeUnits?: number;
248
335
  }): SolanaDeployData;
336
+ /**
337
+ * Deploy the verifying key to Solana.
338
+ *
339
+ * This method handles the full deployment flow:
340
+ * 1. Generates a keypair for the VK account
341
+ * 2. Builds the init transaction
342
+ * 3. Sends and confirms the transaction
343
+ * 4. Stores the VK account address on the instance
344
+ *
345
+ * @param wallet - Wallet adapter with publicKey and sendTransaction
346
+ * @returns Deploy result with VK account address and transaction signature
347
+ * @throws Error if not in Solana chain mode or prove() hasn't been called
348
+ *
349
+ * @example
350
+ * ```typescript
351
+ * const izi = await IziNoir.init({
352
+ * provider: Provider.Arkworks,
353
+ * chain: Chain.Solana,
354
+ * network: Network.Devnet
355
+ * });
356
+ *
357
+ * await izi.compile(noirCode);
358
+ * await izi.prove(inputs);
359
+ *
360
+ * // Deploy VK in one line
361
+ * const { vkAccount, signature } = await izi.deploy(wallet);
362
+ * console.log(`VK deployed at: ${vkAccount}`);
363
+ * ```
364
+ */
365
+ deploy(wallet: WalletAdapter): Promise<DeployResult>;
366
+ /**
367
+ * Verify the proof on-chain.
368
+ *
369
+ * @param wallet - Wallet adapter with publicKey and sendTransaction
370
+ * @param vkAccount - VK account address (optional if deploy() was called on this instance)
371
+ * @returns Verification result with transaction signature
372
+ * @throws Error if not in Solana chain mode or no VK account available
373
+ *
374
+ * @example
375
+ * ```typescript
376
+ * // After deploy()
377
+ * const { verified, signature } = await izi.verifyOnChain(wallet);
378
+ *
379
+ * // Or with explicit VK account
380
+ * const { verified } = await izi.verifyOnChain(wallet, 'VkAccountAddress...');
381
+ * ```
382
+ */
383
+ verifyOnChain(wallet: WalletAdapter, vkAccount?: string): Promise<VerifyOnChainResult>;
249
384
  }
250
385
 
251
386
  /**
@@ -279,4 +414,4 @@ declare function isWasmInitialized(): boolean;
279
414
  */
280
415
  declare function markWasmInitialized(): void;
281
416
 
282
- export { type ChainProofDataFor as C, type IChainFormatter as I, type SolanaDeployData as S, IziNoir as a, isWasmInitialized as b, initNoirWasm as i, markWasmInitialized as m };
417
+ export { type ChainProofDataFor as C, type DeployResult as D, type IChainFormatter as I, type SolanaDeployData as S, type VerifyOnChainResult as V, type WalletAdapter as W, IziNoir as a, isWasmInitialized as b, initNoirWasm as i, markWasmInitialized as m };