@izi-noir/sdk 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/{IProvingSystem-TKNofoo8.d.cts → IProvingSystem-BpI0rmve.d.cts} +32 -2
  2. package/dist/{IProvingSystem-D9TnEig0.d.ts → IProvingSystem-D0X9Rp3W.d.ts} +32 -2
  3. package/dist/index.cjs +29968 -1358
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.cts +47 -7
  6. package/dist/index.d.ts +47 -7
  7. package/dist/index.js +29948 -1317
  8. package/dist/index.js.map +1 -1
  9. package/dist/providers/arkworks.cjs +29061 -173
  10. package/dist/providers/arkworks.cjs.map +1 -1
  11. package/dist/providers/arkworks.d.cts +11 -5
  12. package/dist/providers/arkworks.d.ts +11 -5
  13. package/dist/providers/arkworks.js +29081 -167
  14. package/dist/providers/arkworks.js.map +1 -1
  15. package/dist/providers/barretenberg.cjs +29061 -173
  16. package/dist/providers/barretenberg.cjs.map +1 -1
  17. package/dist/providers/barretenberg.d.cts +4 -4
  18. package/dist/providers/barretenberg.d.ts +4 -4
  19. package/dist/providers/barretenberg.js +29081 -167
  20. package/dist/providers/barretenberg.js.map +1 -1
  21. package/dist/providers/solana.cjs +2 -20
  22. package/dist/providers/solana.cjs.map +1 -1
  23. package/dist/providers/solana.d.cts +1 -1
  24. package/dist/providers/solana.d.ts +1 -1
  25. package/dist/providers/solana.js +2 -20
  26. package/dist/providers/solana.js.map +1 -1
  27. package/dist/providers/sunspot.cjs.map +1 -1
  28. package/dist/providers/sunspot.d.cts +3 -3
  29. package/dist/providers/sunspot.d.ts +3 -3
  30. package/dist/providers/sunspot.js.map +1 -1
  31. package/dist/{types-CaaigonG.d.cts → types-CxkI04bP.d.cts} +14 -2
  32. package/dist/{types-CaaigonG.d.ts → types-CxkI04bP.d.ts} +14 -2
  33. package/dist/wasm/nodejs/arkworks_groth16_wasm.js +52 -0
  34. package/dist/wasm/nodejs/arkworks_groth16_wasm_bg.wasm +0 -0
  35. package/dist/wasm/web/arkworks_groth16_wasm.js +50 -0
  36. package/dist/wasm/web/arkworks_groth16_wasm_bg.wasm +0 -0
  37. package/dist/{wasmInit-iEYiiB8M.d.cts → wasmInit-D615cpte.d.cts} +147 -12
  38. package/dist/{wasmInit-KV6DTj4J.d.ts → wasmInit-oOZwkgo_.d.ts} +147 -12
  39. package/package.json +6 -2
@@ -1,5 +1,5 @@
1
- import { C as ChainId, a as CircuitMetadata, b as ChainMetadataFor, c as Chain, I as IziNoirConfig, d as IProvingSystem } from './IProvingSystem-D9TnEig0.js';
2
- import { P as ProofData, S as SolanaProofData, V as VerifyingKeyData } from './types-CaaigonG.js';
1
+ import { b as ChainId, c as CircuitMetadata, d as ChainMetadataFor, N as Network, e as Chain, a as IziNoirConfig, I as IProvingSystem } from './IProvingSystem-D0X9Rp3W.js';
2
+ import { P as ProofData, S as SolanaProofData, V as VerifyingKeyData, C as CompileResult } from './types-CxkI04bP.js';
3
3
  import { CompiledCircuit, InputMap } from '@noir-lang/types';
4
4
 
5
5
  /**
@@ -46,6 +46,70 @@ interface IChainFormatter<TChain extends ChainId = ChainId> {
46
46
  */
47
47
  type ChainProofDataFor<T extends ChainId> = T extends 'solana' ? SolanaProofData : ProofData;
48
48
 
