@izi-noir/sdk 0.1.9 → 0.1.11

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.
@@ -30,6 +30,377 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
30
  ));
31
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
32
 
33
+ // src/infra/provingSystems/R1csBuilder.ts
34
+ var R1csBuilder;
35
+ var init_R1csBuilder = __esm({
36
+ "src/infra/provingSystems/R1csBuilder.ts"() {
37
+ "use strict";
38
+ R1csBuilder = class {
39
+ constructor(parsedCircuit) {
40
+ this.parsedCircuit = parsedCircuit;
41
+ }
42
+ constraints = [];
43
+ witnessMap = /* @__PURE__ */ new Map();
44
+ nextWitnessIdx = 1;
45
+ // w_0 = 1 is reserved
46
+ publicIndices = [];
47
+ privateIndices = [];
48
+ // BN254 scalar field modulus - 1 (for representing -1)
49
+ // Fr modulus = 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001
50
+ // -1 mod Fr = Fr - 1
51
+ NEG_ONE = "0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000000";
52
+ /**
53
+ * Build R1CS definition from the parsed circuit
54
+ */
55
+ build() {
56
+ this.registerInputs();
57
+ for (const stmt of this.parsedCircuit.statements) {
58
+ this.processStatement(stmt);
59
+ }
60
+ return {
61
+ num_witnesses: this.nextWitnessIdx,
62
+ public_inputs: this.publicIndices,
63
+ private_inputs: this.privateIndices,
64
+ constraints: this.constraints
65
+ };
66
+ }
67
+ /**
68
+ * Get the witness index for an input parameter name
69
+ */
70
+ getWitnessIndex(name) {
71
+ return this.witnessMap.get(name);
72
+ }
73
+ /**
74
+ * Register all circuit inputs as witnesses
75
+ * Public inputs come first, then private inputs
76
+ */
77
+ registerInputs() {
78
+ for (const param of this.parsedCircuit.publicParams) {
79
+ const idx = this.nextWitnessIdx++;
80
+ this.witnessMap.set(param.name, idx);
81
+ this.publicIndices.push(idx);
82
+ }
83
+ for (const param of this.parsedCircuit.privateParams) {
84
+ const idx = this.nextWitnessIdx++;
85
+ this.witnessMap.set(param.name, idx);
86
+ this.privateIndices.push(idx);
87
+ }
88
+ }
89
+ /**
90
+ * Process a single statement and generate constraints
91
+ */
92
+ processStatement(stmt) {
93
+ switch (stmt.kind) {
94
+ case "assert":
95
+ this.processAssert(stmt.condition);
96
+ break;
97
+ case "variable_declaration":
98
+ this.processVariableDecl(stmt.name, stmt.initializer);
99
+ break;
100
+ case "assignment":
101
+ this.processAssignment(stmt.target, stmt.value);
102
+ break;
103
+ case "if_statement":
104
+ for (const s of stmt.consequent) {
105
+ this.processStatement(s);
106
+ }
107
+ if (stmt.alternate) {
108
+ for (const s of stmt.alternate) {
109
+ this.processStatement(s);
110
+ }
111
+ }
112
+ break;
113
+ case "for_statement":
114
+ throw new Error(
115
+ "For loops are not yet supported in R1CS generation. Use the Barretenberg backend for complex circuits."
116
+ );
117
+ }
118
+ }
119
+ /**
120
+ * Process an assert statement
121
+ * The condition must evaluate to true for a valid proof
122
+ */
123
+ processAssert(condition) {
124
+ if (condition.kind === "binary") {
125
+ this.processBinaryAssert(condition);
126
+ } else if (condition.kind === "identifier") {
127
+ const idx = this.getOrCreateWitness(condition);
128
+ this.constraints.push({
129
+ a: [["0x1", idx]],
130
+ b: [["0x1", 0]],
131
+ // * 1
132
+ c: [["0x1", 0]]
133
+ // = 1 (w_0)
134
+ });
135
+ } else {
136
+ throw new Error(`Unsupported assert condition kind: ${condition.kind}`);
137
+ }
138
+ }
139
+ /**
140
+ * Process a binary expression in an assert
141
+ */
142
+ processBinaryAssert(expr) {
143
+ const { left, operator, right } = expr;
144
+ switch (operator) {
145
+ case "==":
146
+ this.processEquality(left, right);
147
+ break;
148
+ case "!=":
149
+ throw new Error(
150
+ "Inequality (!=) is not yet supported in R1CS. Use equality (==) instead."
151
+ );
152
+ case "+":
153
+ case "-":
154
+ case "*":
155
+ case "/":
156
+ case "%":
157
+ throw new Error(
158
+ `Arithmetic operator ${operator} must be part of an equality assertion. Use: assert(a ${operator} b == c)`
159
+ );
160
+ case "<":
161
+ case ">":
162
+ case "<=":
163
+ case ">=":
164
+ throw new Error(
165
+ `Comparison operators (${operator}) require range proofs which are not yet supported. Use the Barretenberg backend for comparison operations.`
166
+ );
167
+ case "&":
168
+ case "|":
169
+ throw new Error(
170
+ `Logical operator ${operator} is not yet supported in R1CS.`
171
+ );
172
+ default:
173
+ throw new Error(`Unsupported operator in assert: ${operator}`);
174
+ }
175
+ }
176
+ /**
177
+ * Process an equality assertion: assert(left == right)
178
+ */
179
+ processEquality(left, right) {
180
+ if (left.kind === "binary" && left.operator === "*") {
181
+ this.processMultiplicationEquality(left.left, left.right, right);
182
+ return;
183
+ }
184
+ if (right.kind === "binary" && right.operator === "*") {
185
+ this.processMultiplicationEquality(right.left, right.right, left);
186
+ return;
187
+ }
188
+ if (left.kind === "binary" && left.operator === "+") {
189
+ this.processAdditionEquality(left.left, left.right, right);
190
+ return;
191
+ }
192
+ if (right.kind === "binary" && right.operator === "+") {
193
+ this.processAdditionEquality(right.left, right.right, left);
194
+ return;
195
+ }
196
+ if (left.kind === "binary" && left.operator === "-") {
197
+ this.processSubtractionEquality(left.left, left.right, right);
198
+ return;
199
+ }
200
+ if (right.kind === "binary" && right.operator === "-") {
201
+ this.processSubtractionEquality(right.left, right.right, left);
202
+ return;
203
+ }
204
+ const leftIdx = this.getOrCreateWitness(left);
205
+ const rightIdx = this.getOrCreateWitness(right);
206
+ this.constraints.push({
207
+ a: [
208
+ ["0x1", leftIdx],
209
+ [this.NEG_ONE, rightIdx]
210
+ ],
211
+ // a - b
212
+ b: [["0x1", 0]],
213
+ // * 1 (w_0 = 1)
214
+ c: []
215
+ // = 0
216
+ });
217
+ }
218
+ /**
219
+ * Process multiplication equality: assert(a * b == c)
220
+ * R1CS: a * b = c
221
+ */
222
+ processMultiplicationEquality(left, right, result) {
223
+ const leftIdx = this.getOrCreateWitness(left);
224
+ const rightIdx = this.getOrCreateWitness(right);
225
+ const resultIdx = this.getOrCreateWitness(result);
226
+ this.constraints.push({
227
+ a: [["0x1", leftIdx]],
228
+ b: [["0x1", rightIdx]],
229
+ c: [["0x1", resultIdx]]
230
+ });
231
+ }
232
+ /**
233
+ * Process addition equality: assert(a + b == c)
234
+ * R1CS: (a + b - c) * 1 = 0
235
+ * Which is: (a + b) * 1 = c
236
+ */
237
+ processAdditionEquality(left, right, result) {
238
+ const leftIdx = this.getOrCreateWitness(left);
239
+ const rightIdx = this.getOrCreateWitness(right);
240
+ const resultIdx = this.getOrCreateWitness(result);
241
+ this.constraints.push({
242
+ a: [
243
+ ["0x1", leftIdx],
244
+ ["0x1", rightIdx]
245
+ ],
246
+ // a + b
247
+ b: [["0x1", 0]],
248
+ // * 1
249
+ c: [["0x1", resultIdx]]
250
+ // = c
251
+ });
252
+ }
253
+ /**
254
+ * Process subtraction equality: assert(a - b == c)
255
+ * R1CS: (a - b) * 1 = c
256
+ */
257
+ processSubtractionEquality(left, right, result) {
258
+ const leftIdx = this.getOrCreateWitness(left);
259
+ const rightIdx = this.getOrCreateWitness(right);
260
+ const resultIdx = this.getOrCreateWitness(result);
261
+ this.constraints.push({
262
+ a: [
263
+ ["0x1", leftIdx],
264
+ [this.NEG_ONE, rightIdx]
265
+ ],
266
+ // a - b
267
+ b: [["0x1", 0]],
268
+ // * 1
269
+ c: [["0x1", resultIdx]]
270
+ // = c
271
+ });
272
+ }
273
+ /**
274
+ * Process a variable declaration: let x = expr
275
+ * Creates a new witness for x and adds constraint if needed
276
+ */
277
+ processVariableDecl(name, initializer) {
278
+ const varIdx = this.nextWitnessIdx++;
279
+ this.witnessMap.set(name, varIdx);
280
+ if (initializer.kind === "identifier") {
281
+ const initIdx = this.getOrCreateWitness(initializer);
282
+ this.constraints.push({
283
+ a: [
284
+ ["0x1", varIdx],
285
+ [this.NEG_ONE, initIdx]
286
+ ],
287
+ b: [["0x1", 0]],
288
+ c: []
289
+ });
290
+ } else if (initializer.kind === "literal") {
291
+ } else if (initializer.kind === "binary") {
292
+ this.processVariableInitBinary(varIdx, initializer);
293
+ } else {
294
+ throw new Error(
295
+ `Unsupported initializer kind for variable declaration: ${initializer.kind}`
296
+ );
297
+ }
298
+ }
299
+ /**
300
+ * Process a binary expression as variable initializer
301
+ */
302
+ processVariableInitBinary(varIdx, expr) {
303
+ const { left, operator, right } = expr;
304
+ const leftIdx = this.getOrCreateWitness(left);
305
+ const rightIdx = this.getOrCreateWitness(right);
306
+ switch (operator) {
307
+ case "*":
308
+ this.constraints.push({
309
+ a: [["0x1", leftIdx]],
310
+ b: [["0x1", rightIdx]],
311
+ c: [["0x1", varIdx]]
312
+ });
313
+ break;
314
+ case "+":
315
+ this.constraints.push({
316
+ a: [
317
+ ["0x1", leftIdx],
318
+ ["0x1", rightIdx]
319
+ ],
320
+ b: [["0x1", 0]],
321
+ c: [["0x1", varIdx]]
322
+ });
323
+ break;
324
+ case "-":
325
+ this.constraints.push({
326
+ a: [
327
+ ["0x1", leftIdx],
328
+ [this.NEG_ONE, rightIdx]
329
+ ],
330
+ b: [["0x1", 0]],
331
+ c: [["0x1", varIdx]]
332
+ });
333
+ break;
334
+ default:
335
+ throw new Error(
336
+ `Unsupported operator in variable initializer: ${operator}`
337
+ );
338
+ }
339
+ }
340
+ /**
341
+ * Process an assignment: x = expr
342
+ * Updates the witness mapping
343
+ */
344
+ processAssignment(target, value) {
345
+ const existingIdx = this.witnessMap.get(target);
346
+ if (existingIdx === void 0) {
347
+ throw new Error(`Assignment to undeclared variable: ${target}`);
348
+ }
349
+ if (value.kind === "identifier") {
350
+ const valueIdx = this.getOrCreateWitness(value);
351
+ this.constraints.push({
352
+ a: [
353
+ ["0x1", existingIdx],
354
+ [this.NEG_ONE, valueIdx]
355
+ ],
356
+ b: [["0x1", 0]],
357
+ c: []
358
+ });
359
+ } else if (value.kind === "binary") {
360
+ this.processVariableInitBinary(existingIdx, value);
361
+ }
362
+ }
363
+ /**
364
+ * Get or create a witness index for an expression
365
+ */
366
+ getOrCreateWitness(expr) {
367
+ if (expr.kind === "identifier") {
368
+ const existing = this.witnessMap.get(expr.name);
369
+ if (existing !== void 0) {
370
+ return existing;
371
+ }
372
+ const idx = this.nextWitnessIdx++;
373
+ this.witnessMap.set(expr.name, idx);
374
+ return idx;
375
+ }
376
+ if (expr.kind === "literal") {
377
+ const idx = this.nextWitnessIdx++;
378
+ return idx;
379
+ }
380
+ if (expr.kind === "binary") {
381
+ const idx = this.nextWitnessIdx++;
382
+ this.processVariableInitBinary(idx, expr);
383
+ return idx;
384
+ }
385
+ if (expr.kind === "unary") {
386
+ const operandIdx = this.getOrCreateWitness(expr.operand);
387
+ if (expr.operator === "-") {
388
+ const idx = this.nextWitnessIdx++;
389
+ this.constraints.push({
390
+ a: [[this.NEG_ONE, operandIdx]],
391
+ b: [["0x1", 0]],
392
+ c: [["0x1", idx]]
393
+ });
394
+ return idx;
395
+ }
396
+ throw new Error(`Unsupported unary operator: ${expr.operator}`);
397
+ }
398
+ throw new Error(`Unsupported expression kind: ${expr.kind}`);
399
+ }
400
+ };
401
+ }
402
+ });
403
+
33
404
  // src/infra/provingSystems/ArkworksWasm.ts
