@aztec/noir-acvm_js 2.0.0-nightly.20250903 → 3.0.0-canary.a9708bd

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.
@@ -6,59 +6,6 @@
6
6
  * @param {LogLevel} level - The maximum level of logging to be emitted.
7
7
  */
8
8
  export function initLogLevel(filter: string): void;
9
- /**
10
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
11
- *
12
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
13
- * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
14
- * @returns {WitnessMap} A witness map containing the circuit's return values.
15
- */
16
- export function getReturnWitness(program: Uint8Array, witness_map: WitnessMap): WitnessMap;
17
- /**
18
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
19
- *
20
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
21
- * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
22
- * @returns {WitnessMap} A witness map containing the circuit's public parameters.
23
- */
24
- export function getPublicParametersWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
25
- /**
26
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
27
- *
28
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
29
- * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
30
- * @returns {WitnessMap} A witness map containing the circuit's public inputs.
31
- */
32
- export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
33
- /**
34
- * Performs a bitwise AND operation between `lhs` and `rhs`
35
- */
36
- export function and(lhs: string, rhs: string): string;
37
- /**
38
- * Performs a bitwise XOR operation between `lhs` and `rhs`
39
- */
40
- export function xor(lhs: string, rhs: string): string;
41
- /**
42
- * Sha256 compression function
43
- */
44
- export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
45
- /**
46
- * Calculates the Blake2s256 hash of the input bytes
47
- */
48
- export function blake2s256(inputs: Uint8Array): Uint8Array;
49
- /**
50
- * Verifies a ECDSA signature over the secp256k1 curve.
51
- */
52
- export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
53
- /**
54
- * Verifies a ECDSA signature over the secp256r1 curve.
55
- */
56
- export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
57
- /**
58
- * Returns the `BuildInfo` object containing information about how the installed package was built.
59
- * @returns {BuildInfo} - Information on how the installed package was built.
60
- */
61
- export function buildInfo(): BuildInfo;
62
9
  /**
63
10
  * Compresses a `WitnessMap` into the binary format outputted by Nargo.
64
11
  *
@@ -116,6 +63,82 @@ export function executeCircuitWithReturnWitness(program: Uint8Array, initial_wit
116
63
  * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
117
64
  */
118
65
  export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
66
+ /**
67
+ * Performs a bitwise AND operation between `lhs` and `rhs`
68
+ */
69
+ export function and(lhs: string, rhs: string): string;
70
+ /**
71
+ * Performs a bitwise XOR operation between `lhs` and `rhs`
72
+ */
73
+ export function xor(lhs: string, rhs: string): string;
74
+ /**
75
+ * Sha256 compression function
76
+ */
77
+ export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
78
+ /**
79
+ * Calculates the Blake2s256 hash of the input bytes
80
+ */
81
+ export function blake2s256(inputs: Uint8Array): Uint8Array;
82
+ /**
83
+ * Verifies a ECDSA signature over the secp256k1 curve.
84
+ */
85
+ export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
86
+ /**
87
+ * Verifies a ECDSA signature over the secp256r1 curve.
88
+ */
89
+ export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
90
+ /**
91
+ * Returns the `BuildInfo` object containing information about how the installed package was built.
92
+ * @returns {BuildInfo} - Information on how the installed package was built.
93
+ */
94
+ export function buildInfo(): BuildInfo;
95
+ /**
96
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
97
+ *
98
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
99
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
100
+ * @returns {WitnessMap} A witness map containing the circuit's return values.
101
+ */
102
+ export function getReturnWitness(program: Uint8Array, witness_map: WitnessMap): WitnessMap;
103
+ /**
104
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
105
+ *
106
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
107
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
108
+ * @returns {WitnessMap} A witness map containing the circuit's public parameters.
109
+ */
110
+ export function getPublicParametersWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
111
+ /**
112
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
113
+ *
114
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
115
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
116
+ * @returns {WitnessMap} A witness map containing the circuit's public inputs.
117
+ */
118
+ export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
119
+
120
+ export type StackItem = {
121
+ index: number;
122
+ witness: WitnessMap;
123
+ }
124
+
125
+ export type WitnessStack = Array<StackItem>;
126
+
127
+
128
+
129
+ /**
130
+ * @typedef {Object} BuildInfo - Information about how the installed package was built
131
+ * @property {string} gitHash - The hash of the git commit from which the package was built.
132
+ * @property {string} version - The version of the package at the built git commit.
133
+ * @property {boolean} dirty - Whether the package contained uncommitted changes when built.
134
+ */
135
+ export type BuildInfo = {
136
+ gitHash: string;
137
+ version: string;
138
+ dirty: string;
139
+ }
140
+
141
+
119
142
 