49
+ /**
50
+ * Solana types for IZI-NOIR SDK.
51
+ */
52
+ /**
53
+ * Minimal wallet adapter interface compatible with @solana/wallet-adapter-react.
54
+ *
55
+ * This interface requires only the essential methods for deploying and verifying
56
+ * proofs on Solana, making it compatible with any wallet adapter implementation.
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * // Works with @solana/wallet-adapter-react
61
+ * const { publicKey, sendTransaction } = useWallet();
62
+ *
63
+ * await izi.deploy({ publicKey, sendTransaction });
64
+ * ```
65
+ */
66
+ interface WalletAdapter {
67
+ /**
68
+ * The wallet's public key.
69
+ */
70
+ publicKey: {
71
+ toBase58(): string;
72
+ toBytes(): Uint8Array;
73
+ } | null;
74
+ /**
75
+ * Send a transaction to the network.
76
+ * This signature is compatible with @solana/wallet-adapter-react's sendTransaction.
77
+ *
78
+ * @param transaction - The transaction to send (web3.js Transaction type)
79
+ * @param connection - The Solana connection
80
+ * @param options - Optional send options
81
+ * @returns The transaction signature
82
+ */
83
+ sendTransaction: SendTransactionFunction;
84
+ }
85
+ /**
86
+ * Function type for sending transactions.
87
+ * Compatible with @solana/wallet-adapter-react.
88
+ */
89
+ type SendTransactionFunction = (transaction: any, connection: any, options?: any) => Promise<string>;
90
+ /**
91
+ * Result of a deploy operation.
92
+ */
93
+ interface DeployResult {
94
+ /** The VK account address (base58) */
95
+ vkAccount: string;
96
+ /** Transaction signature */
97
+ signature: string;
98
+ /** Explorer URL for the transaction */
99
+ explorerUrl: string;
100
+ }
101
+ /**
102
+ * Result of an on-chain verification.
103
+ */
104
+ interface VerifyOnChainResult {
105
+ /** Whether the proof was verified successfully */
106
+ verified: boolean;
107
+ /** Transaction signature */
108
+ signature: string;
109
+ /** Explorer URL for the transaction */
110
+ explorerUrl: string;
111
+ }
112
+
49
113
  /**
50
114
  * Data needed to deploy a verifying key to Solana.
51
115
  * Use with SolanaTransactionBuilder or your own transaction logic.
@@ -88,12 +152,23 @@ declare class IziNoir {
88
152
  private readonly chain?;
89
153
  private _verifyingKey?;
90
154
  private _lastProof?;
155
+ private readonly _network;
156
+ private _vkAccount?;
91
157
  private constructor();
92
158
  /**
93
- * Get the verifying key from the last proof generation.
94
- * Only available after calling prove() with a chain configured.
159
+ * Get the verifying key.
160
+ * Available after calling compile() (for Arkworks/Sunspot providers with chain configured).
95
161
  */
96
162
  get vk(): VerifyingKeyData | undefined;
163
+ /**
164
+ * Get the deployed VK account address.
165
+ * Only available after calling deploy().
166
+ */
167
+ get vkAccount(): string | undefined;
168
+ /**
169
+ * Get the configured network.
170
+ */
171
+ get network(): Network;
97
172
  /**
98
173
  * Get the configured chain, if any.
99
174
  */
@@ -150,16 +225,30 @@ declare class IziNoir {
150
225
  getCompiledCircuit(): CompiledCircuit | null;
151
226
  /**
152
227
  * Compile Noir code into a circuit.
228
+ * Performs trusted setup (generates PK and VK) during compilation.
229
+ * After compile(), the verifying key is available via `this.vk`.
153
230
  *
154
231
  * @param noirCode - The Noir source code to compile
155
- * @returns The compiled circuit
232
+ * @returns CompileResult with circuit and verifying key
233
+ *
234
+ * @example
235
+ * ```typescript
236
+ * const { circuit, verifyingKey } = await izi.compile(noirCode);
237
+ * console.log('VK:', izi.vk); // Available immediately after compile
238
+ * ```
239
+ */
240
+ compile(noirCode: string): Promise<CompileResult>;
241
+ /**
242
+ * Extract verifying key from compiled circuit.
243
+ * Works for Arkworks circuits that have VK cached after setup.
156
244
  */
157
- compile(noirCode: string): Promise<CompiledCircuit>;
245
+ private extractVerifyingKey;
158
246
  /**
159
247
  * Generate a proof for the given inputs.
248
+ * Uses the cached proving key from compile() for fast proof generation.
160
249
  *
161
- * If a chain is configured, returns chain-formatted proof data and stores
162
- * the verifying key in `this.vk`. Otherwise, returns raw proof data.
250
+ * If a chain is configured, returns chain-formatted proof data.
251
+ * Otherwise, returns raw proof data.
163
252
  *
164
253
  * @param inputs - The inputs (both public and private) for the circuit
165
254
  * @param circuit - Optional circuit to use (defaults to last compiled circuit)
@@ -170,15 +259,13 @@ declare class IziNoir {
170
259
  * ```typescript
171
260
  * // With chain configured - returns SolanaProofData
172
261
  * const izi = await IziNoir.init({ provider: Provider.Arkworks, chain: Chain.Solana });
173
- * await izi.compile(noirCode);
262
+ * await izi.compile(noirCode); // VK available after compile
174
263
  * const proof = await izi.prove({ expected: '100', secret: '10' });
175
- * // proof is SolanaProofData, izi.vk is available
176
264
  *
177
265
  * // Offchain mode - returns ProofData
178
266
  * const iziOffchain = await IziNoir.init({ provider: Provider.Arkworks });
179
267
  * await iziOffchain.compile(noirCode);
180
268
  * const rawProof = await iziOffchain.prove({ expected: '100', secret: '10' });
181
- * // rawProof is ProofData, iziOffchain.vk is undefined
182
269
  * ```
183
270
  */
184
271
  prove(inputs: InputMap, circuit?: CompiledCircuit): Promise<ProofData | SolanaProofData>;
@@ -246,6 +333,54 @@ declare class IziNoir {
246
333
  programId?: string;
247
334
  computeUnits?: number;
248
335
  }): SolanaDeployData;
