@noir-lang/acvm_js 0.51.0 → 0.52.0-600ffeb.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
@@ -23,28 +23,6 @@ function takeObject(idx) {
23
23
  return ret;
24
24
  }
25
25
 
26
- function isLikeNone(x) {
27
- return x === undefined || x === null;
28
- }
29
-
30
- let cachedFloat64Memory0 = null;
31
-
32
- function getFloat64Memory0() {
33
- if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
34
- cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
35
- }
36
- return cachedFloat64Memory0;
37
- }
38
-
39
- let cachedInt32Memory0 = null;
40
-
41
- function getInt32Memory0() {
42
- if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
43
- cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
44
- }
45
- return cachedInt32Memory0;
46
- }
47
-
48
26
  function addHeapObject(obj) {
49
27
  if (heap_next === heap.length) heap.push(heap.length + 1);
50
28
  const idx = heap_next;
@@ -127,6 +105,28 @@ function passStringToWasm0(arg, malloc, realloc) {
127
105
  return ptr;
128
106
  }
129
107
 
108
+ function isLikeNone(x) {
109
+ return x === undefined || x === null;
110
+ }
111
+
112
+ let cachedInt32Memory0 = null;
113
+
114
+ function getInt32Memory0() {
115
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
116
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
117
+ }
118
+ return cachedInt32Memory0;
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
  function debugString(val) {
131
131
  // primitive types
132
132
  const type = typeof val;
@@ -221,32 +221,104 @@ function __wbg_adapter_22(arg0, arg1, arg2) {
221
221
  }
222
222
 
223
223
  /**
224
- * Sets the package's logging level.
224
+ * Returns the `BuildInfo` object containing information about how the installed package was built.
225
+ * @returns {BuildInfo} - Information on how the installed package was built.
226
+ */
227
+ module.exports.buildInfo = function() {
228
+ const ret = wasm.buildInfo();
229
+ return takeObject(ret);
230
+ };
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;
237
+ }
238
+ /**
239
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
225
240
  *
226
- * @param {LogLevel} level - The maximum level of logging to be emitted.
241
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
242
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
243
+ * @returns {WitnessMap} A witness map containing the circuit's return values.
244
+ * @param {Uint8Array} program
245
+ * @param {WitnessMap} witness_map
246
+ * @returns {WitnessMap}
227
247
  */
228
- module.exports.initLogLevel = function(filter) {
248
+ module.exports.getReturnWitness = function(program, witness_map) {
229
249
  try {
230
250
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
231
- const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
251
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
232
252
  const len0 = WASM_VECTOR_LEN;
233
- wasm.initLogLevel(retptr, ptr0, len0);
253
+ wasm.getReturnWitness(retptr, ptr0, len0, addHeapObject(witness_map));
234
254
  var r0 = getInt32Memory0()[retptr / 4 + 0];
235
255
  var r1 = getInt32Memory0()[retptr / 4 + 1];
236
- if (r1) {
237
- throw takeObject(r0);
256
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
257
+ if (r2) {
258
+ throw takeObject(r1);
238
259
  }
260
+ return takeObject(r0);
261
+ } finally {
262
+ wasm.__wbindgen_add_to_stack_pointer(16);
263
+ }
264
+ };
265
+
266
+ /**
267
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
268
+ *
269
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
270
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
271
+ * @returns {WitnessMap} A witness map containing the circuit's public parameters.
272
+ * @param {Uint8Array} program
273
+ * @param {WitnessMap} solved_witness
274
+ * @returns {WitnessMap}
275
+ */
276
+ module.exports.getPublicParametersWitness = function(program, solved_witness) {
277
+ try {
278
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
279
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
280
+ const len0 = WASM_VECTOR_LEN;
281
+ wasm.getPublicParametersWitness(retptr, ptr0, len0, addHeapObject(solved_witness));
282
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
283
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
284
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
285
+ if (r2) {
286
+ throw takeObject(r1);
287
+ }
288
+ return takeObject(r0);
289
+ } finally {
290
+ wasm.__wbindgen_add_to_stack_pointer(16);
291
+ }
292
+ };
293
+
294
+ /**
295
+ * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
296
+ *
297
+ * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
298
+ * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
299
+ * @returns {WitnessMap} A witness map containing the circuit's public inputs.
300
+ * @param {Uint8Array} program
301
+ * @param {WitnessMap} solved_witness
302
+ * @returns {WitnessMap}
303
+ */
304
+ module.exports.getPublicWitness = function(program, solved_witness) {
305
+ try {
306
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
307
+ const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
308
+ const len0 = WASM_VECTOR_LEN;
309
+ wasm.getPublicWitness(retptr, ptr0, len0, addHeapObject(solved_witness));
310
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
311
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
312
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
313
+ if (r2) {
314
+ throw takeObject(r1);
315
+ }
316
+ return takeObject(r0);
239
317
  } finally {
240
318
  wasm.__wbindgen_add_to_stack_pointer(16);
241
319
  }
242
320
  };
243
321
 
244
- function passArray8ToWasm0(arg, malloc) {
245
- const ptr = malloc(arg.length * 1) >>> 0;
246
- getUint8Memory0().set(arg, ptr / 1);
247
- WASM_VECTOR_LEN = arg.length;
248
- return ptr;
249
- }
250
322
  /**
251
323
  * Executes an ACIR circuit to generate the solved witness from the initial witness.
252
324
  *
@@ -293,198 +365,97 @@ module.exports.executeProgram = function(program, initial_witness, foreign_call_
293
365
  return takeObject(ret);
294
366
  };
295
367
 
296
- /**
297
- * Performs a bitwise AND operation between `lhs` and `rhs`
298
- * @param {string} lhs
299
- * @param {string} rhs
300
- * @returns {string}
301
- */
302
- module.exports.and = function(lhs, rhs) {
303
- const ret = wasm.and(addHeapObject(lhs), addHeapObject(rhs));
304
- return takeObject(ret);
305
- };
306
-
307
- /**
308
- * Performs a bitwise XOR operation between `lhs` and `rhs`
309
- * @param {string} lhs
310
- * @param {string} rhs
311
- * @returns {string}
312
- */
313
- module.exports.xor = function(lhs, rhs) {
314
- const ret = wasm.xor(addHeapObject(lhs), addHeapObject(rhs));
315
- return takeObject(ret);
316
- };
317
-
318
- let cachedUint32Memory0 = null;
319
-
320
- function getUint32Memory0() {
321
- if (cachedUint32Memory0 === null || cachedUint32Memory0.byteLength === 0) {
322
- cachedUint32Memory0 = new Uint32Array(wasm.memory.buffer);
323
- }
324
- return cachedUint32Memory0;
325
- }
326
-
327
- function passArray32ToWasm0(arg, malloc) {
328
- const ptr = malloc(arg.length * 4) >>> 0;
329
- getUint32Memory0().set(arg, ptr / 4);
330
- WASM_VECTOR_LEN = arg.length;
331
- return ptr;
332
- }
333
-
334
- function getArrayU32FromWasm0(ptr, len) {
368
+ function getArrayU8FromWasm0(ptr, len) {
335
369
  ptr = ptr >>> 0;
336
- return getUint32Memory0().subarray(ptr / 4, ptr / 4 + len);
370
+ return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
337
371
  }
338
372
  /**
339
- * Sha256 compression function
340
- * @param {Uint32Array} inputs
341
- * @param {Uint32Array} state
342
- * @returns {Uint32Array}
373
+ * Compresses a `WitnessMap` into the binary format outputted by Nargo.
374
+ *
375
+ * @param {WitnessMap} witness_map - A witness map.
376
+ * @returns {Uint8Array} A compressed witness map
343
377
  */
344
- module.exports.sha256_compression = function(inputs, state) {
378
+ module.exports.compressWitness = function(witness_map) {
345
379
  try {
346
380
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
347
- const ptr0 = passArray32ToWasm0(inputs, wasm.__wbindgen_malloc);
348
- const len0 = WASM_VECTOR_LEN;
349
- const ptr1 = passArray32ToWasm0(state, wasm.__wbindgen_malloc);
350
- const len1 = WASM_VECTOR_LEN;
351
- wasm.sha256_compression(retptr, ptr0, len0, ptr1, len1);
381
+ wasm.compressWitness(retptr, addHeapObject(witness_map));
352
382
  var r0 = getInt32Memory0()[retptr / 4 + 0];
353
383
  var r1 = getInt32Memory0()[retptr / 4 + 1];
354
- var v3 = getArrayU32FromWasm0(r0, r1).slice();
355
- wasm.__wbindgen_free(r0, r1 * 4);
356
- return v3;
384
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
385
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
386
+ if (r3) {
387
+ throw takeObject(r2);
388
+ }
389
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
390
+ wasm.__wbindgen_free(r0, r1 * 1);
391
+ return v1;
357
392
  } finally {
358
393
  wasm.__wbindgen_add_to_stack_pointer(16);
359
394
  }
360
395
  };
361
396
 
362
- function getArrayU8FromWasm0(ptr, len) {
363
- ptr = ptr >>> 0;
364
- return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
365
- }
366
397
  /**
367
- * Calculates the Blake2s256 hash of the input bytes
368
- * @param {Uint8Array} inputs
369
- * @returns {Uint8Array}
398
+ * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
399
+ * This should be used to only fetch the witness map for the main function.
400
+ *
401
+ * @param {Uint8Array} compressed_witness - A compressed witness.
402
+ * @returns {WitnessMap} The decompressed witness map.
370
403
  */
371
- module.exports.blake2s256 = function(inputs) {
404
+ module.exports.decompressWitness = function(compressed_witness) {
372
405
  try {
373
406
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
374
- const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
407
+ const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
375
408
  const len0 = WASM_VECTOR_LEN;
376
- wasm.blake2s256(retptr, ptr0, len0);
409
+ wasm.decompressWitness(retptr, ptr0, len0);
377
410
  var r0 = getInt32Memory0()[retptr / 4 + 0];
378
411
  var r1 = getInt32Memory0()[retptr / 4 + 1];
379
- var v2 = getArrayU8FromWasm0(r0, r1).slice();
380
- wasm.__wbindgen_free(r0, r1 * 1);
381
- return v2;
412
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
413
+ if (r2) {
414
+ throw takeObject(r1);
415
+ }
416
+ return takeObject(r0);
382
417
  } finally {
383
418
  wasm.__wbindgen_add_to_stack_pointer(16);
384
419
  }
385
420
  };
386
421
 
387
422
  /**
388
- * Calculates the Keccak256 hash of the input bytes
389
- * @param {Uint8Array} inputs
390
- * @returns {Uint8Array}
423
+ * Compresses a `WitnessStack` into the binary format outputted by Nargo.
424
+ *
425
+ * @param {WitnessStack} witness_stack - A witness stack.
426
+ * @returns {Uint8Array} A compressed witness stack
391
427
  */
392
- module.exports.keccak256 = function(inputs) {
428
+ module.exports.compressWitnessStack = function(witness_stack) {
393
429
  try {
394
430
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
395
- const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
396
- const len0 = WASM_VECTOR_LEN;
397
- wasm.keccak256(retptr, ptr0, len0);
431
+ wasm.compressWitnessStack(retptr, addHeapObject(witness_stack));
398
432
  var r0 = getInt32Memory0()[retptr / 4 + 0];
399
433
  var r1 = getInt32Memory0()[retptr / 4 + 1];
400
- var v2 = getArrayU8FromWasm0(r0, r1).slice();
434
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
435
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
436
+ if (r3) {
437
+ throw takeObject(r2);
438
+ }
439
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
401
440
  wasm.__wbindgen_free(r0, r1 * 1);
402
- return v2;
441
+ return v1;
403
442
  } finally {
404
443
  wasm.__wbindgen_add_to_stack_pointer(16);
405
444
  }
406
445
  };
407
446
 
408
447
  /**
409
- * Verifies a ECDSA signature over the secp256k1 curve.
410
- * @param {Uint8Array} hashed_msg
411
- * @param {Uint8Array} public_key_x_bytes
412
- * @param {Uint8Array} public_key_y_bytes
413
- * @param {Uint8Array} signature
414
- * @returns {boolean}
415
- */
416
- module.exports.ecdsa_secp256k1_verify = function(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
417
- const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
418
- const len0 = WASM_VECTOR_LEN;
419
- const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
420
- const len1 = WASM_VECTOR_LEN;
421
- const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
422
- const len2 = WASM_VECTOR_LEN;
423
- const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
424
- const len3 = WASM_VECTOR_LEN;
425
- const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
426
- return ret !== 0;
427
- };
428
-
429
- /**
430
- * Verifies a ECDSA signature over the secp256r1 curve.
431
- * @param {Uint8Array} hashed_msg
432
- * @param {Uint8Array} public_key_x_bytes
433
- * @param {Uint8Array} public_key_y_bytes
434
- * @param {Uint8Array} signature
435
- * @returns {boolean}
436
- */
437
- module.exports.ecdsa_secp256r1_verify = function(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
438
- const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
439
- const len0 = WASM_VECTOR_LEN;
440
- const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
441
- const len1 = WASM_VECTOR_LEN;
442
- const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
443
- const len2 = WASM_VECTOR_LEN;
444
- const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
445
- const len3 = WASM_VECTOR_LEN;
446
- const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
447
- return ret !== 0;
448
- };
449
-
450
- /**
451
- * Compresses a `WitnessMap` into the binary format outputted by Nargo.
452
- *
453
- * @param {WitnessMap} witness_map - A witness map.
454
- * @returns {Uint8Array} A compressed witness map
455
- */
456
- module.exports.compressWitness = function(witness_map) {
457
- try {
458
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
459
- wasm.compressWitness(retptr, addHeapObject(witness_map));
460
- var r0 = getInt32Memory0()[retptr / 4 + 0];
461
- var r1 = getInt32Memory0()[retptr / 4 + 1];
462
- var r2 = getInt32Memory0()[retptr / 4 + 2];
463
- var r3 = getInt32Memory0()[retptr / 4 + 3];
464
- if (r3) {
465
- throw takeObject(r2);
466
- }
467
- var v1 = getArrayU8FromWasm0(r0, r1).slice();
468
- wasm.__wbindgen_free(r0, r1 * 1);
469
- return v1;
470
- } finally {
471
- wasm.__wbindgen_add_to_stack_pointer(16);
472
- }
473
- };
474
-
475
- /**
476
- * Decompresses a compressed witness as outputted by Nargo into a `WitnessMap`.
477
- * This should be used to only fetch the witness map for the main function.
448
+ * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
478
449
  *
479
450
  * @param {Uint8Array} compressed_witness - A compressed witness.
480
- * @returns {WitnessMap} The decompressed witness map.
451
+ * @returns {WitnessStack} The decompressed witness stack.
481
452
  */
482
- module.exports.decompressWitness = function(compressed_witness) {
453
+ module.exports.decompressWitnessStack = function(compressed_witness) {
483
454
  try {
484
455
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
485
456
  const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
486
457
  const len0 = WASM_VECTOR_LEN;
487
- wasm.decompressWitness(retptr, ptr0, len0);
458
+ wasm.decompressWitnessStack(retptr, ptr0, len0);
488
459
  var r0 = getInt32Memory0()[retptr / 4 + 0];
489
460
  var r1 = getInt32Memory0()[retptr / 4 + 1];
490
461
  var r2 = getInt32Memory0()[retptr / 4 + 2];
@@ -498,148 +469,156 @@ module.exports.decompressWitness = function(compressed_witness) {
498
469
  };
499
470
 
500
471
  /**
501
- * Compresses a `WitnessStack` into the binary format outputted by Nargo.
472
+ * Sets the package's logging level.
502
473
  *
503
- * @param {WitnessStack} witness_stack - A witness stack.
504
- * @returns {Uint8Array} A compressed witness stack
474
+ * @param {LogLevel} level - The maximum level of logging to be emitted.
505
475
  */
506
- module.exports.compressWitnessStack = function(witness_stack) {
476
+ module.exports.initLogLevel = function(filter) {
507
477
  try {
508
478
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
509
- wasm.compressWitnessStack(retptr, addHeapObject(witness_stack));
479
+ const ptr0 = passStringToWasm0(filter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
480
+ const len0 = WASM_VECTOR_LEN;
481
+ wasm.initLogLevel(retptr, ptr0, len0);
510
482
  var r0 = getInt32Memory0()[retptr / 4 + 0];
511
483
  var r1 = getInt32Memory0()[retptr / 4 + 1];
512
- var r2 = getInt32Memory0()[retptr / 4 + 2];
513
- var r3 = getInt32Memory0()[retptr / 4 + 3];
514
- if (r3) {
515
- throw takeObject(r2);
484
+ if (r1) {
485
+ throw takeObject(r0);
516
486
  }
517
- var v1 = getArrayU8FromWasm0(r0, r1).slice();
518
- wasm.__wbindgen_free(r0, r1 * 1);
519
- return v1;
520
487
  } finally {
521
488
  wasm.__wbindgen_add_to_stack_pointer(16);
522
489
  }
523
490
  };
524
491
 
525
492
  /**
526
- * Decompresses a compressed witness stack as outputted by Nargo into a `WitnessStack`.
527
- *
528
- * @param {Uint8Array} compressed_witness - A compressed witness.
529
- * @returns {WitnessStack} The decompressed witness stack.
493
+ * Performs a bitwise AND operation between `lhs` and `rhs`
494
+ * @param {string} lhs
495
+ * @param {string} rhs
496
+ * @returns {string}
530
497
  */
531
- module.exports.decompressWitnessStack = function(compressed_witness) {
532
- try {
533
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
534
- const ptr0 = passArray8ToWasm0(compressed_witness, wasm.__wbindgen_malloc);
535
- const len0 = WASM_VECTOR_LEN;
536
- wasm.decompressWitnessStack(retptr, ptr0, len0);
537
- var r0 = getInt32Memory0()[retptr / 4 + 0];
538
- var r1 = getInt32Memory0()[retptr / 4 + 1];
539
- var r2 = getInt32Memory0()[retptr / 4 + 2];
540
- if (r2) {
541
- throw takeObject(r1);
542
- }
543
- return takeObject(r0);
544
- } finally {
545
- wasm.__wbindgen_add_to_stack_pointer(16);
546
- }
498
+ module.exports.and = function(lhs, rhs) {
499
+ const ret = wasm.and(addHeapObject(lhs), addHeapObject(rhs));
500
+ return takeObject(ret);
547
501
  };
548
502
 
549
503
  /**
550
- * Returns the `BuildInfo` object containing information about how the installed package was built.
551
- * @returns {BuildInfo} - Information on how the installed package was built.
504
+ * Performs a bitwise XOR operation between `lhs` and `rhs`
505
+ * @param {string} lhs
506
+ * @param {string} rhs
507
+ * @returns {string}
552
508
  */
553
- module.exports.buildInfo = function() {
554
- const ret = wasm.buildInfo();
509
+ module.exports.xor = function(lhs, rhs) {
510
+ const ret = wasm.xor(addHeapObject(lhs), addHeapObject(rhs));
555
511
  return takeObject(ret);
556
512
  };
557
513
 
514
+ let cachedUint32Memory0 = null;
515
+
516
+ function getUint32Memory0() {
517
+ if (cachedUint32Memory0 === null || cachedUint32Memory0.byteLength === 0) {
518
+ cachedUint32Memory0 = new Uint32Array(wasm.memory.buffer);
519
+ }
520
+ return cachedUint32Memory0;
521
+ }
522
+
523
+ function passArray32ToWasm0(arg, malloc) {
524
+ const ptr = malloc(arg.length * 4) >>> 0;
525
+ getUint32Memory0().set(arg, ptr / 4);
526
+ WASM_VECTOR_LEN = arg.length;
527
+ return ptr;
528
+ }
529
+
530
+ function getArrayU32FromWasm0(ptr, len) {
531
+ ptr = ptr >>> 0;
532
+ return getUint32Memory0().subarray(ptr / 4, ptr / 4 + len);
533
+ }
558
534
  /**
559
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's return values.
560
- *
561
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
562
- * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
563
- * @returns {WitnessMap} A witness map containing the circuit's return values.
564
- * @param {Uint8Array} program
565
- * @param {WitnessMap} witness_map
566
- * @returns {WitnessMap}
535
+ * Sha256 compression function
536
+ * @param {Uint32Array} inputs
537
+ * @param {Uint32Array} state
538
+ * @returns {Uint32Array}
567
539
  */
568
- module.exports.getReturnWitness = function(program, witness_map) {
540
+ module.exports.sha256_compression = function(inputs, state) {
569
541
  try {
570
542
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
571
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
543
+ const ptr0 = passArray32ToWasm0(inputs, wasm.__wbindgen_malloc);
572
544
  const len0 = WASM_VECTOR_LEN;
573
- wasm.getReturnWitness(retptr, ptr0, len0, addHeapObject(witness_map));
545
+ const ptr1 = passArray32ToWasm0(state, wasm.__wbindgen_malloc);
546
+ const len1 = WASM_VECTOR_LEN;
547
+ wasm.sha256_compression(retptr, ptr0, len0, ptr1, len1);
574
548
  var r0 = getInt32Memory0()[retptr / 4 + 0];
575
549
  var r1 = getInt32Memory0()[retptr / 4 + 1];
576
- var r2 = getInt32Memory0()[retptr / 4 + 2];
577
- if (r2) {
578
- throw takeObject(r1);
579
- }
580
- return takeObject(r0);
550
+ var v3 = getArrayU32FromWasm0(r0, r1).slice();
551
+ wasm.__wbindgen_free(r0, r1 * 4);
552
+ return v3;
581
553
  } finally {
582
554
  wasm.__wbindgen_add_to_stack_pointer(16);
583
555
  }
584
556
  };
585
557
 
586
558
  /**
587
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public parameters.
588
- *
589
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
590
- * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
591
- * @returns {WitnessMap} A witness map containing the circuit's public parameters.
592
- * @param {Uint8Array} program
593
- * @param {WitnessMap} solved_witness
594
- * @returns {WitnessMap}
559
+ * Calculates the Blake2s256 hash of the input bytes
560
+ * @param {Uint8Array} inputs
561
+ * @returns {Uint8Array}
595
562
  */
596
- module.exports.getPublicParametersWitness = function(program, solved_witness) {
563
+ module.exports.blake2s256 = function(inputs) {
597
564
  try {
598
565
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
599
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
566
+ const ptr0 = passArray8ToWasm0(inputs, wasm.__wbindgen_malloc);
600
567
  const len0 = WASM_VECTOR_LEN;
601
- wasm.getPublicParametersWitness(retptr, ptr0, len0, addHeapObject(solved_witness));
568
+ wasm.blake2s256(retptr, ptr0, len0);
602
569
  var r0 = getInt32Memory0()[retptr / 4 + 0];
603
570
  var r1 = getInt32Memory0()[retptr / 4 + 1];
604
- var r2 = getInt32Memory0()[retptr / 4 + 2];
605
- if (r2) {
606
- throw takeObject(r1);
607
- }
608
- return takeObject(r0);
571
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
572
+ wasm.__wbindgen_free(r0, r1 * 1);
573
+ return v2;
609
574
  } finally {
610
575
  wasm.__wbindgen_add_to_stack_pointer(16);
611
576
  }
612
577
  };
613
578
 
614
579
  /**
615
- * Extracts a `WitnessMap` containing the witness indices corresponding to the circuit's public inputs.
616
- *
617
- * @param {Uint8Array} circuit - A serialized representation of an ACIR circuit
618
- * @param {WitnessMap} witness_map - The completed witness map after executing the circuit.
619
- * @returns {WitnessMap} A witness map containing the circuit's public inputs.
620
- * @param {Uint8Array} program
621
- * @param {WitnessMap} solved_witness
622
- * @returns {WitnessMap}
580
+ * Verifies a ECDSA signature over the secp256k1 curve.
581
+ * @param {Uint8Array} hashed_msg
582
+ * @param {Uint8Array} public_key_x_bytes
583
+ * @param {Uint8Array} public_key_y_bytes
584
+ * @param {Uint8Array} signature
585
+ * @returns {boolean}
623
586
  */
624
- module.exports.getPublicWitness = function(program, solved_witness) {
625
- try {
626
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
627
- const ptr0 = passArray8ToWasm0(program, wasm.__wbindgen_malloc);
628
- const len0 = WASM_VECTOR_LEN;
629
- wasm.getPublicWitness(retptr, ptr0, len0, addHeapObject(solved_witness));
630
- var r0 = getInt32Memory0()[retptr / 4 + 0];
631
- var r1 = getInt32Memory0()[retptr / 4 + 1];
632
- var r2 = getInt32Memory0()[retptr / 4 + 2];
633
- if (r2) {
634
- throw takeObject(r1);
635
- }
636
- return takeObject(r0);
637
- } finally {
638
- wasm.__wbindgen_add_to_stack_pointer(16);
639
- }
587
+ module.exports.ecdsa_secp256k1_verify = function(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
588
+ const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
589
+ const len0 = WASM_VECTOR_LEN;
590
+ const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
591
+ const len1 = WASM_VECTOR_LEN;
592
+ const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
593
+ const len2 = WASM_VECTOR_LEN;
594
+ const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
595
+ const len3 = WASM_VECTOR_LEN;
596
+ const ret = wasm.ecdsa_secp256k1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
597
+ return ret !== 0;
598
+ };
599
+
600
+ /**
601
+ * Verifies a ECDSA signature over the secp256r1 curve.
602
+ * @param {Uint8Array} hashed_msg
603
+ * @param {Uint8Array} public_key_x_bytes
604
+ * @param {Uint8Array} public_key_y_bytes
605
+ * @param {Uint8Array} signature
606
+ * @returns {boolean}
607
+ */
608
+ module.exports.ecdsa_secp256r1_verify = function(hashed_msg, public_key_x_bytes, public_key_y_bytes, signature) {
609
+ const ptr0 = passArray8ToWasm0(hashed_msg, wasm.__wbindgen_malloc);
610
+ const len0 = WASM_VECTOR_LEN;
611
+ const ptr1 = passArray8ToWasm0(public_key_x_bytes, wasm.__wbindgen_malloc);
612
+ const len1 = WASM_VECTOR_LEN;
613
+ const ptr2 = passArray8ToWasm0(public_key_y_bytes, wasm.__wbindgen_malloc);
614
+ const len2 = WASM_VECTOR_LEN;
615
+ const ptr3 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
616
+ const len3 = WASM_VECTOR_LEN;
617
+ const ret = wasm.ecdsa_secp256r1_verify(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
618
+ return ret !== 0;
640
619
  };
641
620
 
642
- function __wbg_adapter_76(arg0, arg1, arg2, arg3, arg4) {
621
+ function __wbg_adapter_75(arg0, arg1, arg2, arg3, arg4) {
643
622
  wasm.wasm_bindgen__convert__closures__invoke3_mut__h17fc532521b46256(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4));
644
623
  }
645
624
 
@@ -650,33 +629,26 @@ function handleError(f, args) {
650
629
  wasm.__wbindgen_exn_store(addHeapObject(e));
651
630
  }
652
631
  }
653
- function __wbg_adapter_93(arg0, arg1, arg2, arg3) {
632
+ function __wbg_adapter_92(arg0, arg1, arg2, arg3) {
654
633
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h0d187b0f08495587(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
655
634
  }
656
635
 
657
- module.exports.__wbindgen_cb_drop = function(arg0) {
658
- const obj = takeObject(arg0).original;
659
- if (obj.cnt-- == 1) {
660
- obj.a = 0;
661
- return true;
662
- }
663
- const ret = false;
664
- return ret;
636
+ module.exports.__wbindgen_object_drop_ref = function(arg0) {
637
+ takeObject(arg0);
665
638
  };
666
639
 
667
- module.exports.__wbindgen_number_get = function(arg0, arg1) {
668
- const obj = getObject(arg1);
669
- const ret = typeof(obj) === 'number' ? obj : undefined;
670
- getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
671
- getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
640
+ module.exports.__wbindgen_is_string = function(arg0) {
641
+ const ret = typeof(getObject(arg0)) === 'string';
642
+ return ret;
672
643
  };
673
644
 
674
- module.exports.__wbindgen_object_drop_ref = function(arg0) {
675
- takeObject(arg0);
645
+ module.exports.__wbindgen_is_array = function(arg0) {
646
+ const ret = Array.isArray(getObject(arg0));
647
+ return ret;
676
648
  };
677
649
 
678
- module.exports.__wbg_new_3b3e21164d5381ca = function() {
679
- const ret = new Map();
650
+ module.exports.__wbg_new_55c288bb849e1b31 = function() {
651
+ const ret = new Array();
680
652
  return addHeapObject(ret);
681
653
  };
682
654
 
@@ -690,33 +662,40 @@ module.exports.__wbindgen_string_new = function(arg0, arg1) {
690
662
  return addHeapObject(ret);
691
663
  };
692
664
 
693
- module.exports.__wbindgen_string_get = function(arg0, arg1) {
694
- const obj = getObject(arg1);
695
- const ret = typeof(obj) === 'string' ? obj : undefined;
696
- var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
697
- var len1 = WASM_VECTOR_LEN;
698
- getInt32Memory0()[arg0 / 4 + 1] = len1;
699
- getInt32Memory0()[arg0 / 4 + 0] = ptr1;
700
- };
701
-
702
- module.exports.__wbg_constructor_f4bcf4c70838c703 = function(arg0) {
665
+ module.exports.__wbg_constructor_720343c738f4344c = function(arg0) {
703
666
  const ret = new Error(takeObject(arg0));
704
667
  return addHeapObject(ret);
705
668
  };
706
669
 
707
- module.exports.__wbindgen_is_array = function(arg0) {
708
- const ret = Array.isArray(getObject(arg0));
670
+ module.exports.__wbindgen_cb_drop = function(arg0) {
671
+ const obj = takeObject(arg0).original;
672
+ if (obj.cnt-- == 1) {
673
+ obj.a = 0;
674
+ return true;
675
+ }
676
+ const ret = false;
709
677
  return ret;
710
678
  };
711
679
 
712
- module.exports.__wbindgen_is_string = function(arg0) {
713
- const ret = typeof(getObject(arg0)) === 'string';
714
- return ret;
680
+ module.exports.__wbg_new_7379c57bfbea14d0 = function() {
681
+ const ret = new Map();
682
+ return addHeapObject(ret);
715
683
  };
716
684
 
717
- module.exports.__wbg_new_e14625531a95427d = function() {
718
- const ret = new Array();
719
- return addHeapObject(ret);
685
+ module.exports.__wbindgen_string_get = function(arg0, arg1) {
686
+ const obj = getObject(arg1);
687
+ const ret = typeof(obj) === 'string' ? obj : undefined;
688
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
689
+ var len1 = WASM_VECTOR_LEN;
690
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
691
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
692
+ };
693
+
694
+ module.exports.__wbindgen_number_get = function(arg0, arg1) {
695
+ const obj = getObject(arg1);
696
+ const ret = typeof(obj) === 'number' ? obj : undefined;
697
+ getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
698
+ getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
720
699
  };
721
700
 
722
701
  module.exports.__wbg_new_abda76e883ba8a5f = function() {
@@ -808,7 +787,7 @@ module.exports.__wbg_forEach_5ae261259d7517c8 = function(arg0, arg1, arg2) {
808
787
  const a = state0.a;
809
788
  state0.a = 0;
810
789
  try {
811
- return __wbg_adapter_76(a, state0.b, arg0, arg1, arg2);
790
+ return __wbg_adapter_75(a, state0.b, arg0, arg1, arg2);
812
791
  } finally {
813
792
  state0.a = a;
814
793
  }
@@ -855,7 +834,7 @@ module.exports.__wbg_forEach_942772130a8d06a6 = function(arg0, arg1, arg2) {
855
834
  const a = state0.a;
856
835
  state0.a = 0;
857
836
  try {
858
- return __wbg_adapter_93(a, state0.b, arg0, arg1);
837
+ return __wbg_adapter_92(a, state0.b, arg0, arg1);
859
838
  } finally {
860
839
  state0.a = a;
861
840
  }
@@ -888,7 +867,7 @@ module.exports.__wbg_new_2b55e405e4af4986 = function(arg0, arg1) {
888
867
  const a = state0.a;
889
868
  state0.a = 0;
890
869
  try {
891
- return __wbg_adapter_93(a, state0.b, arg0, arg1);
870
+ return __wbg_adapter_92(a, state0.b, arg0, arg1);
892
871
  } finally {
893
872
  state0.a = a;
894
873
  }
@@ -937,8 +916,8 @@ module.exports.__wbindgen_throw = function(arg0, arg1) {
937
916
  throw new Error(getStringFromWasm0(arg0, arg1));
938
917
  };
939
918
 
940
- module.exports.__wbindgen_closure_wrapper747 = function(arg0, arg1, arg2) {
941
- const ret = makeMutClosure(arg0, arg1, 266, __wbg_adapter_22);
919
+ module.exports.__wbindgen_closure_wrapper738 = function(arg0, arg1, arg2) {
920
+ const ret = makeMutClosure(arg0, arg1, 270, __wbg_adapter_22);
942
921
  return addHeapObject(ret);
943
922
  };
944
923