@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/web/acvm_js.js CHANGED
@@ -20,16 +20,31 @@ function takeObject(idx) {
20
20
  return ret;
21
21
  }
22
22
 
23
- function addHeapObject(obj) {
24
- if (heap_next === heap.length) heap.push(heap.length + 1);
25
- const idx = heap_next;
26
- heap_next = heap[idx];
23
+ function isLikeNone(x) {
24
+ return x === undefined || x === null;
25
+ }
27
26
 
28
- heap[idx] = obj;
29
- return idx;
27
+ let cachedFloat64Memory0 = null;
28
+
29
+ function getFloat64Memory0() {
30
+ if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
31
+ cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
32
+ }
33
+ return cachedFloat64Memory0;
30
34
  }
31
35
 
32
- let WASM_VECTOR_LEN = 0;
36
+ let cachedInt32Memory0 = null;
37
+
38
+ function getInt32Memory0() {
39
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
40
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
41
+ }
42
+ return cachedInt32Memory0;
43
+ }
44
+
45
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
46
+
47
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
33
48
 
34
49
  let cachedUint8Memory0 = null;
35
50
 
@@ -40,6 +55,22 @@ function getUint8Memory0() {
40
55
  return cachedUint8Memory0;
41
56
  }
42
57
 
58
+ function getStringFromWasm0(ptr, len) {
59
+ ptr = ptr >>> 0;
60
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
61
+ }
62
+
63
+ function addHeapObject(obj) {
64
+ if (heap_next === heap.length) heap.push(heap.length + 1);
65
+ const idx = heap_next;
66
+ heap_next = heap[idx];
67
+
68
+ heap[idx] = obj;
69
+ return idx;
70
+ }
71
+
72
+ let WASM_VECTOR_LEN = 0;
73
+
43
74
  const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
44
75
 
45
76
  const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
@@ -93,37 +124,6 @@ function passStringToWasm0(arg, malloc, realloc) {
93
124
  return ptr;
94
125
  }
95
126
 
96
- function isLikeNone(x) {
97
- return x === undefined || x === null;
98
- }
99
-
100
- let cachedInt32Memory0 = null;
101
-
102
- function getInt32Memory0() {
103
- if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
104
- cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
105
- }
106
- return cachedInt32Memory0;
107
- }
108
-
109
- const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
110
-
111
- if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
112
-
113
- function getStringFromWasm0(ptr, len) {
114
- ptr = ptr >>> 0;
115
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
116
- }
117
-
118
- let cachedFloat64Memory0 = null;
119
-
120
- function getFloat64Memory0() {
121
- if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
122
- cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
123
- }
124
- return cachedFloat64Memory0;
125
- }
126
-
127
127
  let cachedBigInt64Memory0 = null;
128
128
 