336
+ /**
337
+ * Deploy the verifying key to Solana.
338
+ *
339
+ * This method handles the full deployment flow:
340
+ * 1. Generates a keypair for the VK account
341
+ * 2. Builds the init transaction
342
+ * 3. Sends and confirms the transaction
343
+ * 4. Stores the VK account address on the instance
344
+ *
345
+ * @param wallet - Wallet adapter with publicKey and sendTransaction
346
+ * @returns Deploy result with VK account address and transaction signature
347
+ * @throws Error if not in Solana chain mode or prove() hasn't been called
348
+ *
349
+ * @example
350
+ * ```typescript
351
+ * const izi = await IziNoir.init({
352
+ * provider: Provider.Arkworks,
353
+ * chain: Chain.Solana,
354
+ * network: Network.Devnet
355
+ * });
356
+ *
357
+ * await izi.compile(noirCode);
358
+ * await izi.prove(inputs);
359
+ *
360
+ * // Deploy VK in one line
361
+ * const { vkAccount, signature } = await izi.deploy(wallet);
362
+ * console.log(`VK deployed at: ${vkAccount}`);
363
+ * ```
364
+ */
365
+ deploy(wallet: WalletAdapter): Promise<DeployResult>;
366
+ /**
367
+ * Verify the proof on-chain.
368
+ *
369
+ * @param wallet - Wallet adapter with publicKey and sendTransaction
370
+ * @param vkAccount - VK account address (optional if deploy() was called on this instance)
371
+ * @returns Verification result with transaction signature
372
+ * @throws Error if not in Solana chain mode or no VK account available
373
+ *
374
+ * @example
375
+ * ```typescript
376
+ * // After deploy()
377
+ * const { verified, signature } = await izi.verifyOnChain(wallet);
378
+ *
379
+ * // Or with explicit VK account
380
+ * const { verified } = await izi.verifyOnChain(wallet, 'VkAccountAddress...');
381
+ * ```
382
+ */
383
+ verifyOnChain(wallet: WalletAdapter, vkAccount?: string): Promise<VerifyOnChainResult>;
249
384
  }
250
385
 
251
386
  /**
@@ -279,4 +414,4 @@ declare function isWasmInitialized(): boolean;
279
414
  */
280
415
  declare function markWasmInitialized(): void;
281
416
 
282
- export { type ChainProofDataFor as C, type IChainFormatter as I, type SolanaDeployData as S, IziNoir as a, isWasmInitialized as b, initNoirWasm as i, markWasmInitialized as m };
417
+ export { type ChainProofDataFor as C, type DeployResult as D, type IChainFormatter as I, type SolanaDeployData as S, type VerifyOnChainResult as V, type WalletAdapter as W, IziNoir as a, isWasmInitialized as b, initNoirWasm as i, markWasmInitialized as m };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@izi-noir/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Write ZK circuits in JavaScript/TypeScript, generate Noir code and proofs automatically",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -29,7 +29,11 @@
29
29
  "import": "./dist/providers/solana.js"
30
30
  }
31
31
  },
32
- "files": ["dist", "README.md", "LICENSE"],
32
+ "files": [
33
+ "dist",
34
+ "README.md",
35
+ "LICENSE"
36
+ ],
33
37
  "scripts": {
34
38
  "build": "tsup",
35
39
  "dev": "tsup --watch",