34
405
  var ArkworksWasm_exports = {};
35
406
  __export(ArkworksWasm_exports, {
@@ -163,6 +534,7 @@ var init_ArkworksWasm = __esm({
163
534
  import_noir_wasm = require("@noir-lang/noir_wasm");
164
535
  import_noir_js = require("@noir-lang/noir_js");
165
536
  import_acvm_js = require("@noir-lang/acvm_js");
537
+ init_R1csBuilder();
166
538
  import_meta = {};
167
539
  wasmModule = null;
168
540
  wasmInitPromise = null;
@@ -177,8 +549,11 @@ var init_ArkworksWasm = __esm({
177
549
  }
178
550
  /**
179
551
  * Compile Noir code to a circuit with ACIR for Groth16 proving
552
+ *
553
+ * @param noirCode - The Noir source code to compile
554
+ * @param options - Optional compilation options including ParsedCircuit for dynamic R1CS
180
555
  */
181
- async compile(noirCode) {
556
+ async compile(noirCode, options) {
182
557
  const wasm = await initWasm();
183
558
  const { basePath, cleanup } = await createTempDir();
184
559
  const fm = (0, import_noir_wasm.createFileManager)(basePath);
@@ -203,36 +578,52 @@ authors = [""]
203
578
  throw new Error("Compilation failed: no bytecode generated");
204
579
  }
205
580
  const parameters = compiled.abi.parameters;
206
- const publicR1csIndices = [];
207
- const privateR1csIndices = [];
581
+ let r1cs;
208
582
  const witnessIndexMapping = /* @__PURE__ */ new Map();
209
- parameters.forEach((p, noirIndex) => {
210
- const r1csIndex = noirIndex + 1;
211
- witnessIndexMapping.set(noirIndex, r1csIndex);
212
- if (p.visibility === "public") {
213
- publicR1csIndices.push(r1csIndex);
214
- } else if (p.visibility === "private") {
215
- privateR1csIndices.push(r1csIndex);
216
- }
217
- });
218
- const r1cs = {
219
- num_witnesses: parameters.length + 1,
220
- // +1 for w_0
221
- public_inputs: publicR1csIndices,
222
- private_inputs: privateR1csIndices,
223
- constraints: []
224
- };
225
- if (privateR1csIndices.length === 1 && publicR1csIndices.length === 1) {
226
- const privateIdx = privateR1csIndices[0];
227
- const publicIdx = publicR1csIndices[0];
228
- r1cs.constraints.push({
229
- a: [["0x1", privateIdx]],
230
- // secret
231
- b: [["0x1", privateIdx]],
232
- // secret
233
- c: [["0x1", publicIdx]]
234
- // expected
583
+ if (options?.parsedCircuit) {
584
+ const builder = new R1csBuilder(options.parsedCircuit);
585
+ r1cs = builder.build();
586
+ parameters.forEach((p, noirIndex) => {
587
+ const r1csIndex = noirIndex + 1;
588
+ witnessIndexMapping.set(noirIndex, r1csIndex);
589
+ });
590
+ console.log("=== R1CS BUILDER DEBUG ===");
591
+ console.log("ParsedCircuit publicParams:", options.parsedCircuit.publicParams);
592
+ console.log("ParsedCircuit privateParams:", options.parsedCircuit.privateParams);
593
+ console.log("ParsedCircuit statements:", JSON.stringify(options.parsedCircuit.statements, null, 2));
594
+ console.log("Generated R1CS:", JSON.stringify(r1cs, null, 2));
595
+ console.log("==========================");
596
+ } else {
597
+ const publicR1csIndices = [];
598
+ const privateR1csIndices = [];
599
+ parameters.forEach((p, noirIndex) => {
600
+ const r1csIndex = noirIndex + 1;
601
+ witnessIndexMapping.set(noirIndex, r1csIndex);
602
+ if (p.visibility === "public") {
603
+ publicR1csIndices.push(r1csIndex);
604
+ } else if (p.visibility === "private") {
605
+ privateR1csIndices.push(r1csIndex);
606
+ }
235
607
  });
608
+ r1cs = {
609
+ num_witnesses: parameters.length + 1,
610
+ public_inputs: publicR1csIndices,
611
+ private_inputs: privateR1csIndices,
612
+ constraints: []
613
+ };
614
+ if (privateR1csIndices.length === 1 && publicR1csIndices.length === 1) {
615
+ const privateIdx = privateR1csIndices[0];
616
+ const publicIdx = publicR1csIndices[0];
617
+ r1cs.constraints.push({
618
+ a: [["0x1", privateIdx]],
619
+ b: [["0x1", privateIdx]],
620
+ c: [["0x1", publicIdx]]
621
+ });
622
+ }
623
+ console.log("=== R1CS HARDCODED DEBUG ===");
624
+ console.log("Using hardcoded R1CS pattern (no ParsedCircuit provided)");
625
+ console.log("R1CS:", JSON.stringify(r1cs, null, 2));
626
+ console.log("============================");
236
627
  }
237
628
  const r1csJson = JSON.stringify(r1cs);
238
629
  let provingKey;
@@ -249,7 +640,7 @@ authors = [""]
249
640
  }
250
641
  }
251
642
  const acirJson = JSON.stringify({
252
- functions: [{ current_witness_index: parameters.length, opcodes: [], private_parameters: privateR1csIndices, public_parameters: { witnesses: publicR1csIndices }, return_values: { witnesses: [] } }]
643
+ functions: [{ current_witness_index: parameters.length, opcodes: [], private_parameters: r1cs.private_inputs, public_parameters: { witnesses: r1cs.public_inputs }, return_values: { witnesses: [] } }]
253
644
  });
254
645
  const arkworksCircuit = {
255
646
  ...compiled,
@@ -297,6 +688,7 @@ authors = [""]
297
688
  circuit.verifyingKey = setupResult.verifying_key;
298
689
  circuit.verifyingKeyGnark = setupResult.verifying_key_gnark;
299
690
  }
691
+ const toHex = (arr) => Array.from(arr).map((b) => b.toString(16).padStart(2, "0")).join("");
300
692
  console.log("=== ARKWORKS PROVE DEBUG ===");
301
693
  console.log("Witness JSON:", witnessJson);
302
694
  console.log("R1CS JSON:", circuit.r1csJson);
@@ -305,7 +697,7 @@ authors = [""]
305
697
  console.log("Proof gnark base64 length:", proofResult.proof_gnark.length);
306
698
  const proofBytes = base64ToUint8Array(proofResult.proof_gnark);
307
699
  console.log("Proof bytes length:", proofBytes.length);
308
- console.log("Proof bytes hex:", Buffer.from(proofBytes).toString("hex"));
700
+ console.log("Proof bytes hex:", toHex(proofBytes));
309
701
  console.log("============================");
310
702
  return {
311
703
  proof: proofBytes,
@@ -396,7 +788,9 @@ var init_Barretenberg = __esm({
396
788
  import_noir_js2 = require("@noir-lang/noir_js");
397
789
  import_bb = require("@aztec/bb.js");
398
790
  Barretenberg = class {
399
- async compile(noirCode) {
791
+ // Note: options parameter is accepted but not used - Barretenberg uses Noir's ACIR directly
792
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
793
+ async compile(noirCode, _options) {
400
794
  const { basePath, cleanup } = await createTempDir2();
401
795
  const fm = (0, import_noir_wasm2.createFileManager)(basePath);
402
796
  const nargoToml = `[package]
@@ -1070,16 +1464,20 @@ var IziNoir = class _IziNoir {
1070
1464
  * After compile(), the verifying key is available via `this.vk`.
1071
1465
  *
1072
1466
  * @param noirCode - The Noir source code to compile
1467
+ * @param options - Optional compilation options including ParsedCircuit for dynamic R1CS
1073
1468
  * @returns CompileResult with circuit and verifying key
1074
1469
  *
1075
1470
  * @example
1076
1471
  * ```typescript
1472
+ * // Basic usage
1077
1473
  * const { circuit, verifyingKey } = await izi.compile(noirCode);
1078
- * console.log('VK:', izi.vk); // Available immediately after compile
1474
+ *
1475
+ * // With ParsedCircuit for dynamic R1CS generation
1476
+ * const { circuit } = await izi.compile(noirCode, { parsedCircuit });
1079
1477
  * ```
1080
1478
  */
1081
- async compile(noirCode) {
1082
- this.compiledCircuit = await this.provingSystem.compile(noirCode);
1479
+ async compile(noirCode, options) {
1480
+ this.compiledCircuit = await this.provingSystem.compile(noirCode, options);
1083
1481
  const vk = await this.extractVerifyingKey(this.compiledCircuit);
1084
1482
  if (vk) {
1085
1483
  this._verifyingKey = vk;
@@ -1294,14 +1692,15 @@ var IziNoir = class _IziNoir {
1294
1692
  const connection = new Connection(networkConfig.rpcUrl, "confirmed");
1295
1693
  const vkKeypair = Keypair.generate();
1296
1694
  const authority = wallet.publicKey;
1695
+ const toHex = (arr) => Array.from(arr).map((b) => b.toString(16).padStart(2, "0")).join("");
1297
1696
  console.log("=== DEPLOY VK DEBUG ===");
1298
1697
  console.log("VK nrPublicInputs:", proofData.verifyingKey.nrPublicInputs);
1299
1698
  console.log("VK bytes length:", proofData.verifyingKey.bytes.length);
1300
- console.log("VK bytes (first 64 - alpha_g1):", import_buffer.Buffer.from(proofData.verifyingKey.bytes.slice(0, 64)).toString("hex"));
1301
- console.log("VK bytes (64-192 - beta_g2):", import_buffer.Buffer.from(proofData.verifyingKey.bytes.slice(64, 192)).toString("hex"));
1302
- console.log("VK bytes (192-320 - gamma_g2):", import_buffer.Buffer.from(proofData.verifyingKey.bytes.slice(192, 320)).toString("hex"));
1303
- console.log("VK bytes (320-448 - delta_g2):", import_buffer.Buffer.from(proofData.verifyingKey.bytes.slice(320, 448)).toString("hex"));
1304
- console.log("VK bytes (448+ - k elements):", import_buffer.Buffer.from(proofData.verifyingKey.bytes.slice(448)).toString("hex"));
1699
+ console.log("VK bytes (first 64 - alpha_g1):", toHex(proofData.verifyingKey.bytes.slice(0, 64)));
1700
+ console.log("VK bytes (64-192 - beta_g2):", toHex(proofData.verifyingKey.bytes.slice(64, 192)));
1701
+ console.log("VK bytes (192-320 - gamma_g2):", toHex(proofData.verifyingKey.bytes.slice(192, 320)));
1702
+ console.log("VK bytes (320-448 - delta_g2):", toHex(proofData.verifyingKey.bytes.slice(320, 448)));
1703
+ console.log("VK bytes (448+ - k elements):", toHex(proofData.verifyingKey.bytes.slice(448)));
1305
1704
  console.log("=======================");
1306
1705
  const builder = new SolanaTransactionBuilder({
1307
1706
  programId: networkConfig.programId,
@@ -1393,16 +1792,17 @@ var IziNoir = class _IziNoir {
1393
1792
  `VK account ${vk} has invalid data (${accountInfo.data.length} bytes). Expected at least 8 bytes for a valid account.`
1394
1793
  );
1395
1794
  }
1795
+ const toHex = (arr) => Array.from(arr).map((b) => b.toString(16).padStart(2, "0")).join("");
1396
1796
  console.log("=== VERIFY ON-CHAIN DEBUG ===");
1397
1797
  console.log("VK Account:", vk);
1398
1798
  console.log("VK Account data length:", accountInfo.data.length, "bytes");
1399
1799
  console.log("Proof size:", proofData.proof.bytes.length, "bytes");
1400
- console.log("Proof (first 64 bytes - A point):", import_buffer.Buffer.from(proofData.proof.bytes.slice(0, 64)).toString("hex"));
1401
- console.log("Proof (bytes 64-192 - B point):", import_buffer.Buffer.from(proofData.proof.bytes.slice(64, 192)).toString("hex"));
1402
- console.log("Proof (bytes 192-256 - C point):", import_buffer.Buffer.from(proofData.proof.bytes.slice(192, 256)).toString("hex"));
1800
+ console.log("Proof (first 64 bytes - A point):", toHex(proofData.proof.bytes.slice(0, 64)));
1801
+ console.log("Proof (bytes 64-192 - B point):", toHex(proofData.proof.bytes.slice(64, 192)));
1802
+ console.log("Proof (bytes 192-256 - C point):", toHex(proofData.proof.bytes.slice(192, 256)));
1403
1803
  console.log("Public inputs count:", proofData.publicInputs.bytes.length);
1404
1804
  proofData.publicInputs.bytes.forEach((input, i) => {
1405
- console.log(` Public input[${i}]:`, import_buffer.Buffer.from(input).toString("hex"));
1805
+ console.log(` Public input[${i}]:`, toHex(input));
1406
1806
  });
1407
1807
  console.log("Public inputs hex:", proofData.publicInputs.hex);
1408
1808
  console.log("VK nrPublicInputs:", proofData.verifyingKey.nrPublicInputs);
@@ -1,9 +1,9 @@
1
- import { I as IProvingSystem } from '../IProvingSystem-BpI0rmve.cjs';
2
- export { C as CircuitPaths, a as IziNoirConfig, P as Provider } from '../IProvingSystem-BpI0rmve.cjs';
1
+ import { I as IProvingSystem, f as CompileOptions } from '../IProvingSystem-SfzgcbqH.cjs';
2
+ export { C as CircuitPaths, a as IziNoirConfig, P as Provider } from '../IProvingSystem-SfzgcbqH.cjs';
3
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
- export { a as IziNoir, i as initNoirWasm, b as isWasmInitialized } from '../wasmInit-D615cpte.cjs';
6
+ export { a as IziNoir, i as initNoirWasm, b as isWasmInitialized } from '../wasmInit-Wyynuk6r.cjs';
7
7
 
8
8
  /**
9
9
  * ArkworksWasm proving system.
@@ -108,8 +108,11 @@ declare class ArkworksWasm implements IProvingSystem {
108
108
  constructor(config?: ArkworksWasmConfig);
109
109
  /**
110
110
  * Compile Noir code to a circuit with ACIR for Groth16 proving
111
+ *
112
+ * @param noirCode - The Noir source code to compile
113
+ * @param options - Optional compilation options including ParsedCircuit for dynamic R1CS
111
114
  */
112
- compile(noirCode: string): Promise<CompiledCircuit>;
115
+ compile(noirCode: string, options?: CompileOptions): Promise<CompiledCircuit>;
113
116
  /**
114
117
  * Generate a Groth16 proof
115
118
  */
@@ -1,9 +1,9 @@
1
- import { I as IProvingSystem } from '../IProvingSystem-D0X9Rp3W.js';
2
- export { C as CircuitPaths, a as IziNoirConfig, P as Provider } from '../IProvingSystem-D0X9Rp3W.js';
1
+ import { I as IProvingSystem, f as CompileOptions } from '../IProvingSystem-BKgFRl27.js';
2
+ export { C as CircuitPaths, a as IziNoirConfig, P as Provider } from '../IProvingSystem-BKgFRl27.js';
3
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
- export { a as IziNoir, i as initNoirWasm, b as isWasmInitialized } from '../wasmInit-oOZwkgo_.js';
6
+ export { a as IziNoir, i as initNoirWasm, b as isWasmInitialized } from '../wasmInit-D3RyRKIC.js';
7
7
 
8
8
  /**
9
9
  * ArkworksWasm proving system.
@@ -108,8 +108,11 @@ declare class ArkworksWasm implements IProvingSystem {
108
108
  constructor(config?: ArkworksWasmConfig);
109
109
  /**
110
110
  * Compile Noir code to a circuit with ACIR for Groth16 proving
111
+ *
112
+ * @param noirCode - The Noir source code to compile
113
+ * @param options - Optional compilation options including ParsedCircuit for dynamic R1CS
111
114
  */
112
- compile(noirCode: string): Promise<CompiledCircuit>;
115
+ compile(noirCode: string, options?: CompileOptions): Promise<CompiledCircuit>;
113
116
  /**
114
117
  * Generate a Groth16 proof
115
118
  */