@noir-lang/acvm_js 0.42.0 → 0.43.0-90ee479.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.
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
 
@@ -32,7 +32,9 @@ function addHeapObject(obj) {
32
32
  return idx;
33
33
  }
34
34
 
35
- let WASM_VECTOR_LEN = 0;
35
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
36
+
37
+ cachedTextDecoder.decode();
36
38
 
37
39
  let cachedUint8Memory0 = null;
38
40
 
@@ -43,6 +45,35 @@ function getUint8Memory0() {
43
45
  return cachedUint8Memory0;
44
46
  }
45
47
 
48
+ function getStringFromWasm0(ptr, len) {
49
+ ptr = ptr >>> 0;
50
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
51
+ }
52
+
53
+ function isLikeNone(x) {
54
+ return x === undefined || x === null;
55
+ }
56
+
57
+ let cachedFloat64Memory0 = null;
58
+
59
+ function getFloat64Memory0() {
60
+ if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
61
+ cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
62
+ }
63
+ return cachedFloat64Memory0;
64
+ }
65
+
66
+ let cachedInt32Memory0 = null;
67
+
68
+ function getInt32Memory0() {
69
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
70
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
71
+ }
72
+ return cachedInt32Memory0;
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];
@@ -501,71 +492,149 @@ module.exports.getReturnWitness = function(program, witness_map) {
501
492
  *
502
493
  * @param {LogLevel} level - The maximum level of logging to be emitted.
503
494
  */
504
- module.exports.initLogLevel = function(filter) {
495
+ module.exports.initLogLevel = function(filter) {
496
+ try {
497
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
498
+ const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
499
+ const len0 = WASM_VECTOR_LEN;
500
+ wasm.initLogLevel(retptr, ptr0, len0);
501
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
502
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
503
+ if (r1) {
504
+ throw takeObject(r0);
505
+ }
506
+ } finally {
507
+ wasm.__wbindgen_add_to_stack_pointer(16);
508
+ }
509
+ };
510
+
511
+ /**
512
+ * Performs a bitwise AND operation between `lhs` and `rhs`
513
+ * @param {string} lhs
514
+ * @param {string} rhs
515
+ * @returns {string}
516
+ */
517
+ module.exports.and = function(lhs, rhs) {
518
+ const ret = wasm.and(addHeapObject(lhs), addHeapObject(rhs));
519
+ return takeObject(ret);
520
+ };
521
+
522
+ /**
523
+ * Performs a bitwise XOR operation between `lhs` and `rhs`
524
+ * @param {string} lhs
525
+ * @param {string} rhs
526
+ * @returns {string}
527
+ */
528
+ module.exports.xor = function(lhs, rhs) {
529
+ const ret = wasm.xor(addHeapObject(lhs), addHeapObject(rhs));
530
+ return takeObject(ret);
531
+ };
532
+
533
+ /**
534
+ * Calculates the SHA256 hash of the input bytes
535
+ * @param {Uint8Array} inputs
536
+ * @returns {Uint8Array}
537
+ */
538
+ module.exports.sha256 = function(inputs) {
505
539
  try {
506
540
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
507
- const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
541
+ const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
508
542
  const len0 = WASM_VECTOR_LEN;
509
- wasm.initLogLevel(retptr, ptr0, len0);
543
+ wasm.sha256(retptr, ptr0, len0);
510
544
  var r0 = getInt32Memory0()[retptr / 4 + 0];
511
545
  var r1 = getInt32Memory0()[retptr / 4 + 1];
512
- if (r1) {
513
- throw takeObject(r0);
514
- }
546
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
547
+ wasm.__wbindgen_free(r0, r1 * 1);
548
+ return v2;
515
549
  } finally {
516
550
  wasm.__wbindgen_add_to_stack_pointer(16);
517
551
  }
518
552
  };
519
553
 
520
554
  /**
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.
555
+ * Calculates the Blake2s256 hash of the input bytes
556
+ * @param {Uint8Array} inputs
557
+ * @returns {Uint8Array}
525
558
  */
526
- module.exports.decompressWitness = function(compressed_witness) {
559
+ module.exports.blake2s256 = function(inputs) {
527
560
  try {
528
561
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
529
- const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
562
+ const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
530
563
  const len0 = WASM_VECTOR_LEN;
531
- wasm.decompressWitness(retptr, ptr0, len0);
564
+ wasm.blake2s256(retptr, ptr0, len0);
532
565
  var r0 = getInt32Memory0()[retptr / 4 + 0];
533
566
  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);
567
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
568
+ wasm.__wbindgen_free(r0, r1 * 1);
569
+ return v2;
539
570
  } finally {
540
571
  wasm.__wbindgen_add_to_stack_pointer(16);
541
572
  }
542
573
  };
543
574
 
544
575
  /**
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
576
+ * Calculates the Keccak256 hash of the input bytes
577
+ * @param {Uint8Array} inputs
578
+ * @returns {Uint8Array}
549
579
  */
550
- module.exports.compressWitness = function(witness_map) {
580
+ module.exports.keccak256 = function(inputs) {
551
581
  try {
552
582
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
553
- wasm.compressWitness(retptr, addHeapObject(witness_map));
583
+ const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
584
+ const len0 = WASM_VECTOR_LEN;
585
+ wasm.keccak256(retptr, ptr0, len0);
554
586
  var r0 = getInt32Memory0()[retptr / 4 + 0];
555
587
  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();
588
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
562
589
  wasm.__wbindgen_free(r0, r1 * 1);
563
- return v1;
590
+ return v2;
564
591
  } finally {
565
592
  wasm.__wbindgen_add_to_stack_pointer(16);
566
593
  }
567
594
  };
568
595
 
596
+ /**
597
+ * Verifies a ECDSA signature over the secp256k1 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_secp256k1_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_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
614
+ return ret !== 0;
615
+ };
616
+
617
+ /**
618
+ * Verifies a ECDSA signature over the secp256r1 curve.
619
+ * @param {Uint8Array} hashed_msg
620
+ * @param {Uint8Array} public_key_x_bytes
621
+ * @param {Uint8Array} public_key_y_bytes
622
+ * @param {Uint8Array} signature
623
+ * @returns {boolean}
624
+ */
625
+ module.exports.ecdsa_secp256r1_verify = function(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
626
+ const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
627
+ const len0 = WASM_VECTOR_LEN;
628
+ const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
629
+ const len1 = WASM_VECTOR_LEN;
630
+ const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
631
+ const len2 = WASM_VECTOR_LEN;
632
+ const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
633
+ const len3 = WASM_VECTOR_LEN;
634
+ const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
635
+ return ret !== 0;
636
+ };
637
+
569
638
  /**
570
639
  * Returns the `BuildInfo` object containing information about how the installed package was built.
571
640
  * @returns {BuildInfo} - Information on how the installed package was built.
@@ -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,47 +714,28 @@ module.exports.__wbindgen_object_drop_ref = function(arg0) {
641
714
  takeObject(arg0);
642
715
  };
643
716
 
644
- module.exports.__wbindgen_object_clone_ref = function(arg0) {
645
- const ret = getObject(arg0);
646
- return addHeapObject(ret);
647
- };
648
-
649
- module.exports.__wbg_new_0d2c031c3755a625 = function() {
650
- const ret = new Map();
651
- return addHeapObject(ret);
652
- };
653
-
654
- module.exports.__wbindgen_number_new = function(arg0) {
655
- const ret = arg0;
717
+ module.exports.__wbg_wasmblackboxfunctionsolver_new = function(arg0) {
718
+ const ret = WasmBlackBoxFunctionSolver.__wrap(arg0);
656
719
  return addHeapObject(ret);
657
720
  };
658
721
 
659
- module.exports.__wbindgen_string_get = function(arg0, arg1) {
660
- const obj = getObject(arg1);
661
- const ret = typeof(obj) === 'string' ? obj : undefined;
662
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
663
- var len1 = WASM_VECTOR_LEN;
664
- getInt32Memory0()[arg0 / 4 + 1] = len1;
665
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
666
- };
667
-
668
- module.exports.__wbg_constructor_9a4af6ecd5050c55 = function(arg0) {
669
- const ret = new Error(takeObject(arg0));
670
- return addHeapObject(ret);
722
+ module.exports.__wbindgen_is_array = function(arg0) {
723
+ const ret = Array.isArray(getObject(arg0));
724
+ return ret;
671
725
  };
672
726
 
673
- module.exports.__wbindgen_string_new = function(arg0, arg1) {
674
- const ret = getStringFromWasm0(arg0, arg1);
727
+ module.exports.__wbindgen_object_clone_ref = function(arg0) {
728
+ const ret = getObject(arg0);
675
729
  return addHeapObject(ret);
676
730
  };
677
731
 
678
- module.exports.__wbg_wasmblackboxfunctionsolver_new = function(arg0) {
679
- const ret = WasmBlackBoxFunctionSolver.__wrap(arg0);
732
+ module.exports.__wbindgen_error_new = function(arg0, arg1) {
733
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
680
734
  return addHeapObject(ret);
681
735
  };
682
736
 
683
- module.exports.__wbindgen_error_new = function(arg0, arg1) {
684
- const ret = new Error(getStringFromWasm0(arg0, arg1));
737
+ module.exports.__wbg_constructor_885d22c82fec0fdb = function(arg0) {
738
+ const ret = new Error(takeObject(arg0));
685
739
  return addHeapObject(ret);
686
740
  };
687
741
 
@@ -692,6 +746,11 @@ module.exports.__wbindgen_number_get = function(arg0, arg1) {
692
746
  getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
693
747
  };
694
748
 
749
+ module.exports.__wbindgen_string_new = function(arg0, arg1) {
750
+ const ret = getStringFromWasm0(arg0, arg1);
751
+ return addHeapObject(ret);
752
+ };
753
+
695
754
  module.exports.__wbindgen_is_undefined = function(arg0) {
696
755
  const ret = getObject(arg0) === undefined;
697
756
  return ret;
@@ -702,9 +761,28 @@ module.exports.__wbindgen_is_string = function(arg0) {
702
761
  return ret;
703
762
  };
704
763
 
705
- module.exports.__wbindgen_is_array = function(arg0) {
706
- const ret = Array.isArray(getObject(arg0));
707
- return ret;
764
+ module.exports.__wbindgen_string_get = function(arg0, arg1) {
765
+ const obj = getObject(arg1);
766
+ const ret = typeof(obj) === 'string' ? obj : undefined;
767
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
768
+ var len1 = WASM_VECTOR_LEN;
769
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
770
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
771
+ };
772
+
773
+ module.exports.__wbg_new_e1076c3a38c86fee = function() {
774
+ const ret = new Map();
775
+ return addHeapObject(ret);
776
+ };
777
+
778
+ module.exports.__wbindgen_number_new = function(arg0) {
779
+ const ret = arg0;
780
+ return addHeapObject(ret);
781
+ };
782
+
783
+ module.exports.__wbg_new_967d701c7af7cc58 = function() {
784
+ const ret = new Array();
785
+ return addHeapObject(ret);
708
786
  };
709
787
 
710
788
  module.exports.__wbindgen_cb_drop = function(arg0) {
@@ -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_wrapper2084 = function(arg0, arg1, arg2) {
1350
+ const ret = makeMutClosure(arg0, arg1, 718, __wbg_adapter_52);
1235
1351
  return addHeapObject(ret);
1236
1352
  };
1237
1353