@izi-noir/sdk 0.1.1 → 0.1.3

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 (31) 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 +29010 -2186
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.cts +6 -6
  6. package/dist/index.d.ts +6 -6
  7. package/dist/index.js +28982 -2141
  8. package/dist/index.js.map +1 -1
  9. package/dist/providers/arkworks.cjs +28084 -1002
  10. package/dist/providers/arkworks.cjs.map +1 -1
  11. package/dist/providers/arkworks.d.cts +4 -4
  12. package/dist/providers/arkworks.d.ts +4 -4
  13. package/dist/providers/arkworks.js +28105 -1002
  14. package/dist/providers/arkworks.js.map +1 -1
  15. package/dist/providers/barretenberg.cjs +28083 -1001
  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 +28104 -1001
  20. package/dist/providers/barretenberg.js.map +1 -1
  21. package/dist/providers/solana.d.cts +1 -1
  22. package/dist/providers/solana.d.ts +1 -1
  23. package/dist/providers/sunspot.cjs.map +1 -1
  24. package/dist/providers/sunspot.d.cts +3 -3
  25. package/dist/providers/sunspot.d.ts +3 -3
  26. package/dist/providers/sunspot.js.map +1 -1
  27. package/dist/{types-CaaigonG.d.cts → types-CxkI04bP.d.cts} +14 -2
  28. package/dist/{types-CaaigonG.d.ts → types-CxkI04bP.d.ts} +14 -2
  29. package/dist/{wasmInit-iEYiiB8M.d.cts → wasmInit-D615cpte.d.cts} +147 -12
  30. package/dist/{wasmInit-KV6DTj4J.d.ts → wasmInit-oOZwkgo_.d.ts} +147 -12
  31. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- export { P as ProofData } from '../types-CaaigonG.cjs';
1
+ export { P as ProofData } from '../types-CxkI04bP.cjs';
2
2
  export { CompiledCircuit, InputMap } from '@noir-lang/types';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- export { P as ProofData } from '../types-CaaigonG.js';
1
+ export { P as ProofData } from '../types-CxkI04bP.js';
2
2
  export { CompiledCircuit, InputMap } from '@noir-lang/types';
3
3
 
4
4
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/providers/sunspot.ts","../../src/infra/provingSystems/Sunspot.ts","../../src/infra/sunspot/types.ts","../../src/infra/sunspot/SunspotCliExecutor.ts","../../src/domain/types/provider.ts"],"sourcesContent":["/**\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","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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,sBAAwD;AACxD,uBAA8B;AAC9B,qBAAuB;;;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,gCAAsB;AAOf,IAAM,qBAAN,MAAyB;AAAA,EAC9B,YAA6B,QAAuB;AAAvB;A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aAAa,qBAA8C;AACzD,UAAM,UAAU,IAAI,QAAQ;AAC5B,WAAO,IAAI,gBAAe,OAAO;AAAA,EACnC;AAAA,EAEA,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/providers/sunspot.ts","../../src/infra/provingSystems/Sunspot.ts","../../src/infra/sunspot/types.ts","../../src/infra/sunspot/SunspotCliExecutor.ts","../../src/domain/types/provider.ts"],"sourcesContent":["/**\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","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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,sBAAwD;AACxD,uBAA8B;AAC9B,qBAAuB;;;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,gCAAsB;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,WAAO,iCAAM,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,OAA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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,6 +1,6 @@
1
- import { d as IProvingSystem, e as CircuitPaths } from '../IProvingSystem-TKNofoo8.cjs';
2
- export { I as IziNoirConfig, P as Provider } from '../IProvingSystem-TKNofoo8.cjs';
3
- import { P as ProofData } from '../types-CaaigonG.cjs';
1
+ import { I as IProvingSystem, C as CircuitPaths } from '../IProvingSystem-BpI0rmve.cjs';
2
+ export { a as IziNoirConfig, P as Provider } from '../IProvingSystem-BpI0rmve.cjs';
3
+ import { P as ProofData } from '../types-CxkI04bP.cjs';
4
4
  import { CompiledCircuit, InputMap } from '@noir-lang/types';
5
5
  export { CompiledCircuit, InputMap } from '@noir-lang/types';
6
6
 
@@ -1,6 +1,6 @@
1
- import { d as IProvingSystem, e as CircuitPaths } from '../IProvingSystem-D9TnEig0.js';
2
- export { I as IziNoirConfig, P as Provider } from '../IProvingSystem-D9TnEig0.js';
3
- import { P as ProofData } from '../types-CaaigonG.js';
1
+ import { I as IProvingSystem, C as CircuitPaths } from '../IProvingSystem-D0X9Rp3W.js';
2
+ export { a as IziNoirConfig, P as Provider } from '../IProvingSystem-D0X9Rp3W.js';
3
+ import { P as ProofData } from '../types-CxkI04bP.js';
4
4
  import { CompiledCircuit, InputMap } from '@noir-lang/types';
5
5
  export { CompiledCircuit, InputMap } from '@noir-lang/types';
6
6
 
@@ -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,MAAc,QAAQ,SAAiB,MAAgB,KAAkC;AACvF,WAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,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A,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):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AAY;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 };