@noir-lang/acvm_js 0.42.0 → 0.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/nodejs/acvm_js.js CHANGED
@@ -1,7 +1,7 @@
1
1
  let imports = {};
2
2
  imports['__wbindgen_placeholder__'] = module.exports;
3
3
  let wasm;
4
- const { TextEncoder, TextDecoder } = require(`util`);
4
+ const { TextDecoder, TextEncoder } = require(`util`);
5
5
 
6
6
  const heap = new Array(128).fill(undefined);
7
7
 
@@ -23,16 +23,31 @@ function takeObject(idx) {
23
23
  return ret;
24
24
  }
25
25
 
26
- function addHeapObject(obj) {
27
- if (heap_next === heap.length) heap.push(heap.length + 1);
28
- const idx = heap_next;
29
- heap_next = heap[idx];
26
+ function isLikeNone(x) {
27
+ return x === undefined || x === null;
28
+ }
30
29
 
31
- heap[idx] = obj;
32
- return idx;
30
+ let cachedFloat64Memory0 = null;
31
+
32
+ function getFloat64Memory0() {
33
+ if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
34
+ cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
35
+ }
36
+ return cachedFloat64Memory0;
33
37
  }
34
38
 
35
- let WASM_VECTOR_LEN = 0;
39
+ let cachedInt32Memory0 = null;
40
+
41
+ function getInt32Memory0() {
42
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
43
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
44
+ }
45
+ return cachedInt32Memory0;
46
+ }
47
+
48
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
49
+
50
+ cachedTextDecoder.decode();
36
51
 
37
52
  let cachedUint8Memory0 = null;
38
53
 
@@ -43,6 +58,22 @@ function getUint8Memory0() {
43
58
  return cachedUint8Memory0;
44
59
  }
45
60
 
61
+ function getStringFromWasm0(ptr, len) {
62
+ ptr = ptr >>> 0;
63
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
64
+ }
65
+
66
+ function addHeapObject(obj) {
67
+ if (heap_next === heap.length) heap.push(heap.length + 1);
68
+ const idx = heap_next;
69
+ heap_next = heap[idx];
70
+
71
+ heap[idx] = obj;
72
+ return idx;
73
+ }
74
+
75
+ let WASM_VECTOR_LEN = 0;
76
+
46
77
  let cachedTextEncoder = new TextEncoder('utf-8');
47
78
 
48
79
  const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
@@ -96,37 +127,6 @@ function passStringToWasm0(arg, malloc, realloc) {
96
127
  return ptr;
97
128
  }
98
129
 
99
- function isLikeNone(x) {
100
- return x === undefined || x === null;
101
- }
102
-
103
- let cachedInt32Memory0 = null;
104
-
105
- function getInt32Memory0() {
106
- if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
107
- cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
108
- }
109
- return cachedInt32Memory0;
110
- }
111
-
112
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
113
-
114
- cachedTextDecoder.decode();
115
-
116
- function getStringFromWasm0(ptr, len) {
117
- ptr = ptr >>> 0;
118
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
119
- }
120
-
121
- let cachedFloat64Memory0 = null;
122
-
123
- function getFloat64Memory0() {
124
- if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
125
- cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
126
- }
127
- return cachedFloat64Memory0;
128
- }
129
-
130
130
  let cachedBigInt64Memory0 = null;
131
131
 
