@noir-lang/acvm_js 0.42.0 → 0.43.0-0adeb08.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/web/acvm_js.js CHANGED
@@ -20,6 +20,24 @@ function takeObject(idx) {
20
20
  return ret;
21
21
  }
22
22
 
23
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
24
+
25
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
26
+
27
+ let cachedUint8Memory0 = null;
28
+
29
+ function getUint8Memory0() {
30
+ if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
31
+ cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
32
+ }
33
+ return cachedUint8Memory0;
34
+ }
35
+
36
+ function getStringFromWasm0(ptr, len) {
37
+ ptr = ptr >>> 0;
38
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
39
+ }
40
+
23
41
  function addHeapObject(obj) {
24
42
  if (heap_next === heap.length) heap.push(heap.length + 1);
25
43
  const idx = heap_next;
@@ -29,17 +47,30 @@ function addHeapObject(obj) {
29
47
  return idx;
30
48
  }
31
49
 
32
- let WASM_VECTOR_LEN = 0;
50
+ function isLikeNone(x) {
51
+ return x === undefined || x === null;
52
+ }
33
53
 
34
- let cachedUint8Memory0 = null;
54
+ let cachedFloat64Memory0 = null;
35
55
 
36
- function getUint8Memory0() {
37
- if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
38
- cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
56
+ function getFloat64Memory0() {
57
+ if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
58
+ cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
39
59
  }
40
- return cachedUint8Memory0;
60
+ return cachedFloat64Memory0;
41
61
  }
42
62
 
63
+ let cachedInt32Memory0 = null;
64
+
65
+ function getInt32Memory0() {
66
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
67
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
68
+ }
69
+ return cachedInt32Memory0;
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
 
@@ -371,60 +366,74 @@ function _assertClass(instance, klass) {
371
366
  }
372
367
  /**
373
368
  * Executes an ACIR circuit to generate the solved witness from the initial witness.
369
+ * This method also extracts the public return values from the solved witness into its own return witness.
374
370
  *
375
371
  * @param {&WasmBlackBoxFunctionSolver} solver - A black box solver.
376
372
  * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
377
373
  * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
378
374
  * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
379
- * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
375
+ * @returns {SolvedAndReturnWitness} The solved witness calculated by executing the circuit on the provided inputs, as well as the return witness indices as specified by the circuit.
380
376
  */
381
- export function executeCircuitWithBlackBoxSolver(solver, program, initial_witness, foreign_call_handler) {
377
+ export function executeCircuitWithReturnWitness(solver, program, initial_witness, foreign_call_handler) {
382
378
  _assertClass(solver, WasmBlackBoxFunctionSolver);
383
379
  const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
384
380
  const len0 = WASM_VECTOR_LEN;
385
- const ret = wasm.executeCircuitWithBlackBoxSolver(solver.__wbg_ptr, ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
381
+ const ret = wasm.executeCircuitWithReturnWitness(solver.__wbg_ptr, ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
386
382
  return takeObject(ret);
387
383
  }
388
384
 
389
385
  /**
390
386
  * Executes an ACIR circuit to generate the solved witness from the initial witness.
391
387
  *
388
+ * @param {&WasmBlackBoxFunctionSolver} solver - A black box solver.
392
389
  * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
393
390
  * @param {WitnessMap} initial_witness - The initial witness map defining all of the inputs to `circuit`..
394
391
  * @param {ForeignCallHandler} foreign_call_handler - A callback to process any foreign calls from the circuit.
395
392
  * @returns {WitnessMap} The solved witness calculated by executing the circuit on the provided inputs.
396
393
  */
397
- export function executeCircuit(program, initial_witness, foreign_call_handler) {
394
+ export function executeCircuitWithBlackBoxSolver(solver, program, initial_witness, foreign_call_handler) {
395
+ _assertClass(solver, WasmBlackBoxFunctionSolver);
398
396
  const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
399
397
  const len0 = WASM_VECTOR_LEN;
400
- const ret = wasm.executeCircuit(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
398
+ const ret = wasm.executeCircuitWithBlackBoxSolver(solver.__wbg_ptr, ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
401
399
  return takeObject(ret);
402
400
  }
403
401
 
404
402
  /**
405
- * @returns {Promise<WasmBlackBoxFunctionSolver>}
406
403
  */
407
- export function createBlackBoxSolver() {
408
- const ret = wasm.createBlackBoxSolver();
404
+ export function executeProgram(program, initial_witness, foreign_call_handler) {
405
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
406
+ const len0 = WASM_VECTOR_LEN;
407
+ const ret = wasm.executeProgram(ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_handler));
409
408
  return takeObject(ret);
410
409
  }
411
410
 
412
411
  /**
413
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
412
+ */
413
+ export function executeProgramWithBlackBoxSolver(solver, program, initial_witness, foreign_call_executor) {
414
+ _assertClass(solver, WasmBlackBoxFunctionSolver);
415
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
416
+ const len0 = WASM_VECTOR_LEN;
417
+ const ret = wasm.executeProgramWithBlackBoxSolver(solver.__wbg_ptr, ptr0, len0, addHeapObject(initial_witness), addHeapObject(foreign_call_executor));
418
+ return takeObject(ret);
419
+ }
420
+
421
+ /**
422
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
414
423
  *
415
424
  * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
416
425
  * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
417
- * @returns {WitnessMap} A witness map containing the circuit's public inputs.
426
+ * @returns {WitnessMap} A witness map containing the circuit's return values.
418
427
  * @param {Uint8Array} program
419
- * @param {WitnessMap} solved_witness
428
+ * @param {WitnessMap} witness_map
420
429
  * @returns {WitnessMap}
421
430
  */
422
- export function getPublicWitness(program, solved_witness) {
431
+ export function getReturnWitness(program, witness_map) {
423
432
  try {
424
433
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
425
434
  const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
426
435
  const len0 = WASM_VECTOR_LEN;
427
- wasm.getPublicWitness(retptr, ptr0, len0, addHeapObject(solved_witness));
436
+ wasm.getReturnWitness(retptr, ptr0, len0, addHeapObject(witness_map));
428
437
  var r0 = getInt32Memory0()[retptr / 4 + 0];
429
438
  var r1 = getInt32Memory0()[retptr / 4 + 1];
430
439
  var r2 = getInt32Memory0()[retptr / 4 + 2];
@@ -466,21 +475,21 @@ export function getPublicParametersWitness(program, solved_witness) {
466
475
  }
467
476
 
468
477
  /**
469
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
478
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
470
479
  *
471
480
  * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
472
481
  * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
473
- * @returns {WitnessMap} A witness map containing the circuit's return values.
482
+ * @returns {WitnessMap} A witness map containing the circuit's public inputs.
474
483
  * @param {Uint8Array} program
475
- * @param {WitnessMap} witness_map
484
+ * @param {WitnessMap} solved_witness
476
485
  * @returns {WitnessMap}
477
486
  */
478
- export function getReturnWitness(program, witness_map) {
487
+ export function getPublicWitness(program, solved_witness) {
479
488
  try {
480
489
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
481
490
  const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
482
491
  const len0 = WASM_VECTOR_LEN;
483
- wasm.getReturnWitness(retptr, ptr0, len0, addHeapObject(witness_map));
492
+ wasm.getPublicWitness(retptr, ptr0, len0, addHeapObject(solved_witness));
484
493
  var r0 = getInt32Memory0()[retptr / 4 + 0];
485
494
  var r1 = getInt32Memory0()[retptr / 4 + 1];
486
495
  var r2 = getInt32Memory0()[retptr / 4 + 2];
@@ -494,75 +503,132 @@ export function getReturnWitness(program, witness_map) {
494
503
  }
495
504
 
496
505
  /**
497
- * Sets the package's logging level.
498
- *
499
- * @param {LogLevel} level - The maximum level of logging to be emitted.
506
+ * Performs a bitwise AND operation between `lhs` and `rhs`
507
+ * @param {string} lhs
508
+ * @param {string} rhs
509
+ * @returns {string}
500
510
  */
501
- export function initLogLevel(filter) {
511
+ export function and(lhs, rhs) {
512
+ const ret = wasm.and(addHeapObject(lhs), addHeapObject(rhs));
513
+ return takeObject(ret);
514
+ }
515
+
516
+ /**
517
+ * Performs a bitwise XOR operation between `lhs` and `rhs`
518
+ * @param {string} lhs
519
+ * @param {string} rhs
520
+ * @returns {string}
521
+ */
522
+ export function xor(lhs, rhs) {
523
+ const ret = wasm.xor(addHeapObject(lhs), addHeapObject(rhs));
524
+ return takeObject(ret);
525
+ }
526
+
527
+ /**
528
+ * Calculates the SHA256 hash of the input bytes
529
+ * @param {Uint8Array} inputs
530
+ * @returns {Uint8Array}
531
+ */
532
+ export function sha256(inputs) {
502
533
  try {
503
534
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
504
- const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
535
+ const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
505
536
  const len0 = WASM_VECTOR_LEN;
506
- wasm.initLogLevel(retptr, ptr0, len0);
537
+ wasm.sha256(retptr, ptr0, len0);
507
538
  var r0 = getInt32Memory0()[retptr / 4 + 0];
508
539
  var r1 = getInt32Memory0()[retptr / 4 + 1];
509
- if (r1) {
510
- throw takeObject(r0);
511
- }
540
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
541
+ wasm.__wbindgen_free(r0, r1 * 1);
542
+ return v2;
512
543
  } finally {
513
544
  wasm.__wbindgen_add_to_stack_pointer(16);
514
545
  }
515
546
  }
516
547
 
517
548
  /**
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.
549
+ * Calculates the Blake2s256 hash of the input bytes
550
+ * @param {Uint8Array} inputs
551
+ * @returns {Uint8Array}
522
552
  */
523
- export function decompressWitness(compressed_witness) {
553
+ export function blake2s256(inputs) {
524
554
  try {
525
555
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
526
- const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
556
+ const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
527
557
  const len0 = WASM_VECTOR_LEN;
528
- wasm.decompressWitness(retptr, ptr0, len0);
558
+ wasm.blake2s256(retptr, ptr0, len0);
529
559
  var r0 = getInt32Memory0()[retptr / 4 + 0];
530
560
  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);
561
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
562
+ wasm.__wbindgen_free(r0, r1 * 1);
563
+ return v2;
536
564
  } finally {
537
565
  wasm.__wbindgen_add_to_stack_pointer(16);
538
566
  }
539
567
  }
540
568
 
541
569
  /**
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
570
+ * Calculates the Keccak256 hash of the input bytes
571
+ * @param {Uint8Array} inputs
572
+ * @returns {Uint8Array}
546
573
  */
547
- export function compressWitness(witness_map) {
574
+ export function keccak256(inputs) {
548
575
  try {
549
576
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
550
- wasm.compressWitness(retptr, addHeapObject(witness_map));
577
+ const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
578
+ const len0 = WASM_VECTOR_LEN;
579
+ wasm.keccak256(retptr, ptr0, len0);
551
580
  var r0 = getInt32Memory0()[retptr / 4 + 0];
552
581
  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();
582
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
559
583
  wasm.__wbindgen_free(r0, r1 * 1);
560
- return v1;
584
+ return v2;
561
585
  } finally {
562
586
  wasm.__wbindgen_add_to_stack_pointer(16);
563
587
  }
564
588
  }
565
589
 
590
+ /**
591
+ * Verifies a ECDSA signature over the secp256k1 curve.
592
+ * @param {Uint8Array} hashed_msg
593
+ * @param {Uint8Array} public_key_x_bytes
594
+ * @param {Uint8Array} public_key_y_bytes
595
+ * @param {Uint8Array} signature
596
+ * @returns {boolean}
597
+ */
598
+ export function ecdsa_secp256k1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
599
+ const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
600
+ const len0 = WASM_VECTOR_LEN;
601
+ const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
602
+ const len1 = WASM_VECTOR_LEN;
603
+ const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
604
+ const len2 = WASM_VECTOR_LEN;
605
+ const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
606
+ const len3 = WASM_VECTOR_LEN;
607
+ const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
608
+ return ret !== 0;
609
+ }
610
+
611
+ /**
612
+ * Verifies a ECDSA signature over the secp256r1 curve.
613
+ * @param {Uint8Array} hashed_msg
614
+ * @param {Uint8Array} public_key_x_bytes
615
+ * @param {Uint8Array} public_key_y_bytes
616
+ * @param {Uint8Array} signature
617
+ * @returns {boolean}
618
+ */
619
+ export function ecdsa_secp256r1_verify(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
620
+ const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
621
+ const len0 = WASM_VECTOR_LEN;
622
+ const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
623
+ const len1 = WASM_VECTOR_LEN;
624
+ const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
625
+ const len2 = WASM_VECTOR_LEN;
626
+ const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
627
+ const len3 = WASM_VECTOR_LEN;
628
+ const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
629
+ return ret !== 0;
630
+ }
631
+
566
632
  /**
567
633
  * Returns the `BuildInfo` object containing information about how the installed package was built.
568
634
  * @returns {BuildInfo} - Information on how the installed package was built.
@@ -572,6 +638,27 @@ export function buildInfo() {
572
638
  return takeObject(ret);
573
639
  }
574
640
 
641
+ /**
642
+ * Sets the package's logging level.
643
+ *
644
+ * @param {LogLevel} level - The maximum level of logging to be emitted.
645
+ */
646
+ export function initLogLevel(filter) {
647
+ try {
648
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
649
+ const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
650
+ const len0 = WASM_VECTOR_LEN;
651
+ wasm.initLogLevel(retptr, ptr0, len0);
652
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
653
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
654
+ if (r1) {
655
+ throw takeObject(r0);
656
+ }
657
+ } finally {
658
+ wasm.__wbindgen_add_to_stack_pointer(16);
659
+ }
660
+ }
661
+
575
662
  function handleError(f, args) {
576
663
  try {
577
664
  return f.apply(this, args);
@@ -579,7 +666,11 @@ function handleError(f, args) {
579
666
  wasm.__wbindgen_exn_store(addHeapObject(e));
580
667
  }
581
668
  }
582
- function __wbg_adapter_159(arg0, arg1, arg2, arg3) {
669
+ function __wbg_adapter_134(arg0, arg1, arg2, arg3, arg4) {
670
+ wasm.wasm_bindgen__convert__closures__invoke3_mut__h28a07b2d2a2056af(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4));
671
+ }
672
+
673
+ function __wbg_adapter_171(arg0, arg1, arg2, arg3) {
583
674
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h79f8a29187e94f15(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
584
675
  }
585
676
 
@@ -669,41 +760,34 @@ function __wbg_get_imports() {
669
760
  imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
670
761
  takeObject(arg0);
671
762
  };
672
- imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
673
- const ret = getObject(arg0);
674
- return addHeapObject(ret);
675
- };
676
- imports.wbg.__wbg_new_0d2c031c3755a625 = function() {
677
- const ret = new Map();
763
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
764
+ const ret = getStringFromWasm0(arg0, arg1);
678
765
  return addHeapObject(ret);
679
766
  };
680
- imports.wbg.__wbindgen_number_new = function(arg0) {
681
- const ret = arg0;
767
+ imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
768
+ const ret = getObject(arg0);
682
769
  return addHeapObject(ret);
683
770
  };
684
- imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
685
- const obj = getObject(arg1);
686
- const ret = typeof(obj) === 'string' ? obj : undefined;
687
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
688
- var len1 = WASM_VECTOR_LEN;
689
- getInt32Memory0()[arg0 / 4 + 1] = len1;
690
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
691
- };
692
- imports.wbg.__wbg_constructor_9a4af6ecd5050c55 = function(arg0) {
693
- const ret = new Error(takeObject(arg0));
771
+ imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
772
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
694
773
  return addHeapObject(ret);
695
774
  };
696
- imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
697
- const ret = getStringFromWasm0(arg0, arg1);
698
- return addHeapObject(ret);
775
+ imports.wbg.__wbindgen_cb_drop = function(arg0) {
776
+ const obj = takeObject(arg0).original;
777
+ if (obj.cnt-- == 1) {
778
+ obj.a = 0;
779
+ return true;
780
+ }
781
+ const ret = false;
782
+ return ret;
699
783
  };
700
784
  imports.wbg.__wbg_wasmblackboxfunctionsolver_new = function(arg0) {
701
785
  const ret = WasmBlackBoxFunctionSolver.__wrap(arg0);
702
786
  return addHeapObject(ret);
703
787
  };
704
- imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
705
- const ret = new Error(getStringFromWasm0(arg0, arg1));
706
- return addHeapObject(ret);
788
+ imports.wbg.__wbindgen_is_array = function(arg0) {
789
+ const ret = Array.isArray(getObject(arg0));
790
+ return ret;
707
791
  };
708
792
  imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
709
793
  const obj = getObject(arg1);
@@ -719,18 +803,29 @@ function __wbg_get_imports() {
719
803
  const ret = typeof(getObject(arg0)) === 'string';
720
804
  return ret;
721
805
  };
722
- imports.wbg.__wbindgen_is_array = function(arg0) {
723
- const ret = Array.isArray(getObject(arg0));
724
- return ret;
806
+ imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
807
+ const obj = getObject(arg1);
808
+ const ret = typeof(obj) === 'string' ? obj : undefined;
809
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
810
+ var len1 = WASM_VECTOR_LEN;
811
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
812
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
725
813
  };
726
- imports.wbg.__wbindgen_cb_drop = function(arg0) {
727
- const obj = takeObject(arg0).original;
728
- if (obj.cnt-- == 1) {
729
- obj.a = 0;
730
- return true;
731
- }
732
- const ret = false;
733
- return ret;
814
+ imports.wbg.__wbg_new_e1076c3a38c86fee = function() {
815
+ const ret = new Map();
816
+ return addHeapObject(ret);
817
+ };
818
+ imports.wbg.__wbindgen_number_new = function(arg0) {
819
+ const ret = arg0;
820
+ return addHeapObject(ret);
821
+ };
822
+ imports.wbg.__wbg_new_967d701c7af7cc58 = function() {
823
+ const ret = new Array();
824
+ return addHeapObject(ret);
825
+ };
826
+ imports.wbg.__wbg_constructor_885d22c82fec0fdb = function(arg0) {
827
+ const ret = new Error(takeObject(arg0));
828
+ return addHeapObject(ret);
734
829
  };
735
830
  imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
736
831
  const ret = new Error();
@@ -801,6 +896,30 @@ function __wbg_get_imports() {
801
896
  const ret = result;
802
897
  return ret;
803
898
  };
899
+ imports.wbg.__wbg_debug_e3f6a1578e6d45ca = function(arg0) {
900
+ console.debug(getObject(arg0));
901
+ };
902
+ imports.wbg.__wbg_debug_efabe4eb183aa5d4 = function(arg0, arg1, arg2, arg3) {
903
+ console.debug(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
904
+ };
905
+ imports.wbg.__wbg_error_a7e23606158b68b9 = function(arg0) {
906
+ console.error(getObject(arg0));
907
+ };
908
+ imports.wbg.__wbg_error_50f42b952a595a23 = function(arg0, arg1, arg2, arg3) {
909
+ console.error(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
910
+ };
911
+ imports.wbg.__wbg_info_05db236d79f1b785 = function(arg0) {
912
+ console.info(getObject(arg0));
913
+ };
914
+ imports.wbg.__wbg_info_24d8f53d98f12b95 = function(arg0, arg1, arg2, arg3) {
915
+ console.info(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
916
+ };
917
+ imports.wbg.__wbg_warn_9bdd743e9f5fe1e0 = function(arg0) {
918
+ console.warn(getObject(arg0));
919
+ };
920
+ imports.wbg.__wbg_warn_8342bfbc6028193a = function(arg0, arg1, arg2, arg3) {
921
+ console.warn(getObject(arg0), getObject(arg1), getObject(arg2), getObject(arg3));
922
+ };
804
923
  imports.wbg.__wbg_crypto_c48a774b022d20ac = function(arg0) {
805
924
  const ret = getObject(arg0).crypto;
806
925
  return addHeapObject(ret);
@@ -831,30 +950,6 @@ function __wbg_get_imports() {
831
950
  imports.wbg.__wbg_randomFillSync_dc1e9a60c158336d = function() { return handleError(function (arg0, arg1) {
832
951
  getObject(arg0).randomFillSync(takeObject(arg1));
833
952
  }, 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
953
  imports.wbg.__wbg_get_7303ed2ef026b2f5 = function(arg0, arg1) {
859
954
  const ret = getObject(arg0)[arg1 >>> 0];
860
955
  return addHeapObject(ret);
@@ -875,6 +970,10 @@ function __wbg_get_imports() {
875
970
  const ret = new Function(getStringFromWasm0(arg0, arg1));
876
971
  return addHeapObject(ret);
877
972
  };
973
+ imports.wbg.__wbg_new_0f2b71ca2f2a6029 = function() {
974
+ const ret = new Map();
975
+ return addHeapObject(ret);
976
+ };
878
977
  imports.wbg.__wbg_get_f53c921291c381bd = function() { return handleError(function (arg0, arg1) {
879
978
  const ret = Reflect.get(getObject(arg0), getObject(arg1));
880
979
  return addHeapObject(ret);
@@ -914,10 +1013,31 @@ function __wbg_get_imports() {
914
1013
  const ret = Array.from(getObject(arg0));
915
1014
  return addHeapObject(ret);
916
1015
  };
1016
+ imports.wbg.__wbg_forEach_5ae261259d7517c8 = function(arg0, arg1, arg2) {
1017
+ try {
1018
+ var state0 = {a: arg1, b: arg2};
1019
+ var cb0 = (arg0, arg1, arg2) => {
1020
+ const a = state0.a;
1021
+ state0.a = 0;
1022
+ try {
1023
+ return __wbg_adapter_134(a, state0.b, arg0, arg1, arg2);
1024
+ } finally {
1025
+ state0.a = a;
1026
+ }
1027
+ };
1028
+ getObject(arg0).forEach(cb0);
1029
+ } finally {
1030
+ state0.a = state0.b = 0;
1031
+ }
1032
+ };
917
1033
  imports.wbg.__wbg_push_109cfc26d02582dd = function(arg0, arg1) {
918
1034
  const ret = getObject(arg0).push(getObject(arg1));
919
1035
  return ret;
920
1036
  };
1037
+ imports.wbg.__wbg_reverse_a322332d916e2705 = function(arg0) {
1038
+ const ret = getObject(arg0).reverse();
1039
+ return addHeapObject(ret);
1040
+ };
921
1041
  imports.wbg.__wbg_byteLength_1a59a59856fc656a = function(arg0) {
922
1042
  const ret = getObject(arg0).byteLength;
923
1043
  return ret;
@@ -983,7 +1103,7 @@ function __wbg_get_imports() {
983
1103
  const a = state0.a;
984
1104
  state0.a = 0;
985
1105
  try {
986
- return __wbg_adapter_159(a, state0.b, arg0, arg1);
1106
+ return __wbg_adapter_171(a, state0.b, arg0, arg1);
987
1107
  } finally {
988
1108
  state0.a = a;
989
1109
  }
@@ -1011,10 +1131,18 @@ function __wbg_get_imports() {
1011
1131
  const ret = getObject(arg0).constructor;
1012
1132
  return addHeapObject(ret);
1013
1133
  };
1134
+ imports.wbg.__wbg_fromEntries_d1b310956d20d858 = function() { return handleError(function (arg0) {
1135
+ const ret = Object.fromEntries(getObject(arg0));
1136
+ return addHeapObject(ret);
1137
+ }, arguments) };
1014
1138
  imports.wbg.__wbg_toString_e2b23ac99490a381 = function(arg0) {
1015
1139
  const ret = getObject(arg0).toString();
1016
1140
  return addHeapObject(ret);
1017
1141
  };
1142
+ imports.wbg.__wbg_values_099fd000c271c313 = function(arg0) {
1143
+ const ret = Object.values(getObject(arg0));
1144
+ return addHeapObject(ret);
1145
+ };
1018
1146
  imports.wbg.__wbg_new_2b55e405e4af4986 = function(arg0, arg1) {
1019
1147
  try {
1020
1148
  var state0 = {a: arg0, b: arg1};
@@ -1022,7 +1150,7 @@ function __wbg_get_imports() {
1022
1150
  const a = state0.a;
1023
1151
  state0.a = 0;
1024
1152
  try {
1025
- return __wbg_adapter_159(a, state0.b, arg0, arg1);
1153
+ return __wbg_adapter_171(a, state0.b, arg0, arg1);
1026
1154
  } finally {
1027
1155
  state0.a = a;
1028
1156
  }
@@ -1156,8 +1284,8 @@ function __wbg_get_imports() {
1156
1284
  const ret = wasm.__wbindgen_export_2;
1157
1285
  return addHeapObject(ret);
1158
1286
  };
1159
- imports.wbg.__wbindgen_closure_wrapper1401 = function(arg0, arg1, arg2) {
1160
- const ret = makeMutClosure(arg0, arg1, 486, __wbg_adapter_52);
1287
+ imports.wbg.__wbindgen_closure_wrapper2118 = function(arg0, arg1, arg2) {
1288
+ const ret = makeMutClosure(arg0, arg1, 723, __wbg_adapter_52);
1161
1289
  return addHeapObject(ret);
1162
1290
  };
1163
1291