@noir-lang/acvm_js 0.40.0 → 0.41.0-265bd8b.nightly

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.
@@ -1,6 +1,29 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
5
+ *
6
+ * @param {&WasmBlackBoxFunctionSolver} solver - A black box solver.
7
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
8
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
9
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
10
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
11
+ */
12
+ export function executeCircuitWithBlackBoxSolver(solver: WasmBlackBoxFunctionSolver, circuit: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
13
+ /**
14
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
15
+ *
16
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
17
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
18
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
19
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
20
+ */
21
+ export function executeCircuit(circuit: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
22
+ /**
23
+ * @returns {Promise<WasmBlackBoxFunctionSolver>}
24
+ */
25
+ export function createBlackBoxSolver(): Promise<WasmBlackBoxFunctionSolver>;
26
+ /**
4
27
  * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
5
28
  *
6
29
  * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
@@ -34,34 +57,19 @@ export function getPublicParametersWitness(circuit: Uint8Array, solved_witness:
34
57
  */
35
58
  export function getReturnWitness(circuit: Uint8Array, witness_map: WitnessMap): WitnessMap;
36
59
  /**
37
- * Sets the package's logging level.
38
- *
39
- * @param {LogLevel} level - The maximum level of logging to be emitted.
40
- */
41
- export function initLogLevel(filter: string): void;
42
- /**
43
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
60
+ * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
44
61
  *
45
- * @param {&WasmBlackBoxFunctionSolver} solver - A black box solver.
46
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
47
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
48
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
49
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
62
+ * @param {Uint8Array} compressed_witness - A compressed witness.
63
+ * @returns {WitnessMap} The decompressed witness map.
50
64
  */
51
- export function executeCircuitWithBlackBoxSolver(solver: WasmBlackBoxFunctionSolver, circuit: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
65
+ export function decompressWitness(compressed_witness: Uint8Array): WitnessMap;
52
66
  /**
53
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
67
+ * Compresses a `WitnessMap` into the binary format outputted by Nargo.
54
68
  *
55
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
56
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
57
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
58
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
59
- */
60
- export function executeCircuit(circuit: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
61
- /**
62
- * @returns {Promise<WasmBlackBoxFunctionSolver>}
69
+ * @param {Uint8Array} compressed_witness - A witness map.
70
+ * @returns {WitnessMap} A compressed witness map
63
71
  */
64
- export function createBlackBoxSolver(): Promise<WasmBlackBoxFunctionSolver>;
72
+ export function compressWitness(witness_map: WitnessMap): Uint8Array;
65
73
  /**
66
74
  * Verifies a ECDSA signature over the secp256r1 curve.
67
75
  * @param {Uint8Array} hashed_msg
@@ -113,36 +121,17 @@ export function xor(lhs: string, rhs: string): string;
113
121
  */
114
122
  export function and(lhs: string, rhs: string): string;
115
123
  /**
116
- * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
117
- *
118
- * @param {Uint8Array} compressed_witness - A compressed witness.
119
- * @returns {WitnessMap} The decompressed witness map.
120
- */
121
- export function decompressWitness(compressed_witness: Uint8Array): WitnessMap;
122
- /**
123
- * Compresses a `WitnessMap` into the binary format outputted by Nargo.
124
+ * Sets the package's logging level.
124
125
  *
125
- * @param {Uint8Array} compressed_witness - A witness map.
126
- * @returns {WitnessMap} A compressed witness map
126
+ * @param {LogLevel} level - The maximum level of logging to be emitted.
127
127
  */
128
- export function compressWitness(witness_map: WitnessMap): Uint8Array;
128
+ export function initLogLevel(filter: string): void;
129
129
  /**
130
130
  * Returns the `BuildInfo` object containing information about how the installed package was built.
131
131
  * @returns {BuildInfo} - Information on how the installed package was built.
132
132
  */
133
133
  export function buildInfo(): BuildInfo;
134
134
 
135
- // Map from witness index to hex string value of witness.
136
- export type WitnessMap = Map<number, string>;
137
-
138
-
139
-
140
- export type ExecutionError = Error & {
141
- callStack?: string[];
142
- };
143
-
144
-
145
-
146
135
  export type ForeignCallInput = string[]
147
136
  export type ForeignCallOutput = string | string[]
148
137
 
@@ -157,6 +146,17 @@ export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => P
157
146
 
158
147
 
159
148
 
149
+ // Map from witness index to hex string value of witness.
150
+ export type WitnessMap = Map<number, string>;
151
+
152
+
153
+
154
+ export type ExecutionError = Error & {
155
+ callStack?: string[];
156
+ };
157
+
158
+
159
+
160
160
  /**
161
161
  * @typedef {Object} BuildInfo - Information about how the installed package was built
162
162
  * @property {string} gitHash - The hash of the git commit from which the package was built.
package/nodejs/acvm_js.js CHANGED
@@ -226,7 +226,14 @@ function makeMutClosure(arg0, arg1, dtor, f) {
226
226
  return real;
227
227
  }
228
228
  function __wbg_adapter_52(arg0, arg1, arg2) {
229
- wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h0c6c8312617d6ad4(arg0, arg1, addHeapObject(arg2));
229
+ wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hfdf1d0fa4debaf70(arg0, arg1, addHeapObject(arg2));
230
+ }
231
+
232
+ function _assertClass(instance, klass) {
233
+ if (!(instance instanceof klass)) {
234
+ throw new Error(`expected instance of ${klass.name}`);
235
+ }
236
+ return instance.ptr;
230
237
  }
231
238
 
232
239
  function passArray8ToWasm0(arg, malloc) {
@@ -235,6 +242,46 @@ function passArray8ToWasm0(arg, malloc) {
235
242
  WASM_VECTOR_LEN = arg.length;
236
243
  return ptr;
237
244
  }
245
+ /**
246
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
247
+ *
248
+ * @param {&WasmBlackBoxFunctionSolver} solver - A black box solver.
249
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
250
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
251
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
252
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
253
+ */
254
+ module.exports.executeCircuitWithBlackBoxSolver = function(solver, circuit, initial_witness, foreign_call_handler) {
255
+ _assertClass(solver, WasmBlackBoxFunctionSolver);
256
+ const ptr0 = passArray8ToWasm0(circuit, wasm.__wbindgen_malloc);
257
+ const len0 = WASM_VECTOR_LEN;
258
+ const ret = wasm.executeCircuitWithBlackBoxSolver(solver.__wbg_ptr, ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
259
+ return takeObject(ret);
260
+ };
261
+
262
+ /**
263
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
264
+ *
265
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
266
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
267
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
268
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
269
+ */
270
+ module.exports.executeCircuit = function(circuit, initial_witness, foreign_call_handler) {
271
+ const ptr0 = passArray8ToWasm0(circuit, wasm.__wbindgen_malloc);
272
+ const len0 = WASM_VECTOR_LEN;
273
+ const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
274
+ return takeObject(ret);
275
+ };
276
+
277
+ /**
278
+ * @returns {Promise<WasmBlackBoxFunctionSolver>}
279
+ */
280
+ module.exports.createBlackBoxSolver = function() {
281
+ const ret = wasm.createBlackBoxSolver();
282
+ return takeObject(ret);
283
+ };
284
+
238
285
  /**
239
286
  * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
240
287
  *
@@ -320,70 +367,56 @@ module.exports.getReturnWitness = function(circuit, witness_map) {
320
367
  };
321
368
 
322
369
  /**
323
- * Sets the package's logging level.
370
+ * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
324
371
  *
325
- * @param {LogLevel} level - The maximum level of logging to be emitted.
372
+ * @param {Uint8Array} compressed_witness - A compressed witness.
373
+ * @returns {WitnessMap} The decompressed witness map.
326
374
  */
327
- module.exports.initLogLevel = function(filter) {
375
+ module.exports.decompressWitness = function(compressed_witness) {
328
376
  try {
329
377
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
330
- const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
378
+ const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
331
379
  const len0 = WASM_VECTOR_LEN;
332
- wasm.initLogLevel(retptr, ptr0, len0);
380
+ wasm.decompressWitness(retptr, ptr0, len0);
333
381
  var r0 = getInt32Memory0()[retptr / 4 + 0];
334
382
  var r1 = getInt32Memory0()[retptr / 4 + 1];
335
- if (r1) {
336
- throw takeObject(r0);
383
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
384
+ if (r2) {
385
+ throw takeObject(r1);
337
386
  }
387
+ return takeObject(r0);
338
388
  } finally {
339
389
  wasm.__wbindgen_add_to_stack_pointer(16);
340
390
  }
341
391
  };
342
392
 
343
- function _assertClass(instance, klass) {
344
- if (!(instance instanceof klass)) {
345
- throw new Error(`expected instance of ${klass.name}`);
346
- }
347
- return instance.ptr;
393
+ function getArrayU8FromWasm0(ptr, len) {
394
+ ptr = ptr >>> 0;
395
+ return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
348
396
  }
349
397
  /**
350
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
351
- *
352
- * @param {&WasmBlackBoxFunctionSolver} solver - A black box solver.
353
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
354
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
355
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
356
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
357
- */
358
- module.exports.executeCircuitWithBlackBoxSolver = function(solver, circuit, initial_witness, foreign_call_handler) {
359
- _assertClass(solver, WasmBlackBoxFunctionSolver);
360
- const ptr0 = passArray8ToWasm0(circuit, wasm.__wbindgen_malloc);
361
- const len0 = WASM_VECTOR_LEN;
362
- const ret = wasm.executeCircuitWithBlackBoxSolver(solver.__wbg_ptr, ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
363
- return takeObject(ret);
364
- };
365
-
366
- /**
367
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
398
+ * Compresses a `WitnessMap` into the binary format outputted by Nargo.
368
399
  *
369
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
370
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
371
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
372
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
373
- */
374
- module.exports.executeCircuit = function(circuit, initial_witness, foreign_call_handler) {
375
- const ptr0 = passArray8ToWasm0(circuit, wasm.__wbindgen_malloc);
376
- const len0 = WASM_VECTOR_LEN;
377
- const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
378
- return takeObject(ret);
379
- };
380
-
381
- /**
382
- * @returns {Promise<WasmBlackBoxFunctionSolver>}
400
+ * @param {Uint8Array} compressed_witness - A witness map.
401
+ * @returns {WitnessMap} A compressed witness map
383
402
  */
384
- module.exports.createBlackBoxSolver = function() {
385
- const ret = wasm.createBlackBoxSolver();
386
- return takeObject(ret);
403
+ module.exports.compressWitness = function(witness_map) {
404
+ try {
405
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
406
+ wasm.compressWitness(retptr, addHeapObject(witness_map));
407
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
408
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
409
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
410
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
411
+ if (r3) {
412
+ throw takeObject(r2);
413
+ }
414
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
415
+ wasm.__wbindgen_free(r0, r1 * 1);
416
+ return v1;
417
+ } finally {
418
+ wasm.__wbindgen_add_to_stack_pointer(16);
419
+ }
387
420
  };
388
421
 
389
422
  /**
@@ -428,10 +461,6 @@ module.exports.ecdsa_secp256k1_verify = function(hashed_msg, public_key_x_bytes,
428
461
  return ret !== 0;
429
462
  };
430
463
 
431
- function getArrayU8FromWasm0(ptr, len) {
432
- ptr = ptr >>> 0;
433
- return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
434
- }
435
464
  /**
436
465
  * Calculates the Keccak256 hash of the input bytes
437
466
  * @param {Uint8Array} inputs
@@ -518,49 +547,21 @@ module.exports.and = function(lhs, rhs) {
518
547
  };
519
548
 
520
549
  /**
521
- * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
550
+ * Sets the package's logging level.
522
551
  *
523
- * @param {Uint8Array} compressed_witness - A compressed witness.
524
- * @returns {WitnessMap} The decompressed witness map.
552
+ * @param {LogLevel} level - The maximum level of logging to be emitted.
525
553
  */
526
- module.exports.decompressWitness = function(compressed_witness) {
554
+ module.exports.initLogLevel = function(filter) {
527
555
  try {
528
556
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
529
- const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
557
+ const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
530
558
  const len0 = WASM_VECTOR_LEN;
531
- wasm.decompressWitness(retptr, ptr0, len0);
532
- var r0 = getInt32Memory0()[retptr / 4 + 0];
533
- var r1 = getInt32Memory0()[retptr / 4 + 1];
534
- var r2 = getInt32Memory0()[retptr / 4 + 2];
535
- if (r2) {
536
- throw takeObject(r1);
537
- }
538
- return takeObject(r0);
539
- } finally {
540
- wasm.__wbindgen_add_to_stack_pointer(16);
541
- }
542
- };
543
-
544
- /**
545
- * Compresses a `WitnessMap` into the binary format outputted by Nargo.
546
- *
547
- * @param {Uint8Array} compressed_witness - A witness map.
548
- * @returns {WitnessMap} A compressed witness map
549
- */
550
- module.exports.compressWitness = function(witness_map) {
551
- try {
552
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
553
- wasm.compressWitness(retptr, addHeapObject(witness_map));
559
+ wasm.initLogLevel(retptr, ptr0, len0);
554
560
  var r0 = getInt32Memory0()[retptr / 4 + 0];
555
561
  var r1 = getInt32Memory0()[retptr / 4 + 1];
556
- var r2 = getInt32Memory0()[retptr / 4 + 2];
557
- var r3 = getInt32Memory0()[retptr / 4 + 3];
558
- if (r3) {
559
- throw takeObject(r2);
562
+ if (r1) {
563
+ throw takeObject(r0);
560
564
  }
561
- var v1 = getArrayU8FromWasm0(r0, r1).slice();
562
- wasm.__wbindgen_free(r0, r1 * 1);
563
- return v1;
564
565
  } finally {
565
566
  wasm.__wbindgen_add_to_stack_pointer(16);
566
567
  }
@@ -583,7 +584,7 @@ function handleError(f, args) {
583
584
  }
584
585
  }
585
586
  function __wbg_adapter_159(arg0, arg1, arg2, arg3) {
586
- wasm.wasm_bindgen__convert__closures__invoke2_mut__hc5e8ba855f687f9d(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
587
+ wasm.wasm_bindgen__convert__closures__invoke2_mut__h79f8a29187e94f15(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
587
588
  }
588
589
 
589
590
  /**
@@ -641,13 +642,28 @@ module.exports.__wbindgen_object_drop_ref = function(arg0) {
641
642
  takeObject(arg0);
642
643
  };
643
644
 
645
+ module.exports.__wbindgen_error_new = function(arg0, arg1) {
646
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
647
+ return addHeapObject(ret);
648
+ };
649
+
650
+ module.exports.__wbindgen_object_clone_ref = function(arg0) {
651
+ const ret = getObject(arg0);
652
+ return addHeapObject(ret);
653
+ };
654
+
644
655
  module.exports.__wbg_wasmblackboxfunctionsolver_new = function(arg0) {
645
656
  const ret = WasmBlackBoxFunctionSolver.__wrap(arg0);
646
657
  return addHeapObject(ret);
647
658
  };
648
659
 
649
- module.exports.__wbindgen_is_array = function(arg0) {
650
- const ret = Array.isArray(getObject(arg0));
660
+ module.exports.__wbindgen_cb_drop = function(arg0) {
661
+ const obj = takeObject(arg0).original;
662
+ if (obj.cnt-- == 1) {
663
+ obj.a = 0;
664
+ return true;
665
+ }
666
+ const ret = false;
651
667
  return ret;
652
668
  };
653
669
 
@@ -656,17 +672,7 @@ module.exports.__wbindgen_string_new = function(arg0, arg1) {
656
672
  return addHeapObject(ret);
657
673
  };
658
674
 
659
- module.exports.__wbg_constructor_8444207292d12e94 = function(arg0) {
660
- const ret = new Error(takeObject(arg0));
661
- return addHeapObject(ret);
662
- };
663
-
664
- module.exports.__wbindgen_is_string = function(arg0) {
665
- const ret = typeof(getObject(arg0)) === 'string';
666
- return ret;
667
- };
668
-
669
- module.exports.__wbg_new_12499e712355d566 = function() {
675
+ module.exports.__wbg_new_ab82e8584bdd2143 = function() {
670
676
  const ret = new Map();
671
677
  return addHeapObject(ret);
672
678
  };
@@ -685,6 +691,11 @@ module.exports.__wbindgen_string_get = function(arg0, arg1) {
685
691
  getInt32Memory0()[arg0 / 4 + 0] = ptr1;
686
692
  };
687
693
 
694
+ module.exports.__wbg_constructor_d9cb984c4e2c6bcd = function(arg0) {
695
+ const ret = new Error(takeObject(arg0));
696
+ return addHeapObject(ret);
697
+ };
698
+
688
699
  module.exports.__wbindgen_number_get = function(arg0, arg1) {
689
700
  const obj = getObject(arg1);
690
701
  const ret = typeof(obj) === 'number' ? obj : undefined;
@@ -692,28 +703,18 @@ module.exports.__wbindgen_number_get = function(arg0, arg1) {
692
703
  getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
693
704
  };
694
705
 
695
- module.exports.__wbindgen_error_new = function(arg0, arg1) {
696
- const ret = new Error(getStringFromWasm0(arg0, arg1));
697
- return addHeapObject(ret);
698
- };
699
-
700
- module.exports.__wbindgen_object_clone_ref = function(arg0) {
701
- const ret = getObject(arg0);
702
- return addHeapObject(ret);
706
+ module.exports.__wbindgen_is_undefined = function(arg0) {
707
+ const ret = getObject(arg0) === undefined;
708
+ return ret;
703
709
  };
704
710
 
705
- module.exports.__wbindgen_cb_drop = function(arg0) {
706
- const obj = takeObject(arg0).original;
707
- if (obj.cnt-- == 1) {
708
- obj.a = 0;
709
- return true;
710
- }
711
- const ret = false;
711
+ module.exports.__wbindgen_is_string = function(arg0) {
712
+ const ret = typeof(getObject(arg0)) === 'string';
712
713
  return ret;
713
714
  };
714
715
 
715
- module.exports.__wbindgen_is_undefined = function(arg0) {
716
- const ret = getObject(arg0) === undefined;
716
+ module.exports.__wbindgen_is_array = function(arg0) {
717
+ const ret = Array.isArray(getObject(arg0));
717
718
  return ret;
718
719
  };
719
720
 
@@ -742,16 +743,6 @@ module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
742
743
  }
743
744
  };
744
745
 
745
- module.exports.__wbindgen_bigint_from_i64 = function(arg0) {
746
- const ret = arg0;
747
- return addHeapObject(ret);
748
- };
749
-
750
- module.exports.__wbindgen_bigint_from_u128 = function(arg0, arg1) {
751
- const ret = BigInt.asUintN(64, arg0) << BigInt(64) | BigInt.asUintN(64, arg1);
752
- return addHeapObject(ret);
753
- };
754
-
755
746
  module.exports.__wbindgen_ge = function(arg0, arg1) {
756
747
  const ret = getObject(arg0) >= getObject(arg1);
757
748
  return ret;
@@ -777,14 +768,19 @@ module.exports.__wbindgen_is_bigint = function(arg0) {
777
768
  return ret;
778
769
  };
779
770
 
780
- module.exports.__wbg_instanceof_Global_1c3b64df1a5c886c = function(arg0) {
781
- let result;
782
- try {
783
- result = getObject(arg0) instanceof WebAssembly.Global;
784
- } catch {
785
- result = false;
786
- }
787
- const ret = result;
771
+ module.exports.__wbindgen_bigint_from_i64 = function(arg0) {
772
+ const ret = arg0;
773
+ return addHeapObject(ret);
774
+ };
775
+
776
+ module.exports.__wbindgen_bigint_from_u128 = function(arg0, arg1) {
777
+ const ret = BigInt.asUintN(64, arg0) << BigInt(64) | BigInt.asUintN(64, arg1);
778
+ return addHeapObject(ret);
779
+ };
780
+
781
+ module.exports.__wbindgen_is_object = function(arg0) {
782
+ const val = getObject(arg0);
783
+ const ret = typeof(val) === 'object' && val !== null;
788
784
  return ret;
789
785
  };
790
786
 
@@ -793,9 +789,14 @@ module.exports.__wbindgen_is_function = function(arg0) {
793
789
  return ret;
794
790
  };
795
791
 
796
- module.exports.__wbindgen_is_object = function(arg0) {
797
- const val = getObject(arg0);
798
- const ret = typeof(val) === 'object' && val !== null;
792
+ module.exports.__wbg_instanceof_Global_f4b019d2b45e18ab = function(arg0) {
793
+ let result;
794
+ try {
795
+ result = getObject(arg0) instanceof WebAssembly.Global;
796
+ } catch {
797
+ result = false;
798
+ }
799
+ const ret = result;
799
800
  return ret;
800
801
  };
801
802
 
@@ -1129,6 +1130,11 @@ module.exports.__wbg_subarray_d82be056deb4ad27 = function(arg0, arg1, arg2) {
1129
1130
  return addHeapObject(ret);
1130
1131
  };
1131
1132
 
1133
+ module.exports.__wbg_parse_76a8a18ca3f8730b = function() { return handleError(function (arg0, arg1) {
1134
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
1135
+ return addHeapObject(ret);
1136
+ }, arguments) };
1137
+
1132
1138
  module.exports.__wbg_compile_eefe73dfb19bff3d = function(arg0) {
1133
1139
  const ret = WebAssembly.compile(getObject(arg0));
1134
1140
  return addHeapObject(ret);
@@ -1196,11 +1202,6 @@ module.exports.__wbg_set_07da13cc24b69217 = function() { return handleError(func
1196
1202
  return ret;
1197
1203
  }, arguments) };
1198
1204
 
1199
- module.exports.__wbg_parse_76a8a18ca3f8730b = function() { return handleError(function (arg0, arg1) {
1200
- const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
1201
- return addHeapObject(ret);
1202
- }, arguments) };
1203
-
1204
1205
  module.exports.__wbindgen_bigint_get_as_i64 = function(arg0, arg1) {
1205
1206
  const v = getObject(arg1);
1206
1207
  const ret = typeof(v) === 'bigint' ? v : undefined;
@@ -1230,8 +1231,8 @@ module.exports.__wbindgen_function_table = function() {
1230
1231
  return addHeapObject(ret);
1231
1232
  };
1232
1233
 
1233
- module.exports.__wbindgen_closure_wrapper1433 = function(arg0, arg1, arg2) {
1234
- const ret = makeMutClosure(arg0, arg1, 501, __wbg_adapter_52);
1234
+ module.exports.__wbindgen_closure_wrapper1388 = function(arg0, arg1, arg2) {
1235
+ const ret = makeMutClosure(arg0, arg1, 484, __wbg_adapter_52);
1235
1236
  return addHeapObject(ret);
1236
1237
  };
1237
1238
 
Binary file
@@ -1,14 +1,15 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
- export function getPublicWitness(a: number, b: number, c: number, d: number): void;
5
- export function getPublicParametersWitness(a: number, b: number, c: number, d: number): void;
6
- export function getReturnWitness(a: number, b: number, c: number, d: number): void;
7
- export function initLogLevel(a: number, b: number, c: number): void;
8
4
  export function executeCircuitWithBlackBoxSolver(a: number, b: number, c: number, d: number, e: number): number;
9
5
  export function executeCircuit(a: number, b: number, c: number, d: number): number;
10
6
  export function createBlackBoxSolver(): number;
11
7
  export function __wbg_wasmblackboxfunctionsolver_free(a: number): void;
8
+ export function getPublicWitness(a: number, b: number, c: number, d: number): void;
9
+ export function getPublicParametersWitness(a: number, b: number, c: number, d: number): void;
10
+ export function getReturnWitness(a: number, b: number, c: number, d: number): void;
11
+ export function decompressWitness(a: number, b: number, c: number): void;
12
+ export function compressWitness(a: number, b: number): void;
12
13
  export function ecdsa_secp256r1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
13
14
  export function ecdsa_secp256k1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
14
15
  export function keccak256(a: number, b: number, c: number): void;
@@ -16,16 +17,15 @@ export function blake2s256(a: number, b: number, c: number): void;
16
17
  export function sha256(a: number, b: number, c: number): void;
17
18
  export function xor(a: number, b: number): number;
18
19
  export function and(a: number, b: number): number;
19
- export function decompressWitness(a: number, b: number, c: number): void;
20
- export function compressWitness(a: number, b: number): void;
20
+ export function initLogLevel(a: number, b: number, c: number): void;
21
21
  export function buildInfo(): number;
22
22
  export function __wbg_trap_free(a: number): void;
23
23
  export function trap___wbg_wasmer_trap(): void;
24
24
  export function __wbindgen_malloc(a: number): number;
25
25
  export function __wbindgen_realloc(a: number, b: number, c: number): number;
26
26
  export const __wbindgen_export_2: WebAssembly.Table;
27
- export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h0c6c8312617d6ad4(a: number, b: number, c: number): void;
27
+ export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hfdf1d0fa4debaf70(a: number, b: number, c: number): void;
28
28
  export function __wbindgen_add_to_stack_pointer(a: number): number;
29
29
  export function __wbindgen_free(a: number, b: number): void;
30
30
  export function __wbindgen_exn_store(a: number): void;
31
- export function wasm_bindgen__convert__closures__invoke2_mut__hc5e8ba855f687f9d(a: number, b: number, c: number, d: number): void;
31
+ export function wasm_bindgen__convert__closures__invoke2_mut__h79f8a29187e94f15(a: number, b: number, c: number, d: number): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noir-lang/acvm_js",
3
- "version": "0.40.0",
3
+ "version": "0.41.0-265bd8b.nightly",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/web/acvm_js.d.ts CHANGED
@@ -1,6 +1,29 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
5
+ *
6
+ * @param {&WasmBlackBoxFunctionSolver} solver - A black box solver.
7
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
8
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
9
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
10
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
11
+ */
12
+ export function executeCircuitWithBlackBoxSolver(solver: WasmBlackBoxFunctionSolver, circuit: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
13
+ /**
14
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
15
+ *
16
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
17
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
18
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
19
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
20
+ */
21
+ export function executeCircuit(circuit: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
22
+ /**
23
+ * @returns {Promise<WasmBlackBoxFunctionSolver>}
24
+ */
25
+ export function createBlackBoxSolver(): Promise<WasmBlackBoxFunctionSolver>;
26
+ /**
4
27
  * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
5
28
  *
6
29
  * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
@@ -34,34 +57,19 @@ export function getPublicParametersWitness(circuit: Uint8Array, solved_witness:
34
57
  */
35
58
  export function getReturnWitness(circuit: Uint8Array, witness_map: WitnessMap): WitnessMap;
36
59
  /**
37
- * Sets the package's logging level.
38
- *
39
- * @param {LogLevel} level - The maximum level of logging to be emitted.
40
- */
41
- export function initLogLevel(filter: string): void;
42
- /**
43
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
60
+ * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
44
61
  *
45
- * @param {&WasmBlackBoxFunctionSolver} solver - A black box solver.
46
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
47
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
48
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
49
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
62
+ * @param {Uint8Array} compressed_witness - A compressed witness.
63
+ * @returns {WitnessMap} The decompressed witness map.
50
64
  */
51
- export function executeCircuitWithBlackBoxSolver(solver: WasmBlackBoxFunctionSolver, circuit: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
65
+ export function decompressWitness(compressed_witness: Uint8Array): WitnessMap;
52
66
  /**
53
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
67
+ * Compresses a `WitnessMap` into the binary format outputted by Nargo.
54
68
  *
55
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
56
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
57
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
58
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
59
- */
60
- export function executeCircuit(circuit: Uint8Array, initial_witness: WitnessMap, foreign_call_handler: ForeignCallHandler): Promise<WitnessMap>;
61
- /**
62
- * @returns {Promise<WasmBlackBoxFunctionSolver>}
69
+ * @param {Uint8Array} compressed_witness - A witness map.
70
+ * @returns {WitnessMap} A compressed witness map
63
71
  */
64
- export function createBlackBoxSolver(): Promise<WasmBlackBoxFunctionSolver>;
72
+ export function compressWitness(witness_map: WitnessMap): Uint8Array;
65
73
  /**
66
74
  * Verifies a ECDSA signature over the secp256r1 curve.
67
75
  * @param {Uint8Array} hashed_msg
@@ -113,36 +121,17 @@ export function xor(lhs: string, rhs: string): string;
113
121
  */
114
122
  export function and(lhs: string, rhs: string): string;
115
123
  /**
116
- * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
117
- *
118
- * @param {Uint8Array} compressed_witness - A compressed witness.
119
- * @returns {WitnessMap} The decompressed witness map.
120
- */
121
- export function decompressWitness(compressed_witness: Uint8Array): WitnessMap;
122
- /**
123
- * Compresses a `WitnessMap` into the binary format outputted by Nargo.
124
+ * Sets the package's logging level.
124
125
  *
125
- * @param {Uint8Array} compressed_witness - A witness map.
126
- * @returns {WitnessMap} A compressed witness map
126
+ * @param {LogLevel} level - The maximum level of logging to be emitted.
127
127
  */
128
- export function compressWitness(witness_map: WitnessMap): Uint8Array;
128
+ export function initLogLevel(filter: string): void;
129
129
  /**
130
130
  * Returns the `BuildInfo` object containing information about how the installed package was built.
131
131
  * @returns {BuildInfo} - Information on how the installed package was built.
132
132
  */
133
133
  export function buildInfo(): BuildInfo;
134
134
 
135
- // Map from witness index to hex string value of witness.
136
- export type WitnessMap = Map<number, string>;
137
-
138
-
139
-
140
- export type ExecutionError = Error & {
141
- callStack?: string[];
142
- };
143
-
144
-
145
-
146
135
  export type ForeignCallInput = string[]
147
136
  export type ForeignCallOutput = string | string[]
148
137
 
@@ -157,6 +146,17 @@ export type ForeignCallHandler = (name: string, inputs: ForeignCallInput[]) => P
157
146
 
158
147
 
159
148
 
149
+ // Map from witness index to hex string value of witness.
150
+ export type WitnessMap = Map<number, string>;
151
+
152
+
153
+
154
+ export type ExecutionError = Error & {
155
+ callStack?: string[];
156
+ };
157
+
158
+
159
+
160
160
  /**
161
161
  * @typedef {Object} BuildInfo - Information about how the installed package was built
162
162
  * @property {string} gitHash - The hash of the git commit from which the package was built.
@@ -180,14 +180,15 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
180
180
 
181
181
  export interface InitOutput {
182
182
  readonly memory: WebAssembly.Memory;
183
- readonly getPublicWitness: (a: number, b: number, c: number, d: number) => void;
184
- readonly getPublicParametersWitness: (a: number, b: number, c: number, d: number) => void;
185
- readonly getReturnWitness: (a: number, b: number, c: number, d: number) => void;
186
- readonly initLogLevel: (a: number, b: number, c: number) => void;
187
183
  readonly executeCircuitWithBlackBoxSolver: (a: number, b: number, c: number, d: number, e: number) => number;
188
184
  readonly executeCircuit: (a: number, b: number, c: number, d: number) => number;
189
185
  readonly createBlackBoxSolver: () => number;
190
186
  readonly __wbg_wasmblackboxfunctionsolver_free: (a: number) => void;
187
+ readonly getPublicWitness: (a: number, b: number, c: number, d: number) => void;
188
+ readonly getPublicParametersWitness: (a: number, b: number, c: number, d: number) => void;
189
+ readonly getReturnWitness: (a: number, b: number, c: number, d: number) => void;
190
+ readonly decompressWitness: (a: number, b: number, c: number) => void;
191
+ readonly compressWitness: (a: number, b: number) => void;
191
192
  readonly ecdsa_secp256r1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
192
193
  readonly ecdsa_secp256k1_verify: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => number;
193
194
  readonly keccak256: (a: number, b: number, c: number) => void;
@@ -195,19 +196,18 @@ export interface InitOutput {
195
196
  readonly sha256: (a: number, b: number, c: number) => void;
196
197
  readonly xor: (a: number, b: number) => number;
197
198
  readonly and: (a: number, b: number) => number;
198
- readonly decompressWitness: (a: number, b: number, c: number) => void;
199
- readonly compressWitness: (a: number, b: number) => void;
199
+ readonly initLogLevel: (a: number, b: number, c: number) => void;
200
200
  readonly buildInfo: () => number;
201
201
  readonly __wbg_trap_free: (a: number) => void;
202
202
  readonly trap___wbg_wasmer_trap: () => void;
203
203
  readonly __wbindgen_malloc: (a: number) => number;
204
204
  readonly __wbindgen_realloc: (a: number, b: number, c: number) => number;
205
205
  readonly __wbindgen_export_2: WebAssembly.Table;
206
- readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h0c6c8312617d6ad4: (a: number, b: number, c: number) => void;
206
+ readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hfdf1d0fa4debaf70: (a: number, b: number, c: number) => void;
207
207
  readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
208
208
  readonly __wbindgen_free: (a: number, b: number) => void;
209
209
  readonly __wbindgen_exn_store: (a: number) => void;
210
- readonly wasm_bindgen__convert__closures__invoke2_mut__hc5e8ba855f687f9d: (a: number, b: number, c: number, d: number) => void;
210
+ readonly wasm_bindgen__convert__closures__invoke2_mut__h79f8a29187e94f15: (a: number, b: number, c: number, d: number) => void;
211
211
  }
212
212
 
213
213
  export type SyncInitInput = BufferSource | WebAssembly.Module;
package/web/acvm_js.js CHANGED
@@ -223,7 +223,14 @@ function makeMutClosure(arg0, arg1, dtor, f) {
223
223
  return real;
224
224
  }
225
225
  function __wbg_adapter_52(arg0, arg1, arg2) {
226
- wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h0c6c8312617d6ad4(arg0, arg1, addHeapObject(arg2));
226
+ wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hfdf1d0fa4debaf70(arg0, arg1, addHeapObject(arg2));
227
+ }
228
+
229
+ function _assertClass(instance, klass) {
230
+ if (!(instance instanceof klass)) {
231
+ throw new Error(`expected instance of ${klass.name}`);
232
+ }
233
+ return instance.ptr;
227
234
  }
228
235
 
229
236
  function passArray8ToWasm0(arg, malloc) {
@@ -232,6 +239,46 @@ function passArray8ToWasm0(arg, malloc) {
232
239
  WASM_VECTOR_LEN = arg.length;
233
240
  return ptr;
234
241
  }
242
+ /**
243
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
244
+ *
245
+ * @param {&WasmBlackBoxFunctionSolver} solver - A black box solver.
246
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
247
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
248
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
249
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
250
+ */
251
+ export function executeCircuitWithBlackBoxSolver(solver, circuit, initial_witness, foreign_call_handler) {
252
+ _assertClass(solver, WasmBlackBoxFunctionSolver);
253
+ const ptr0 = passArray8ToWasm0(circuit, wasm.__wbindgen_malloc);
254
+ const len0 = WASM_VECTOR_LEN;
255
+ const ret = wasm.executeCircuitWithBlackBoxSolver(solver.__wbg_ptr, ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
256
+ return takeObject(ret);
257
+ }
258
+
259
+ /**
260
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
261
+ *
262
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
263
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
264
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
265
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
266
+ */
267
+ export function executeCircuit(circuit, initial_witness, foreign_call_handler) {
268
+ const ptr0 = passArray8ToWasm0(circuit, wasm.__wbindgen_malloc);
269
+ const len0 = WASM_VECTOR_LEN;
270
+ const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
271
+ return takeObject(ret);
272
+ }
273
+
274
+ /**
275
+ * @returns {Promise<WasmBlackBoxFunctionSolver>}
276
+ */
277
+ export function createBlackBoxSolver() {
278
+ const ret = wasm.createBlackBoxSolver();
279
+ return takeObject(ret);
280
+ }
281
+
235
282
  /**
236
283
  * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
237
284
  *
@@ -317,70 +364,56 @@ export function getReturnWitness(circuit, witness_map) {
317
364
  }
318
365
 
319
366
  /**
320
- * Sets the package's logging level.
367
+ * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
321
368
  *
322
- * @param {LogLevel} level - The maximum level of logging to be emitted.
369
+ * @param {Uint8Array} compressed_witness - A compressed witness.
370
+ * @returns {WitnessMap} The decompressed witness map.
323
371
  */
324
- export function initLogLevel(filter) {
372
+ export function decompressWitness(compressed_witness) {
325
373
  try {
326
374
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
327
- const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
375
+ const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
328
376
  const len0 = WASM_VECTOR_LEN;
329
- wasm.initLogLevel(retptr, ptr0, len0);
377
+ wasm.decompressWitness(retptr, ptr0, len0);
330
378
  var r0 = getInt32Memory0()[retptr / 4 + 0];
331
379
  var r1 = getInt32Memory0()[retptr / 4 + 1];
332
- if (r1) {
333
- throw takeObject(r0);
380
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
381
+ if (r2) {
382
+ throw takeObject(r1);
334
383
  }
384
+ return takeObject(r0);
335
385
  } finally {
336
386
  wasm.__wbindgen_add_to_stack_pointer(16);
337
387
  }
338
388
  }
339
389
 
340
- function _assertClass(instance, klass) {
341
- if (!(instance instanceof klass)) {
342
- throw new Error(`expected instance of ${klass.name}`);
343
- }
344
- return instance.ptr;
345
- }
346
- /**
347
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
348
- *
349
- * @param {&WasmBlackBoxFunctionSolver} solver - A black box solver.
350
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
351
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
352
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
353
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
354
- */
355
- export function executeCircuitWithBlackBoxSolver(solver, circuit, initial_witness, foreign_call_handler) {
356
- _assertClass(solver, WasmBlackBoxFunctionSolver);
357
- const ptr0 = passArray8ToWasm0(circuit, wasm.__wbindgen_malloc);
358
- const len0 = WASM_VECTOR_LEN;
359
- const ret = wasm.executeCircuitWithBlackBoxSolver(solver.__wbg_ptr, ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
360
- return takeObject(ret);
390
+ function getArrayU8FromWasm0(ptr, len) {
391
+ ptr = ptr >>> 0;
392
+ return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
361
393
  }
362
-
363
394
  /**
364
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
395
+ * Compresses a `WitnessMap` into the binary format outputted by Nargo.
365
396
  *
366
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
367
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
368
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
369
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
370
- */
371
- export function executeCircuit(circuit, initial_witness, foreign_call_handler) {
372
- const ptr0 = passArray8ToWasm0(circuit, wasm.__wbindgen_malloc);
373
- const len0 = WASM_VECTOR_LEN;
374
- const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
375
- return takeObject(ret);
376
- }
377
-
378
- /**
379
- * @returns {Promise<WasmBlackBoxFunctionSolver>}
397
+ * @param {Uint8Array} compressed_witness - A witness map.
398
+ * @returns {WitnessMap} A compressed witness map
380
399
  */
381
- export function createBlackBoxSolver() {
382
- const ret = wasm.createBlackBoxSolver();
383
- return takeObject(ret);
400
+ export function compressWitness(witness_map) {
401
+ try {
402
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
403
+ wasm.compressWitness(retptr, addHeapObject(witness_map));
404
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
405
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
406
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
407
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
408
+ if (r3) {
409
+ throw takeObject(r2);
410
+ }
411
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
412
+ wasm.__wbindgen_free(r0, r1 * 1);
413
+ return v1;
414
+ } finally {
415
+ wasm.__wbindgen_add_to_stack_pointer(16);
416
+ }
384
417
  }
385
418
 
386
419
  /**
@@ -425,10 +458,6 @@ export function ecdsa_secp256k1_verify(hashed_msg, public_key_x_bytes, public_ke
425
458
  return ret !== 0;
426
459
  }
427
460
 
428
- function getArrayU8FromWasm0(ptr, len) {
429
- ptr = ptr >>> 0;
430
- return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
431
- }
432
461
  /**
433
462
  * Calculates the Keccak256 hash of the input bytes
434
463
  * @param {Uint8Array} inputs
@@ -515,49 +544,21 @@ export function and(lhs, rhs) {
515
544
  }
516
545
 
517
546
  /**
518
- * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
547
+ * Sets the package's logging level.
519
548
  *
520
- * @param {Uint8Array} compressed_witness - A compressed witness.
521
- * @returns {WitnessMap} The decompressed witness map.
549
+ * @param {LogLevel} level - The maximum level of logging to be emitted.
522
550
  */
523
- export function decompressWitness(compressed_witness) {
551
+ export function initLogLevel(filter) {
524
552
  try {
525
553
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
526
- const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
554
+ const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
527
555
  const len0 = WASM_VECTOR_LEN;
528
- wasm.decompressWitness(retptr, ptr0, len0);
529
- var r0 = getInt32Memory0()[retptr / 4 + 0];
530
- var r1 = getInt32Memory0()[retptr / 4 + 1];
531
- var r2 = getInt32Memory0()[retptr / 4 + 2];
532
- if (r2) {
533
- throw takeObject(r1);
534
- }
535
- return takeObject(r0);
536
- } finally {
537
- wasm.__wbindgen_add_to_stack_pointer(16);
538
- }
539
- }
540
-
541
- /**
542
- * Compresses a `WitnessMap` into the binary format outputted by Nargo.
543
- *
544
- * @param {Uint8Array} compressed_witness - A witness map.
545
- * @returns {WitnessMap} A compressed witness map
546
- */
547
- export function compressWitness(witness_map) {
548
- try {
549
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
550
- wasm.compressWitness(retptr, addHeapObject(witness_map));
556
+ wasm.initLogLevel(retptr, ptr0, len0);
551
557
  var r0 = getInt32Memory0()[retptr / 4 + 0];
552
558
  var r1 = getInt32Memory0()[retptr / 4 + 1];
553
- var r2 = getInt32Memory0()[retptr / 4 + 2];
554
- var r3 = getInt32Memory0()[retptr / 4 + 3];
555
- if (r3) {
556
- throw takeObject(r2);
559
+ if (r1) {
560
+ throw takeObject(r0);
557
561
  }
558
- var v1 = getArrayU8FromWasm0(r0, r1).slice();
559
- wasm.__wbindgen_free(r0, r1 * 1);
560
- return v1;
561
562
  } finally {
562
563
  wasm.__wbindgen_add_to_stack_pointer(16);
563
564
  }
@@ -580,7 +581,7 @@ function handleError(f, args) {
580
581
  }
581
582
  }
582
583
  function __wbg_adapter_159(arg0, arg1, arg2, arg3) {
583
- wasm.wasm_bindgen__convert__closures__invoke2_mut__hc5e8ba855f687f9d(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
584
+ wasm.wasm_bindgen__convert__closures__invoke2_mut__h79f8a29187e94f15(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
584
585
  }
585
586
 
586
587
  /**
@@ -669,27 +670,32 @@ function __wbg_get_imports() {
669
670
  imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
670
671
  takeObject(arg0);
671
672
  };
673
+ imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
674
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
675
+ return addHeapObject(ret);
676
+ };
677
+ imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
678
+ const ret = getObject(arg0);
679
+ return addHeapObject(ret);
680
+ };
672
681
  imports.wbg.__wbg_wasmblackboxfunctionsolver_new = function(arg0) {
673
682
  const ret = WasmBlackBoxFunctionSolver.__wrap(arg0);
674
683
  return addHeapObject(ret);
675
684
  };
676
- imports.wbg.__wbindgen_is_array = function(arg0) {
677
- const ret = Array.isArray(getObject(arg0));
685
+ imports.wbg.__wbindgen_cb_drop = function(arg0) {
686
+ const obj = takeObject(arg0).original;
687
+ if (obj.cnt-- == 1) {
688
+ obj.a = 0;
689
+ return true;
690
+ }
691
+ const ret = false;
678
692
  return ret;
679
693
  };
680
694
  imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
681
695
  const ret = getStringFromWasm0(arg0, arg1);
682
696
  return addHeapObject(ret);
683
697
  };
684
- imports.wbg.__wbg_constructor_8444207292d12e94 = function(arg0) {
685
- const ret = new Error(takeObject(arg0));
686
- return addHeapObject(ret);
687
- };
688
- imports.wbg.__wbindgen_is_string = function(arg0) {
689
- const ret = typeof(getObject(arg0)) === 'string';
690
- return ret;
691
- };
692
- imports.wbg.__wbg_new_12499e712355d566 = function() {
698
+ imports.wbg.__wbg_new_ab82e8584bdd2143 = function() {
693
699
  const ret = new Map();
694
700
  return addHeapObject(ret);
695
701
  };
@@ -705,31 +711,26 @@ function __wbg_get_imports() {
705
711
  getInt32Memory0()[arg0 / 4 + 1] = len1;
706
712
  getInt32Memory0()[arg0 / 4 + 0] = ptr1;
707
713
  };
714
+ imports.wbg.__wbg_constructor_d9cb984c4e2c6bcd = function(arg0) {
715
+ const ret = new Error(takeObject(arg0));
716
+ return addHeapObject(ret);
717
+ };
708
718
  imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
709
719
  const obj = getObject(arg1);
710
720
  const ret = typeof(obj) === 'number' ? obj : undefined;
711
721
  getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
712
722
  getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
713
723
  };
714
- imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
715
- const ret = new Error(getStringFromWasm0(arg0, arg1));
716
- return addHeapObject(ret);
717
- };
718
- imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
719
- const ret = getObject(arg0);
720
- return addHeapObject(ret);
724
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
725
+ const ret = getObject(arg0) === undefined;
726
+ return ret;
721
727
  };
722
- imports.wbg.__wbindgen_cb_drop = function(arg0) {
723
- const obj = takeObject(arg0).original;
724
- if (obj.cnt-- == 1) {
725
- obj.a = 0;
726
- return true;
727
- }
728
- const ret = false;
728
+ imports.wbg.__wbindgen_is_string = function(arg0) {
729
+ const ret = typeof(getObject(arg0)) === 'string';
729
730
  return ret;
730
731
  };
731
- imports.wbg.__wbindgen_is_undefined = function(arg0) {
732
- const ret = getObject(arg0) === undefined;
732
+ imports.wbg.__wbindgen_is_array = function(arg0) {
733
+ const ret = Array.isArray(getObject(arg0));
733
734
  return ret;
734
735
  };
735
736
  imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
@@ -754,14 +755,6 @@ function __wbg_get_imports() {
754
755
  wasm.__wbindgen_free(deferred0_0, deferred0_1);
755
756
  }
756
757
  };
757
- imports.wbg.__wbindgen_bigint_from_i64 = function(arg0) {
758
- const ret = arg0;
759
- return addHeapObject(ret);
760
- };
761
- imports.wbg.__wbindgen_bigint_from_u128 = function(arg0, arg1) {
762
- const ret = BigInt.asUintN(64, arg0) << BigInt(64) | BigInt.asUintN(64, arg1);
763
- return addHeapObject(ret);
764
- };
765
758
  imports.wbg.__wbindgen_ge = function(arg0, arg1) {
766
759
  const ret = getObject(arg0) >= getObject(arg1);
767
760
  return ret;
@@ -782,7 +775,24 @@ function __wbg_get_imports() {
782
775
  const ret = typeof(getObject(arg0)) === 'bigint';
783
776
  return ret;
784
777
  };
785
- imports.wbg.__wbg_instanceof_Global_1c3b64df1a5c886c = function(arg0) {
778
+ imports.wbg.__wbindgen_bigint_from_i64 = function(arg0) {
779
+ const ret = arg0;
780
+ return addHeapObject(ret);
781
+ };
782
+ imports.wbg.__wbindgen_bigint_from_u128 = function(arg0, arg1) {
783
+ const ret = BigInt.asUintN(64, arg0) << BigInt(64) | BigInt.asUintN(64, arg1);
784
+ return addHeapObject(ret);
785
+ };
786
+ imports.wbg.__wbindgen_is_object = function(arg0) {
787
+ const val = getObject(arg0);
788
+ const ret = typeof(val) === 'object' && val !== null;
789
+ return ret;
790
+ };
791
+ imports.wbg.__wbindgen_is_function = function(arg0) {
792
+ const ret = typeof(getObject(arg0)) === 'function';
793
+ return ret;
794
+ };
795
+ imports.wbg.__wbg_instanceof_Global_f4b019d2b45e18ab = function(arg0) {
786
796
  let result;
787
797
  try {
788
798
  result = getObject(arg0) instanceof WebAssembly.Global;
@@ -792,15 +802,6 @@ function __wbg_get_imports() {
792
802
  const ret = result;
793
803
  return ret;
794
804
  };
795
- imports.wbg.__wbindgen_is_function = function(arg0) {
796
- const ret = typeof(getObject(arg0)) === 'function';
797
- return ret;
798
- };
799
- imports.wbg.__wbindgen_is_object = function(arg0) {
800
- const val = getObject(arg0);
801
- const ret = typeof(val) === 'object' && val !== null;
802
- return ret;
803
- };
804
805
  imports.wbg.__wbg_crypto_c48a774b022d20ac = function(arg0) {
805
806
  const ret = getObject(arg0).crypto;
806
807
  return addHeapObject(ret);
@@ -1072,6 +1073,10 @@ function __wbg_get_imports() {
1072
1073
  const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
1073
1074
  return addHeapObject(ret);
1074
1075
  };
1076
+ imports.wbg.__wbg_parse_76a8a18ca3f8730b = function() { return handleError(function (arg0, arg1) {
1077
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
1078
+ return addHeapObject(ret);
1079
+ }, arguments) };
1075
1080
  imports.wbg.__wbg_compile_eefe73dfb19bff3d = function(arg0) {
1076
1081
  const ret = WebAssembly.compile(getObject(arg0));
1077
1082
  return addHeapObject(ret);
@@ -1128,10 +1133,6 @@ function __wbg_get_imports() {
1128
1133
  const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
1129
1134
  return ret;
1130
1135
  }, arguments) };
1131
- imports.wbg.__wbg_parse_76a8a18ca3f8730b = function() { return handleError(function (arg0, arg1) {
1132
- const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
1133
- return addHeapObject(ret);
1134
- }, arguments) };
1135
1136
  imports.wbg.__wbindgen_bigint_get_as_i64 = function(arg0, arg1) {
1136
1137
  const v = getObject(arg1);
1137
1138
  const ret = typeof(v) === 'bigint' ? v : undefined;
@@ -1156,8 +1157,8 @@ function __wbg_get_imports() {
1156
1157
  const ret = wasm.__wbindgen_export_2;
1157
1158
  return addHeapObject(ret);
1158
1159
  };
1159
- imports.wbg.__wbindgen_closure_wrapper1433 = function(arg0, arg1, arg2) {
1160
- const ret = makeMutClosure(arg0, arg1, 501, __wbg_adapter_52);
1160
+ imports.wbg.__wbindgen_closure_wrapper1388 = function(arg0, arg1, arg2) {
1161
+ const ret = makeMutClosure(arg0, arg1, 484, __wbg_adapter_52);
1161
1162
  return addHeapObject(ret);
1162
1163
  };
1163
1164
 
Binary file
@@ -1,14 +1,15 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
- export function getPublicWitness(a: number, b: number, c: number, d: number): void;
5
- export function getPublicParametersWitness(a: number, b: number, c: number, d: number): void;
6
- export function getReturnWitness(a: number, b: number, c: number, d: number): void;
7
- export function initLogLevel(a: number, b: number, c: number): void;
8
4
  export function executeCircuitWithBlackBoxSolver(a: number, b: number, c: number, d: number, e: number): number;
9
5
  export function executeCircuit(a: number, b: number, c: number, d: number): number;
10
6
  export function createBlackBoxSolver(): number;
11
7
  export function __wbg_wasmblackboxfunctionsolver_free(a: number): void;
8
+ export function getPublicWitness(a: number, b: number, c: number, d: number): void;
9
+ export function getPublicParametersWitness(a: number, b: number, c: number, d: number): void;
10
+ export function getReturnWitness(a: number, b: number, c: number, d: number): void;
11
+ export function decompressWitness(a: number, b: number, c: number): void;
12
+ export function compressWitness(a: number, b: number): void;
12
13
  export function ecdsa_secp256r1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
13
14
  export function ecdsa_secp256k1_verify(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number): number;
14
15
  export function keccak256(a: number, b: number, c: number): void;
@@ -16,16 +17,15 @@ export function blake2s256(a: number, b: number, c: number): void;
16
17
  export function sha256(a: number, b: number, c: number): void;
17
18
  export function xor(a: number, b: number): number;
18
19
  export function and(a: number, b: number): number;
19
- export function decompressWitness(a: number, b: number, c: number): void;
20
- export function compressWitness(a: number, b: number): void;
20
+ export function initLogLevel(a: number, b: number, c: number): void;
21
21
  export function buildInfo(): number;
22
22
  export function __wbg_trap_free(a: number): void;
23
23
  export function trap___wbg_wasmer_trap(): void;
24
24
  export function __wbindgen_malloc(a: number): number;
25
25
  export function __wbindgen_realloc(a: number, b: number, c: number): number;
26
26
  export const __wbindgen_export_2: WebAssembly.Table;
27
- export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h0c6c8312617d6ad4(a: number, b: number, c: number): void;
27
+ export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hfdf1d0fa4debaf70(a: number, b: number, c: number): void;
28
28
  export function __wbindgen_add_to_stack_pointer(a: number): number;
29
29
  export function __wbindgen_free(a: number, b: number): void;
30
30
  export function __wbindgen_exn_store(a: number): void;
31
- export function wasm_bindgen__convert__closures__invoke2_mut__hc5e8ba855f687f9d(a: number, b: number, c: number, d: number): void;
31
+ export function wasm_bindgen__convert__closures__invoke2_mut__h79f8a29187e94f15(a: number, b: number, c: number, d: number): void;