120
143
  export type RawAssertionPayload = {
121
144
  selector: string;
@@ -146,29 +169,6 @@ export type SolvedAndReturnWitness = {
146
169
 
147
170
 
148
171
 
149
- export type StackItem = {
150
- index: number;
151
- witness: WitnessMap;
152
- }
153
-
154
- export type WitnessStack = Array<StackItem>;
155
-
156
-
157
-
158
- /**
159
- * @typedef {Object} BuildInfo - Information about how the installed package was built
160
- * @property {string} gitHash - The hash of the git commit from which the package was built.
161
- * @property {string} version - The version of the package at the built git commit.
162
- * @property {boolean} dirty - Whether the package contained uncommitted changes when built.
163
- */
164
- export type BuildInfo = {
165
- gitHash: string;
166
- version: string;
167
- dirty: string;
168
- }
169
-
170
-
171
-
172
172
  export type ForeignCallInput = string[]
173
173
  export type ForeignCallOutput = string | string[]
174
174
 
package/nodejs/acvm_js.js CHANGED
@@ -221,6 +221,26 @@ module.exports.initLogLevel = function(filter) {
221
221
  }
222
222
  };
223
223
 
224
+ function getArrayU8FromWasm0(ptr, len) {
225
+ ptr = ptr >>> 0;
226
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
227
+ }
228
+ /**
229
+ * Compresses a `WitnessMap` into the binary format outputted by Nargo.
230
+ *
231
+ * @param {WitnessMap} witness_map - A witness map.
232
+ * @returns {Uint8Array} A compressed witness map
233
+ */
234
+ module.exports.compressWitness = function(witness_map) {
235
+ const ret = wasm.compressWitness(witness_map);
236
+ if (ret[3]) {
237
+ throw takeFromExternrefTable0(ret[2]);
238
+ }
239
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
240
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
241
+ return v1;
242
+ };
243
+
224
244
  function passArray8ToWasm0(arg, malloc) {
225
245
  const ptr = malloc(arg.length * 1, 1) >>> 0;
226
246
  getUint8ArrayMemory0().set(arg, ptr / 1);
@@ -228,19 +248,16 @@ function passArray8ToWasm0(arg, malloc) {
228
248
  return ptr;
229
249
  }
230
250
  /**
231
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
251
+ * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
252
+ * This should be used to only fetch the witness map for the main function.
232
253
  *
233
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
234
- * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
235
- * @returns {WitnessMap} A witness map containing the circuit's return values.
236
- * @param {Uint8Array} program
237
- * @param {WitnessMap} witness_map
238
- * @returns {WitnessMap}
254
+ * @param {Uint8Array} compressed_witness - A compressed witness.
255
+ * @returns {WitnessMap} The decompressed witness map.
239
256
  */
240
- module.exports.getReturnWitness = function(program, witness_map) {
241
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
257
+ module.exports.decompressWitness = function(compressed_witness) {
258
+ const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
242
259
  const len0 = WASM_VECTOR_LEN;
243
- const ret = wasm.getReturnWitness(ptr0, len0, witness_map);
260
+ const ret = wasm.decompressWitness(ptr0, len0);
244
261
  if (ret[2]) {
245
262
  throw takeFromExternrefTable0(ret[1]);
246
263
  }
@@ -248,19 +265,31 @@ module.exports.getReturnWitness = function(program, witness_map) {
248
265
  };
249
266
 
250
267
  /**
251
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
268
+ * Compresses a `WitnessStack` into the binary format outputted by Nargo.
252
269
  *
253
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
254
- * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
255
- * @returns {WitnessMap} A witness map containing the circuit's public parameters.
256
- * @param {Uint8Array} program
257
- * @param {WitnessMap} solved_witness
258
- * @returns {WitnessMap}
270
+ * @param {WitnessStack} witness_stack - A witness stack.
271
+ * @returns {Uint8Array} A compressed witness stack
259
272
  */
260
- module.exports.getPublicParametersWitness = function(program, solved_witness) {
261
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
273
+ module.exports.compressWitnessStack = function(witness_stack) {
274
+ const ret = wasm.compressWitnessStack(witness_stack);
275
+ if (ret[3]) {
276
+ throw takeFromExternrefTable0(ret[2]);
277
+ }
278
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
279
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
280
+ return v1;
281
+ };
282
+
283
+ /**
284
+ * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
285
+ *
286
+ * @param {Uint8Array} compressed_witness - A compressed witness.
287
+ * @returns {WitnessStack} The decompressed witness stack.
288
+ */
289
+ module.exports.decompressWitnessStack = function(compressed_witness) {
290
+ const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
262
291
  const len0 = WASM_VECTOR_LEN;
263
- const ret = wasm.getPublicParametersWitness(ptr0, len0, solved_witness);
292
+ const ret = wasm.decompressWitnessStack(ptr0, len0);
264
293
  if (ret[2]) {
265
294
  throw takeFromExternrefTable0(ret[1]);
266
295
  }
@@ -268,23 +297,49 @@ module.exports.getPublicParametersWitness = function(program, solved_witness) {
268
297
  };
269
298
 
270
299
  /**
271
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
300
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
272
301
  *
273
302
  * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
274
- * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
275
- * @returns {WitnessMap} A witness map containing the circuit's public inputs.
276
- * @param {Uint8Array} program
277
- * @param {WitnessMap} solved_witness
278
- * @returns {WitnessMap}
303
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
304
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
305
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
279
306
  */
280
- module.exports.getPublicWitness = function(program, solved_witness) {
307
+ module.exports.executeCircuit = function(program, initial_witness, foreign_call_handler) {
281
308
  const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
282
309
  const len0 = WASM_VECTOR_LEN;
283
- const ret = wasm.getPublicWitness(ptr0, len0, solved_witness);
284
- if (ret[2]) {
285
- throw takeFromExternrefTable0(ret[1]);
286
- }
287
- return takeFromExternrefTable0(ret[0]);
310
+ const ret = wasm.executeCircuit(ptr0, len0, initial_witness, foreign_call_handler);
311
+ return ret;
312
+ };
313
+
314
+ /**
315
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
316
+ * This method also extracts the public return values from the solved witness into its own return witness.
317
+ *
318
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
319
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
320
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
321
+ * @returns {SolvedAndReturnWitness} The solved witness calculated by executing the circuit on the provided inputs, as well as the return witness indices as specified by the circuit.
322
+ */
323
+ module.exports.executeCircuitWithReturnWitness = function(program, initial_witness, foreign_call_handler) {
324
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
325
+ const len0 = WASM_VECTOR_LEN;
326
+ const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, initial_witness, foreign_call_handler);
327
+ return ret;
328
+ };
329
+
330
+ /**
331
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
332
+ *
333
+ * @param {Uint8Array} program - A serialized representation of an ACIR program
334
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
335
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
336
+ * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
337
+ */
338
+ module.exports.executeProgram = function(program, initial_witness, foreign_call_handler) {
339
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
340
+ const len0 = WASM_VECTOR_LEN;
341
+ const ret = wasm.executeProgram(ptr0, len0, initial_witness, foreign_call_handler);
342
+ return ret;
288
343
  };
289
344
 
290
345
  /**
@@ -346,10 +401,6 @@ module.exports.sha256_compression = function(inputs, state) {
346
401
  return v3;
347
402
  };
348
403
 
349
- function getArrayU8FromWasm0(ptr, len) {
350
- ptr = ptr >>> 0;
351
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
352
- }
353
404
  /**
354
405
  * Calculates the Blake2s256 hash of the input bytes
355
406
  * @param {Uint8Array} inputs
@@ -416,32 +467,19 @@ module.exports.buildInfo = function() {
416
467
  };
417
468
 
418
469
  /**
419
- * Compresses a `WitnessMap` into the binary format outputted by Nargo.
420
- *
421
- * @param {WitnessMap} witness_map - A witness map.
422
- * @returns {Uint8Array} A compressed witness map
423
- */
424
- module.exports.compressWitness = function(witness_map) {
425
- const ret = wasm.compressWitness(witness_map);
426
- if (ret[3]) {
427
- throw takeFromExternrefTable0(ret[2]);
428
- }
429
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
430
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
431
- return v1;
432
- };
433
-
434
- /**
435
- * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
436
- * This should be used to only fetch the witness map for the main function.
470
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
437
471
  *
438
- * @param {Uint8Array} compressed_witness - A compressed witness.
439
- * @returns {WitnessMap} The decompressed witness map.
472
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
473
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
474
+ * @returns {WitnessMap} A witness map containing the circuit's return values.
475
+ * @param {Uint8Array} program
476
+ * @param {WitnessMap} witness_map
477
+ * @returns {WitnessMap}
440
478
  */
441
- module.exports.decompressWitness = function(compressed_witness) {
442
- const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
479
+ module.exports.getReturnWitness = function(program, witness_map) {
480
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
443
481
  const len0 = WASM_VECTOR_LEN;
444
- const ret = wasm.decompressWitness(ptr0, len0);
482
+ const ret = wasm.getReturnWitness(ptr0, len0, witness_map);
445
483
  if (ret[2]) {
446
484
  throw takeFromExternrefTable0(ret[1]);
447
485
  }
@@ -449,31 +487,19 @@ module.exports.decompressWitness = function(compressed_witness) {
449
487
  };
450
488
 
451
489
  /**
452
- * Compresses a `WitnessStack` into the binary format outputted by Nargo.
453
- *
454
- * @param {WitnessStack} witness_stack - A witness stack.
455
- * @returns {Uint8Array} A compressed witness stack
456
- */
457
- module.exports.compressWitnessStack = function(witness_stack) {
458
- const ret = wasm.compressWitnessStack(witness_stack);
459
- if (ret[3]) {
460
- throw takeFromExternrefTable0(ret[2]);
461
- }
462
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
463
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
464
- return v1;
465
- };
466
-
467
- /**
468
- * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
490
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
469
491
  *
470
- * @param {Uint8Array} compressed_witness - A compressed witness.
471
- * @returns {WitnessStack} The decompressed witness stack.
492
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
493
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
494
+ * @returns {WitnessMap} A witness map containing the circuit's public parameters.
495
+ * @param {Uint8Array} program
496
+ * @param {WitnessMap} solved_witness
497
+ * @returns {WitnessMap}
472
498
  */
473
- module.exports.decompressWitnessStack = function(compressed_witness) {
474
- const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
499
+ module.exports.getPublicParametersWitness = function(program, solved_witness) {
500
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
475
501
  const len0 = WASM_VECTOR_LEN;
476
- const ret = wasm.decompressWitnessStack(ptr0, len0);
502
+ const ret = wasm.getPublicParametersWitness(ptr0, len0, solved_witness);
477
503
  if (ret[2]) {
478
504
  throw takeFromExternrefTable0(ret[1]);
479
505
  }
@@ -481,61 +507,35 @@ module.exports.decompressWitnessStack = function(compressed_witness) {
481
507
  };
482
508
 
483
509
  /**
484
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
485
- *
486
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
487
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
488
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
489
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
490
- */
491
- module.exports.executeCircuit = function(program, initial_witness, foreign_call_handler) {
492
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
493
- const len0 = WASM_VECTOR_LEN;
494
- const ret = wasm.executeCircuit(ptr0, len0, initial_witness, foreign_call_handler);
495
- return ret;
496
- };
497
-
498
- /**
499
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
500
- * This method also extracts the public return values from the solved witness into its own return witness.
510
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
501
511
  *
502
512
  * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
503
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
504
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
505
- * @returns {SolvedAndReturnWitness} The solved witness calculated by executing the circuit on the provided inputs, as well as the return witness indices as specified by the circuit.
506
- */
507
- module.exports.executeCircuitWithReturnWitness = function(program, initial_witness, foreign_call_handler) {
508
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
509
- const len0 = WASM_VECTOR_LEN;
510
- const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, initial_witness, foreign_call_handler);
511
- return ret;
512
- };
513
-
514
- /**
515
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
516
- *
517
- * @param {Uint8Array} program - A serialized representation of an ACIR program
518
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
519
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
520
- * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
513
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
514
+ * @returns {WitnessMap} A witness map containing the circuit's public inputs.
515
+ * @param {Uint8Array} program
516
+ * @param {WitnessMap} solved_witness
517
+ * @returns {WitnessMap}
521
518
  */
522
- module.exports.executeProgram = function(program, initial_witness, foreign_call_handler) {
519
+ module.exports.getPublicWitness = function(program, solved_witness) {
523
520
  const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
524
521
  const len0 = WASM_VECTOR_LEN;
525
- const ret = wasm.executeProgram(ptr0, len0, initial_witness, foreign_call_handler);
526
- return ret;
522
+ const ret = wasm.getPublicWitness(ptr0, len0, solved_witness);
523
+ if (ret[2]) {
524
+ throw takeFromExternrefTable0(ret[1]);
525
+ }
526
+ return takeFromExternrefTable0(ret[0]);
527
527
  };
528
528
 
529
529
  function __wbg_adapter_30(arg0, arg1, arg2) {
530
- wasm.closure645_externref_shim(arg0, arg1, arg2);
530
+ wasm.closure571_externref_shim(arg0, arg1, arg2);
531
531
  }
532
532
 
533
533
  function __wbg_adapter_89(arg0, arg1, arg2, arg3, arg4) {
534
- wasm.closure1243_externref_shim(arg0, arg1, arg2, arg3, arg4);
534
+ wasm.closure1165_externref_shim(arg0, arg1, arg2, arg3, arg4);
535
535
  }
536
536
 
537
537
  function __wbg_adapter_110(arg0, arg1, arg2, arg3) {
538
- wasm.closure1247_externref_shim(arg0, arg1, arg2, arg3);
538
+ wasm.closure1169_externref_shim(arg0, arg1, arg2, arg3);
539
539
  }
540
540
 
541
541
  module.exports.__wbg_call_672a4d21634d4a24 = function() { return handleError(function (arg0, arg1) {
@@ -813,8 +813,8 @@ module.exports.__wbindgen_cb_drop = function(arg0) {
813
813
  return ret;
814
814
  };
815
815
 
816
- module.exports.__wbindgen_closure_wrapper2151 = function(arg0, arg1, arg2) {
817
- const ret = makeMutClosure(arg0, arg1, 646, __wbg_adapter_30);
816
+ module.exports.__wbindgen_closure_wrapper1986 = function(arg0, arg1, arg2) {
817
+ const ret = makeMutClosure(arg0, arg1, 572, __wbg_adapter_30);
818
818
  return ret;
819
819
  };
820
820
 
Binary file
@@ -2,16 +2,6 @@
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const initLogLevel: (a: number, b: number) => [number, number];
5
- export const getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
6
- export const getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
7
- export const getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
8
- export const and: (a: any, b: any) => any;
9
- export const xor: (a: any, b: any) => any;
10
- export const sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
11
- export const blake2s256: (a: number, b: number) => [number, number];
12
- export const ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
13
- export const ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
14
- export const buildInfo: () => any;
15
5
  export const compressWitness: (a: any) => [number, number, number, number];
16
6
  export const decompressWitness: (a: number, b: number) => [number, number, number];
17
7
  export const compressWitnessStack: (a: any) => [number, number, number, number];
@@ -19,6 +9,16 @@ export const decompressWitnessStack: (a: number, b: number) => [number, number,
19
9
  export const executeCircuit: (a: number, b: number, c: any, d: any) => any;
20
10
  export const executeCircuitWithReturnWitness: (a: number, b: number, c: any, d: any) => any;
21
11
  export const executeProgram: (a: number, b: number, c: any, d: any) => any;
12
+ export const and: (a: any, b: any) => any;
13
+ export const xor: (a: any, b: any) => any;
14
+ export const sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
15
+ export const blake2s256: (a: number, b: number) => [number, number];
16
+ export const ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
17
+ export const ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
18
+ export const buildInfo: () => any;
19
+ export const getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
20
+ export const getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
21
+ export const getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
22
22
  export const __wbindgen_exn_store: (a: number) => void;
23
23
  export const __externref_table_alloc: () => number;
24
24
  export const __wbindgen_export_2: WebAssembly.Table;
@@ -27,7 +27,7 @@ export const __wbindgen_malloc: (a: number, b: number) => number;
27
27
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
28
28
  export const __wbindgen_export_6: WebAssembly.Table;
29
29
  export const __externref_table_dealloc: (a: number) => void;
30
- export const closure645_externref_shim: (a: number, b: number, c: any) => void;
31
- export const closure1243_externref_shim: (a: number, b: number, c: any, d: number, e: any) => void;
32
- export const closure1247_externref_shim: (a: number, b: number, c: any, d: any) => void;
30
+ export const closure571_externref_shim: (a: number, b: number, c: any) => void;
31
+ export const closure1165_externref_shim: (a: number, b: number, c: any, d: number, e: any) => void;
32
+ export const closure1169_externref_shim: (a: number, b: number, c: any, d: any) => void;
33
33
  export const __wbindgen_start: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/noir-acvm_js",
3
- "version": "2.0.0-nightly.20250903",
3
+ "version": "3.0.0-canary.a9708bd",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/web/acvm_js.d.ts CHANGED
@@ -6,59 +6,6 @@
6
6
  * @param {LogLevel} level - The maximum level of logging to be emitted.
7
7
  */
8
8
  export function initLogLevel(filter: string): void;
9
- /**
10
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
11
- *
12
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
13
- * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
14
- * @returns {WitnessMap} A witness map containing the circuit's return values.
15
- */
16
- export function getReturnWitness(program: Uint8Array, witness_map: WitnessMap): WitnessMap;
17
- /**
18
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
19
- *
20
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
21
- * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
22
- * @returns {WitnessMap} A witness map containing the circuit's public parameters.
23
- */
24
- export function getPublicParametersWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
25
- /**
26
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
27
- *
28
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
29
- * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
30
- * @returns {WitnessMap} A witness map containing the circuit's public inputs.
31
- */
32
- export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
33
- /**
34
- * Performs a bitwise AND operation between `lhs` and `rhs`
35
- */
36
- export function and(lhs: string, rhs: string): string;
37
- /**
38
- * Performs a bitwise XOR operation between `lhs` and `rhs`
39
- */
40
- export function xor(lhs: string, rhs: string): string;
41
- /**
42
- * Sha256 compression function
43
- */
44
- export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
45
- /**
46
- * Calculates the Blake2s256 hash of the input bytes
47
- */
48
- export function blake2s256(inputs: Uint8Array): Uint8Array;
49
- /**
50
- * Verifies a ECDSA signature over the secp256k1 curve.
51
- */
52
- export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
53
- /**
54
- * Verifies a ECDSA signature over the secp256r1 curve.
55
- */
56
- export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
57
- /**
58
- * Returns the `BuildInfo` object containing information about how the installed package was built.
59
- * @returns {BuildInfo} - Information on how the installed package was built.
60
- */
61
- export function buildInfo(): BuildInfo;
62
9
  /**
63
10
  * Compresses a `WitnessMap` into the binary format outputted by Nargo.
64
11
  *
@@ -116,6 +63,82 @@ export function executeCircuitWithReturnWitness(program: Uint8Array, initial_wit
116
63
  * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
117
64
  */
118
65
  export function executeProgram(program: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessStack>;
66
+ /**
67
+ * Performs a bitwise AND operation between `lhs` and `rhs`
68
+ */
69
+ export function and(lhs: string, rhs: string): string;
70
+ /**
71
+ * Performs a bitwise XOR operation between `lhs` and `rhs`
72
+ */
73
+ export function xor(lhs: string, rhs: string): string;
74
+ /**
75
+ * Sha256 compression function
76
+ */
77
+ export function sha256_compression(inputs: Uint32Array, state: Uint32Array): Uint32Array;
78
+ /**
79
+ * Calculates the Blake2s256 hash of the input bytes
80
+ */
81
+ export function blake2s256(inputs: Uint8Array): Uint8Array;
82
+ /**
83
+ * Verifies a ECDSA signature over the secp256k1 curve.
84
+ */
85
+ export function ecdsa_secp256k1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
86
+ /**
87
+ * Verifies a ECDSA signature over the secp256r1 curve.
88
+ */
89
+ export function ecdsa_secp256r1_verify(hashed_msg: Uint8Array, public_key_x_bytes: Uint8Array, public_key_y_bytes: Uint8Array, signature: Uint8Array): boolean;
90
+ /**
91
+ * Returns the `BuildInfo` object containing information about how the installed package was built.
92
+ * @returns {BuildInfo} - Information on how the installed package was built.
93
+ */
94
+ export function buildInfo(): BuildInfo;
95
+ /**
96
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
97
+ *
98
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
99
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
100
+ * @returns {WitnessMap} A witness map containing the circuit's return values.
101
+ */
102
+ export function getReturnWitness(program: Uint8Array, witness_map: WitnessMap): WitnessMap;
103
+ /**
104
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
105
+ *
106
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
107
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
108
+ * @returns {WitnessMap} A witness map containing the circuit's public parameters.
109
+ */
110
+ export function getPublicParametersWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
111
+ /**
112
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
113
+ *
114
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
115
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
116
+ * @returns {WitnessMap} A witness map containing the circuit's public inputs.
117
+ */
118
+ export function getPublicWitness(program: Uint8Array, solved_witness: WitnessMap): WitnessMap;
119
+
120
+ export type StackItem = {
121
+ index: number;
122
+ witness: WitnessMap;
123
+ }
124
+
125
+ export type WitnessStack = Array<StackItem>;
126
+
127
+
128
+
129
+ /**
130
+ * @typedef {Object} BuildInfo - Information about how the installed package was built
131
+ * @property {string} gitHash - The hash of the git commit from which the package was built.
132
+ * @property {string} version - The version of the package at the built git commit.
133
+ * @property {boolean} dirty - Whether the package contained uncommitted changes when built.
134
+ */
135
+ export type BuildInfo = {
136
+ gitHash: string;
137
+ version: string;
138
+ dirty: string;
139
+ }
140
+
141
+
119
142
 
120
143
  export type RawAssertionPayload = {
121
144
  selector: string;
@@ -146,29 +169,6 @@ export type SolvedAndReturnWitness = {
146
169
 
147
170
 
148
171
 
149
- export type StackItem = {
150
- index: number;
151
- witness: WitnessMap;
152
- }
153
-
154
- export type WitnessStack = Array<StackItem>;
155
-
156
-
157
-
158
- /**
159
- * @typedef {Object} BuildInfo - Information about how the installed package was built
160
- * @property {string} gitHash - The hash of the git commit from which the package was built.
161
- * @property {string} version - The version of the package at the built git commit.
162
- * @property {boolean} dirty - Whether the package contained uncommitted changes when built.
163
- */
164
- export type BuildInfo = {
165
- gitHash: string;
166
- version: string;
167
- dirty: string;
168
- }
169
-
170
-
171
-
172
172
  export type ForeignCallInput = string[]
173
173
  export type ForeignCallOutput = string | string[]
174
174
 
@@ -188,16 +188,6 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
188
188
  export interface InitOutput {
189
189
  readonly memory: WebAssembly.Memory;
190
190
  readonly initLogLevel: (a: number, b: number) => [number, number];
191
- readonly getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
192
- readonly getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
193
- readonly getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
194
- readonly and: (a: any, b: any) => any;
195
- readonly xor: (a: any, b: any) => any;
196
- readonly sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
197
- readonly blake2s256: (a: number, b: number) => [number, number];
198
- readonly ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
199
- readonly ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
200
- readonly buildInfo: () => any;
201
191
  readonly compressWitness: (a: any) => [number, number, number, number];
202
192
  readonly decompressWitness: (a: number, b: number) => [number, number, number];
203
193
  readonly compressWitnessStack: (a: any) => [number, number, number, number];
@@ -205,6 +195,16 @@ export interface InitOutput {
205
195
  readonly executeCircuit: (a: number, b: number, c: any, d: any) => any;
206
196
  readonly executeCircuitWithReturnWitness: (a: number, b: number, c: any, d: any) => any;
207
197
  readonly executeProgram: (a: number, b: number, c: any, d: any) => any;
198
+ readonly and: (a: any, b: any) => any;
199
+ readonly xor: (a: any, b: any) => any;
200
+ readonly sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
201
+ readonly blake2s256: (a: number, b: number) => [number, number];
202
+ readonly ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
203
+ readonly ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
204
+ readonly buildInfo: () => any;
205
+ readonly getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
206
+ readonly getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
207
+ readonly getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
208
208
  readonly __wbindgen_exn_store: (a: number) => void;
209
209
  readonly __externref_table_alloc: () => number;
210
210
  readonly __wbindgen_export_2: WebAssembly.Table;
@@ -213,9 +213,9 @@ export interface InitOutput {
213
213
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
214
214
  readonly __wbindgen_export_6: WebAssembly.Table;
215
215
  readonly __externref_table_dealloc: (a: number) => void;
216
- readonly closure645_externref_shim: (a: number, b: number, c: any) => void;
217
- readonly closure1243_externref_shim: (a: number, b: number, c: any, d: number, e: any) => void;
218
- readonly closure1247_externref_shim: (a: number, b: number, c: any, d: any) => void;
216
+ readonly closure571_externref_shim: (a: number, b: number, c: any) => void;
217
+ readonly closure1165_externref_shim: (a: number, b: number, c: any, d: number, e: any) => void;
218
+ readonly closure1169_externref_shim: (a: number, b: number, c: any, d: any) => void;
219
219
  readonly __wbindgen_start: () => void;
220
220
  }
221
221
 
package/web/acvm_js.js CHANGED
@@ -217,6 +217,26 @@ export function initLogLevel(filter) {
217
217
  }
218
218
  }
219
219
 
220
+ function getArrayU8FromWasm0(ptr, len) {
221
+ ptr = ptr >>> 0;
222
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
223
+ }
224
+ /**
225
+ * Compresses a `WitnessMap` into the binary format outputted by Nargo.
226
+ *
227
+ * @param {WitnessMap} witness_map - A witness map.
228
+ * @returns {Uint8Array} A compressed witness map
229
+ */
230
+ export function compressWitness(witness_map) {
231
+ const ret = wasm.compressWitness(witness_map);
232
+ if (ret[3]) {
233
+ throw takeFromExternrefTable0(ret[2]);
234
+ }
235
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
236
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
237
+ return v1;
238
+ }
239
+
220
240
  function passArray8ToWasm0(arg, malloc) {
221
241
  const ptr = malloc(arg.length * 1, 1) >>> 0;
222
242
  getUint8ArrayMemory0().set(arg, ptr / 1);
@@ -224,19 +244,16 @@ function passArray8ToWasm0(arg, malloc) {
224
244
  return ptr;
225
245
  }
226
246
  /**
227
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
247
+ * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
248
+ * This should be used to only fetch the witness map for the main function.
228
249
  *
229
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
230
- * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
231
- * @returns {WitnessMap} A witness map containing the circuit's return values.
232
- * @param {Uint8Array} program
233
- * @param {WitnessMap} witness_map
234
- * @returns {WitnessMap}
250
+ * @param {Uint8Array} compressed_witness - A compressed witness.
251
+ * @returns {WitnessMap} The decompressed witness map.
235
252
  */
236
- export function getReturnWitness(program, witness_map) {
237
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
253
+ export function decompressWitness(compressed_witness) {
254
+ const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
238
255
  const len0 = WASM_VECTOR_LEN;
239
- const ret = wasm.getReturnWitness(ptr0, len0, witness_map);
256
+ const ret = wasm.decompressWitness(ptr0, len0);
240
257
  if (ret[2]) {
241
258
  throw takeFromExternrefTable0(ret[1]);
242
259
  }
@@ -244,19 +261,31 @@ export function getReturnWitness(program, witness_map) {
244
261
  }
245
262
 
246
263
  /**
247
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
264
+ * Compresses a `WitnessStack` into the binary format outputted by Nargo.
248
265
  *
249
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
250
- * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
251
- * @returns {WitnessMap} A witness map containing the circuit's public parameters.
252
- * @param {Uint8Array} program
253
- * @param {WitnessMap} solved_witness
254
- * @returns {WitnessMap}
266
+ * @param {WitnessStack} witness_stack - A witness stack.
267
+ * @returns {Uint8Array} A compressed witness stack
255
268
  */
256
- export function getPublicParametersWitness(program, solved_witness) {
257
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
269
+ export function compressWitnessStack(witness_stack) {
270
+ const ret = wasm.compressWitnessStack(witness_stack);
271
+ if (ret[3]) {
272
+ throw takeFromExternrefTable0(ret[2]);
273
+ }
274
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
275
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
276
+ return v1;
277
+ }
278
+
279
+ /**
280
+ * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
281
+ *
282
+ * @param {Uint8Array} compressed_witness - A compressed witness.
283
+ * @returns {WitnessStack} The decompressed witness stack.
284
+ */
285
+ export function decompressWitnessStack(compressed_witness) {
286
+ const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
258
287
  const len0 = WASM_VECTOR_LEN;
259
- const ret = wasm.getPublicParametersWitness(ptr0, len0, solved_witness);
288
+ const ret = wasm.decompressWitnessStack(ptr0, len0);
260
289
  if (ret[2]) {
261
290
  throw takeFromExternrefTable0(ret[1]);
262
291
  }
@@ -264,23 +293,49 @@ export function getPublicParametersWitness(program, solved_witness) {
264
293
  }
265
294
 
266
295
  /**
267
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
296
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
268
297
  *
269
298
  * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
270
- * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
271
- * @returns {WitnessMap} A witness map containing the circuit's public inputs.
272
- * @param {Uint8Array} program
273
- * @param {WitnessMap} solved_witness
274
- * @returns {WitnessMap}
299
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
300
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
301
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
275
302
  */
276
- export function getPublicWitness(program, solved_witness) {
303
+ export function executeCircuit(program, initial_witness, foreign_call_handler) {
277
304
  const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
278
305
  const len0 = WASM_VECTOR_LEN;
279
- const ret = wasm.getPublicWitness(ptr0, len0, solved_witness);
280
- if (ret[2]) {
281
- throw takeFromExternrefTable0(ret[1]);
282
- }
283
- return takeFromExternrefTable0(ret[0]);
306
+ const ret = wasm.executeCircuit(ptr0, len0, initial_witness, foreign_call_handler);
307
+ return ret;
308
+ }
309
+
310
+ /**
311
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
312
+ * This method also extracts the public return values from the solved witness into its own return witness.
313
+ *
314
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
315
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
316
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
317
+ * @returns {SolvedAndReturnWitness} The solved witness calculated by executing the circuit on the provided inputs, as well as the return witness indices as specified by the circuit.
318
+ */
319
+ export function executeCircuitWithReturnWitness(program, initial_witness, foreign_call_handler) {
320
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
321
+ const len0 = WASM_VECTOR_LEN;
322
+ const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, initial_witness, foreign_call_handler);
323
+ return ret;
324
+ }
325
+
326
+ /**
327
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
328
+ *
329
+ * @param {Uint8Array} program - A serialized representation of an ACIR program
330
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
331
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
332
+ * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
333
+ */
334
+ export function executeProgram(program, initial_witness, foreign_call_handler) {
335
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
336
+ const len0 = WASM_VECTOR_LEN;
337
+ const ret = wasm.executeProgram(ptr0, len0, initial_witness, foreign_call_handler);
338
+ return ret;
284
339
  }
285
340
 
286
341
  /**
@@ -342,10 +397,6 @@ export function sha256_compression(inputs, state) {
342
397
  return v3;
343
398
  }
344
399
 
345
- function getArrayU8FromWasm0(ptr, len) {
346
- ptr = ptr >>> 0;
347
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
348
- }
349
400
  /**
350
401
  * Calculates the Blake2s256 hash of the input bytes
351
402
  * @param {Uint8Array} inputs
@@ -412,32 +463,19 @@ export function buildInfo() {
412
463
  }
413
464
 
414
465
  /**
415
- * Compresses a `WitnessMap` into the binary format outputted by Nargo.
416
- *
417
- * @param {WitnessMap} witness_map - A witness map.
418
- * @returns {Uint8Array} A compressed witness map
419
- */
420
- export function compressWitness(witness_map) {
421
- const ret = wasm.compressWitness(witness_map);
422
- if (ret[3]) {
423
- throw takeFromExternrefTable0(ret[2]);
424
- }
425
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
426
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
427
- return v1;
428
- }
429
-
430
- /**
431
- * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
432
- * This should be used to only fetch the witness map for the main function.
466
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
433
467
  *
434
- * @param {Uint8Array} compressed_witness - A compressed witness.
435
- * @returns {WitnessMap} The decompressed witness map.
468
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
469
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
470
+ * @returns {WitnessMap} A witness map containing the circuit's return values.
471
+ * @param {Uint8Array} program
472
+ * @param {WitnessMap} witness_map
473
+ * @returns {WitnessMap}
436
474
  */
437
- export function decompressWitness(compressed_witness) {
438
- const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
475
+ export function getReturnWitness(program, witness_map) {
476
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
439
477
  const len0 = WASM_VECTOR_LEN;
440
- const ret = wasm.decompressWitness(ptr0, len0);
478
+ const ret = wasm.getReturnWitness(ptr0, len0, witness_map);
441
479
  if (ret[2]) {
442
480
  throw takeFromExternrefTable0(ret[1]);
443
481
  }
@@ -445,31 +483,19 @@ export function decompressWitness(compressed_witness) {
445
483
  }
446
484
 
447
485
  /**
448
- * Compresses a `WitnessStack` into the binary format outputted by Nargo.
449
- *
450
- * @param {WitnessStack} witness_stack - A witness stack.
451
- * @returns {Uint8Array} A compressed witness stack
452
- */
453
- export function compressWitnessStack(witness_stack) {
454
- const ret = wasm.compressWitnessStack(witness_stack);
455
- if (ret[3]) {
456
- throw takeFromExternrefTable0(ret[2]);
457
- }
458
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
459
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
460
- return v1;
461
- }
462
-
463
- /**
464
- * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
486
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
465
487
  *
466
- * @param {Uint8Array} compressed_witness - A compressed witness.
467
- * @returns {WitnessStack} The decompressed witness stack.
488
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
489
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
490
+ * @returns {WitnessMap} A witness map containing the circuit's public parameters.
491
+ * @param {Uint8Array} program
492
+ * @param {WitnessMap} solved_witness
493
+ * @returns {WitnessMap}
468
494
  */
469
- export function decompressWitnessStack(compressed_witness) {
470
- const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
495
+ export function getPublicParametersWitness(program, solved_witness) {
496
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
471
497
  const len0 = WASM_VECTOR_LEN;
472
- const ret = wasm.decompressWitnessStack(ptr0, len0);
498
+ const ret = wasm.getPublicParametersWitness(ptr0, len0, solved_witness);
473
499
  if (ret[2]) {
474
500
  throw takeFromExternrefTable0(ret[1]);
475
501
  }
@@ -477,61 +503,35 @@ export function decompressWitnessStack(compressed_witness) {
477
503
  }
478
504
 
479
505
  /**
480
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
481
- *
482
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
483
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
484
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
485
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
486
- */
487
- export function executeCircuit(program, initial_witness, foreign_call_handler) {
488
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
489
- const len0 = WASM_VECTOR_LEN;
490
- const ret = wasm.executeCircuit(ptr0, len0, initial_witness, foreign_call_handler);
491
- return ret;
492
- }
493
-
494
- /**
495
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
496
- * This method also extracts the public return values from the solved witness into its own return witness.
506
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
497
507
  *
498
508
  * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
499
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
500
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
501
- * @returns {SolvedAndReturnWitness} The solved witness calculated by executing the circuit on the provided inputs, as well as the return witness indices as specified by the circuit.
502
- */
503
- export function executeCircuitWithReturnWitness(program, initial_witness, foreign_call_handler) {
504
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
505
- const len0 = WASM_VECTOR_LEN;
506
- const ret = wasm.executeCircuitWithReturnWitness(ptr0, len0, initial_witness, foreign_call_handler);
507
- return ret;
508
- }
509
-
510
- /**
511
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
512
- *
513
- * @param {Uint8Array} program - A serialized representation of an ACIR program
514
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `program`.
515
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the program.
516
- * @returns {WitnessStack} The solved witness calculated by executing the program on the provided inputs.
509
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
510
+ * @returns {WitnessMap} A witness map containing the circuit's public inputs.
511
+ * @param {Uint8Array} program
512
+ * @param {WitnessMap} solved_witness
513
+ * @returns {WitnessMap}
517
514
  */
518
- export function executeProgram(program, initial_witness, foreign_call_handler) {
515
+ export function getPublicWitness(program, solved_witness) {
519
516
  const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
520
517
  const len0 = WASM_VECTOR_LEN;
521
- const ret = wasm.executeProgram(ptr0, len0, initial_witness, foreign_call_handler);
522
- return ret;
518
+ const ret = wasm.getPublicWitness(ptr0, len0, solved_witness);
519
+ if (ret[2]) {
520
+ throw takeFromExternrefTable0(ret[1]);
521
+ }
522
+ return takeFromExternrefTable0(ret[0]);
523
523
  }
524
524
 
525
525
  function __wbg_adapter_30(arg0, arg1, arg2) {
526
- wasm.closure645_externref_shim(arg0, arg1, arg2);
526
+ wasm.closure571_externref_shim(arg0, arg1, arg2);
527
527
  }
528
528
 
529
529
  function __wbg_adapter_89(arg0, arg1, arg2, arg3, arg4) {
530
- wasm.closure1243_externref_shim(arg0, arg1, arg2, arg3, arg4);
530
+ wasm.closure1165_externref_shim(arg0, arg1, arg2, arg3, arg4);
531
531
  }
532
532
 
533
533
  function __wbg_adapter_110(arg0, arg1, arg2, arg3) {
534
- wasm.closure1247_externref_shim(arg0, arg1, arg2, arg3);
534
+ wasm.closure1169_externref_shim(arg0, arg1, arg2, arg3);
535
535
  }
536
536
 
537
537
  async function __wbg_load(module, imports) {
@@ -797,8 +797,8 @@ function __wbg_get_imports() {
797
797
  const ret = false;
798
798
  return ret;
799
799
  };
800
- imports.wbg.__wbindgen_closure_wrapper2151 = function(arg0, arg1, arg2) {
801
- const ret = makeMutClosure(arg0, arg1, 646, __wbg_adapter_30);
800
+ imports.wbg.__wbindgen_closure_wrapper1986 = function(arg0, arg1, arg2) {
801
+ const ret = makeMutClosure(arg0, arg1, 572, __wbg_adapter_30);
802
802
  return ret;
803
803
  };
804
804
  imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
Binary file
@@ -2,16 +2,6 @@
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const initLogLevel: (a: number, b: number) => [number, number];
5
- export const getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
6
- export const getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
7
- export const getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
8
- export const and: (a: any, b: any) => any;
9
- export const xor: (a: any, b: any) => any;
10
- export const sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
11
- export const blake2s256: (a: number, b: number) => [number, number];
12
- export const ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
13
- export const ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
14
- export const buildInfo: () => any;
15
5
  export const compressWitness: (a: any) => [number, number, number, number];
16
6
  export const decompressWitness: (a: number, b: number) => [number, number, number];
17
7
  export const compressWitnessStack: (a: any) => [number, number, number, number];
@@ -19,6 +9,16 @@ export const decompressWitnessStack: (a: number, b: number) => [number, number,
19
9
  export const executeCircuit: (a: number, b: number, c: any, d: any) => any;
20
10
  export const executeCircuitWithReturnWitness: (a: number, b: number, c: any, d: any) => any;
21
11
  export const executeProgram: (a: number, b: number, c: any, d: any) => any;
12
+ export const and: (a: any, b: any) => any;
13
+ export const xor: (a: any, b: any) => any;
14
+ export const sha256_compression: (a: number, b: number, c: number, d: number) => [number, number];
15
+ export const blake2s256: (a: number, b: number) => [number, number];
16
+ export const ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
17
+ export const ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
18
+ export const buildInfo: () => any;
19
+ export const getReturnWitness: (a: number, b: number, c: any) => [number, number, number];
20
+ export const getPublicParametersWitness: (a: number, b: number, c: any) => [number, number, number];
21
+ export const getPublicWitness: (a: number, b: number, c: any) => [number, number, number];
22
22
  export const __wbindgen_exn_store: (a: number) => void;
23
23
  export const __externref_table_alloc: () => number;
24
24
  export const __wbindgen_export_2: WebAssembly.Table;
@@ -27,7 +27,7 @@ export const __wbindgen_malloc: (a: number, b: number) => number;
27
27
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
28
28
  export const __wbindgen_export_6: WebAssembly.Table;
29
29
  export const __externref_table_dealloc: (a: number) => void;
30
- export const closure645_externref_shim: (a: number, b: number, c: any) => void;
31
- export const closure1243_externref_shim: (a: number, b: number, c: any, d: number, e: any) => void;
32
- export const closure1247_externref_shim: (a: number, b: number, c: any, d: any) => void;
30
+ export const closure571_externref_shim: (a: number, b: number, c: any) => void;
31
+ export const closure1165_externref_shim: (a: number, b: number, c: any, d: number, e: any) => void;
32
+ export const closure1169_externref_shim: (a: number, b: number, c: any, d: any) => void;
33
33
  export const __wbindgen_start: () => void;