129
129
  function getBigInt64Memory0() {
@@ -226,140 +226,135 @@ function __wbg_adapter_52(arg0, arg1, arg2) {
226
226
  wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hfdf1d0fa4debaf70(arg0, arg1, addHeapObject(arg2));
227
227
  }
228
228
 
229
- function passArray8ToWasm0(arg, malloc) {
230
- const ptr = malloc(arg.length * 1) >>> 0;
231
- getUint8Memory0().set(arg, ptr / 1);
232
- WASM_VECTOR_LEN = arg.length;
233
- return ptr;
234
- }
235
- /**
236
- * Verifies a ECDSA signature over the secp256r1 curve.
237
- * @param {Uint8Array} hashed_msg
238
- * @param {Uint8Array} public_key_x_bytes
239
- * @param {Uint8Array} public_key_y_bytes
240
- * @param {Uint8Array} signature
241
- * @returns {boolean}
242
- */
243
- export function ecdsa_secp256r1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
244
- const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
245
- const len0 = WASM_VECTOR_LEN;
246
- const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
247
- const len1 = WASM_VECTOR_LEN;
248
- const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
249
- const len2 = WASM_VECTOR_LEN;
250
- const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
251
- const len3 = WASM_VECTOR_LEN;
252
- const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
253
- return ret !== 0;
229
+ function getArrayU8FromWasm0(ptr, len) {
230
+ ptr = ptr >>> 0;
231
+ return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
254
232
  }
255
-
256
233
  /**
257
- * Verifies a ECDSA signature over the secp256k1 curve.
258
- * @param {Uint8Array} hashed_msg
259
- * @param {Uint8Array} public_key_x_bytes
260
- * @param {Uint8Array} public_key_y_bytes
261
- * @param {Uint8Array} signature
262
- * @returns {boolean}
234
+ * Compresses a `WitnessMap` into the binary format outputted by Nargo.
235
+ *
236
+ * @param {WitnessMap} witness_map - A witness map.
237
+ * @returns {Uint8Array} A compressed witness map
263
238
  */
264
- export function ecdsa_secp256k1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
265
- const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
266
- const len0 = WASM_VECTOR_LEN;
267
- const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
268
- const len1 = WASM_VECTOR_LEN;
269
- const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
270
- const len2 = WASM_VECTOR_LEN;
271
- const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
272
- const len3 = WASM_VECTOR_LEN;
273
- const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
274
- return ret !== 0;
239
+ export function compressWitness(witness_map) {
240
+ try {
241
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
242
+ wasm.compressWitness(retptr, addHeapObject(witness_map));
243
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
244
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
245
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
246
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
247
+ if (r3) {
248
+ throw takeObject(r2);
249
+ }
250
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
251
+ wasm.__wbindgen_free(r0, r1 * 1);
252
+ return v1;
253
+ } finally {
254
+ wasm.__wbindgen_add_to_stack_pointer(16);
255
+ }
275
256
  }
276
257
 
277
- function getArrayU8FromWasm0(ptr, len) {
278
- ptr = ptr >>> 0;
279
- return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
258
+ function passArray8ToWasm0(arg, malloc) {
259
+ const ptr = malloc(arg.length * 1) >>> 0;
260
+ getUint8Memory0().set(arg, ptr / 1);
261
+ WASM_VECTOR_LEN = arg.length;
262
+ return ptr;
280
263
  }
281
264
  /**
282
- * Calculates the Keccak256 hash of the input bytes
283
- * @param {Uint8Array} inputs
284
- * @returns {Uint8Array}
265
+ * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
266
+ * This should be used to only fetch the witness map for the main function.
267
+ *
268
+ * @param {Uint8Array} compressed_witness - A compressed witness.
269
+ * @returns {WitnessMap} The decompressed witness map.
285
270
  */
286
- export function keccak256(inputs) {
271
+ export function decompressWitness(compressed_witness) {
287
272
  try {
288
273
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
289
- const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
274
+ const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
290
275
  const len0 = WASM_VECTOR_LEN;
291
- wasm.keccak256(retptr, ptr0, len0);
276
+ wasm.decompressWitness(retptr, ptr0, len0);
292
277
  var r0 = getInt32Memory0()[retptr / 4 + 0];
293
278
  var r1 = getInt32Memory0()[retptr / 4 + 1];
294
- var v2 = getArrayU8FromWasm0(r0, r1).slice();
295
- wasm.__wbindgen_free(r0, r1 * 1);
296
- return v2;
279
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
280
+ if (r2) {
281
+ throw takeObject(r1);
282
+ }
283
+ return takeObject(r0);
297
284
  } finally {
298
285
  wasm.__wbindgen_add_to_stack_pointer(16);
299
286
  }
300
287
  }
301
288
 
302
289
  /**
303
- * Calculates the Blake2s256 hash of the input bytes
304
- * @param {Uint8Array} inputs
305
- * @returns {Uint8Array}
290
+ * Compresses a `WitnessStack` into the binary format outputted by Nargo.
291
+ *
292
+ * @param {WitnessStack} witness_stack - A witness stack.
293
+ * @returns {Uint8Array} A compressed witness stack
306
294
  */
307
- export function blake2s256(inputs) {
295
+ export function compressWitnessStack(witness_stack) {
308
296
  try {
309
297
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
310
- const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
311
- const len0 = WASM_VECTOR_LEN;
312
- wasm.blake2s256(retptr, ptr0, len0);
298
+ wasm.compressWitnessStack(retptr, addHeapObject(witness_stack));
313
299
  var r0 = getInt32Memory0()[retptr / 4 + 0];
314
300
  var r1 = getInt32Memory0()[retptr / 4 + 1];
315
- var v2 = getArrayU8FromWasm0(r0, r1).slice();
301
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
302
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
303
+ if (r3) {
304
+ throw takeObject(r2);
305
+ }
306
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
316
307
  wasm.__wbindgen_free(r0, r1 * 1);
317
- return v2;
308
+ return v1;
318
309
  } finally {
319
310
  wasm.__wbindgen_add_to_stack_pointer(16);
320
311
  }
321
312
  }
322
313
 
323
314
  /**
324
- * Calculates the SHA256 hash of the input bytes
325
- * @param {Uint8Array} inputs
326
- * @returns {Uint8Array}
315
+ * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
316
+ *
317
+ * @param {Uint8Array} compressed_witness - A compressed witness.
318
+ * @returns {WitnessStack} The decompressed witness stack.
327
319
  */
328
- export function sha256(inputs) {
320
+ export function decompressWitnessStack(compressed_witness) {
329
321
  try {
330
322
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
331
- const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
323
+ const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
332
324
  const len0 = WASM_VECTOR_LEN;
333
- wasm.sha256(retptr, ptr0, len0);
325
+ wasm.decompressWitnessStack(retptr, ptr0, len0);
334
326
  var r0 = getInt32Memory0()[retptr / 4 + 0];
335
327
  var r1 = getInt32Memory0()[retptr / 4 + 1];
336
- var v2 = getArrayU8FromWasm0(r0, r1).slice();
337
- wasm.__wbindgen_free(r0, r1 * 1);
338
- return v2;
328
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
329
+ if (r2) {
330
+ throw takeObject(r1);
331
+ }
332
+ return takeObject(r0);
339
333
  } finally {
340
334
  wasm.__wbindgen_add_to_stack_pointer(16);
341
335
  }
342
336
  }
343
337
 
344
338
  /**
345
- * Performs a bitwise XOR operation between `lhs` and `rhs`
346
- * @param {string} lhs
347
- * @param {string} rhs
348
- * @returns {string}
339
+ * @returns {Promise<WasmBlackBoxFunctionSolver>}
349
340
  */
350
- export function xor(lhs, rhs) {
351
- const ret = wasm.xor(addHeapObject(lhs), addHeapObject(rhs));
341
+ export function createBlackBoxSolver() {
342
+ const ret = wasm.createBlackBoxSolver();
352
343
  return takeObject(ret);
353
344
  }
354
345
 
355
346
  /**
356
- * Performs a bitwise AND operation between `lhs` and `rhs`
357
- * @param {string} lhs
358
- * @param {string} rhs
359
- * @returns {string}
347
+ * Executes an ACIR circuit to generate the solved witness from the initial witness.
348
+ *
349
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
350
+ * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
351
+ * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
352
+ * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
360
353
  */
361
- export function and(lhs, rhs) {
362
- const ret = wasm.and(addHeapObject(lhs), addHeapObject(rhs));
354
+ export function executeCircuit(program, initial_witness, foreign_call_handler) {
355
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
356
+ const len0 = WASM_VECTOR_LEN;
357
+ const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
363
358
  return takeObject(ret);
364
359
  }
365
360
 
@@ -387,44 +382,40 @@ export function executeCircuitWithBlackBoxSolver(solver, program, initial_witnes
387
382
  }
388
383
 
389
384
  /**
390
- * Executes an ACIR circuit to generate the solved witness from the initial witness.
391
- *
392
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
393
- * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
394
- * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
395
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
396
385
  */
397
- export function executeCircuit(program, initial_witness, foreign_call_handler) {
386
+ export function executeProgram(program, initial_witness, foreign_call_handler) {
398
387
  const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
399
388
  const len0 = WASM_VECTOR_LEN;
400
- const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
389
+ const ret = wasm.executeProgram(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
401
390
  return takeObject(ret);
402
391
  }
403
392
 
404
393
  /**
405
- * @returns {Promise<WasmBlackBoxFunctionSolver>}
406
394
  */
407
- export function createBlackBoxSolver() {
408
- const ret = wasm.createBlackBoxSolver();
395
+ export function executeProgramWithBlackBoxSolver(solver, program, initial_witness, foreign_call_executor) {
396
+ _assertClass(solver, WasmBlackBoxFunctionSolver);
397
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
398
+ const len0 = WASM_VECTOR_LEN;
399
+ const ret = wasm.executeProgramWithBlackBoxSolver(solver.__wbg_ptr, ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_executor));
409
400
  return takeObject(ret);
410
401
  }
411
402
 
412
403
  /**
413
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
404
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
414
405
  *
415
406
  * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
416
407
  * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
417
- * @returns {WitnessMap} A witness map containing the circuit's public inputs.
408
+ * @returns {WitnessMap} A witness map containing the circuit's return values.
418
409
  * @param {Uint8Array} program
419
- * @param {WitnessMap} solved_witness
410
+ * @param {WitnessMap} witness_map
420
411
  * @returns {WitnessMap}
421
412
  */
422
- export function getPublicWitness(program, solved_witness) {
413
+ export function getReturnWitness(program, witness_map) {
423
414
  try {
424
415
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
425
416
  const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
426
417
  const len0 = WASM_VECTOR_LEN;
427
- wasm.getPublicWitness(retptr, ptr0, len0, addHeapObject(solved_witness));
418
+ wasm.getReturnWitness(retptr, ptr0, len0, addHeapObject(witness_map));
428
419
  var r0 = getInt32Memory0()[retptr / 4 + 0];
429
420
  var r1 = getInt32Memory0()[retptr / 4 + 1];
430
421
  var r2 = getInt32Memory0()[retptr / 4 + 2];
@@ -466,21 +457,21 @@ export function getPublicParametersWitness(program, solved_witness) {
466
457
  }
467
458
 
468
459
  /**
469
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
460
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
470
461
  *
471
462
  * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
472
463
  * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
473
- * @returns {WitnessMap} A witness map containing the circuit's return values.
464
+ * @returns {WitnessMap} A witness map containing the circuit's public inputs.
474
465
  * @param {Uint8Array} program
475
- * @param {WitnessMap} witness_map
466
+ * @param {WitnessMap} solved_witness
476
467
  * @returns {WitnessMap}
477
468
  */
478
- export function getReturnWitness(program, witness_map) {
469
+ export function getPublicWitness(program, solved_witness) {
479
470
  try {
480
471
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
481
472
  const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
482
473
  const len0 = WASM_VECTOR_LEN;
483
- wasm.getReturnWitness(retptr, ptr0, len0, addHeapObject(witness_map));
474
+ wasm.getPublicWitness(retptr, ptr0, len0, addHeapObject(solved_witness));
484
475
  var r0 = getInt32Memory0()[retptr / 4 + 0];
485
476
  var r1 = getInt32Memory0()[retptr / 4 + 1];
486
477
  var r2 = getInt32Memory0()[retptr / 4 + 2];
@@ -494,75 +485,132 @@ export function getReturnWitness(program, witness_map) {
494
485
  }
495
486
 
496
487
  /**
497
- * Sets the package's logging level.
498
- *
499
- * @param {LogLevel} level - The maximum level of logging to be emitted.
488
+ * Performs a bitwise AND operation between `lhs` and `rhs`
489
+ * @param {string} lhs
490
+ * @param {string} rhs
491
+ * @returns {string}
492
+ */
493
+ export function and(lhs, rhs) {
494
+ const ret = wasm.and(addHeapObject(lhs), addHeapObject(rhs));
495
+ return takeObject(ret);
496
+ }
497
+
498
+ /**
499
+ * Performs a bitwise XOR operation between `lhs` and `rhs`
500
+ * @param {string} lhs
501
+ * @param {string} rhs
502
+ * @returns {string}
503
+ */
504
+ export function xor(lhs, rhs) {
505
+ const ret = wasm.xor(addHeapObject(lhs), addHeapObject(rhs));
506
+ return takeObject(ret);
507
+ }
508
+
509
+ /**
510
+ * Calculates the SHA256 hash of the input bytes
511
+ * @param {Uint8Array} inputs
512
+ * @returns {Uint8Array}
500
513
  */
501
- export function initLogLevel(filter) {
514
+ export function sha256(inputs) {
502
515
  try {
503
516
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
504
- const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
517
+ const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
505
518
  const len0 = WASM_VECTOR_LEN;
506
- wasm.initLogLevel(retptr, ptr0, len0);
519
+ wasm.sha256(retptr, ptr0, len0);
507
520
  var r0 = getInt32Memory0()[retptr / 4 + 0];
508
521
  var r1 = getInt32Memory0()[retptr / 4 + 1];
509
- if (r1) {
510
- throw takeObject(r0);
511
- }
522
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
523
+ wasm.__wbindgen_free(r0, r1 * 1);
524
+ return v2;
512
525
  } finally {
513
526
  wasm.__wbindgen_add_to_stack_pointer(16);
514
527
  }
515
528
  }
516
529
 
517
530
  /**
518
- * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
519
- *
520
- * @param {Uint8Array} compressed_witness - A compressed witness.
521
- * @returns {WitnessMap} The decompressed witness map.
531
+ * Calculates the Blake2s256 hash of the input bytes
532
+ * @param {Uint8Array} inputs
533
+ * @returns {Uint8Array}
522
534
  */
523
- export function decompressWitness(compressed_witness) {
535
+ export function blake2s256(inputs) {
524
536
  try {
525
537
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
526
- const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
538
+ const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
527
539
  const len0 = WASM_VECTOR_LEN;
528
- wasm.decompressWitness(retptr, ptr0, len0);
540
+ wasm.blake2s256(retptr, ptr0, len0);
529
541
  var r0 = getInt32Memory0()[retptr / 4 + 0];
530
542
  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);
543
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
544
+ wasm.__wbindgen_free(r0, r1 * 1);
545
+ return v2;
536
546
  } finally {
537
547
  wasm.__wbindgen_add_to_stack_pointer(16);
538
548
  }
539
549
  }
540
550
 
541
551
  /**
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
552
+ * Calculates the Keccak256 hash of the input bytes
553
+ * @param {Uint8Array} inputs
554
+ * @returns {Uint8Array}
546
555
  */
547
- export function compressWitness(witness_map) {
556
+ export function keccak256(inputs) {
548
557
  try {
549
558
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
550
- wasm.compressWitness(retptr, addHeapObject(witness_map));
559
+ const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
560
+ const len0 = WASM_VECTOR_LEN;
561
+ wasm.keccak256(retptr, ptr0, len0);
551
562
  var r0 = getInt32Memory0()[retptr / 4 + 0];
552
563
  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);
557
- }
558
- var v1 = getArrayU8FromWasm0(r0, r1).slice();
564
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
559
565
  wasm.__wbindgen_free(r0, r1 * 1);
560
- return v1;
566
+ return v2;
561
567
  } finally {
562
568
  wasm.__wbindgen_add_to_stack_pointer(16);
563
569
  }
564
570
  }
565
571
 
572
+ /**
573
+ * Verifies a ECDSA signature over the secp256k1 curve.
574
+ * @param {Uint8Array} hashed_msg
575
+ * @param {Uint8Array} public_key_x_bytes
576
+ * @param {Uint8Array} public_key_y_bytes
577
+ * @param {Uint8Array} signature
578
+ * @returns {boolean}
579
+ */
580
+ export function ecdsa_secp256k1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
581
+ const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
582
+ const len0 = WASM_VECTOR_LEN;
583
+ const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
584
+ const len1 = WASM_VECTOR_LEN;
585
+ const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
586
+ const len2 = WASM_VECTOR_LEN;
587
+ const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
588
+ const len3 = WASM_VECTOR_LEN;
589
+ const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
590
+ return ret !== 0;
591
+ }
592
+
593
+ /**
594
+ * Verifies a ECDSA signature over the secp256r1 curve.
595
+ * @param {Uint8Array} hashed_msg
596
+ * @param {Uint8Array} public_key_x_bytes
597
+ * @param {Uint8Array} public_key_y_bytes
598
+ * @param {Uint8Array} signature
599
+ * @returns {boolean}
600
+ */
601
+ export function ecdsa_secp256r1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
602
+ const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
603
+ const len0 = WASM_VECTOR_LEN;
604
+ const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
605
+ const len1 = WASM_VECTOR_LEN;
606
+ const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
607
+ const len2 = WASM_VECTOR_LEN;
608
+ const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
609
+ const len3 = WASM_VECTOR_LEN;
610
+ const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
611
+ return ret !== 0;
612
+ }
613
+
566
614
  /**
567
615
  * Returns the `BuildInfo` object containing information about how the installed package was built.
568
616
  * @returns {BuildInfo} - Information on how the installed package was built.
@@ -572,6 +620,27 @@ export function buildInfo() {
572
620
  return takeObject(ret);
573
621
  }
574
622
 
623
+ /**
624
+ * Sets the package's logging level.
625
+ *
626
+ * @param {LogLevel} level - The maximum level of logging to be emitted.
627
+ */
628
+ export function initLogLevel(filter) {
629
+ try {
630
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
631
+ const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
632
+ const len0 = WASM_VECTOR_LEN;
633
+ wasm.initLogLevel(retptr, ptr0, len0);
634
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
635
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
636
+ if (r1) {
637
+ throw takeObject(r0);
638
+ }
639
+ } finally {
640
+ wasm.__wbindgen_add_to_stack_pointer(16);
641
+ }
642
+ }
643
+
575
644
  function handleError(f, args) {
576
645
  try {
577
646
  return f.apply(this, args);
@@ -579,7 +648,11 @@ function handleError(f, args) {
579
648
  wasm.__wbindgen_exn_store(addHeapObject(e));
580
649
  }
581
650
  }
582
- function __wbg_adapter_159(arg0, arg1, arg2, arg3) {
651
+ function __wbg_adapter_133(arg0, arg1, arg2, arg3, arg4) {
652
+ wasm.wasm_bindgen__convert__closures__invoke3_mut__h28a07b2d2a2056af(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4));
653
+ }
654
+
655
+ function __wbg_adapter_170(arg0, arg1, arg2, arg3) {
583
656
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h79f8a29187e94f15(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
584
657
  }
585
658
 
@@ -669,17 +742,39 @@ function __wbg_get_imports() {
669
742
  imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
670
743
  takeObject(arg0);
671
744
  };
745
+ imports.wbg.__wbg_wasmblackboxfunctionsolver_new = function(arg0) {
746
+ const ret = WasmBlackBoxFunctionSolver.__wrap(arg0);
747
+ return addHeapObject(ret);
748
+ };
749
+ imports.wbg.__wbindgen_is_array = function(arg0) {
750
+ const ret = Array.isArray(getObject(arg0));
751
+ return ret;
752
+ };
753
+ imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
754
+ const obj = getObject(arg1);
755
+ const ret = typeof(obj) === 'number' ? obj : undefined;
756
+ getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
757
+ getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
758
+ };
759
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
760
+ const ret = getStringFromWasm0(arg0, arg1);
761
+ return addHeapObject(ret);
762
+ };
763
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
764
+ const ret = getObject(arg0) === undefined;
765
+ return ret;
766
+ };
672
767
  imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
673
768
  const ret = getObject(arg0);
674
769
  return addHeapObject(ret);
675
770
  };
676
- imports.wbg.__wbg_new_0d2c031c3755a625 = function() {
677
- const ret = new Map();
771
+ imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
772
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
678
773
  return addHeapObject(ret);
679
774
  };
680
- imports.wbg.__wbindgen_number_new = function(arg0) {
681
- const ret = arg0;
682
- return addHeapObject(ret);
775
+ imports.wbg.__wbindgen_is_string = function(arg0) {
776
+ const ret = typeof(getObject(arg0)) === 'string';
777
+ return ret;
683
778
  };
684
779
  imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
685
780
  const obj = getObject(arg1);
@@ -689,40 +784,22 @@ function __wbg_get_imports() {
689
784
  getInt32Memory0()[arg0 / 4 + 1] = len1;
690
785
  getInt32Memory0()[arg0 / 4 + 0] = ptr1;
691
786
  };
692
- imports.wbg.__wbg_constructor_9a4af6ecd5050c55 = function(arg0) {
787
+ imports.wbg.__wbg_constructor_885d22c82fec0fdb = function(arg0) {
693
788
  const ret = new Error(takeObject(arg0));
694
789
  return addHeapObject(ret);
695
790
  };
696
- imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
697
- const ret = getStringFromWasm0(arg0, arg1);
791
+ imports.wbg.__wbg_new_e1076c3a38c86fee = function() {
792
+ const ret = new Map();
698
793
  return addHeapObject(ret);
699
794
  };
700
- imports.wbg.__wbg_wasmblackboxfunctionsolver_new = function(arg0) {
701
- const ret = WasmBlackBoxFunctionSolver.__wrap(arg0);
795
+ imports.wbg.__wbindgen_number_new = function(arg0) {
796
+ const ret = arg0;
702
797
  return addHeapObject(ret);
703
798
  };
704
- imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
705
- const ret = new Error(getStringFromWasm0(arg0, arg1));
799
+ imports.wbg.__wbg_new_967d701c7af7cc58 = function() {
800
+ const ret = new Array();
706
801
  return addHeapObject(ret);
707
802
  };
708
- imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
709
- const obj = getObject(arg1);
710
- const ret = typeof(obj) === 'number' ? obj : undefined;
711
- getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
712
- getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
713
- };
714
- imports.wbg.__wbindgen_is_undefined = function(arg0) {
715
- const ret = getObject(arg0) === undefined;
716
- return ret;
717
- };
718
- imports.wbg.__wbindgen_is_string = function(arg0) {
719
- const ret = typeof(getObject(arg0)) === 'string';
720
- return ret;
721
- };
722
- imports.wbg.__wbindgen_is_array = function(arg0) {
723
- const ret = Array.isArray(getObject(arg0));
724
- return ret;
725
- };
726
803
  imports.wbg.__wbindgen_cb_drop = function(arg0) {
727
804
  const obj = takeObject(arg0).original;
728
805
  if (obj.cnt-- == 1) {
@@ -801,6 +878,30 @@ function __wbg_get_imports() {
801
878
  const ret = result;
802
879
  return ret;
803
880
  };
881
+ imports.wbg.__wbg_debug_e3f6a1578e6d45ca = function(arg0) {
882
+ console.debug(getObject(arg0));
883
+ };
884
+ imports.wbg.__wbg_debug_efabe4eb183aa5d4 = function(arg0, arg1, arg2, arg3) {
885
+ console.debug(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
886
+ };
887
+ imports.wbg.__wbg_error_a7e23606158b68b9 = function(arg0) {
888
+ console.error(getObject(arg0));
889
+ };
890
+ imports.wbg.__wbg_error_50f42b952a595a23 = function(arg0, arg1, arg2, arg3) {
891
+ console.error(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
892
+ };
893
+ imports.wbg.__wbg_info_05db236d79f1b785 = function(arg0) {
894
+ console.info(getObject(arg0));
895
+ };
896
+ imports.wbg.__wbg_info_24d8f53d98f12b95 = function(arg0, arg1, arg2, arg3) {
897
+ console.info(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
898
+ };
899
+ imports.wbg.__wbg_warn_9bdd743e9f5fe1e0 = function(arg0) {
900
+ console.warn(getObject(arg0));
901
+ };
902
+ imports.wbg.__wbg_warn_8342bfbc6028193a = function(arg0, arg1, arg2, arg3) {
903
+ console.warn(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
904
+ };
804
905
  imports.wbg.__wbg_crypto_c48a774b022d20ac = function(arg0) {
805
906
  const ret = getObject(arg0).crypto;
806
907
  return addHeapObject(ret);
@@ -831,30 +932,6 @@ function __wbg_get_imports() {
831
932
  imports.wbg.__wbg_randomFillSync_dc1e9a60c158336d = function() { return handleError(function (arg0, arg1) {
832
933
  getObject(arg0).randomFillSync(takeObject(arg1));
833
934
  }, arguments) };
834
- imports.wbg.__wbg_debug_e3f6a1578e6d45ca = function(arg0) {
835
- console.debug(getObject(arg0));
836
- };
837
- imports.wbg.__wbg_debug_efabe4eb183aa5d4 = function(arg0, arg1, arg2, arg3) {
838
- console.debug(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
839
- };
840
- imports.wbg.__wbg_error_a7e23606158b68b9 = function(arg0) {
841
- console.error(getObject(arg0));
842
- };
843
- imports.wbg.__wbg_error_50f42b952a595a23 = function(arg0, arg1, arg2, arg3) {
844
- console.error(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
845
- };
846
- imports.wbg.__wbg_info_05db236d79f1b785 = function(arg0) {
847
- console.info(getObject(arg0));
848
- };
849
- imports.wbg.__wbg_info_24d8f53d98f12b95 = function(arg0, arg1, arg2, arg3) {
850
- console.info(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
851
- };
852
- imports.wbg.__wbg_warn_9bdd743e9f5fe1e0 = function(arg0) {
853
- console.warn(getObject(arg0));
854
- };
855
- imports.wbg.__wbg_warn_8342bfbc6028193a = function(arg0, arg1, arg2, arg3) {
856
- console.warn(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
857
- };
858
935
  imports.wbg.__wbg_get_7303ed2ef026b2f5 = function(arg0, arg1) {
859
936
  const ret = getObject(arg0)[arg1 >>> 0];
860
937
  return addHeapObject(ret);
@@ -875,6 +952,10 @@ function __wbg_get_imports() {
875
952
  const ret = new Function(getStringFromWasm0(arg0, arg1));
876
953
  return addHeapObject(ret);
877
954
  };
955
+ imports.wbg.__wbg_new_0f2b71ca2f2a6029 = function() {
956
+ const ret = new Map();
957
+ return addHeapObject(ret);
958
+ };
878
959
  imports.wbg.__wbg_get_f53c921291c381bd = function() { return handleError(function (arg0, arg1) {
879
960
  const ret = Reflect.get(getObject(arg0), getObject(arg1));
880
961
  return addHeapObject(ret);
@@ -914,10 +995,31 @@ function __wbg_get_imports() {
914
995
  const ret = Array.from(getObject(arg0));
915
996
  return addHeapObject(ret);
916
997
  };
998
+ imports.wbg.__wbg_forEach_5ae261259d7517c8 = function(arg0, arg1, arg2) {
999
+ try {
1000
+ var state0 = {a: arg1, b: arg2};
1001
+ var cb0 = (arg0, arg1, arg2) => {
1002
+ const a = state0.a;
1003
+ state0.a = 0;
1004
+ try {
1005
+ return __wbg_adapter_133(a, state0.b, arg0, arg1, arg2);
1006
+ } finally {
1007
+ state0.a = a;
1008
+ }
1009
+ };
1010
+ getObject(arg0).forEach(cb0);
1011
+ } finally {
1012
+ state0.a = state0.b = 0;
1013
+ }
1014
+ };
917
1015
  imports.wbg.__wbg_push_109cfc26d02582dd = function(arg0, arg1) {
918
1016
  const ret = getObject(arg0).push(getObject(arg1));
919
1017
  return ret;
920
1018
  };
1019
+ imports.wbg.__wbg_reverse_a322332d916e2705 = function(arg0) {
1020
+ const ret = getObject(arg0).reverse();
1021
+ return addHeapObject(ret);
1022
+ };
921
1023
  imports.wbg.__wbg_byteLength_1a59a59856fc656a = function(arg0) {
922
1024
  const ret = getObject(arg0).byteLength;
923
1025
  return ret;
@@ -983,7 +1085,7 @@ function __wbg_get_imports() {
983
1085
  const a = state0.a;
984
1086
  state0.a = 0;
985
1087
  try {
986
- return __wbg_adapter_159(a, state0.b, arg0, arg1);
1088
+ return __wbg_adapter_170(a, state0.b, arg0, arg1);
987
1089
  } finally {
988
1090
  state0.a = a;
989
1091
  }
@@ -1011,10 +1113,18 @@ function __wbg_get_imports() {
1011
1113
  const ret = getObject(arg0).constructor;
1012
1114
  return addHeapObject(ret);
1013
1115
  };
1116
+ imports.wbg.__wbg_fromEntries_d1b310956d20d858 = function() { return handleError(function (arg0) {
1117
+ const ret = Object.fromEntries(getObject(arg0));
1118
+ return addHeapObject(ret);
1119
+ }, arguments) };
1014
1120
  imports.wbg.__wbg_toString_e2b23ac99490a381 = function(arg0) {
1015
1121
  const ret = getObject(arg0).toString();
1016
1122
  return addHeapObject(ret);
1017
1123
  };
1124
+ imports.wbg.__wbg_values_099fd000c271c313 = function(arg0) {
1125
+ const ret = Object.values(getObject(arg0));
1126
+ return addHeapObject(ret);
1127
+ };
1018
1128
  imports.wbg.__wbg_new_2b55e405e4af4986 = function(arg0, arg1) {
1019
1129
  try {
1020
1130
  var state0 = {a: arg0, b: arg1};
@@ -1022,7 +1132,7 @@ function __wbg_get_imports() {
1022
1132
  const a = state0.a;
1023
1133
  state0.a = 0;
1024
1134
  try {
1025
- return __wbg_adapter_159(a, state0.b, arg0, arg1);
1135
+ return __wbg_adapter_170(a, state0.b, arg0, arg1);
1026
1136
  } finally {
1027
1137
  state0.a = a;
1028
1138
  }
@@ -1156,8 +1266,8 @@ function __wbg_get_imports() {
1156
1266
  const ret = wasm.__wbindgen_export_2;
1157
1267
  return addHeapObject(ret);
1158
1268
  };
1159
- imports.wbg.__wbindgen_closure_wrapper1401 = function(arg0, arg1, arg2) {
1160
- const ret = makeMutClosure(arg0, arg1, 486, __wbg_adapter_52);
1269
+ imports.wbg.__wbindgen_closure_wrapper2087 = function(arg0, arg1, arg2) {
1270
+ const ret = makeMutClosure(arg0, arg1, 718, __wbg_adapter_52);
1161
1271
  return addHeapObject(ret);
1162
1272
  };
1163
1273