132
132
  function getBigInt64Memory0() {
@@ -229,140 +229,135 @@ function __wbg_adapter_52(arg0, arg1, arg2) {
229
229
  wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hfdf1d0fa4debaf70(arg0, arg1, addHeapObject(arg2));
230
230
  }
231
231
 
232
- function passArray8ToWasm0(arg, malloc) {
233
- const ptr = malloc(arg.length * 1) >>> 0;
234
- getUint8Memory0().set(arg, ptr / 1);
235
- WASM_VECTOR_LEN = arg.length;
236
- return ptr;
232
+ function getArrayU8FromWasm0(ptr, len) {
233
+ ptr = ptr >>> 0;
234
+ return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
237
235
  }
238
236
  /**
239
- * Verifies a ECDSA signature over the secp256r1 curve.
240
- * @param {Uint8Array} hashed_msg
241
- * @param {Uint8Array} public_key_x_bytes
242
- * @param {Uint8Array} public_key_y_bytes
243
- * @param {Uint8Array} signature
244
- * @returns {boolean}
245
- */
246
- module.exports.ecdsa_secp256r1_verify = function(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
247
- const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
248
- const len0 = WASM_VECTOR_LEN;
249
- const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
250
- const len1 = WASM_VECTOR_LEN;
251
- const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
252
- const len2 = WASM_VECTOR_LEN;
253
- const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
254
- const len3 = WASM_VECTOR_LEN;
255
- const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
256
- return ret !== 0;
257
- };
258
-
259
- /**
260
- * Verifies a ECDSA signature over the secp256k1 curve.
261
- * @param {Uint8Array} hashed_msg
262
- * @param {Uint8Array} public_key_x_bytes
263
- * @param {Uint8Array} public_key_y_bytes
264
- * @param {Uint8Array} signature
265
- * @returns {boolean}
237
+ * Compresses a `WitnessMap` into the binary format outputted by Nargo.
238
+ *
239
+ * @param {WitnessMap} witness_map - A witness map.
240
+ * @returns {Uint8Array} A compressed witness map
266
241
  */
267
- module.exports.ecdsa_secp256k1_verify = function(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
268
- const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
269
- const len0 = WASM_VECTOR_LEN;
270
- const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
271
- const len1 = WASM_VECTOR_LEN;
272
- const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
273
- const len2 = WASM_VECTOR_LEN;
274
- const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
275
- const len3 = WASM_VECTOR_LEN;
276
- const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
277
- return ret !== 0;
242
+ module.exports.compressWitness = function(witness_map) {
243
+ try {
244
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
245
+ wasm.compressWitness(retptr, addHeapObject(witness_map));
246
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
247
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
248
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
249
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
250
+ if (r3) {
251
+ throw takeObject(r2);
252
+ }
253
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
254
+ wasm.__wbindgen_free(r0, r1 * 1);
255
+ return v1;
256
+ } finally {
257
+ wasm.__wbindgen_add_to_stack_pointer(16);
258
+ }
278
259
  };
279
260
 
280
- function getArrayU8FromWasm0(ptr, len) {
281
- ptr = ptr >>> 0;
282
- return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
261
+ function passArray8ToWasm0(arg, malloc) {
262
+ const ptr = malloc(arg.length * 1) >>> 0;
263
+ getUint8Memory0().set(arg, ptr / 1);
264
+ WASM_VECTOR_LEN = arg.length;
265
+ return ptr;
283
266
  }
284
267
  /**
285
- * Calculates the Keccak256 hash of the input bytes
286
- * @param {Uint8Array} inputs
287
- * @returns {Uint8Array}
268
+ * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
269
+ * This should be used to only fetch the witness map for the main function.
270
+ *
271
+ * @param {Uint8Array} compressed_witness - A compressed witness.
272
+ * @returns {WitnessMap} The decompressed witness map.
288
273
  */
289
- module.exports.keccak256 = function(inputs) {
274
+ module.exports.decompressWitness = function(compressed_witness) {
290
275
  try {
291
276
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
292
- const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
277
+ const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
293
278
  const len0 = WASM_VECTOR_LEN;
294
- wasm.keccak256(retptr, ptr0, len0);
279
+ wasm.decompressWitness(retptr, ptr0, len0);
295
280
  var r0 = getInt32Memory0()[retptr / 4 + 0];
296
281
  var r1 = getInt32Memory0()[retptr / 4 + 1];
297
- var v2 = getArrayU8FromWasm0(r0, r1).slice();
298
- wasm.__wbindgen_free(r0, r1 * 1);
299
- return v2;
282
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
283
+ if (r2) {
284
+ throw takeObject(r1);
285
+ }
286
+ return takeObject(r0);
300
287
  } finally {
301
288
  wasm.__wbindgen_add_to_stack_pointer(16);
302
289
  }
303
290
  };
304
291
 
305
292
  /**
306
- * Calculates the Blake2s256 hash of the input bytes
307
- * @param {Uint8Array} inputs
308
- * @returns {Uint8Array}
293
+ * Compresses a `WitnessStack` into the binary format outputted by Nargo.
294
+ *
295
+ * @param {WitnessStack} witness_stack - A witness stack.
296
+ * @returns {Uint8Array} A compressed witness stack
309
297
  */
310
- module.exports.blake2s256 = function(inputs) {
298
+ module.exports.compressWitnessStack = function(witness_stack) {
311
299
  try {
312
300
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
313
- const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
314
- const len0 = WASM_VECTOR_LEN;
315
- wasm.blake2s256(retptr, ptr0, len0);
301
+ wasm.compressWitnessStack(retptr, addHeapObject(witness_stack));
316
302
  var r0 = getInt32Memory0()[retptr / 4 + 0];
317
303
  var r1 = getInt32Memory0()[retptr / 4 + 1];
318
- var v2 = getArrayU8FromWasm0(r0, r1).slice();
304
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
305
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
306
+ if (r3) {
307
+ throw takeObject(r2);
308
+ }
309
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
319
310
  wasm.__wbindgen_free(r0, r1 * 1);
320
- return v2;
311
+ return v1;
321
312
  } finally {
322
313
  wasm.__wbindgen_add_to_stack_pointer(16);
323
314
  }
324
315
  };
325
316
 
326
317
  /**
327
- * Calculates the SHA256 hash of the input bytes
328
- * @param {Uint8Array} inputs
329
- * @returns {Uint8Array}
318
+ * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
319
+ *
320
+ * @param {Uint8Array} compressed_witness - A compressed witness.
321
+ * @returns {WitnessStack} The decompressed witness stack.
330
322
  */
331
- module.exports.sha256 = function(inputs) {
323
+ module.exports.decompressWitnessStack = function(compressed_witness) {
332
324
  try {
333
325
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
334
- const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
326
+ const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
335
327
  const len0 = WASM_VECTOR_LEN;
336
- wasm.sha256(retptr, ptr0, len0);
328
+ wasm.decompressWitnessStack(retptr, ptr0, len0);
337
329
  var r0 = getInt32Memory0()[retptr / 4 + 0];
338
330
  var r1 = getInt32Memory0()[retptr / 4 + 1];
339
- var v2 = getArrayU8FromWasm0(r0, r1).slice();
340
- wasm.__wbindgen_free(r0, r1 * 1);
341
- return v2;
331
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
332
+ if (r2) {
333
+ throw takeObject(r1);
334
+ }
335
+ return takeObject(r0);
342
336
  } finally {
343
337
  wasm.__wbindgen_add_to_stack_pointer(16);
344
338
  }
345
339
  };
346
340
 
347
341
  /**
348
- * Performs a bitwise XOR operation between `lhs` and `rhs`
349
- * @param {string} lhs
350
- * @param {string} rhs
351
- * @returns {string}
342
+ * @returns {Promise<WasmBlackBoxFunctionSolver>}
352
343
  */
353
- module.exports.xor = function(lhs, rhs) {
354
- const ret = wasm.xor(addHeapObject(lhs), addHeapObject(rhs));
344
+ module.exports.createBlackBoxSolver = function() {
345
+ const ret = wasm.createBlackBoxSolver();
355
346
  return takeObject(ret);
356
347
  };
357
348
 
358
349
  /**
359
- * Performs a bitwise AND operation between `lhs` and `rhs`
360
- * @param {string} lhs
361
- * @param {string} rhs
362
- * @returns {string}
350
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
351
+ *
352
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
353
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
354
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
355
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
363
356
  */
364
- module.exports.and = function(lhs, rhs) {
365
- const ret = wasm.and(addHeapObject(lhs), addHeapObject(rhs));
357
+ module.exports.executeCircuit = function(program, initial_witness, foreign_call_handler) {
358
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
359
+ const len0 = WASM_VECTOR_LEN;
360
+ const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
366
361
  return takeObject(ret);
367
362
  };
368
363
 
@@ -390,44 +385,40 @@ module.exports.executeCircuitWithBlackBoxSolver = function(solver, program, init
390
385
  };
391
386
 
392
387
  /**
393
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
394
- *
395
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
396
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
397
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
398
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
399
388
  */
400
- module.exports.executeCircuit = function(program, initial_witness, foreign_call_handler) {
389
+ module.exports.executeProgram = function(program, initial_witness, foreign_call_handler) {
401
390
  const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
402
391
  const len0 = WASM_VECTOR_LEN;
403
- const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
392
+ const ret = wasm.executeProgram(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
404
393
  return takeObject(ret);
405
394
  };
406
395
 
407
396
  /**
408
- * @returns {Promise<WasmBlackBoxFunctionSolver>}
409
397
  */
410
- module.exports.createBlackBoxSolver = function() {
411
- const ret = wasm.createBlackBoxSolver();
398
+ module.exports.executeProgramWithBlackBoxSolver = function(solver, program, initial_witness, foreign_call_executor) {
399
+ _assertClass(solver, WasmBlackBoxFunctionSolver);
400
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
401
+ const len0 = WASM_VECTOR_LEN;
402
+ const ret = wasm.executeProgramWithBlackBoxSolver(solver.__wbg_ptr, ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_executor));
412
403
  return takeObject(ret);
413
404
  };
414
405
 
415
406
  /**
416
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
407
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
417
408
  *
418
409
  * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
419
410
  * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
420
- * @returns {WitnessMap} A witness map containing the circuit's public inputs.
411
+ * @returns {WitnessMap} A witness map containing the circuit's return values.
421
412
  * @param {Uint8Array} program
422
- * @param {WitnessMap} solved_witness
413
+ * @param {WitnessMap} witness_map
423
414
  * @returns {WitnessMap}
424
415
  */
425
- module.exports.getPublicWitness = function(program, solved_witness) {
416
+ module.exports.getReturnWitness = function(program, witness_map) {
426
417
  try {
427
418
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
428
419
  const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
429
420
  const len0 = WASM_VECTOR_LEN;
430
- wasm.getPublicWitness(retptr, ptr0, len0, addHeapObject(solved_witness));
421
+ wasm.getReturnWitness(retptr, ptr0, len0, addHeapObject(witness_map));
431
422
  var r0 = getInt32Memory0()[retptr / 4 + 0];
432
423
  var r1 = getInt32Memory0()[retptr / 4 + 1];
433
424
  var r2 = getInt32Memory0()[retptr / 4 + 2];
@@ -469,21 +460,21 @@ module.exports.getPublicParametersWitness = function(program, solved_witness) {
469
460
  };
470
461
 
471
462
  /**
472
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
463
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
473
464
  *
474
465
  * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
475
466
  * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
476
- * @returns {WitnessMap} A witness map containing the circuit's return values.
467
+ * @returns {WitnessMap} A witness map containing the circuit's public inputs.
477
468
  * @param {Uint8Array} program
478
- * @param {WitnessMap} witness_map
469
+ * @param {WitnessMap} solved_witness
479
470
  * @returns {WitnessMap}
480
471
  */
481
- module.exports.getReturnWitness = function(program, witness_map) {
472
+ module.exports.getPublicWitness = function(program, solved_witness) {
482
473
  try {
483
474
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
484
475
  const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
485
476
  const len0 = WASM_VECTOR_LEN;
486
- wasm.getReturnWitness(retptr, ptr0, len0, addHeapObject(witness_map));
477
+ wasm.getPublicWitness(retptr, ptr0, len0, addHeapObject(solved_witness));
487
478
  var r0 = getInt32Memory0()[retptr / 4 + 0];
488
479
  var r1 = getInt32Memory0()[retptr / 4 + 1];
489
480
  var r2 = getInt32Memory0()[retptr / 4 + 2];
@@ -497,75 +488,132 @@ module.exports.getReturnWitness = function(program, witness_map) {
497
488
  };
498
489
 
499
490
  /**
500
- * Sets the package's logging level.
501
- *
502
- * @param {LogLevel} level - The maximum level of logging to be emitted.
491
+ * Performs a bitwise AND operation between `lhs` and `rhs`
492
+ * @param {string} lhs
493
+ * @param {string} rhs
494
+ * @returns {string}
503
495
  */
504
- module.exports.initLogLevel = function(filter) {
496
+ module.exports.and = function(lhs, rhs) {
497
+ const ret = wasm.and(addHeapObject(lhs), addHeapObject(rhs));
498
+ return takeObject(ret);
499
+ };
500
+
501
+ /**
502
+ * Performs a bitwise XOR operation between `lhs` and `rhs`
503
+ * @param {string} lhs
504
+ * @param {string} rhs
505
+ * @returns {string}
506
+ */
507
+ module.exports.xor = function(lhs, rhs) {
508
+ const ret = wasm.xor(addHeapObject(lhs), addHeapObject(rhs));
509
+ return takeObject(ret);
510
+ };
511
+
512
+ /**
513
+ * Calculates the SHA256 hash of the input bytes
514
+ * @param {Uint8Array} inputs
515
+ * @returns {Uint8Array}
516
+ */
517
+ module.exports.sha256 = function(inputs) {
505
518
  try {
506
519
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
507
- const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
520
+ const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
508
521
  const len0 = WASM_VECTOR_LEN;
509
- wasm.initLogLevel(retptr, ptr0, len0);
522
+ wasm.sha256(retptr, ptr0, len0);
510
523
  var r0 = getInt32Memory0()[retptr / 4 + 0];
511
524
  var r1 = getInt32Memory0()[retptr / 4 + 1];
512
- if (r1) {
513
- throw takeObject(r0);
514
- }
525
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
526
+ wasm.__wbindgen_free(r0, r1 * 1);
527
+ return v2;
515
528
  } finally {
516
529
  wasm.__wbindgen_add_to_stack_pointer(16);
517
530
  }
518
531
  };
519
532
 
520
533
  /**
521
- * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
522
- *
523
- * @param {Uint8Array} compressed_witness - A compressed witness.
524
- * @returns {WitnessMap} The decompressed witness map.
534
+ * Calculates the Blake2s256 hash of the input bytes
535
+ * @param {Uint8Array} inputs
536
+ * @returns {Uint8Array}
525
537
  */
526
- module.exports.decompressWitness = function(compressed_witness) {
538
+ module.exports.blake2s256 = function(inputs) {
527
539
  try {
528
540
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
529
- const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
541
+ const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
530
542
  const len0 = WASM_VECTOR_LEN;
531
- wasm.decompressWitness(retptr, ptr0, len0);
543
+ wasm.blake2s256(retptr, ptr0, len0);
532
544
  var r0 = getInt32Memory0()[retptr / 4 + 0];
533
545
  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);
546
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
547
+ wasm.__wbindgen_free(r0, r1 * 1);
548
+ return v2;
539
549
  } finally {
540
550
  wasm.__wbindgen_add_to_stack_pointer(16);
541
551
  }
542
552
  };
543
553
 
544
554
  /**
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
555
+ * Calculates the Keccak256 hash of the input bytes
556
+ * @param {Uint8Array} inputs
557
+ * @returns {Uint8Array}
549
558
  */
550
- module.exports.compressWitness = function(witness_map) {
559
+ module.exports.keccak256 = function(inputs) {
551
560
  try {
552
561
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
553
- wasm.compressWitness(retptr, addHeapObject(witness_map));
562
+ const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
563
+ const len0 = WASM_VECTOR_LEN;
564
+ wasm.keccak256(retptr, ptr0, len0);
554
565
  var r0 = getInt32Memory0()[retptr / 4 + 0];
555
566
  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);
560
- }
561
- var v1 = getArrayU8FromWasm0(r0, r1).slice();
567
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
562
568
  wasm.__wbindgen_free(r0, r1 * 1);
563
- return v1;
569
+ return v2;
564
570
  } finally {
565
571
  wasm.__wbindgen_add_to_stack_pointer(16);
566
572
  }
567
573
  };
568
574
 
575
+ /**
576
+ * Verifies a ECDSA signature over the secp256k1 curve.
577
+ * @param {Uint8Array} hashed_msg
578
+ * @param {Uint8Array} public_key_x_bytes
579
+ * @param {Uint8Array} public_key_y_bytes
580
+ * @param {Uint8Array} signature
581
+ * @returns {boolean}
582
+ */
583
+ module.exports.ecdsa_secp256k1_verify = function(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
584
+ const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
585
+ const len0 = WASM_VECTOR_LEN;
586
+ const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
587
+ const len1 = WASM_VECTOR_LEN;
588
+ const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
589
+ const len2 = WASM_VECTOR_LEN;
590
+ const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
591
+ const len3 = WASM_VECTOR_LEN;
592
+ const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
593
+ return ret !== 0;
594
+ };
595
+
596
+ /**
597
+ * Verifies a ECDSA signature over the secp256r1 curve.
598
+ * @param {Uint8Array} hashed_msg
599
+ * @param {Uint8Array} public_key_x_bytes
600
+ * @param {Uint8Array} public_key_y_bytes
601
+ * @param {Uint8Array} signature
602
+ * @returns {boolean}
603
+ */
604
+ module.exports.ecdsa_secp256r1_verify = function(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
605
+ const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
606
+ const len0 = WASM_VECTOR_LEN;
607
+ const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
608
+ const len1 = WASM_VECTOR_LEN;
609
+ const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
610
+ const len2 = WASM_VECTOR_LEN;
611
+ const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
612
+ const len3 = WASM_VECTOR_LEN;
613
+ const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
614
+ return ret !== 0;
615
+ };
616
+
569
617
  /**
570
618
  * Returns the `BuildInfo` object containing information about how the installed package was built.
571
619
  * @returns {BuildInfo} - Information on how the installed package was built.
@@ -575,6 +623,27 @@ module.exports.buildInfo = function() {
575
623
  return takeObject(ret);
576
624
  };
577
625
 
626
+ /**
627
+ * Sets the package's logging level.
628
+ *
629
+ * @param {LogLevel} level - The maximum level of logging to be emitted.
630
+ */
631
+ module.exports.initLogLevel = function(filter) {
632
+ try {
633
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
634
+ const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
635
+ const len0 = WASM_VECTOR_LEN;
636
+ wasm.initLogLevel(retptr, ptr0, len0);
637
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
638
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
639
+ if (r1) {
640
+ throw takeObject(r0);
641
+ }
642
+ } finally {
643
+ wasm.__wbindgen_add_to_stack_pointer(16);
644
+ }
645
+ };
646
+
578
647
  function handleError(f, args) {
579
648
  try {
580
649
  return f.apply(this, args);
@@ -582,7 +651,11 @@ function handleError(f, args) {
582
651
  wasm.__wbindgen_exn_store(addHeapObject(e));
583
652
  }
584
653
  }
585
- function __wbg_adapter_159(arg0, arg1, arg2, arg3) {
654
+ function __wbg_adapter_133(arg0, arg1, arg2, arg3, arg4) {
655
+ wasm.wasm_bindgen__convert__closures__invoke3_mut__h28a07b2d2a2056af(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4));
656
+ }
657
+
658
+ function __wbg_adapter_170(arg0, arg1, arg2, arg3) {
586
659
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h79f8a29187e94f15(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
587
660
  }
588
661
 
@@ -641,19 +714,46 @@ module.exports.__wbindgen_object_drop_ref = function(arg0) {
641
714
  takeObject(arg0);
642
715
  };
643
716
 
717
+ module.exports.__wbg_wasmblackboxfunctionsolver_new = function(arg0) {
718
+ const ret = WasmBlackBoxFunctionSolver.__wrap(arg0);
719
+ return addHeapObject(ret);
720
+ };
721
+
722
+ module.exports.__wbindgen_is_array = function(arg0) {
723
+ const ret = Array.isArray(getObject(arg0));
724
+ return ret;
725
+ };
726
+
727
+ module.exports.__wbindgen_number_get = function(arg0, arg1) {
728
+ const obj = getObject(arg1);
729
+ const ret = typeof(obj) === 'number' ? obj : undefined;
730
+ getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
731
+ getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
732
+ };
733
+
734
+ module.exports.__wbindgen_string_new = function(arg0, arg1) {
735
+ const ret = getStringFromWasm0(arg0, arg1);
736
+ return addHeapObject(ret);
737
+ };
738
+
739
+ module.exports.__wbindgen_is_undefined = function(arg0) {
740
+ const ret = getObject(arg0) === undefined;
741
+ return ret;
742
+ };
743
+
644
744
  module.exports.__wbindgen_object_clone_ref = function(arg0) {
645
745
  const ret = getObject(arg0);
646
746
  return addHeapObject(ret);
647
747
  };
648
748
 
649
- module.exports.__wbg_new_0d2c031c3755a625 = function() {
650
- const ret = new Map();
749
+ module.exports.__wbindgen_error_new = function(arg0, arg1) {
750
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
651
751
  return addHeapObject(ret);
652
752
  };
653
753
 
654
- module.exports.__wbindgen_number_new = function(arg0) {
655
- const ret = arg0;
656
- return addHeapObject(ret);
754
+ module.exports.__wbindgen_is_string = function(arg0) {
755
+ const ret = typeof(getObject(arg0)) === 'string';
756
+ return ret;
657
757
  };
658
758
 
659
759
  module.exports.__wbindgen_string_get = function(arg0, arg1) {
@@ -665,48 +765,26 @@ module.exports.__wbindgen_string_get = function(arg0, arg1) {
665
765
  getInt32Memory0()[arg0 / 4 + 0] = ptr1;
666
766
  };
667
767
 
668
- module.exports.__wbg_constructor_9a4af6ecd5050c55 = function(arg0) {
768
+ module.exports.__wbg_constructor_885d22c82fec0fdb = function(arg0) {
669
769
  const ret = new Error(takeObject(arg0));
670
770
  return addHeapObject(ret);
671
771
  };
672
772
 
673
- module.exports.__wbindgen_string_new = function(arg0, arg1) {
674
- const ret = getStringFromWasm0(arg0, arg1);
773
+ module.exports.__wbg_new_e1076c3a38c86fee = function() {
774
+ const ret = new Map();
675
775
  return addHeapObject(ret);
676
776
  };
677
777
 
678
- module.exports.__wbg_wasmblackboxfunctionsolver_new = function(arg0) {
679
- const ret = WasmBlackBoxFunctionSolver.__wrap(arg0);
778
+ module.exports.__wbindgen_number_new = function(arg0) {
779
+ const ret = arg0;
680
780
  return addHeapObject(ret);
681
781
  };
682
782
 
683
- module.exports.__wbindgen_error_new = function(arg0, arg1) {
684
- const ret = new Error(getStringFromWasm0(arg0, arg1));
783
+ module.exports.__wbg_new_967d701c7af7cc58 = function() {
784
+ const ret = new Array();
685
785
  return addHeapObject(ret);
686
786
  };
687
787
 
688
- module.exports.__wbindgen_number_get = function(arg0, arg1) {
689
- const obj = getObject(arg1);
690
- const ret = typeof(obj) === 'number' ? obj : undefined;
691
- getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
692
- getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
693
- };
694
-
695
- module.exports.__wbindgen_is_undefined = function(arg0) {
696
- const ret = getObject(arg0) === undefined;
697
- return ret;
698
- };
699
-
700
- module.exports.__wbindgen_is_string = function(arg0) {
701
- const ret = typeof(getObject(arg0)) === 'string';
702
- return ret;
703
- };
704
-
705
- module.exports.__wbindgen_is_array = function(arg0) {
706
- const ret = Array.isArray(getObject(arg0));
707
- return ret;
708
- };
709
-
710
788
  module.exports.__wbindgen_cb_drop = function(arg0) {
711
789
  const obj = takeObject(arg0).original;
712
790
  if (obj.cnt-- == 1) {
@@ -799,6 +877,38 @@ module.exports.__wbg_instanceof_Global_f4b019d2b45e18ab = function(arg0) {
799
877
  return ret;
800
878
  };
801
879
 
880
+ module.exports.__wbg_debug_e3f6a1578e6d45ca = function(arg0) {
881
+ console.debug(getObject(arg0));
882
+ };
883
+
884
+ module.exports.__wbg_debug_efabe4eb183aa5d4 = function(arg0, arg1, arg2, arg3) {
885
+ console.debug(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
886
+ };
887
+
888
+ module.exports.__wbg_error_a7e23606158b68b9 = function(arg0) {
889
+ console.error(getObject(arg0));
890
+ };
891
+
892
+ module.exports.__wbg_error_50f42b952a595a23 = function(arg0, arg1, arg2, arg3) {
893
+ console.error(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
894
+ };
895
+
896
+ module.exports.__wbg_info_05db236d79f1b785 = function(arg0) {
897
+ console.info(getObject(arg0));
898
+ };
899
+
900
+ module.exports.__wbg_info_24d8f53d98f12b95 = function(arg0, arg1, arg2, arg3) {
901
+ console.info(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
902
+ };
903
+
904
+ module.exports.__wbg_warn_9bdd743e9f5fe1e0 = function(arg0) {
905
+ console.warn(getObject(arg0));
906
+ };
907
+
908
+ module.exports.__wbg_warn_8342bfbc6028193a = function(arg0, arg1, arg2, arg3) {
909
+ console.warn(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
910
+ };
911
+
802
912
  module.exports.__wbg_crypto_c48a774b022d20ac = function(arg0) {
803
913
  const ret = getObject(arg0).crypto;
804
914
  return addHeapObject(ret);
@@ -837,38 +947,6 @@ module.exports.__wbg_randomFillSync_dc1e9a60c158336d = function() { return handl
837
947
  getObject(arg0).randomFillSync(takeObject(arg1));
838
948
  }, arguments) };
839
949
 
840
- module.exports.__wbg_debug_e3f6a1578e6d45ca = function(arg0) {
841
- console.debug(getObject(arg0));
842
- };
843
-
844
- module.exports.__wbg_debug_efabe4eb183aa5d4 = function(arg0, arg1, arg2, arg3) {
845
- console.debug(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
846
- };
847
-
848
- module.exports.__wbg_error_a7e23606158b68b9 = function(arg0) {
849
- console.error(getObject(arg0));
850
- };
851
-
852
- module.exports.__wbg_error_50f42b952a595a23 = function(arg0, arg1, arg2, arg3) {
853
- console.error(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
854
- };
855
-
856
- module.exports.__wbg_info_05db236d79f1b785 = function(arg0) {
857
- console.info(getObject(arg0));
858
- };
859
-
860
- module.exports.__wbg_info_24d8f53d98f12b95 = function(arg0, arg1, arg2, arg3) {
861
- console.info(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
862
- };
863
-
864
- module.exports.__wbg_warn_9bdd743e9f5fe1e0 = function(arg0) {
865
- console.warn(getObject(arg0));
866
- };
867
-
868
- module.exports.__wbg_warn_8342bfbc6028193a = function(arg0, arg1, arg2, arg3) {
869
- console.warn(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
870
- };
871
-
872
950
  module.exports.__wbg_get_7303ed2ef026b2f5 = function(arg0, arg1) {
873
951
  const ret = getObject(arg0)[arg1 >>> 0];
874
952
  return addHeapObject(ret);
@@ -894,6 +972,11 @@ module.exports.__wbg_newnoargs_c9e6043b8ad84109 = function(arg0, arg1) {
894
972
  return addHeapObject(ret);
895
973
  };
896
974
 
975
+ module.exports.__wbg_new_0f2b71ca2f2a6029 = function() {
976
+ const ret = new Map();
977
+ return addHeapObject(ret);
978
+ };
979
+
897
980
  module.exports.__wbg_get_f53c921291c381bd = function() { return handleError(function (arg0, arg1) {
898
981
  const ret = Reflect.get(getObject(arg0), getObject(arg1));
899
982
  return addHeapObject(ret);
@@ -943,11 +1026,34 @@ module.exports.__wbg_from_6bc98a09a0b58bb1 = function(arg0) {
943
1026
  return addHeapObject(ret);
944
1027
  };
945
1028
 
1029
+ module.exports.__wbg_forEach_5ae261259d7517c8 = function(arg0, arg1, arg2) {
1030
+ try {
1031
+ var state0 = {a: arg1, b: arg2};
1032
+ var cb0 = (arg0, arg1, arg2) => {
1033
+ const a = state0.a;
1034
+ state0.a = 0;
1035
+ try {
1036
+ return __wbg_adapter_133(a, state0.b, arg0, arg1, arg2);
1037
+ } finally {
1038
+ state0.a = a;
1039
+ }
1040
+ };
1041
+ getObject(arg0).forEach(cb0);
1042
+ } finally {
1043
+ state0.a = state0.b = 0;
1044
+ }
1045
+ };
1046
+
946
1047
  module.exports.__wbg_push_109cfc26d02582dd = function(arg0, arg1) {
947
1048
  const ret = getObject(arg0).push(getObject(arg1));
948
1049
  return ret;
949
1050
  };
950
1051
 
1052
+ module.exports.__wbg_reverse_a322332d916e2705 = function(arg0) {
1053
+ const ret = getObject(arg0).reverse();
1054
+ return addHeapObject(ret);
1055
+ };
1056
+
951
1057
  module.exports.__wbg_byteLength_1a59a59856fc656a = function(arg0) {
952
1058
  const ret = getObject(arg0).byteLength;
953
1059
  return ret;
@@ -1024,7 +1130,7 @@ module.exports.__wbg_forEach_942772130a8d06a6 = function(arg0, arg1, arg2) {
1024
1130
  const a = state0.a;
1025
1131
  state0.a = 0;
1026
1132
  try {
1027
- return __wbg_adapter_159(a, state0.b, arg0, arg1);
1133
+ return __wbg_adapter_170(a, state0.b, arg0, arg1);
1028
1134
  } finally {
1029
1135
  state0.a = a;
1030
1136
  }
@@ -1056,11 +1162,21 @@ module.exports.__wbg_constructor_f2623999a1f453eb = function(arg0) {
1056
1162
  return addHeapObject(ret);
1057
1163
  };
1058
1164
 
1165
+ module.exports.__wbg_fromEntries_d1b310956d20d858 = function() { return handleError(function (arg0) {
1166
+ const ret = Object.fromEntries(getObject(arg0));
1167
+ return addHeapObject(ret);
1168
+ }, arguments) };
1169
+
1059
1170
  module.exports.__wbg_toString_e2b23ac99490a381 = function(arg0) {
1060
1171
  const ret = getObject(arg0).toString();
1061
1172
  return addHeapObject(ret);
1062
1173
  };
1063
1174
 
1175
+ module.exports.__wbg_values_099fd000c271c313 = function(arg0) {
1176
+ const ret = Object.values(getObject(arg0));
1177
+ return addHeapObject(ret);
1178
+ };
1179
+
1064
1180
  module.exports.__wbg_new_2b55e405e4af4986 = function(arg0, arg1) {
1065
1181
  try {
1066
1182
  var state0 = {a: arg0, b: arg1};
@@ -1068,7 +1184,7 @@ module.exports.__wbg_new_2b55e405e4af4986 = function(arg0, arg1) {
1068
1184
  const a = state0.a;
1069
1185
  state0.a = 0;
1070
1186
  try {
1071
- return __wbg_adapter_159(a, state0.b, arg0, arg1);
1187
+ return __wbg_adapter_170(a, state0.b, arg0, arg1);
1072
1188
  } finally {
1073
1189
  state0.a = a;
1074
1190
  }
@@ -1230,8 +1346,8 @@ module.exports.__wbindgen_function_table = function() {
1230
1346
  return addHeapObject(ret);
1231
1347
  };
1232
1348
 
1233
- module.exports.__wbindgen_closure_wrapper1401 = function(arg0, arg1, arg2) {
1234
- const ret = makeMutClosure(arg0, arg1, 486, __wbg_adapter_52);
1349
+ module.exports.__wbindgen_closure_wrapper2087 = function(arg0, arg1, arg2) {
1350
+ const ret = makeMutClosure(arg0, arg1, 718, __wbg_adapter_52);
1235
1351
  return addHeapObject(ret);
1236
1352
  };
1237
1353