@izi-noir/sdk 0.1.0

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 (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +458 -0
  3. package/dist/IProvingSystem-D9TnEig0.d.ts +140 -0
  4. package/dist/IProvingSystem-TKNofoo8.d.cts +140 -0
  5. package/dist/index.cjs +2793 -0
  6. package/dist/index.cjs.map +1 -0
  7. package/dist/index.d.cts +1196 -0
  8. package/dist/index.d.ts +1196 -0
  9. package/dist/index.js +2730 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/providers/arkworks.cjs +824 -0
  12. package/dist/providers/arkworks.cjs.map +1 -0
  13. package/dist/providers/arkworks.d.cts +121 -0
  14. package/dist/providers/arkworks.d.ts +121 -0
  15. package/dist/providers/arkworks.js +791 -0
  16. package/dist/providers/arkworks.js.map +1 -0
  17. package/dist/providers/barretenberg.cjs +822 -0
  18. package/dist/providers/barretenberg.cjs.map +1 -0
  19. package/dist/providers/barretenberg.d.cts +18 -0
  20. package/dist/providers/barretenberg.d.ts +18 -0
  21. package/dist/providers/barretenberg.js +790 -0
  22. package/dist/providers/barretenberg.js.map +1 -0
  23. package/dist/providers/solana.cjs +262 -0
  24. package/dist/providers/solana.cjs.map +1 -0
  25. package/dist/providers/solana.d.cts +223 -0
  26. package/dist/providers/solana.d.ts +223 -0
  27. package/dist/providers/solana.js +222 -0
  28. package/dist/providers/solana.js.map +1 -0
  29. package/dist/providers/sunspot.cjs +475 -0
  30. package/dist/providers/sunspot.cjs.map +1 -0
  31. package/dist/providers/sunspot.d.cts +210 -0
  32. package/dist/providers/sunspot.d.ts +210 -0
  33. package/dist/providers/sunspot.js +443 -0
  34. package/dist/providers/sunspot.js.map +1 -0
  35. package/dist/types-CaaigonG.d.cts +93 -0
  36. package/dist/types-CaaigonG.d.ts +93 -0
  37. package/dist/wasm/nodejs/arkworks_groth16_wasm.js +448 -0
  38. package/dist/wasm/nodejs/arkworks_groth16_wasm_bg.wasm +0 -0
  39. package/dist/wasm/web/arkworks_groth16_wasm.js +536 -0
  40. package/dist/wasm/web/arkworks_groth16_wasm_bg.wasm +0 -0
  41. package/dist/wasmInit-KV6DTj4J.d.ts +282 -0
  42. package/dist/wasmInit-iEYiiB8M.d.cts +282 -0
  43. package/package.json +87 -0
@@ -0,0 +1,210 @@
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';
4
+ import { CompiledCircuit, InputMap } from '@noir-lang/types';
5
+ export { CompiledCircuit, InputMap } from '@noir-lang/types';
6
+
7
+ /**
8
+ * Configuration for Sunspot CLI execution
9
+ */
10
+ interface SunspotConfig {
11
+ /** Path to nargo binary (default: 'nargo') */
12
+ nargoBinaryPath: string;
13
+ /** Path to sunspot binary (default: 'sunspot') */
14
+ sunspotBinaryPath: string;
15
+ /** Keep temp artifacts for debugging (default: false) */
16
+ keepArtifacts: boolean;
17
+ /** Timeout for CLI commands in ms (default: 120000) */
18
+ timeoutMs: number;
19
+ }
20
+ /**
21
+ * Paths to all Sunspot artifacts in the temp directory
22
+ */
23
+ interface SunspotCircuitPaths {
24
+ /** Base temp directory */
25
+ workDir: string;
26
+ /** Noir project directory with Nargo.toml */
27
+ noirProjectDir: string;
28
+ /** Path to compiled circuit.json (ACIR) */
29
+ circuitJsonPath: string;
30
+ /** Path to witness.gz */
31
+ witnessPath: string;
32
+ /** Path to circuit.ccs */
33
+ ccsPath: string;
34
+ /** Path to proving key */
35
+ pkPath: string;
36
+ /** Path to verification key */
37
+ vkPath: string;
38
+ /** Path to proof file */
39
+ proofPath: string;
40
+ /** Path to public witness file */
41
+ publicWitnessPath: string;
42
+ /** Path to Prover.toml */
43
+ proverTomlPath: string;
44
+ }
45
+ /**
46
+ * Extended CompiledCircuit for Sunspot backend
47
+ */
48
+ interface SunspotCompiledCircuit extends CompiledCircuit {
49
+ /** Marker to identify Sunspot circuits */
50
+ __sunspot: true;
51
+ /** Paths to all artifacts */
52
+ paths: SunspotCircuitPaths;
53
+ }
54
+ /**
55
+ * Type guard to check if a circuit is a Sunspot circuit
56
+ */
57
+ declare function isSunspotCircuit(circuit: CompiledCircuit): circuit is SunspotCompiledCircuit;
58
+ /**
59
+ * Error thrown when CLI command fails
60
+ */
61
+ declare class SunspotCliError extends Error {
62
+ readonly command: string;
63
+ readonly exitCode: number;
64
+ readonly stderr: string;
65
+ constructor(message: string, command: string, exitCode: number, stderr: string);
66
+ }
67
+
68
+ /**
69
+ * Configuration for Sunspot constructor
70
+ */
71
+ interface SunspotInitConfig extends Partial<SunspotConfig> {
72
+ /** Pre-compiled circuit paths (if provided, compile() is disabled) */
73
+ precompiledPaths?: CircuitPaths;
74
+ }
75
+ /**
76
+ * Sunspot proving system using CLI tools.
77
+ * Node.js only (requires nargo and sunspot binaries).
78
+ * Produces Groth16 proofs (~324 bytes) for Solana on-chain verification.
79
+ *
80
+ * Can be used in two modes:
81
+ * 1. Full compilation: Call compile() with Noir code (requires nargo + sunspot CLI)
82
+ * 2. Pre-compiled: Provide circuitPaths in constructor, then only prove/verify
83
+ *
84
+ * @example Full compilation
85
+ * ```typescript
86
+ * const sunspot = new Sunspot();
87
+ * const circuit = await sunspot.compile(noirCode);
88
+ * const proof = await sunspot.generateProof(circuit, inputs);
89
+ * ```
90
+ *
91
+ * @example Pre-compiled (via IziNoir)
92
+ * ```typescript
93
+ * const izi = await IziNoir.init({
94
+ * provider: Provider.Sunspot,
95
+ * circuitPaths: { pkPath: '...', vkPath: '...', circuitPath: '...' }
96
+ * });
97
+ * ```
98
+ */
99
+ declare class Sunspot implements IProvingSystem {
100
+ private readonly config;
101
+ private readonly executor;
102
+ private readonly precompiledPaths?;
103
+ private precompiledCircuit?;
104
+ /**
105
+ * Create a new Sunspot proving system
106
+ * @param config - Configuration options or pre-compiled circuit paths
107
+ */
108
+ constructor(config?: SunspotInitConfig | CircuitPaths);
109
+ /**
110
+ * Create a SunspotCompiledCircuit from pre-compiled paths
111
+ */
112
+ private createPrecompiledCircuit;
113
+ /**
114
+ * Create a temporary Noir project for compilation
115
+ */
116
+ private createNoirProject;
117
+ compile(noirCode: string): Promise<CompiledCircuit>;
118
+ generateProof(circuit: CompiledCircuit, inputs: InputMap): Promise<ProofData>;
119
+ verifyProof(circuit: CompiledCircuit, proof: Uint8Array, publicInputs: string[]): Promise<boolean>;
120
+ /**
121
+ * Resolve which circuit to use - precompiled or provided
122
+ */
123
+ private resolveCircuit;
124
+ private generateProverToml;
125
+ private formatTomlValue;
126
+ private parsePublicWitness;
127
+ private bytesEqual;
128
+ }
129
+
130
+ /**
131
+ * Sunspot entry point for Node.js.
132
+ *
133
+ * This module provides Sunspot support which is NOT available in the main
134
+ * `@izi-noir/sdk` entry point due to Node.js-only dependencies.
135
+ *
136
+ * Note: Sunspot requires nargo and sunspot CLI tools to be installed.
137
+ *
138
+ * @example Using Sunspot directly
139
+ * ```typescript
140
+ * import { Sunspot } from '@izi-noir/sdk/sunspot';
141
+ *
142
+ * // Full compilation mode
143
+ * const sunspot = new Sunspot();
144
+ * const circuit = await sunspot.compile(noirCode);
145
+ * const proof = await sunspot.generateProof(circuit, inputs);
146
+ * const verified = await sunspot.verifyProof(circuit, proof.proof, proof.publicInputs);
147
+ *
148
+ * // Pre-compiled mode
149
+ * const sunspot = new Sunspot({
150
+ * pkPath: './circuit/circuit.pk',
151
+ * vkPath: './circuit/circuit.vk',
152
+ * circuitPath: './circuit/circuit.json',
153
+ * });
154
+ * ```
155
+ *
156
+ * @example Using initSunspotIziNoir helper
157
+ * ```typescript
158
+ * import { initSunspotIziNoir } from '@izi-noir/sdk/sunspot';
159
+ *
160
+ * const izi = await initSunspotIziNoir({
161
+ * pkPath: './circuit/circuit.pk',
162
+ * vkPath: './circuit/circuit.vk',
163
+ * circuitPath: './circuit/circuit.json',
164
+ * });
165
+ *
166
+ * // Use like regular IziNoir (but only prove/verify, not compile)
167
+ * const proof = await izi.prove(inputs);
168
+ * const verified = await izi.verify(proof.proof, proof.publicInputs);
169
+ * ```
170
+ *
171
+ * @module @izi-noir/sdk/sunspot
172
+ */
173
+
174
+ /**
175
+ * IziNoir-like wrapper for Sunspot.
176
+ * Provides a similar API to IziNoir but backed by the Sunspot proving system.
177
+ */
178
+ declare class IziNoirSunspot {
179
+ private provingSystem;
180
+ private compiledCircuit;
181
+ private constructor();
182
+ /**
183
+ * Initialize IziNoirSunspot with pre-compiled circuit paths.
184
+ * Note: Sunspot requires pre-compiled circuits for prove/verify operations.
185
+ *
186
+ * @param circuitPaths - Paths to the pre-compiled circuit files
187
+ */
188
+ static init(circuitPaths: CircuitPaths): Promise<IziNoirSunspot>;
189
+ /**
190
+ * Initialize IziNoirSunspot for full compilation mode.
191
+ * Requires nargo and sunspot CLI tools to be installed.
192
+ */
193
+ static initForCompilation(): Promise<IziNoirSunspot>;
194
+ getProvingSystem(): IProvingSystem;
195
+ getCompiledCircuit(): CompiledCircuit | null;
196
+ compile(noirCode: string): Promise<CompiledCircuit>;
197
+ prove(inputs: InputMap, circuit?: CompiledCircuit): Promise<ProofData>;
198
+ verify(proof: Uint8Array, publicInputs: string[], circuit?: CompiledCircuit): Promise<boolean>;
199
+ createProof(noirCode: string, inputs: InputMap): Promise<{
200
+ proof: ProofData;
201
+ verified: boolean;
202
+ }>;
203
+ }
204
+ /**
205
+ * Helper function to create an IziNoirSunspot instance with pre-compiled circuit paths.
206
+ * @deprecated Use `IziNoirSunspot.init(circuitPaths)` instead.
207
+ */
208
+ declare function initSunspotIziNoir(circuitPaths: CircuitPaths): Promise<IziNoirSunspot>;
209
+
210
+ export { CircuitPaths, IProvingSystem, IziNoirSunspot, ProofData, Sunspot, type SunspotCircuitPaths, SunspotCliError, type SunspotCompiledCircuit, type SunspotConfig, type SunspotInitConfig, initSunspotIziNoir, isSunspotCircuit };
@@ -0,0 +1,210 @@
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';
4
+ import { CompiledCircuit, InputMap } from '@noir-lang/types';
5
+ export { CompiledCircuit, InputMap } from '@noir-lang/types';
6
+
7
+ /**
8
+ * Configuration for Sunspot CLI execution
9
+ */
10
+ interface SunspotConfig {
11
+ /** Path to nargo binary (default: 'nargo') */
12
+ nargoBinaryPath: string;
13
+ /** Path to sunspot binary (default: 'sunspot') */
14
+ sunspotBinaryPath: string;
15
+ /** Keep temp artifacts for debugging (default: false) */
16
+ keepArtifacts: boolean;
17
+ /** Timeout for CLI commands in ms (default: 120000) */
18
+ timeoutMs: number;
19
+ }
20
+ /**
21
+ * Paths to all Sunspot artifacts in the temp directory
22
+ */
23
+ interface SunspotCircuitPaths {
24
+ /** Base temp directory */
25
+ workDir: string;
26
+ /** Noir project directory with Nargo.toml */
27
+ noirProjectDir: string;
28
+ /** Path to compiled circuit.json (ACIR) */
29
+ circuitJsonPath: string;
30
+ /** Path to witness.gz */
31
+ witnessPath: string;
32
+ /** Path to circuit.ccs */
33
+ ccsPath: string;
34
+ /** Path to proving key */
35
+ pkPath: string;
36
+ /** Path to verification key */
37
+ vkPath: string;
38
+ /** Path to proof file */
39
+ proofPath: string;
40
+ /** Path to public witness file */
41
+ publicWitnessPath: string;
42
+ /** Path to Prover.toml */
43
+ proverTomlPath: string;
44
+ }
45
+ /**
46
+ * Extended CompiledCircuit for Sunspot backend
47
+ */
48
+ interface SunspotCompiledCircuit extends CompiledCircuit {
49
+ /** Marker to identify Sunspot circuits */
50
+ __sunspot: true;
51
+ /** Paths to all artifacts */
52
+ paths: SunspotCircuitPaths;
53
+ }
54
+ /**
55
+ * Type guard to check if a circuit is a Sunspot circuit
56
+ */
57
+ declare function isSunspotCircuit(circuit: CompiledCircuit): circuit is SunspotCompiledCircuit;
58
+ /**
59
+ * Error thrown when CLI command fails
60
+ */
61
+ declare class SunspotCliError extends Error {
62
+ readonly command: string;
63
+ readonly exitCode: number;
64
+ readonly stderr: string;
65
+ constructor(message: string, command: string, exitCode: number, stderr: string);
66
+ }
67
+
68
+ /**
69
+ * Configuration for Sunspot constructor
70
+ */
71
+ interface SunspotInitConfig extends Partial<SunspotConfig> {
72
+ /** Pre-compiled circuit paths (if provided, compile() is disabled) */
73
+ precompiledPaths?: CircuitPaths;
74
+ }
75
+ /**
76
+ * Sunspot proving system using CLI tools.
77
+ * Node.js only (requires nargo and sunspot binaries).
78
+ * Produces Groth16 proofs (~324 bytes) for Solana on-chain verification.
79
+ *
80
+ * Can be used in two modes:
81
+ * 1. Full compilation: Call compile() with Noir code (requires nargo + sunspot CLI)
82
+ * 2. Pre-compiled: Provide circuitPaths in constructor, then only prove/verify
83
+ *
84
+ * @example Full compilation
85
+ * ```typescript
86
+ * const sunspot = new Sunspot();
87
+ * const circuit = await sunspot.compile(noirCode);
88
+ * const proof = await sunspot.generateProof(circuit, inputs);
89
+ * ```
90
+ *
91
+ * @example Pre-compiled (via IziNoir)
92
+ * ```typescript
93
+ * const izi = await IziNoir.init({
94
+ * provider: Provider.Sunspot,
95
+ * circuitPaths: { pkPath: '...', vkPath: '...', circuitPath: '...' }
96
+ * });
97
+ * ```
98
+ */
99
+ declare class Sunspot implements IProvingSystem {
100
+ private readonly config;
101
+ private readonly executor;
102
+ private readonly precompiledPaths?;
103
+ private precompiledCircuit?;
104
+ /**
105
+ * Create a new Sunspot proving system
106
+ * @param config - Configuration options or pre-compiled circuit paths
107
+ */
108
+ constructor(config?: SunspotInitConfig | CircuitPaths);
109
+ /**
110
+ * Create a SunspotCompiledCircuit from pre-compiled paths
111
+ */
112
+ private createPrecompiledCircuit;
113
+ /**
114
+ * Create a temporary Noir project for compilation
115
+ */
116
+ private createNoirProject;
117
+ compile(noirCode: string): Promise<CompiledCircuit>;
118
+ generateProof(circuit: CompiledCircuit, inputs: InputMap): Promise<ProofData>;
119
+ verifyProof(circuit: CompiledCircuit, proof: Uint8Array, publicInputs: string[]): Promise<boolean>;
120
+ /**
121
+ * Resolve which circuit to use - precompiled or provided
122
+ */
123
+ private resolveCircuit;
124
+ private generateProverToml;
125
+ private formatTomlValue;
126
+ private parsePublicWitness;
127
+ private bytesEqual;
128
+ }
129
+
130
+ /**
131
+ * Sunspot entry point for Node.js.
132
+ *
133
+ * This module provides Sunspot support which is NOT available in the main
134
+ * `@izi-noir/sdk` entry point due to Node.js-only dependencies.
135
+ *
136
+ * Note: Sunspot requires nargo and sunspot CLI tools to be installed.
137
+ *
138
+ * @example Using Sunspot directly
139
+ * ```typescript
140
+ * import { Sunspot } from '@izi-noir/sdk/sunspot';
141
+ *
142
+ * // Full compilation mode
143
+ * const sunspot = new Sunspot();
144
+ * const circuit = await sunspot.compile(noirCode);
145
+ * const proof = await sunspot.generateProof(circuit, inputs);
146
+ * const verified = await sunspot.verifyProof(circuit, proof.proof, proof.publicInputs);
147
+ *
148
+ * // Pre-compiled mode
149
+ * const sunspot = new Sunspot({
150
+ * pkPath: './circuit/circuit.pk',
151
+ * vkPath: './circuit/circuit.vk',
152
+ * circuitPath: './circuit/circuit.json',
153
+ * });
154
+ * ```
155
+ *
156
+ * @example Using initSunspotIziNoir helper
157
+ * ```typescript
158
+ * import { initSunspotIziNoir } from '@izi-noir/sdk/sunspot';
159
+ *
160
+ * const izi = await initSunspotIziNoir({
161
+ * pkPath: './circuit/circuit.pk',
162
+ * vkPath: './circuit/circuit.vk',
163
+ * circuitPath: './circuit/circuit.json',
164
+ * });
165
+ *
166
+ * // Use like regular IziNoir (but only prove/verify, not compile)
167
+ * const proof = await izi.prove(inputs);
168
+ * const verified = await izi.verify(proof.proof, proof.publicInputs);
169
+ * ```
170
+ *
171
+ * @module @izi-noir/sdk/sunspot
172
+ */
173
+
174
+ /**
175
+ * IziNoir-like wrapper for Sunspot.
176
+ * Provides a similar API to IziNoir but backed by the Sunspot proving system.
177
+ */
178
+ declare class IziNoirSunspot {
179
+ private provingSystem;
180
+ private compiledCircuit;
181
+ private constructor();
182
+ /**
183
+ * Initialize IziNoirSunspot with pre-compiled circuit paths.
184
+ * Note: Sunspot requires pre-compiled circuits for prove/verify operations.
185
+ *
186
+ * @param circuitPaths - Paths to the pre-compiled circuit files
187
+ */
188
+ static init(circuitPaths: CircuitPaths): Promise<IziNoirSunspot>;
189
+ /**
190
+ * Initialize IziNoirSunspot for full compilation mode.
191
+ * Requires nargo and sunspot CLI tools to be installed.
192
+ */
193
+ static initForCompilation(): Promise<IziNoirSunspot>;
194
+ getProvingSystem(): IProvingSystem;
195
+ getCompiledCircuit(): CompiledCircuit | null;
196
+ compile(noirCode: string): Promise<CompiledCircuit>;
197
+ prove(inputs: InputMap, circuit?: CompiledCircuit): Promise<ProofData>;
198
+ verify(proof: Uint8Array, publicInputs: string[], circuit?: CompiledCircuit): Promise<boolean>;
199
+ createProof(noirCode: string, inputs: InputMap): Promise<{
200
+ proof: ProofData;
201
+ verified: boolean;
202
+ }>;
203
+ }
204
+ /**
205
+ * Helper function to create an IziNoirSunspot instance with pre-compiled circuit paths.
206
+ * @deprecated Use `IziNoirSunspot.init(circuitPaths)` instead.
207
+ */
208
+ declare function initSunspotIziNoir(circuitPaths: CircuitPaths): Promise<IziNoirSunspot>;
209
+
210
+ export { CircuitPaths, IProvingSystem, IziNoirSunspot, ProofData, Sunspot, type SunspotCircuitPaths, SunspotCliError, type SunspotCompiledCircuit, type SunspotConfig, type SunspotInitConfig, initSunspotIziNoir, isSunspotCircuit };