@provablehq/wasm 0.8.4 → 0.8.6

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.
@@ -234,6 +234,14 @@ function getArrayU8FromWasm0(ptr, len) {
234
234
  ptr = ptr >>> 0;
235
235
  return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
236
236
  }
237
+
238
+ let stack_pointer = 128;
239
+
240
+ function addBorrowedObject(obj) {
241
+ if (stack_pointer == 1) throw new Error('out of js stack');
242
+ heap[--stack_pointer] = obj;
243
+ return stack_pointer;
244
+ }
237
245
  /**
238
246
  * @param {number} receiver
239
247
  */
@@ -251,11 +259,11 @@ function initThreadPool$1(url, num_threads) {
251
259
  return takeObject(ret);
252
260
  }
253
261
 
254
- function __wbg_adapter_38(arg0, arg1, arg2) {
262
+ function __wbg_adapter_40(arg0, arg1, arg2) {
255
263
  wasm.__wbindgen_export_6(arg0, arg1, addHeapObject(arg2));
256
264
  }
257
265
 
258
- function __wbg_adapter_417(arg0, arg1, arg2, arg3) {
266
+ function __wbg_adapter_491(arg0, arg1, arg2, arg3) {
259
267
  wasm.__wbindgen_export_7(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
260
268
  }
261
269
 
@@ -383,586 +391,1927 @@ class Address {
383
391
  }
384
392
  }
385
393
 
386
- const CiphertextFinalization = (typeof FinalizationRegistry === 'undefined')
394
+ const BHP1024Finalization = (typeof FinalizationRegistry === 'undefined')
387
395
  ? { register: () => {}, unregister: () => {} }
388
- : new FinalizationRegistry(ptr => wasm.__wbg_ciphertext_free(ptr >>> 0, 1));
389
- /**
390
- * SnarkVM Ciphertext object. A Ciphertext represents an symmetrically encrypted plaintext. This
391
- * object provides decryption methods to recover the plaintext from the ciphertext (given the
392
- * api consumer has the proper decryption materials).
393
- *
394
- * @example
395
- */
396
- class Ciphertext {
396
+ : new FinalizationRegistry(ptr => wasm.__wbg_bhp1024_free(ptr >>> 0, 1));
397
+
398
+ class BHP1024 {
397
399
 
398
400
  static __wrap(ptr) {
399
401
  ptr = ptr >>> 0;
400
- const obj = Object.create(Ciphertext.prototype);
402
+ const obj = Object.create(BHP1024.prototype);
401
403
  obj.__wbg_ptr = ptr;
402
- CiphertextFinalization.register(obj, obj.__wbg_ptr, obj);
404
+ BHP1024Finalization.register(obj, obj.__wbg_ptr, obj);
403
405
  return obj;
404
406
  }
405
407
 
406
408
  __destroy_into_raw() {
407
409
  const ptr = this.__wbg_ptr;
408
410
  this.__wbg_ptr = 0;
409
- CiphertextFinalization.unregister(this);
411
+ BHP1024Finalization.unregister(this);
410
412
  return ptr;
411
413
  }
412
414
 
413
415
  free() {
414
416
  const ptr = this.__destroy_into_raw();
415
- wasm.__wbg_ciphertext_free(ptr, 0);
417
+ wasm.__wbg_bhp1024_free(ptr, 0);
416
418
  }
417
419
  /**
418
- * Decrypt the ciphertext using the given view key.
419
- *
420
- * @param {ViewKey} The view key of the account that encrypted the ciphertext.
421
- * @param {Group} The nonce used to encrypt the ciphertext.
422
- *
423
- * @returns {Plaintext} The decrypted plaintext.
424
- * @param {ViewKey} view_key
425
- * @param {Group} nonce
426
- * @returns {Plaintext}
420
+ * Create a BHP hasher with an input size of 1024 bits.
427
421
  */
428
- decrypt(view_key, nonce) {
422
+ constructor() {
423
+ const ret = wasm.bhp1024_new();
424
+ this.__wbg_ptr = ret >>> 0;
425
+ BHP1024Finalization.register(this, this.__wbg_ptr, this);
426
+ return this;
427
+ }
428
+ /**
429
+ * Create a BHP hasher with an input size of 1024 bits with a custom domain separator.
430
+ * @param {string} domain_separator
431
+ * @returns {BHP1024}
432
+ */
433
+ static setup(domain_separator) {
429
434
  try {
430
435
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
431
- _assertClass(view_key, ViewKey);
432
- var ptr0 = view_key.__destroy_into_raw();
433
- _assertClass(nonce, Group);
434
- var ptr1 = nonce.__destroy_into_raw();
435
- wasm.ciphertext_decrypt(retptr, this.__wbg_ptr, ptr0, ptr1);
436
+ const ptr0 = passStringToWasm0(domain_separator, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
437
+ const len0 = WASM_VECTOR_LEN;
438
+ wasm.bhp1024_setup(retptr, ptr0, len0);
436
439
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
437
440
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
438
441
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
439
442
  if (r2) {
440
443
  throw takeObject(r1);
441
444
  }
442
- return Plaintext.__wrap(r0);
445
+ return BHP1024.__wrap(r0);
443
446
  } finally {
444
447
  wasm.__wbindgen_add_to_stack_pointer(16);
445
448
  }
446
449
  }
447
450
  /**
448
- * Decrypts a ciphertext into plaintext using the given transition view key.
449
- *
450
- * @param {Field} transition_view_key The transition view key that was used to encrypt the ciphertext.
451
- *
452
- * @returns {Plaintext} The decrypted plaintext.
453
- * @param {Field} transition_view_key
454
- * @returns {Plaintext}
451
+ * Returns the BHP hash with an input hasher of 1024 bits.
452
+ * @param {Array<any>} input
453
+ * @returns {Field}
455
454
  */
456
- decryptSymmetric(transition_view_key) {
455
+ hash(input) {
457
456
  try {
458
457
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
459
- _assertClass(transition_view_key, Field);
460
- var ptr0 = transition_view_key.__destroy_into_raw();
461
- wasm.ciphertext_decryptSymmetric(retptr, this.__wbg_ptr, ptr0);
458
+ wasm.bhp1024_hash(retptr, this.__wbg_ptr, addHeapObject(input));
462
459
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
463
460
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
464
461
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
465
462
  if (r2) {
466
463
  throw takeObject(r1);
467
464
  }
468
- return Plaintext.__wrap(r0);
465
+ return Field.__wrap(r0);
469
466
  } finally {
470
467
  wasm.__wbindgen_add_to_stack_pointer(16);
471
468
  }
472
469
  }
473
470
  /**
474
- * Deserialize a left endian byte array into a Ciphertext.
475
- *
476
- * @param {Uint8Array} bytes The byte array representing the Ciphertext.
477
- *
478
- * @returns {Ciphertext} The Ciphertext object.
479
- * @param {Uint8Array} bytes
480
- * @returns {Ciphertext}
471
+ * Returns a BHP hash with an input hasher of 1024 bits.
472
+ * @param {Array<any>} input
473
+ * @returns {Group}
481
474
  */
482
- static fromBytesLe(bytes) {
475
+ hashToGroup(input) {
483
476
  try {
484
477
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
485
- wasm.ciphertext_fromBytesLe(retptr, addHeapObject(bytes));
478
+ wasm.bhp1024_hashToGroup(retptr, this.__wbg_ptr, addHeapObject(input));
486
479
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
487
480
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
488
481
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
489
482
  if (r2) {
490
483
  throw takeObject(r1);
491
484
  }
492
- return Ciphertext.__wrap(r0);
485
+ return Group.__wrap(r0);
493
486
  } finally {
494
487
  wasm.__wbindgen_add_to_stack_pointer(16);
495
488
  }
496
489
  }
497
490
  /**
498
- * Deserialize a Ciphertext string into a Ciphertext object.
499
- *
500
- * @param {string} ciphertext A string representation of the ciphertext.
501
- *
502
- * @returns {Ciphertext} The Ciphertext object.
503
- * @param {string} ciphertext
504
- * @returns {Ciphertext}
491
+ * Returns a BHP commitment with an input hasher of 1024 bits and randomizer.
492
+ * @param {Array<any>} input
493
+ * @param {Scalar} randomizer
494
+ * @returns {Field}
505
495
  */
506
- static fromString(ciphertext) {
496
+ commit(input, randomizer) {
507
497
  try {
508
498
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
509
- const ptr0 = passStringToWasm0(ciphertext, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
510
- const len0 = WASM_VECTOR_LEN;
511
- wasm.ciphertext_fromString(retptr, ptr0, len0);
499
+ _assertClass(randomizer, Scalar);
500
+ var ptr0 = randomizer.__destroy_into_raw();
501
+ wasm.bhp1024_commit(retptr, this.__wbg_ptr, addHeapObject(input), ptr0);
512
502
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
513
503
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
514
504
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
515
505
  if (r2) {
516
506
  throw takeObject(r1);
517
507
  }
518
- return Ciphertext.__wrap(r0);
508
+ return Field.__wrap(r0);
519
509
  } finally {
520
510
  wasm.__wbindgen_add_to_stack_pointer(16);
521
511
  }
522
512
  }
523
513
  /**
524
- * Serialize a Ciphertext object into a byte array.
525
- *
526
- * @returns {Uint8Array} The serialized Ciphertext.
527
- * @returns {Uint8Array}
514
+ * Returns a BHP commitment with an input hasher of 1024 bits and randomizer.
515
+ * @param {Array<any>} input
516
+ * @param {Scalar} randomizer
517
+ * @returns {Group}
528
518
  */
529
- toBytes() {
519
+ commitToGroup(input, randomizer) {
530
520
  try {
531
521
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
532
- wasm.ciphertext_toBytes(retptr, this.__wbg_ptr);
522
+ _assertClass(randomizer, Scalar);
523
+ var ptr0 = randomizer.__destroy_into_raw();
524
+ wasm.bhp1024_commitToGroup(retptr, this.__wbg_ptr, addHeapObject(input), ptr0);
533
525
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
534
526
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
535
527
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
536
528
  if (r2) {
537
529
  throw takeObject(r1);
538
530
  }
539
- return takeObject(r0);
540
- } finally {
541
- wasm.__wbindgen_add_to_stack_pointer(16);
542
- }
543
- }
544
- /**
545
- * Serialize a Ciphertext into a js string.
546
- *
547
- * @returns {string} The serialized Ciphertext.
548
- * @returns {string}
549
- */
550
- toString() {
551
- let deferred1_0;
552
- let deferred1_1;
553
- try {
554
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
555
- wasm.ciphertext_toString(retptr, this.__wbg_ptr);
556
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
557
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
558
- deferred1_0 = r0;
559
- deferred1_1 = r1;
560
- return getStringFromWasm0(r0, r1);
531
+ return Group.__wrap(r0);
561
532
  } finally {
562
533
  wasm.__wbindgen_add_to_stack_pointer(16);
563
- wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
564
534
  }
565
535
  }
566
536
  }
567
537
 
568
- const ComputeKeyFinalization = (typeof FinalizationRegistry === 'undefined')
538
+ const BHP256Finalization = (typeof FinalizationRegistry === 'undefined')
569
539
  ? { register: () => {}, unregister: () => {} }
570
- : new FinalizationRegistry(ptr => wasm.__wbg_computekey_free(ptr >>> 0, 1));
540
+ : new FinalizationRegistry(ptr => wasm.__wbg_bhp256_free(ptr >>> 0, 1));
571
541
 
572
- class ComputeKey {
542
+ class BHP256 {
573
543
 
574
544
  static __wrap(ptr) {
575
545
  ptr = ptr >>> 0;
576
- const obj = Object.create(ComputeKey.prototype);
546
+ const obj = Object.create(BHP256.prototype);
577
547
  obj.__wbg_ptr = ptr;
578
- ComputeKeyFinalization.register(obj, obj.__wbg_ptr, obj);
548
+ BHP256Finalization.register(obj, obj.__wbg_ptr, obj);
579
549
  return obj;
580
550
  }
581
551
 
582
552
  __destroy_into_raw() {
583
553
  const ptr = this.__wbg_ptr;
584
554
  this.__wbg_ptr = 0;
585
- ComputeKeyFinalization.unregister(this);
555
+ BHP256Finalization.unregister(this);
586
556
  return ptr;
587
557
  }
588
558
 
589
559
  free() {
590
560
  const ptr = this.__destroy_into_raw();
591
- wasm.__wbg_computekey_free(ptr, 0);
561
+ wasm.__wbg_bhp256_free(ptr, 0);
592
562
  }
593
563
  /**
594
- * Create a new compute key from a private key.
595
- *
596
- * @param {PrivateKey} private_key Private key
597
- *
598
- * @returns {ComputeKey} Compute key
599
- * @param {PrivateKey} private_key
600
- * @returns {ComputeKey}
564
+ * Create a BHP hasher with an input size of 256 bits.
601
565
  */
602
- static from_private_key(private_key) {
603
- _assertClass(private_key, PrivateKey);
604
- const ret = wasm.computekey_from_private_key(private_key.__wbg_ptr);
605
- return ComputeKey.__wrap(ret);
566
+ constructor() {
567
+ const ret = wasm.bhp256_new();
568
+ this.__wbg_ptr = ret >>> 0;
569
+ BHP256Finalization.register(this, this.__wbg_ptr, this);
570
+ return this;
606
571
  }
607
572
  /**
608
- * Get the address from the compute key.
609
- *
610
- * @returns {Address}
611
- * @returns {Address}
573
+ * Create a BHP hasher with an input size of 256 bits with a custom domain separator.
574
+ * @param {string} domain_separator
575
+ * @returns {BHP256}
612
576
  */
613
- address() {
614
- const ret = wasm.address_from_compute_key(this.__wbg_ptr);
615
- return Address.__wrap(ret);
577
+ static setup(domain_separator) {
578
+ try {
579
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
580
+ const ptr0 = passStringToWasm0(domain_separator, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
581
+ const len0 = WASM_VECTOR_LEN;
582
+ wasm.bhp256_setup(retptr, ptr0, len0);
583
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
584
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
585
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
586
+ if (r2) {
587
+ throw takeObject(r1);
588
+ }
589
+ return BHP256.__wrap(r0);
590
+ } finally {
591
+ wasm.__wbindgen_add_to_stack_pointer(16);
592
+ }
616
593
  }
617
594
  /**
618
- * Get the sk_prf of the compute key.
619
- *
620
- * @returns {Scalar} sk_prf
621
- * @returns {Scalar}
595
+ * Returns the BHP hash with an input hasher of 256 bits.
596
+ * @param {Array<any>} input
597
+ * @returns {Field}
622
598
  */
623
- sk_prf() {
624
- const ret = wasm.computekey_sk_prf(this.__wbg_ptr);
625
- return Scalar.__wrap(ret);
599
+ hash(input) {
600
+ try {
601
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
602
+ wasm.bhp256_hash(retptr, this.__wbg_ptr, addHeapObject(input));
603
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
604
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
605
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
606
+ if (r2) {
607
+ throw takeObject(r1);
608
+ }
609
+ return Field.__wrap(r0);
610
+ } finally {
611
+ wasm.__wbindgen_add_to_stack_pointer(16);
612
+ }
626
613
  }
627
614
  /**
628
- * Get the pr_tag of the compute key.
629
- *
630
- * @returns {Group} pr_tag
615
+ * Returns a BHP hash with an input hasher of 256 bits.
616
+ * @param {Array<any>} input
631
617
  * @returns {Group}
632
618
  */
633
- pk_sig() {
634
- const ret = wasm.computekey_pk_sig(this.__wbg_ptr);
635
- return Group.__wrap(ret);
619
+ hashToGroup(input) {
620
+ try {
621
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
622
+ wasm.bhp256_hashToGroup(retptr, this.__wbg_ptr, addHeapObject(input));
623
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
624
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
625
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
626
+ if (r2) {
627
+ throw takeObject(r1);
628
+ }
629
+ return Group.__wrap(r0);
630
+ } finally {
631
+ wasm.__wbindgen_add_to_stack_pointer(16);
632
+ }
636
633
  }
637
634
  /**
638
- * Get the pr_sig of the compute key.
639
- *
640
- * @returns {Group} pr_sig
635
+ * Returns a BHP commitment with an input hasher of 256 bits and randomizer.
636
+ * @param {Array<any>} input
637
+ * @param {Scalar} randomizer
638
+ * @returns {Field}
639
+ */
640
+ commit(input, randomizer) {
641
+ try {
642
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
643
+ _assertClass(randomizer, Scalar);
644
+ var ptr0 = randomizer.__destroy_into_raw();
645
+ wasm.bhp256_commit(retptr, this.__wbg_ptr, addHeapObject(input), ptr0);
646
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
647
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
648
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
649
+ if (r2) {
650
+ throw takeObject(r1);
651
+ }
652
+ return Field.__wrap(r0);
653
+ } finally {
654
+ wasm.__wbindgen_add_to_stack_pointer(16);
655
+ }
656
+ }
657
+ /**
658
+ * Returns a BHP commitment with an input hasher of 256 bits and randomizer.
659
+ * @param {Array<any>} input
660
+ * @param {Scalar} randomizer
641
661
  * @returns {Group}
642
662
  */
643
- pr_sig() {
644
- const ret = wasm.computekey_pr_sig(this.__wbg_ptr);
645
- return Group.__wrap(ret);
663
+ commitToGroup(input, randomizer) {
664
+ try {
665
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
666
+ _assertClass(randomizer, Scalar);
667
+ var ptr0 = randomizer.__destroy_into_raw();
668
+ wasm.bhp256_commitToGroup(retptr, this.__wbg_ptr, addHeapObject(input), ptr0);
669
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
670
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
671
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
672
+ if (r2) {
673
+ throw takeObject(r1);
674
+ }
675
+ return Group.__wrap(r0);
676
+ } finally {
677
+ wasm.__wbindgen_add_to_stack_pointer(16);
678
+ }
646
679
  }
647
680
  }
648
681
 
649
- const ExecutionFinalization = (typeof FinalizationRegistry === 'undefined')
682
+ const BHP512Finalization = (typeof FinalizationRegistry === 'undefined')
650
683
  ? { register: () => {}, unregister: () => {} }
651
- : new FinalizationRegistry(ptr => wasm.__wbg_execution_free(ptr >>> 0, 1));
652
- /**
653
- * Execution of an Aleo program.
654
- */
655
- class Execution {
684
+ : new FinalizationRegistry(ptr => wasm.__wbg_bhp512_free(ptr >>> 0, 1));
685
+
686
+ class BHP512 {
656
687
 
657
688
  static __wrap(ptr) {
658
689
  ptr = ptr >>> 0;
659
- const obj = Object.create(Execution.prototype);
690
+ const obj = Object.create(BHP512.prototype);
660
691
  obj.__wbg_ptr = ptr;
661
- ExecutionFinalization.register(obj, obj.__wbg_ptr, obj);
692
+ BHP512Finalization.register(obj, obj.__wbg_ptr, obj);
662
693
  return obj;
663
694
  }
664
695
 
665
696
  __destroy_into_raw() {
666
697
  const ptr = this.__wbg_ptr;
667
698
  this.__wbg_ptr = 0;
668
- ExecutionFinalization.unregister(this);
699
+ BHP512Finalization.unregister(this);
669
700
  return ptr;
670
701
  }
671
702
 
672
703
  free() {
673
704
  const ptr = this.__destroy_into_raw();
674
- wasm.__wbg_execution_free(ptr, 0);
705
+ wasm.__wbg_bhp512_free(ptr, 0);
675
706
  }
676
707
  /**
677
- * Returns the string representation of the execution.
678
- *
679
- * @returns {string} The string representation of the execution.
680
- * @returns {string}
708
+ * Create a BHP hasher with an input size of 512 bits.
681
709
  */
682
- toString() {
683
- let deferred1_0;
684
- let deferred1_1;
710
+ constructor() {
711
+ const ret = wasm.bhp512_new();
712
+ this.__wbg_ptr = ret >>> 0;
713
+ BHP512Finalization.register(this, this.__wbg_ptr, this);
714
+ return this;
715
+ }
716
+ /**
717
+ * Create a BHP hasher with an input size of 512 bits with a custom domain separator.
718
+ * @param {string} domain_separator
719
+ * @returns {BHP512}
720
+ */
721
+ static setup(domain_separator) {
685
722
  try {
686
723
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
687
- wasm.execution_toString(retptr, this.__wbg_ptr);
724
+ const ptr0 = passStringToWasm0(domain_separator, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
725
+ const len0 = WASM_VECTOR_LEN;
726
+ wasm.bhp512_setup(retptr, ptr0, len0);
688
727
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
689
728
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
690
- deferred1_0 = r0;
691
- deferred1_1 = r1;
692
- return getStringFromWasm0(r0, r1);
729
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
730
+ if (r2) {
731
+ throw takeObject(r1);
732
+ }
733
+ return BHP512.__wrap(r0);
693
734
  } finally {
694
735
  wasm.__wbindgen_add_to_stack_pointer(16);
695
- wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
696
736
  }
697
737
  }
698
738
  /**
699
- * Creates an execution object from a string representation of an execution.
700
- *
701
- * @returns {Execution | Error} The wasm representation of an execution object.
702
- * @param {string} execution
703
- * @returns {Execution}
739
+ * Returns the BHP hash with an input hasher of 512 bits.
740
+ * @param {Array<any>} input
741
+ * @returns {Field}
704
742
  */
705
- static fromString(execution) {
743
+ hash(input) {
706
744
  try {
707
745
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
708
- const ptr0 = passStringToWasm0(execution, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
709
- const len0 = WASM_VECTOR_LEN;
710
- wasm.execution_fromString(retptr, ptr0, len0);
746
+ wasm.bhp512_hash(retptr, this.__wbg_ptr, addHeapObject(input));
711
747
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
712
748
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
713
749
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
714
750
  if (r2) {
715
751
  throw takeObject(r1);
716
752
  }
717
- return Execution.__wrap(r0);
753
+ return Field.__wrap(r0);
718
754
  } finally {
719
755
  wasm.__wbindgen_add_to_stack_pointer(16);
720
756
  }
721
757
  }
722
758
  /**
723
- * Returns the global state root of the execution.
724
- *
725
- * @returns {Execution | Error} The global state root used in the execution.
726
- * @returns {string}
759
+ * Returns a BHP hash with an input hasher of 512 bits.
760
+ * @param {Array<any>} input
761
+ * @returns {Group}
727
762
  */
728
- globalStateRoot() {
729
- let deferred1_0;
730
- let deferred1_1;
763
+ hashToGroup(input) {
731
764
  try {
732
765
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
733
- wasm.execution_globalStateRoot(retptr, this.__wbg_ptr);
766
+ wasm.bhp512_hashToGroup(retptr, this.__wbg_ptr, addHeapObject(input));
734
767
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
735
768
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
736
- deferred1_0 = r0;
737
- deferred1_1 = r1;
738
- return getStringFromWasm0(r0, r1);
769
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
770
+ if (r2) {
771
+ throw takeObject(r1);
772
+ }
773
+ return Group.__wrap(r0);
739
774
  } finally {
740
775
  wasm.__wbindgen_add_to_stack_pointer(16);
741
- wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
742
776
  }
743
777
  }
744
778
  /**
745
- * Returns the proof of the execution.
746
- *
747
- * @returns {string} The execution proof.
748
- * @returns {string}
779
+ * Returns a BHP commitment with an input hasher of 512 bits and randomizer.
780
+ * @param {Array<any>} input
781
+ * @param {Scalar} randomizer
782
+ * @returns {Field}
749
783
  */
750
- proof() {
751
- let deferred1_0;
752
- let deferred1_1;
784
+ commit(input, randomizer) {
753
785
  try {
754
786
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
755
- wasm.execution_proof(retptr, this.__wbg_ptr);
787
+ _assertClass(randomizer, Scalar);
788
+ var ptr0 = randomizer.__destroy_into_raw();
789
+ wasm.bhp512_commit(retptr, this.__wbg_ptr, addHeapObject(input), ptr0);
756
790
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
757
791
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
758
- deferred1_0 = r0;
759
- deferred1_1 = r1;
760
- return getStringFromWasm0(r0, r1);
792
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
793
+ if (r2) {
794
+ throw takeObject(r1);
795
+ }
796
+ return Field.__wrap(r0);
761
797
  } finally {
762
798
  wasm.__wbindgen_add_to_stack_pointer(16);
763
- wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
764
799
  }
765
800
  }
766
801
  /**
767
- * Returns the transitions present in the execution.
768
- *
769
- * @returns Array<Transition> the array of transitions present in the execution.
770
- * @returns {Array<any>}
802
+ * Returns a BHP commitment with an input hasher of 512 bits and randomizer.
803
+ * @param {Array<any>} input
804
+ * @param {Scalar} randomizer
805
+ * @returns {Group}
771
806
  */
772
- transitions() {
773
- const ret = wasm.execution_transitions(this.__wbg_ptr);
774
- return takeObject(ret);
807
+ commitToGroup(input, randomizer) {
808
+ try {
809
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
810
+ _assertClass(randomizer, Scalar);
811
+ var ptr0 = randomizer.__destroy_into_raw();
812
+ wasm.bhp512_commitToGroup(retptr, this.__wbg_ptr, addHeapObject(input), ptr0);
813
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
814
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
815
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
816
+ if (r2) {
817
+ throw takeObject(r1);
818
+ }
819
+ return Group.__wrap(r0);
820
+ } finally {
821
+ wasm.__wbindgen_add_to_stack_pointer(16);
822
+ }
775
823
  }
776
824
  }
777
825
 
778
- const ExecutionResponseFinalization = (typeof FinalizationRegistry === 'undefined')
826
+ const BHP768Finalization = (typeof FinalizationRegistry === 'undefined')
779
827
  ? { register: () => {}, unregister: () => {} }
780
- : new FinalizationRegistry(ptr => wasm.__wbg_executionresponse_free(ptr >>> 0, 1));
781
- /**
782
- * Webassembly Representation of an Aleo function execution response
783
- *
784
- * This object is returned by the execution of an Aleo function off-chain. It provides methods for
785
- * retrieving the outputs of the function execution.
786
- */
787
- class ExecutionResponse {
828
+ : new FinalizationRegistry(ptr => wasm.__wbg_bhp768_free(ptr >>> 0, 1));
829
+
830
+ class BHP768 {
788
831
 
789
832
  static __wrap(ptr) {
790
833
  ptr = ptr >>> 0;
791
- const obj = Object.create(ExecutionResponse.prototype);
834
+ const obj = Object.create(BHP768.prototype);
792
835
  obj.__wbg_ptr = ptr;
793
- ExecutionResponseFinalization.register(obj, obj.__wbg_ptr, obj);
836
+ BHP768Finalization.register(obj, obj.__wbg_ptr, obj);
794
837
  return obj;
795
838
  }
796
839
 
797
840
  __destroy_into_raw() {
798
841
  const ptr = this.__wbg_ptr;
799
842
  this.__wbg_ptr = 0;
800
- ExecutionResponseFinalization.unregister(this);
843
+ BHP768Finalization.unregister(this);
801
844
  return ptr;
802
845
  }
803
846
 
804
847
  free() {
805
848
  const ptr = this.__destroy_into_raw();
806
- wasm.__wbg_executionresponse_free(ptr, 0);
807
- }
808
- /**
809
- * Get the outputs of the executed function
810
- *
811
- * @returns {Array} Array of strings representing the outputs of the function
812
- * @returns {Array<any>}
813
- */
814
- getOutputs() {
815
- const ret = wasm.executionresponse_getOutputs(this.__wbg_ptr);
816
- return takeObject(ret);
849
+ wasm.__wbg_bhp768_free(ptr, 0);
817
850
  }
818
851
  /**
819
- * Returns the execution object if present, null if otherwise.
820
- *
821
- * @returns {Execution | undefined} The execution object if present, null if otherwise
822
- * @returns {Execution | undefined}
852
+ * Create a BHP hasher with an input size of 768 bits.
823
853
  */
824
- getExecution() {
825
- const ret = wasm.executionresponse_getExecution(this.__wbg_ptr);
826
- return ret === 0 ? undefined : Execution.__wrap(ret);
854
+ constructor() {
855
+ const ret = wasm.bhp768_new();
856
+ this.__wbg_ptr = ret >>> 0;
857
+ BHP768Finalization.register(this, this.__wbg_ptr, this);
858
+ return this;
827
859
  }
828
860
  /**
829
- * Returns the program keys if present
830
- * @returns {KeyPair}
861
+ * Create a BHP hasher with an input size of 768 bits with a custom domain separator.
862
+ * @param {string} domain_separator
863
+ * @returns {BHP768}
831
864
  */
832
- getKeys() {
865
+ static setup(domain_separator) {
833
866
  try {
834
867
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
835
- wasm.executionresponse_getKeys(retptr, this.__wbg_ptr);
868
+ const ptr0 = passStringToWasm0(domain_separator, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
869
+ const len0 = WASM_VECTOR_LEN;
870
+ wasm.bhp768_setup(retptr, ptr0, len0);
836
871
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
837
872
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
838
873
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
839
874
  if (r2) {
840
875
  throw takeObject(r1);
841
876
  }
842
- return KeyPair.__wrap(r0);
877
+ return BHP768.__wrap(r0);
843
878
  } finally {
844
879
  wasm.__wbindgen_add_to_stack_pointer(16);
845
880
  }
846
881
  }
847
882
  /**
848
- * Returns the proving_key if the proving key was cached in the Execution response.
849
- * Note the proving key is removed from the response object after the first call to this
850
- * function. Subsequent calls will return null.
851
- *
852
- * @returns {ProvingKey | undefined} The proving key
853
- * @returns {ProvingKey | undefined}
883
+ * Returns the BHP hash with an input hasher of 768 bits.
884
+ * @param {Array<any>} input
885
+ * @returns {Field}
854
886
  */
855
- getProvingKey() {
856
- const ret = wasm.executionresponse_getProvingKey(this.__wbg_ptr);
857
- return ret === 0 ? undefined : ProvingKey.__wrap(ret);
887
+ hash(input) {
888
+ try {
889
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
890
+ wasm.bhp768_hash(retptr, this.__wbg_ptr, addHeapObject(input));
891
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
892
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
893
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
894
+ if (r2) {
895
+ throw takeObject(r1);
896
+ }
897
+ return Field.__wrap(r0);
898
+ } finally {
899
+ wasm.__wbindgen_add_to_stack_pointer(16);
900
+ }
858
901
  }
859
902
  /**
860
- * Returns the verifying_key associated with the program
861
- *
862
- * @returns {VerifyingKey} The verifying key
863
- * @returns {VerifyingKey}
903
+ * Returns a BHP hash with an input hasher of 768 bits.
904
+ * @param {Array<any>} input
905
+ * @returns {Group}
864
906
  */
865
- getVerifyingKey() {
866
- const ret = wasm.executionresponse_getVerifyingKey(this.__wbg_ptr);
867
- return VerifyingKey.__wrap(ret);
907
+ hashToGroup(input) {
908
+ try {
909
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
910
+ wasm.bhp768_hashToGroup(retptr, this.__wbg_ptr, addHeapObject(input));
911
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
912
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
913
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
914
+ if (r2) {
915
+ throw takeObject(r1);
916
+ }
917
+ return Group.__wrap(r0);
918
+ } finally {
919
+ wasm.__wbindgen_add_to_stack_pointer(16);
920
+ }
868
921
  }
869
922
  /**
870
- * Returns the function identifier
871
- * @returns {string}
923
+ * Returns a BHP commitment with an input hasher of 768 bits and randomizer.
924
+ * @param {Array<any>} input
925
+ * @param {Scalar} randomizer
926
+ * @returns {Field}
872
927
  */
873
- getFunctionId() {
874
- let deferred1_0;
875
- let deferred1_1;
928
+ commit(input, randomizer) {
876
929
  try {
877
930
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
878
- wasm.executionresponse_getFunctionId(retptr, this.__wbg_ptr);
931
+ _assertClass(randomizer, Scalar);
932
+ var ptr0 = randomizer.__destroy_into_raw();
933
+ wasm.bhp768_commit(retptr, this.__wbg_ptr, addHeapObject(input), ptr0);
879
934
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
880
935
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
881
- deferred1_0 = r0;
882
- deferred1_1 = r1;
883
- return getStringFromWasm0(r0, r1);
936
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
937
+ if (r2) {
938
+ throw takeObject(r1);
939
+ }
940
+ return Field.__wrap(r0);
884
941
  } finally {
885
942
  wasm.__wbindgen_add_to_stack_pointer(16);
886
- wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
887
943
  }
888
944
  }
889
945
  /**
890
- * Returns the program
891
- * @returns {Program}
946
+ * Returns a BHP commitment with an input hasher of 768 bits and randomizer.
947
+ * @param {Array<any>} input
948
+ * @param {Scalar} randomizer
949
+ * @returns {Group}
892
950
  */
893
- getProgram() {
894
- const ret = wasm.executionresponse_getProgram(this.__wbg_ptr);
895
- return Program.__wrap(ret);
951
+ commitToGroup(input, randomizer) {
952
+ try {
953
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
954
+ _assertClass(randomizer, Scalar);
955
+ var ptr0 = randomizer.__destroy_into_raw();
956
+ wasm.bhp768_commitToGroup(retptr, this.__wbg_ptr, addHeapObject(input), ptr0);
957
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
958
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
959
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
960
+ if (r2) {
961
+ throw takeObject(r1);
962
+ }
963
+ return Group.__wrap(r0);
964
+ } finally {
965
+ wasm.__wbindgen_add_to_stack_pointer(16);
966
+ }
896
967
  }
897
968
  }
898
969
 
899
- const FieldFinalization = (typeof FinalizationRegistry === 'undefined')
970
+ const CiphertextFinalization = (typeof FinalizationRegistry === 'undefined')
900
971
  ? { register: () => {}, unregister: () => {} }
901
- : new FinalizationRegistry(ptr => wasm.__wbg_field_free(ptr >>> 0, 1));
972
+ : new FinalizationRegistry(ptr => wasm.__wbg_ciphertext_free(ptr >>> 0, 1));
902
973
  /**
903
- * Field element.
974
+ * SnarkVM Ciphertext object. A Ciphertext represents an symmetrically encrypted plaintext. This
975
+ * object provides decryption methods to recover the plaintext from the ciphertext (given the
976
+ * api consumer has the proper decryption materials).
977
+ *
978
+ * @example
904
979
  */
905
- class Field {
980
+ class Ciphertext {
906
981
 
907
982
  static __wrap(ptr) {
908
983
  ptr = ptr >>> 0;
909
- const obj = Object.create(Field.prototype);
984
+ const obj = Object.create(Ciphertext.prototype);
910
985
  obj.__wbg_ptr = ptr;
911
- FieldFinalization.register(obj, obj.__wbg_ptr, obj);
986
+ CiphertextFinalization.register(obj, obj.__wbg_ptr, obj);
912
987
  return obj;
913
988
  }
914
989
 
915
990
  __destroy_into_raw() {
916
991
  const ptr = this.__wbg_ptr;
917
992
  this.__wbg_ptr = 0;
918
- FieldFinalization.unregister(this);
993
+ CiphertextFinalization.unregister(this);
919
994
  return ptr;
920
995
  }
921
996
 
922
997
  free() {
923
998
  const ptr = this.__destroy_into_raw();
924
- wasm.__wbg_field_free(ptr, 0);
999
+ wasm.__wbg_ciphertext_free(ptr, 0);
925
1000
  }
926
1001
  /**
927
- * Creates a field object from a string representation of a field.
928
- * @param {string} field
929
- * @returns {Field}
1002
+ * Decrypt the ciphertext using the given view key.
1003
+ *
1004
+ * @param {ViewKey} The view key of the account that encrypted the ciphertext.
1005
+ * @param {Group} The nonce used to encrypt the ciphertext.
1006
+ *
1007
+ * @returns {Plaintext} The decrypted plaintext.
1008
+ * @param {ViewKey} view_key
1009
+ * @param {Group} nonce
1010
+ * @returns {Plaintext}
930
1011
  */
931
- static fromString(field) {
1012
+ decrypt(view_key, nonce) {
932
1013
  try {
933
1014
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
934
- const ptr0 = passStringToWasm0(field, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
935
- const len0 = WASM_VECTOR_LEN;
936
- wasm.field_fromString(retptr, ptr0, len0);
1015
+ _assertClass(view_key, ViewKey);
1016
+ var ptr0 = view_key.__destroy_into_raw();
1017
+ _assertClass(nonce, Group);
1018
+ var ptr1 = nonce.__destroy_into_raw();
1019
+ wasm.ciphertext_decrypt(retptr, this.__wbg_ptr, ptr0, ptr1);
937
1020
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
938
1021
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
939
1022
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
940
1023
  if (r2) {
941
1024
  throw takeObject(r1);
942
1025
  }
943
- return Field.__wrap(r0);
1026
+ return Plaintext.__wrap(r0);
944
1027
  } finally {
945
1028
  wasm.__wbindgen_add_to_stack_pointer(16);
946
1029
  }
947
1030
  }
948
1031
  /**
949
- * Create a plaintext element from a group element.
1032
+ * Decrypt a ciphertext using the view key of the transition signer, transition public key, and
1033
+ * (program, function, index) tuple.
1034
+ * @param {ViewKey} view_key
1035
+ * @param {Group} transition_public_key
1036
+ * @param {string} program
1037
+ * @param {string} function_name
1038
+ * @param {number} index
950
1039
  * @returns {Plaintext}
951
1040
  */
952
- toPlaintext() {
953
- const ret = wasm.field_toPlaintext(this.__wbg_ptr);
954
- return Plaintext.__wrap(ret);
955
- }
956
- /**
957
- * Returns the string representation of the field.
958
- * @returns {string}
959
- */
960
- toString() {
1041
+ decrypt_with_transition_info(view_key, transition_public_key, program, function_name, index) {
1042
+ try {
1043
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1044
+ _assertClass(view_key, ViewKey);
1045
+ var ptr0 = view_key.__destroy_into_raw();
1046
+ _assertClass(transition_public_key, Group);
1047
+ var ptr1 = transition_public_key.__destroy_into_raw();
1048
+ const ptr2 = passStringToWasm0(program, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
1049
+ const len2 = WASM_VECTOR_LEN;
1050
+ const ptr3 = passStringToWasm0(function_name, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
1051
+ const len3 = WASM_VECTOR_LEN;
1052
+ wasm.ciphertext_decrypt_with_transition_info(retptr, this.__wbg_ptr, ptr0, ptr1, ptr2, len2, ptr3, len3, index);
1053
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1054
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1055
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1056
+ if (r2) {
1057
+ throw takeObject(r1);
1058
+ }
1059
+ return Plaintext.__wrap(r0);
1060
+ } finally {
1061
+ wasm.__wbindgen_add_to_stack_pointer(16);
1062
+ }
1063
+ }
1064
+ /**
1065
+ * Decrypt a ciphertext using the transition view key and a (program, function, index) tuple.
1066
+ * @param {Field} transition_view_key
1067
+ * @param {string} program
1068
+ * @param {string} function_name
1069
+ * @param {number} index
1070
+ * @returns {Plaintext}
1071
+ */
1072
+ decrypt_with_transition_view_key(transition_view_key, program, function_name, index) {
1073
+ try {
1074
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1075
+ _assertClass(transition_view_key, Field);
1076
+ var ptr0 = transition_view_key.__destroy_into_raw();
1077
+ const ptr1 = passStringToWasm0(program, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
1078
+ const len1 = WASM_VECTOR_LEN;
1079
+ const ptr2 = passStringToWasm0(function_name, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
1080
+ const len2 = WASM_VECTOR_LEN;
1081
+ wasm.ciphertext_decrypt_with_transition_view_key(retptr, this.__wbg_ptr, ptr0, ptr1, len1, ptr2, len2, index);
1082
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1083
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1084
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1085
+ if (r2) {
1086
+ throw takeObject(r1);
1087
+ }
1088
+ return Plaintext.__wrap(r0);
1089
+ } finally {
1090
+ wasm.__wbindgen_add_to_stack_pointer(16);
1091
+ }
1092
+ }
1093
+ /**
1094
+ * Decrypts a ciphertext into plaintext using the given ciphertext view key.
1095
+ *
1096
+ * @param {Field} transition_view_key The transition view key that was used to encrypt the ciphertext.
1097
+ *
1098
+ * @returns {Plaintext} The decrypted plaintext.
1099
+ * @param {Field} transition_view_key
1100
+ * @returns {Plaintext}
1101
+ */
1102
+ decryptSymmetric(transition_view_key) {
1103
+ try {
1104
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1105
+ _assertClass(transition_view_key, Field);
1106
+ var ptr0 = transition_view_key.__destroy_into_raw();
1107
+ wasm.ciphertext_decryptSymmetric(retptr, this.__wbg_ptr, ptr0);
1108
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1109
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1110
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1111
+ if (r2) {
1112
+ throw takeObject(r1);
1113
+ }
1114
+ return Plaintext.__wrap(r0);
1115
+ } finally {
1116
+ wasm.__wbindgen_add_to_stack_pointer(16);
1117
+ }
1118
+ }
1119
+ /**
1120
+ * Deserialize a left endian byte array into a Ciphertext.
1121
+ *
1122
+ * @param {Uint8Array} bytes The byte array representing the Ciphertext.
1123
+ *
1124
+ * @returns {Ciphertext} The Ciphertext object.
1125
+ * @param {Uint8Array} bytes
1126
+ * @returns {Ciphertext}
1127
+ */
1128
+ static fromBytesLe(bytes) {
1129
+ try {
1130
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1131
+ wasm.ciphertext_fromBytesLe(retptr, addHeapObject(bytes));
1132
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1133
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1134
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1135
+ if (r2) {
1136
+ throw takeObject(r1);
1137
+ }
1138
+ return Ciphertext.__wrap(r0);
1139
+ } finally {
1140
+ wasm.__wbindgen_add_to_stack_pointer(16);
1141
+ }
1142
+ }
1143
+ /**
1144
+ * Deserialize a Ciphertext string into a Ciphertext object.
1145
+ *
1146
+ * @param {string} ciphertext A string representation of the ciphertext.
1147
+ *
1148
+ * @returns {Ciphertext} The Ciphertext object.
1149
+ * @param {string} ciphertext
1150
+ * @returns {Ciphertext}
1151
+ */
1152
+ static fromString(ciphertext) {
1153
+ try {
1154
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1155
+ const ptr0 = passStringToWasm0(ciphertext, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
1156
+ const len0 = WASM_VECTOR_LEN;
1157
+ wasm.ciphertext_fromString(retptr, ptr0, len0);
1158
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1159
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1160
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1161
+ if (r2) {
1162
+ throw takeObject(r1);
1163
+ }
1164
+ return Ciphertext.__wrap(r0);
1165
+ } finally {
1166
+ wasm.__wbindgen_add_to_stack_pointer(16);
1167
+ }
1168
+ }
1169
+ /**
1170
+ * Serialize a Ciphertext object into a byte array.
1171
+ *
1172
+ * @returns {Uint8Array} The serialized Ciphertext.
1173
+ * @returns {Uint8Array}
1174
+ */
1175
+ toBytes() {
1176
+ try {
1177
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1178
+ wasm.ciphertext_toBytes(retptr, this.__wbg_ptr);
1179
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1180
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1181
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1182
+ if (r2) {
1183
+ throw takeObject(r1);
1184
+ }
1185
+ return takeObject(r0);
1186
+ } finally {
1187
+ wasm.__wbindgen_add_to_stack_pointer(16);
1188
+ }
1189
+ }
1190
+ /**
1191
+ * Serialize a Ciphertext into a js string.
1192
+ *
1193
+ * @returns {string} The serialized Ciphertext.
1194
+ * @returns {string}
1195
+ */
1196
+ toString() {
1197
+ let deferred1_0;
1198
+ let deferred1_1;
1199
+ try {
1200
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1201
+ wasm.ciphertext_toString(retptr, this.__wbg_ptr);
1202
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1203
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1204
+ deferred1_0 = r0;
1205
+ deferred1_1 = r1;
1206
+ return getStringFromWasm0(r0, r1);
1207
+ } finally {
1208
+ wasm.__wbindgen_add_to_stack_pointer(16);
1209
+ wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
1210
+ }
1211
+ }
1212
+ }
1213
+
1214
+ const ComputeKeyFinalization = (typeof FinalizationRegistry === 'undefined')
1215
+ ? { register: () => {}, unregister: () => {} }
1216
+ : new FinalizationRegistry(ptr => wasm.__wbg_computekey_free(ptr >>> 0, 1));
1217
+
1218
+ class ComputeKey {
1219
+
1220
+ static __wrap(ptr) {
1221
+ ptr = ptr >>> 0;
1222
+ const obj = Object.create(ComputeKey.prototype);
1223
+ obj.__wbg_ptr = ptr;
1224
+ ComputeKeyFinalization.register(obj, obj.__wbg_ptr, obj);
1225
+ return obj;
1226
+ }
1227
+
1228
+ __destroy_into_raw() {
1229
+ const ptr = this.__wbg_ptr;
1230
+ this.__wbg_ptr = 0;
1231
+ ComputeKeyFinalization.unregister(this);
1232
+ return ptr;
1233
+ }
1234
+
1235
+ free() {
1236
+ const ptr = this.__destroy_into_raw();
1237
+ wasm.__wbg_computekey_free(ptr, 0);
1238
+ }
1239
+ /**
1240
+ * Create a new compute key from a private key.
1241
+ *
1242
+ * @param {PrivateKey} private_key Private key
1243
+ *
1244
+ * @returns {ComputeKey} Compute key
1245
+ * @param {PrivateKey} private_key
1246
+ * @returns {ComputeKey}
1247
+ */
1248
+ static from_private_key(private_key) {
1249
+ _assertClass(private_key, PrivateKey);
1250
+ const ret = wasm.computekey_from_private_key(private_key.__wbg_ptr);
1251
+ return ComputeKey.__wrap(ret);
1252
+ }
1253
+ /**
1254
+ * Get the address from the compute key.
1255
+ *
1256
+ * @returns {Address}
1257
+ * @returns {Address}
1258
+ */
1259
+ address() {
1260
+ const ret = wasm.address_from_compute_key(this.__wbg_ptr);
1261
+ return Address.__wrap(ret);
1262
+ }
1263
+ /**
1264
+ * Get the sk_prf of the compute key.
1265
+ *
1266
+ * @returns {Scalar} sk_prf
1267
+ * @returns {Scalar}
1268
+ */
1269
+ sk_prf() {
1270
+ const ret = wasm.computekey_sk_prf(this.__wbg_ptr);
1271
+ return Scalar.__wrap(ret);
1272
+ }
1273
+ /**
1274
+ * Get the pr_tag of the compute key.
1275
+ *
1276
+ * @returns {Group} pr_tag
1277
+ * @returns {Group}
1278
+ */
1279
+ pk_sig() {
1280
+ const ret = wasm.computekey_pk_sig(this.__wbg_ptr);
1281
+ return Group.__wrap(ret);
1282
+ }
1283
+ /**
1284
+ * Get the pr_sig of the compute key.
1285
+ *
1286
+ * @returns {Group} pr_sig
1287
+ * @returns {Group}
1288
+ */
1289
+ pr_sig() {
1290
+ const ret = wasm.computekey_pr_sig(this.__wbg_ptr);
1291
+ return Group.__wrap(ret);
1292
+ }
1293
+ }
1294
+
1295
+ const ExecutionFinalization = (typeof FinalizationRegistry === 'undefined')
1296
+ ? { register: () => {}, unregister: () => {} }
1297
+ : new FinalizationRegistry(ptr => wasm.__wbg_execution_free(ptr >>> 0, 1));
1298
+ /**
1299
+ * Execution of an Aleo program.
1300
+ */
1301
+ class Execution {
1302
+
1303
+ static __wrap(ptr) {
1304
+ ptr = ptr >>> 0;
1305
+ const obj = Object.create(Execution.prototype);
1306
+ obj.__wbg_ptr = ptr;
1307
+ ExecutionFinalization.register(obj, obj.__wbg_ptr, obj);
1308
+ return obj;
1309
+ }
1310
+
1311
+ __destroy_into_raw() {
1312
+ const ptr = this.__wbg_ptr;
1313
+ this.__wbg_ptr = 0;
1314
+ ExecutionFinalization.unregister(this);
1315
+ return ptr;
1316
+ }
1317
+
1318
+ free() {
1319
+ const ptr = this.__destroy_into_raw();
1320
+ wasm.__wbg_execution_free(ptr, 0);
1321
+ }
1322
+ /**
1323
+ * Returns the string representation of the execution.
1324
+ *
1325
+ * @returns {string} The string representation of the execution.
1326
+ * @returns {string}
1327
+ */
1328
+ toString() {
1329
+ let deferred1_0;
1330
+ let deferred1_1;
1331
+ try {
1332
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1333
+ wasm.execution_toString(retptr, this.__wbg_ptr);
1334
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1335
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1336
+ deferred1_0 = r0;
1337
+ deferred1_1 = r1;
1338
+ return getStringFromWasm0(r0, r1);
1339
+ } finally {
1340
+ wasm.__wbindgen_add_to_stack_pointer(16);
1341
+ wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
1342
+ }
1343
+ }
1344
+ /**
1345
+ * Creates an execution object from a string representation of an execution.
1346
+ *
1347
+ * @returns {Execution | Error} The wasm representation of an execution object.
1348
+ * @param {string} execution
1349
+ * @returns {Execution}
1350
+ */
1351
+ static fromString(execution) {
1352
+ try {
1353
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1354
+ const ptr0 = passStringToWasm0(execution, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
1355
+ const len0 = WASM_VECTOR_LEN;
1356
+ wasm.execution_fromString(retptr, ptr0, len0);
1357
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1358
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1359
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1360
+ if (r2) {
1361
+ throw takeObject(r1);
1362
+ }
1363
+ return Execution.__wrap(r0);
1364
+ } finally {
1365
+ wasm.__wbindgen_add_to_stack_pointer(16);
1366
+ }
1367
+ }
1368
+ /**
1369
+ * Returns the global state root of the execution.
1370
+ *
1371
+ * @returns {Execution | Error} The global state root used in the execution.
1372
+ * @returns {string}
1373
+ */
1374
+ globalStateRoot() {
1375
+ let deferred1_0;
1376
+ let deferred1_1;
1377
+ try {
1378
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1379
+ wasm.execution_globalStateRoot(retptr, this.__wbg_ptr);
1380
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1381
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1382
+ deferred1_0 = r0;
1383
+ deferred1_1 = r1;
1384
+ return getStringFromWasm0(r0, r1);
1385
+ } finally {
1386
+ wasm.__wbindgen_add_to_stack_pointer(16);
1387
+ wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
1388
+ }
1389
+ }
1390
+ /**
1391
+ * Returns the proof of the execution.
1392
+ *
1393
+ * @returns {string} The execution proof.
1394
+ * @returns {string}
1395
+ */
1396
+ proof() {
1397
+ let deferred1_0;
1398
+ let deferred1_1;
1399
+ try {
1400
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1401
+ wasm.execution_proof(retptr, this.__wbg_ptr);
1402
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1403
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1404
+ deferred1_0 = r0;
1405
+ deferred1_1 = r1;
1406
+ return getStringFromWasm0(r0, r1);
1407
+ } finally {
1408
+ wasm.__wbindgen_add_to_stack_pointer(16);
1409
+ wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
1410
+ }
1411
+ }
1412
+ /**
1413
+ * Returns the transitions present in the execution.
1414
+ *
1415
+ * @returns Array<Transition> the array of transitions present in the execution.
1416
+ * @returns {Array<any>}
1417
+ */
1418
+ transitions() {
1419
+ const ret = wasm.execution_transitions(this.__wbg_ptr);
1420
+ return takeObject(ret);
1421
+ }
1422
+ }
1423
+
1424
+ const ExecutionResponseFinalization = (typeof FinalizationRegistry === 'undefined')
1425
+ ? { register: () => {}, unregister: () => {} }
1426
+ : new FinalizationRegistry(ptr => wasm.__wbg_executionresponse_free(ptr >>> 0, 1));
1427
+ /**
1428
+ * Webassembly Representation of an Aleo function execution response
1429
+ *
1430
+ * This object is returned by the execution of an Aleo function off-chain. It provides methods for
1431
+ * retrieving the outputs of the function execution.
1432
+ */
1433
+ class ExecutionResponse {
1434
+
1435
+ static __wrap(ptr) {
1436
+ ptr = ptr >>> 0;
1437
+ const obj = Object.create(ExecutionResponse.prototype);
1438
+ obj.__wbg_ptr = ptr;
1439
+ ExecutionResponseFinalization.register(obj, obj.__wbg_ptr, obj);
1440
+ return obj;
1441
+ }
1442
+
1443
+ __destroy_into_raw() {
1444
+ const ptr = this.__wbg_ptr;
1445
+ this.__wbg_ptr = 0;
1446
+ ExecutionResponseFinalization.unregister(this);
1447
+ return ptr;
1448
+ }
1449
+
1450
+ free() {
1451
+ const ptr = this.__destroy_into_raw();
1452
+ wasm.__wbg_executionresponse_free(ptr, 0);
1453
+ }
1454
+ /**
1455
+ * Get the outputs of the executed function
1456
+ *
1457
+ * @returns {Array} Array of strings representing the outputs of the function
1458
+ * @returns {Array<any>}
1459
+ */
1460
+ getOutputs() {
1461
+ const ret = wasm.executionresponse_getOutputs(this.__wbg_ptr);
1462
+ return takeObject(ret);
1463
+ }
1464
+ /**
1465
+ * Returns the execution object if present, null if otherwise.
1466
+ *
1467
+ * @returns {Execution | undefined} The execution object if present, null if otherwise
1468
+ * @returns {Execution | undefined}
1469
+ */
1470
+ getExecution() {
1471
+ const ret = wasm.executionresponse_getExecution(this.__wbg_ptr);
1472
+ return ret === 0 ? undefined : Execution.__wrap(ret);
1473
+ }
1474
+ /**
1475
+ * Returns the program keys if present
1476
+ * @returns {KeyPair}
1477
+ */
1478
+ getKeys() {
1479
+ try {
1480
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1481
+ wasm.executionresponse_getKeys(retptr, this.__wbg_ptr);
1482
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1483
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1484
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1485
+ if (r2) {
1486
+ throw takeObject(r1);
1487
+ }
1488
+ return KeyPair.__wrap(r0);
1489
+ } finally {
1490
+ wasm.__wbindgen_add_to_stack_pointer(16);
1491
+ }
1492
+ }
1493
+ /**
1494
+ * Returns the proving_key if the proving key was cached in the Execution response.
1495
+ * Note the proving key is removed from the response object after the first call to this
1496
+ * function. Subsequent calls will return null.
1497
+ *
1498
+ * @returns {ProvingKey | undefined} The proving key
1499
+ * @returns {ProvingKey | undefined}
1500
+ */
1501
+ getProvingKey() {
1502
+ const ret = wasm.executionresponse_getProvingKey(this.__wbg_ptr);
1503
+ return ret === 0 ? undefined : ProvingKey.__wrap(ret);
1504
+ }
1505
+ /**
1506
+ * Returns the verifying_key associated with the program
1507
+ *
1508
+ * @returns {VerifyingKey} The verifying key
1509
+ * @returns {VerifyingKey}
1510
+ */
1511
+ getVerifyingKey() {
1512
+ const ret = wasm.executionresponse_getVerifyingKey(this.__wbg_ptr);
1513
+ return VerifyingKey.__wrap(ret);
1514
+ }
1515
+ /**
1516
+ * Returns the function identifier
1517
+ * @returns {string}
1518
+ */
1519
+ getFunctionId() {
1520
+ let deferred1_0;
1521
+ let deferred1_1;
1522
+ try {
1523
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1524
+ wasm.executionresponse_getFunctionId(retptr, this.__wbg_ptr);
1525
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1526
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1527
+ deferred1_0 = r0;
1528
+ deferred1_1 = r1;
1529
+ return getStringFromWasm0(r0, r1);
1530
+ } finally {
1531
+ wasm.__wbindgen_add_to_stack_pointer(16);
1532
+ wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
1533
+ }
1534
+ }
1535
+ /**
1536
+ * Returns the program
1537
+ * @returns {Program}
1538
+ */
1539
+ getProgram() {
1540
+ const ret = wasm.executionresponse_getProgram(this.__wbg_ptr);
1541
+ return Program.__wrap(ret);
1542
+ }
1543
+ }
1544
+
1545
+ const FieldFinalization = (typeof FinalizationRegistry === 'undefined')
1546
+ ? { register: () => {}, unregister: () => {} }
1547
+ : new FinalizationRegistry(ptr => wasm.__wbg_field_free(ptr >>> 0, 1));
1548
+ /**
1549
+ * Field element.
1550
+ */
1551
+ class Field {
1552
+
1553
+ static __wrap(ptr) {
1554
+ ptr = ptr >>> 0;
1555
+ const obj = Object.create(Field.prototype);
1556
+ obj.__wbg_ptr = ptr;
1557
+ FieldFinalization.register(obj, obj.__wbg_ptr, obj);
1558
+ return obj;
1559
+ }
1560
+
1561
+ static __unwrap(jsValue) {
1562
+ if (!(jsValue instanceof Field)) {
1563
+ return 0;
1564
+ }
1565
+ return jsValue.__destroy_into_raw();
1566
+ }
1567
+
1568
+ __destroy_into_raw() {
1569
+ const ptr = this.__wbg_ptr;
1570
+ this.__wbg_ptr = 0;
1571
+ FieldFinalization.unregister(this);
1572
+ return ptr;
1573
+ }
1574
+
1575
+ free() {
1576
+ const ptr = this.__destroy_into_raw();
1577
+ wasm.__wbg_field_free(ptr, 0);
1578
+ }
1579
+ /**
1580
+ * Creates a field object from a string representation of a field element.
1581
+ * @param {string} field
1582
+ * @returns {Field}
1583
+ */
1584
+ static fromString(field) {
1585
+ try {
1586
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1587
+ const ptr0 = passStringToWasm0(field, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
1588
+ const len0 = WASM_VECTOR_LEN;
1589
+ wasm.field_fromString(retptr, ptr0, len0);
1590
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1591
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1592
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1593
+ if (r2) {
1594
+ throw takeObject(r1);
1595
+ }
1596
+ return Field.__wrap(r0);
1597
+ } finally {
1598
+ wasm.__wbindgen_add_to_stack_pointer(16);
1599
+ }
1600
+ }
1601
+ /**
1602
+ * Returns the string representation of the field element.
1603
+ * @returns {string}
1604
+ */
1605
+ toString() {
1606
+ let deferred1_0;
1607
+ let deferred1_1;
1608
+ try {
1609
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1610
+ wasm.field_toString(retptr, this.__wbg_ptr);
1611
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1612
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1613
+ deferred1_0 = r0;
1614
+ deferred1_1 = r1;
1615
+ return getStringFromWasm0(r0, r1);
1616
+ } finally {
1617
+ wasm.__wbindgen_add_to_stack_pointer(16);
1618
+ wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
1619
+ }
1620
+ }
1621
+ /**
1622
+ * Create a field element from a Uint8Array of left endian bytes.
1623
+ * @param {Uint8Array} bytes
1624
+ * @returns {Field}
1625
+ */
1626
+ static fromBytesLe(bytes) {
1627
+ try {
1628
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1629
+ wasm.field_fromBytesLe(retptr, addBorrowedObject(bytes));
1630
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1631
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1632
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1633
+ if (r2) {
1634
+ throw takeObject(r1);
1635
+ }
1636
+ return Field.__wrap(r0);
1637
+ } finally {
1638
+ wasm.__wbindgen_add_to_stack_pointer(16);
1639
+ heap[stack_pointer++] = undefined;
1640
+ }
1641
+ }
1642
+ /**
1643
+ * Encode the field element as a Uint8Array of left endian bytes.
1644
+ * @returns {Uint8Array}
1645
+ */
1646
+ toBytesLe() {
1647
+ try {
1648
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1649
+ wasm.field_toBytesLe(retptr, this.__wbg_ptr);
1650
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1651
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1652
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1653
+ if (r2) {
1654
+ throw takeObject(r1);
1655
+ }
1656
+ return takeObject(r0);
1657
+ } finally {
1658
+ wasm.__wbindgen_add_to_stack_pointer(16);
1659
+ }
1660
+ }
1661
+ /**
1662
+ * Reconstruct a field element from a boolean array representation.
1663
+ * @param {Array<any>} bits
1664
+ * @returns {Field}
1665
+ */
1666
+ static fromBitsLe(bits) {
1667
+ try {
1668
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1669
+ wasm.field_fromBitsLe(retptr, addBorrowedObject(bits));
1670
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1671
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1672
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1673
+ if (r2) {
1674
+ throw takeObject(r1);
1675
+ }
1676
+ return Field.__wrap(r0);
1677
+ } finally {
1678
+ wasm.__wbindgen_add_to_stack_pointer(16);
1679
+ heap[stack_pointer++] = undefined;
1680
+ }
1681
+ }
1682
+ /**
1683
+ * Get the left endian boolean array representation of the field element.
1684
+ * @returns {Array<any>}
1685
+ */
1686
+ toBitsLe() {
1687
+ const ret = wasm.field_toBitsLe(this.__wbg_ptr);
1688
+ return takeObject(ret);
1689
+ }
1690
+ /**
1691
+ * Create a plaintext from the field element.
1692
+ * @returns {Plaintext}
1693
+ */
1694
+ toPlaintext() {
1695
+ const ret = wasm.field_toPlaintext(this.__wbg_ptr);
1696
+ return Plaintext.__wrap(ret);
1697
+ }
1698
+ /**
1699
+ * Clone the field element.
1700
+ * @returns {Field}
1701
+ */
1702
+ clone() {
1703
+ const ret = wasm.field_clone(this.__wbg_ptr);
1704
+ return Field.__wrap(ret);
1705
+ }
1706
+ /**
1707
+ * Generate a random field element.
1708
+ * @returns {Field}
1709
+ */
1710
+ static random() {
1711
+ const ret = wasm.field_random();
1712
+ return Field.__wrap(ret);
1713
+ }
1714
+ /**
1715
+ * Add two field elements.
1716
+ * @param {Field} other
1717
+ * @returns {Field}
1718
+ */
1719
+ add(other) {
1720
+ _assertClass(other, Field);
1721
+ const ret = wasm.field_add(this.__wbg_ptr, other.__wbg_ptr);
1722
+ return Field.__wrap(ret);
1723
+ }
1724
+ /**
1725
+ * Subtract two field elements.
1726
+ * @param {Field} other
1727
+ * @returns {Field}
1728
+ */
1729
+ subtract(other) {
1730
+ _assertClass(other, Field);
1731
+ const ret = wasm.field_subtract(this.__wbg_ptr, other.__wbg_ptr);
1732
+ return Field.__wrap(ret);
1733
+ }
1734
+ /**
1735
+ * Multiply two field elements.
1736
+ * @param {Field} other
1737
+ * @returns {Field}
1738
+ */
1739
+ multiply(other) {
1740
+ _assertClass(other, Field);
1741
+ const ret = wasm.field_multiply(this.__wbg_ptr, other.__wbg_ptr);
1742
+ return Field.__wrap(ret);
1743
+ }
1744
+ /**
1745
+ * Divide two field elements.
1746
+ * @param {Field} other
1747
+ * @returns {Field}
1748
+ */
1749
+ divide(other) {
1750
+ _assertClass(other, Field);
1751
+ const ret = wasm.field_divide(this.__wbg_ptr, other.__wbg_ptr);
1752
+ return Field.__wrap(ret);
1753
+ }
1754
+ /**
1755
+ * Power of a field element.
1756
+ * @param {Field} other
1757
+ * @returns {Field}
1758
+ */
1759
+ pow(other) {
1760
+ _assertClass(other, Field);
1761
+ const ret = wasm.field_pow(this.__wbg_ptr, other.__wbg_ptr);
1762
+ return Field.__wrap(ret);
1763
+ }
1764
+ /**
1765
+ * Invert the field element.
1766
+ * @returns {Field}
1767
+ */
1768
+ inverse() {
1769
+ const ret = wasm.field_inverse(this.__wbg_ptr);
1770
+ return Field.__wrap(ret);
1771
+ }
1772
+ /**
1773
+ * Get the additive identity element of the field.
1774
+ * @returns {Field}
1775
+ */
1776
+ static zero() {
1777
+ const ret = wasm.field_zero();
1778
+ return Field.__wrap(ret);
1779
+ }
1780
+ /**
1781
+ * Get the multiplicative identity of the field.
1782
+ * @returns {Field}
1783
+ */
1784
+ static one() {
1785
+ const ret = wasm.field_one();
1786
+ return Field.__wrap(ret);
1787
+ }
1788
+ /**
1789
+ * Double the field element.
1790
+ * @returns {Field}
1791
+ */
1792
+ double() {
1793
+ const ret = wasm.field_double(this.__wbg_ptr);
1794
+ return Field.__wrap(ret);
1795
+ }
1796
+ /**
1797
+ * Check if one field element equals another.
1798
+ * @param {Field} other
1799
+ * @returns {boolean}
1800
+ */
1801
+ equals(other) {
1802
+ _assertClass(other, Field);
1803
+ const ret = wasm.field_equals(this.__wbg_ptr, other.__wbg_ptr);
1804
+ return ret !== 0;
1805
+ }
1806
+ }
1807
+
1808
+ const GraphKeyFinalization = (typeof FinalizationRegistry === 'undefined')
1809
+ ? { register: () => {}, unregister: () => {} }
1810
+ : new FinalizationRegistry(ptr => wasm.__wbg_graphkey_free(ptr >>> 0, 1));
1811
+
1812
+ class GraphKey {
1813
+
1814
+ static __wrap(ptr) {
1815
+ ptr = ptr >>> 0;
1816
+ const obj = Object.create(GraphKey.prototype);
1817
+ obj.__wbg_ptr = ptr;
1818
+ GraphKeyFinalization.register(obj, obj.__wbg_ptr, obj);
1819
+ return obj;
1820
+ }
1821
+
1822
+ __destroy_into_raw() {
1823
+ const ptr = this.__wbg_ptr;
1824
+ this.__wbg_ptr = 0;
1825
+ GraphKeyFinalization.unregister(this);
1826
+ return ptr;
1827
+ }
1828
+
1829
+ free() {
1830
+ const ptr = this.__destroy_into_raw();
1831
+ wasm.__wbg_graphkey_free(ptr, 0);
1832
+ }
1833
+ /**
1834
+ * Create a new graph key from a view key.
1835
+ *
1836
+ * @param {ViewKey} view_key View key
1837
+ * @returns {GraphKey} Graph key
1838
+ * @param {ViewKey} view_key
1839
+ * @returns {GraphKey}
1840
+ */
1841
+ static from_view_key(view_key) {
1842
+ _assertClass(view_key, ViewKey);
1843
+ const ret = wasm.graphkey_from_view_key(view_key.__wbg_ptr);
1844
+ return GraphKey.__wrap(ret);
1845
+ }
1846
+ /**
1847
+ * Create a new graph key from a string representation of a graph key
1848
+ *
1849
+ * @param {string} graph_key String representation of a graph key
1850
+ * @returns {GraphKey} Graph key
1851
+ * @param {string} graph_key
1852
+ * @returns {GraphKey}
1853
+ */
1854
+ static from_string(graph_key) {
1855
+ const ptr0 = passStringToWasm0(graph_key, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
1856
+ const len0 = WASM_VECTOR_LEN;
1857
+ const ret = wasm.graphkey_from_string(ptr0, len0);
1858
+ return GraphKey.__wrap(ret);
1859
+ }
1860
+ /**
1861
+ * Get a string representation of a graph key
1862
+ *
1863
+ * @returns {string} String representation of a graph key
1864
+ * @returns {string}
1865
+ */
1866
+ to_string() {
1867
+ let deferred1_0;
1868
+ let deferred1_1;
1869
+ try {
1870
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1871
+ wasm.graphkey_to_string(retptr, this.__wbg_ptr);
1872
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1873
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1874
+ deferred1_0 = r0;
1875
+ deferred1_1 = r1;
1876
+ return getStringFromWasm0(r0, r1);
1877
+ } finally {
1878
+ wasm.__wbindgen_add_to_stack_pointer(16);
1879
+ wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
1880
+ }
1881
+ }
1882
+ /**
1883
+ * Get the sk_tag of the graph key. Used to determine ownership of records.
1884
+ * @returns {Field}
1885
+ */
1886
+ sk_tag() {
1887
+ const ret = wasm.field_clone(this.__wbg_ptr);
1888
+ return Field.__wrap(ret);
1889
+ }
1890
+ }
1891
+
1892
+ const GroupFinalization = (typeof FinalizationRegistry === 'undefined')
1893
+ ? { register: () => {}, unregister: () => {} }
1894
+ : new FinalizationRegistry(ptr => wasm.__wbg_group_free(ptr >>> 0, 1));
1895
+ /**
1896
+ * Elliptic curve element.
1897
+ */
1898
+ class Group {
1899
+
1900
+ static __wrap(ptr) {
1901
+ ptr = ptr >>> 0;
1902
+ const obj = Object.create(Group.prototype);
1903
+ obj.__wbg_ptr = ptr;
1904
+ GroupFinalization.register(obj, obj.__wbg_ptr, obj);
1905
+ return obj;
1906
+ }
1907
+
1908
+ __destroy_into_raw() {
1909
+ const ptr = this.__wbg_ptr;
1910
+ this.__wbg_ptr = 0;
1911
+ GroupFinalization.unregister(this);
1912
+ return ptr;
1913
+ }
1914
+
1915
+ free() {
1916
+ const ptr = this.__destroy_into_raw();
1917
+ wasm.__wbg_group_free(ptr, 0);
1918
+ }
1919
+ /**
1920
+ * Creates a group object from a string representation of a group element.
1921
+ * @param {string} group
1922
+ * @returns {Group}
1923
+ */
1924
+ static fromString(group) {
1925
+ try {
1926
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1927
+ const ptr0 = passStringToWasm0(group, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
1928
+ const len0 = WASM_VECTOR_LEN;
1929
+ wasm.group_fromString(retptr, ptr0, len0);
1930
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1931
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1932
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1933
+ if (r2) {
1934
+ throw takeObject(r1);
1935
+ }
1936
+ return Group.__wrap(r0);
1937
+ } finally {
1938
+ wasm.__wbindgen_add_to_stack_pointer(16);
1939
+ }
1940
+ }
1941
+ /**
1942
+ * Returns the string representation of the group element.
1943
+ * @returns {string}
1944
+ */
1945
+ toString() {
1946
+ let deferred1_0;
1947
+ let deferred1_1;
1948
+ try {
1949
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1950
+ wasm.group_toString(retptr, this.__wbg_ptr);
1951
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1952
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1953
+ deferred1_0 = r0;
1954
+ deferred1_1 = r1;
1955
+ return getStringFromWasm0(r0, r1);
1956
+ } finally {
1957
+ wasm.__wbindgen_add_to_stack_pointer(16);
1958
+ wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
1959
+ }
1960
+ }
1961
+ /**
1962
+ * Create a group element from a Uint8Array of left endian bytes.
1963
+ * @param {Uint8Array} bytes
1964
+ * @returns {Group}
1965
+ */
1966
+ static fromBytesLe(bytes) {
1967
+ try {
1968
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1969
+ wasm.group_fromBytesLe(retptr, addBorrowedObject(bytes));
1970
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1971
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1972
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1973
+ if (r2) {
1974
+ throw takeObject(r1);
1975
+ }
1976
+ return Group.__wrap(r0);
1977
+ } finally {
1978
+ wasm.__wbindgen_add_to_stack_pointer(16);
1979
+ heap[stack_pointer++] = undefined;
1980
+ }
1981
+ }
1982
+ /**
1983
+ * Encode the group element as a Uint8Array of left endian bytes.
1984
+ * @returns {Uint8Array}
1985
+ */
1986
+ toBytesLe() {
1987
+ try {
1988
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1989
+ wasm.group_toBytesLe(retptr, this.__wbg_ptr);
1990
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1991
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1992
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1993
+ if (r2) {
1994
+ throw takeObject(r1);
1995
+ }
1996
+ return takeObject(r0);
1997
+ } finally {
1998
+ wasm.__wbindgen_add_to_stack_pointer(16);
1999
+ }
2000
+ }
2001
+ /**
2002
+ * Reconstruct a group element from a boolean array representation.
2003
+ * @param {Array<any>} bits
2004
+ * @returns {Group}
2005
+ */
2006
+ static fromBitsLe(bits) {
2007
+ try {
2008
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2009
+ wasm.group_fromBitsLe(retptr, addBorrowedObject(bits));
2010
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2011
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2012
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2013
+ if (r2) {
2014
+ throw takeObject(r1);
2015
+ }
2016
+ return Group.__wrap(r0);
2017
+ } finally {
2018
+ wasm.__wbindgen_add_to_stack_pointer(16);
2019
+ heap[stack_pointer++] = undefined;
2020
+ }
2021
+ }
2022
+ /**
2023
+ * Get the left endian boolean array representation of the group element.
2024
+ * @returns {Array<any>}
2025
+ */
2026
+ toBitsLe() {
2027
+ const ret = wasm.group_toBitsLe(this.__wbg_ptr);
2028
+ return takeObject(ret);
2029
+ }
2030
+ /**
2031
+ * Get the x-coordinate of the group element.
2032
+ * @returns {Field}
2033
+ */
2034
+ toXCoordinate() {
2035
+ const ret = wasm.group_toXCoordinate(this.__wbg_ptr);
2036
+ return Field.__wrap(ret);
2037
+ }
2038
+ /**
2039
+ * Create a plaintext element from a group element.
2040
+ * @returns {Plaintext}
2041
+ */
2042
+ toPlaintext() {
2043
+ const ret = wasm.group_toPlaintext(this.__wbg_ptr);
2044
+ return Plaintext.__wrap(ret);
2045
+ }
2046
+ /**
2047
+ * Clone the group element.
2048
+ * @returns {Group}
2049
+ */
2050
+ clone() {
2051
+ const ret = wasm.group_clone(this.__wbg_ptr);
2052
+ return Group.__wrap(ret);
2053
+ }
2054
+ /**
2055
+ * Generate a random group element.
2056
+ * @returns {Group}
2057
+ */
2058
+ static random() {
2059
+ const ret = wasm.group_random();
2060
+ return Group.__wrap(ret);
2061
+ }
2062
+ /**
2063
+ * Add two group elements.
2064
+ * @param {Group} other
2065
+ * @returns {Group}
2066
+ */
2067
+ add(other) {
2068
+ _assertClass(other, Group);
2069
+ const ret = wasm.group_add(this.__wbg_ptr, other.__wbg_ptr);
2070
+ return Group.__wrap(ret);
2071
+ }
2072
+ /**
2073
+ * Subtract two group elements (equivalently: add the inverse of an element).
2074
+ * @param {Group} other
2075
+ * @returns {Group}
2076
+ */
2077
+ subtract(other) {
2078
+ _assertClass(other, Group);
2079
+ const ret = wasm.group_subtract(this.__wbg_ptr, other.__wbg_ptr);
2080
+ return Group.__wrap(ret);
2081
+ }
2082
+ /**
2083
+ * Multiply a group element by a scalar element.
2084
+ * @param {Scalar} scalar
2085
+ * @returns {Group}
2086
+ */
2087
+ scalarMultiply(scalar) {
2088
+ _assertClass(scalar, Scalar);
2089
+ const ret = wasm.group_scalarMultiply(this.__wbg_ptr, scalar.__wbg_ptr);
2090
+ return Group.__wrap(ret);
2091
+ }
2092
+ /**
2093
+ * Double the group element.
2094
+ * @returns {Group}
2095
+ */
2096
+ double() {
2097
+ const ret = wasm.group_double(this.__wbg_ptr);
2098
+ return Group.__wrap(ret);
2099
+ }
2100
+ /**
2101
+ * Get the inverse of the group element. This is the reflection of the point about the axis
2102
+ * of symmetry i.e. (x,y) -> (x, -y).
2103
+ * @returns {Group}
2104
+ */
2105
+ inverse() {
2106
+ const ret = wasm.group_inverse(this.__wbg_ptr);
2107
+ return Group.__wrap(ret);
2108
+ }
2109
+ /**
2110
+ * Check if one group element equals another.
2111
+ * @param {Group} other
2112
+ * @returns {boolean}
2113
+ */
2114
+ equals(other) {
2115
+ _assertClass(other, Group);
2116
+ const ret = wasm.group_equals(this.__wbg_ptr, other.__wbg_ptr);
2117
+ return ret !== 0;
2118
+ }
2119
+ /**
2120
+ * Get the group identity element under the group operation (i.e. the point at infinity.)
2121
+ * @returns {Group}
2122
+ */
2123
+ static zero() {
2124
+ const ret = wasm.group_zero();
2125
+ return Group.__wrap(ret);
2126
+ }
2127
+ /**
2128
+ * Get the generator of the group.
2129
+ * @returns {Group}
2130
+ */
2131
+ static generator() {
2132
+ const ret = wasm.group_generator();
2133
+ return Group.__wrap(ret);
2134
+ }
2135
+ }
2136
+
2137
+ const KeyPairFinalization = (typeof FinalizationRegistry === 'undefined')
2138
+ ? { register: () => {}, unregister: () => {} }
2139
+ : new FinalizationRegistry(ptr => wasm.__wbg_keypair_free(ptr >>> 0, 1));
2140
+ /**
2141
+ * Key pair object containing both the function proving and verifying keys
2142
+ */
2143
+ class KeyPair {
2144
+
2145
+ static __wrap(ptr) {
2146
+ ptr = ptr >>> 0;
2147
+ const obj = Object.create(KeyPair.prototype);
2148
+ obj.__wbg_ptr = ptr;
2149
+ KeyPairFinalization.register(obj, obj.__wbg_ptr, obj);
2150
+ return obj;
2151
+ }
2152
+
2153
+ __destroy_into_raw() {
2154
+ const ptr = this.__wbg_ptr;
2155
+ this.__wbg_ptr = 0;
2156
+ KeyPairFinalization.unregister(this);
2157
+ return ptr;
2158
+ }
2159
+
2160
+ free() {
2161
+ const ptr = this.__destroy_into_raw();
2162
+ wasm.__wbg_keypair_free(ptr, 0);
2163
+ }
2164
+ /**
2165
+ * Create new key pair from proving and verifying keys
2166
+ *
2167
+ * @param {ProvingKey} proving_key Proving key corresponding to a function in an Aleo program
2168
+ * @param {VerifyingKey} verifying_key Verifying key corresponding to a function in an Aleo program
2169
+ * @returns {KeyPair} Key pair object containing both the function proving and verifying keys
2170
+ * @param {ProvingKey} proving_key
2171
+ * @param {VerifyingKey} verifying_key
2172
+ */
2173
+ constructor(proving_key, verifying_key) {
2174
+ _assertClass(proving_key, ProvingKey);
2175
+ var ptr0 = proving_key.__destroy_into_raw();
2176
+ _assertClass(verifying_key, VerifyingKey);
2177
+ var ptr1 = verifying_key.__destroy_into_raw();
2178
+ const ret = wasm.keypair_new(ptr0, ptr1);
2179
+ this.__wbg_ptr = ret >>> 0;
2180
+ KeyPairFinalization.register(this, this.__wbg_ptr, this);
2181
+ return this;
2182
+ }
2183
+ /**
2184
+ * Get the proving key. This method will remove the proving key from the key pair
2185
+ *
2186
+ * @returns {ProvingKey}
2187
+ * @returns {ProvingKey}
2188
+ */
2189
+ provingKey() {
2190
+ try {
2191
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2192
+ wasm.keypair_provingKey(retptr, this.__wbg_ptr);
2193
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2194
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2195
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2196
+ if (r2) {
2197
+ throw takeObject(r1);
2198
+ }
2199
+ return ProvingKey.__wrap(r0);
2200
+ } finally {
2201
+ wasm.__wbindgen_add_to_stack_pointer(16);
2202
+ }
2203
+ }
2204
+ /**
2205
+ * Get the verifying key. This method will remove the verifying key from the key pair
2206
+ *
2207
+ * @returns {VerifyingKey}
2208
+ * @returns {VerifyingKey}
2209
+ */
2210
+ verifyingKey() {
2211
+ try {
2212
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2213
+ wasm.keypair_verifyingKey(retptr, this.__wbg_ptr);
2214
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2215
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2216
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2217
+ if (r2) {
2218
+ throw takeObject(r1);
2219
+ }
2220
+ return VerifyingKey.__wrap(r0);
2221
+ } finally {
2222
+ wasm.__wbindgen_add_to_stack_pointer(16);
2223
+ }
2224
+ }
2225
+ }
2226
+
2227
+ const MetadataFinalization = (typeof FinalizationRegistry === 'undefined')
2228
+ ? { register: () => {}, unregister: () => {} }
2229
+ : new FinalizationRegistry(ptr => wasm.__wbg_metadata_free(ptr >>> 0, 1));
2230
+
2231
+ class Metadata {
2232
+
2233
+ static __wrap(ptr) {
2234
+ ptr = ptr >>> 0;
2235
+ const obj = Object.create(Metadata.prototype);
2236
+ obj.__wbg_ptr = ptr;
2237
+ MetadataFinalization.register(obj, obj.__wbg_ptr, obj);
2238
+ return obj;
2239
+ }
2240
+
2241
+ __destroy_into_raw() {
2242
+ const ptr = this.__wbg_ptr;
2243
+ this.__wbg_ptr = 0;
2244
+ MetadataFinalization.unregister(this);
2245
+ return ptr;
2246
+ }
2247
+
2248
+ free() {
2249
+ const ptr = this.__destroy_into_raw();
2250
+ wasm.__wbg_metadata_free(ptr, 0);
2251
+ }
2252
+ /**
2253
+ * @returns {string}
2254
+ */
2255
+ get name() {
2256
+ let deferred1_0;
2257
+ let deferred1_1;
2258
+ try {
2259
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2260
+ wasm.__wbg_get_metadata_name(retptr, this.__wbg_ptr);
2261
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2262
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2263
+ deferred1_0 = r0;
2264
+ deferred1_1 = r1;
2265
+ return getStringFromWasm0(r0, r1);
2266
+ } finally {
2267
+ wasm.__wbindgen_add_to_stack_pointer(16);
2268
+ wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
2269
+ }
2270
+ }
2271
+ /**
2272
+ * @param {string} arg0
2273
+ */
2274
+ set name(arg0) {
2275
+ const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
2276
+ const len0 = WASM_VECTOR_LEN;
2277
+ wasm.__wbg_set_metadata_name(this.__wbg_ptr, ptr0, len0);
2278
+ }
2279
+ /**
2280
+ * @returns {string}
2281
+ */
2282
+ get locator() {
2283
+ let deferred1_0;
2284
+ let deferred1_1;
2285
+ try {
2286
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2287
+ wasm.__wbg_get_metadata_locator(retptr, this.__wbg_ptr);
2288
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2289
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2290
+ deferred1_0 = r0;
2291
+ deferred1_1 = r1;
2292
+ return getStringFromWasm0(r0, r1);
2293
+ } finally {
2294
+ wasm.__wbindgen_add_to_stack_pointer(16);
2295
+ wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
2296
+ }
2297
+ }
2298
+ /**
2299
+ * @param {string} arg0
2300
+ */
2301
+ set locator(arg0) {
2302
+ const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
2303
+ const len0 = WASM_VECTOR_LEN;
2304
+ wasm.__wbg_set_metadata_locator(this.__wbg_ptr, ptr0, len0);
2305
+ }
2306
+ /**
2307
+ * @returns {string}
2308
+ */
2309
+ get prover() {
961
2310
  let deferred1_0;
962
2311
  let deferred1_1;
963
2312
  try {
964
2313
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
965
- wasm.field_toString(retptr, this.__wbg_ptr);
2314
+ wasm.__wbg_get_metadata_prover(retptr, this.__wbg_ptr);
966
2315
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
967
2316
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
968
2317
  deferred1_0 = r0;
@@ -974,242 +2323,279 @@ class Field {
974
2323
  }
975
2324
  }
976
2325
  /**
977
- * Generate a random field element.
978
- * @returns {Field}
2326
+ * @param {string} arg0
979
2327
  */
980
- static random() {
981
- const ret = wasm.field_random();
982
- return Field.__wrap(ret);
2328
+ set prover(arg0) {
2329
+ const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
2330
+ const len0 = WASM_VECTOR_LEN;
2331
+ wasm.__wbg_set_metadata_prover(this.__wbg_ptr, ptr0, len0);
983
2332
  }
984
2333
  /**
985
- * Add two field elements.
986
- * @param {Field} other
987
- * @returns {Field}
2334
+ * @returns {string}
988
2335
  */
989
- add(other) {
990
- _assertClass(other, Field);
991
- const ret = wasm.field_add(this.__wbg_ptr, other.__wbg_ptr);
992
- return Field.__wrap(ret);
2336
+ get verifier() {
2337
+ let deferred1_0;
2338
+ let deferred1_1;
2339
+ try {
2340
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2341
+ wasm.__wbg_get_metadata_verifier(retptr, this.__wbg_ptr);
2342
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2343
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2344
+ deferred1_0 = r0;
2345
+ deferred1_1 = r1;
2346
+ return getStringFromWasm0(r0, r1);
2347
+ } finally {
2348
+ wasm.__wbindgen_add_to_stack_pointer(16);
2349
+ wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
2350
+ }
993
2351
  }
994
2352
  /**
995
- * Subtract two field elements.
996
- * @param {Field} other
997
- * @returns {Field}
2353
+ * @param {string} arg0
998
2354
  */
999
- subtract(other) {
1000
- _assertClass(other, Field);
1001
- const ret = wasm.field_subtract(this.__wbg_ptr, other.__wbg_ptr);
1002
- return Field.__wrap(ret);
2355
+ set verifier(arg0) {
2356
+ const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
2357
+ const len0 = WASM_VECTOR_LEN;
2358
+ wasm.__wbg_set_metadata_verifier(this.__wbg_ptr, ptr0, len0);
1003
2359
  }
1004
2360
  /**
1005
- * Multiply two field elements.
1006
- * @param {Field} other
1007
- * @returns {Field}
2361
+ * @returns {string}
1008
2362
  */
1009
- multiply(other) {
1010
- _assertClass(other, Field);
1011
- const ret = wasm.field_multiply(this.__wbg_ptr, other.__wbg_ptr);
1012
- return Field.__wrap(ret);
2363
+ get verifyingKey() {
2364
+ let deferred1_0;
2365
+ let deferred1_1;
2366
+ try {
2367
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2368
+ wasm.__wbg_get_metadata_verifyingKey(retptr, this.__wbg_ptr);
2369
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2370
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2371
+ deferred1_0 = r0;
2372
+ deferred1_1 = r1;
2373
+ return getStringFromWasm0(r0, r1);
2374
+ } finally {
2375
+ wasm.__wbindgen_add_to_stack_pointer(16);
2376
+ wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
2377
+ }
1013
2378
  }
1014
2379
  /**
1015
- * Divide two field elements.
1016
- * @param {Field} other
1017
- * @returns {Field}
2380
+ * @param {string} arg0
1018
2381
  */
1019
- divide(other) {
1020
- _assertClass(other, Field);
1021
- const ret = wasm.field_divide(this.__wbg_ptr, other.__wbg_ptr);
1022
- return Field.__wrap(ret);
2382
+ set verifyingKey(arg0) {
2383
+ const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
2384
+ const len0 = WASM_VECTOR_LEN;
2385
+ wasm.__wbg_set_metadata_verifyingKey(this.__wbg_ptr, ptr0, len0);
1023
2386
  }
1024
2387
  /**
1025
- * Power of a field element.
1026
- * @param {Field} other
1027
- * @returns {Field}
2388
+ * @returns {string}
1028
2389
  */
1029
- pow(other) {
1030
- _assertClass(other, Field);
1031
- const ret = wasm.field_pow(this.__wbg_ptr, other.__wbg_ptr);
1032
- return Field.__wrap(ret);
2390
+ static baseUrl() {
2391
+ let deferred1_0;
2392
+ let deferred1_1;
2393
+ try {
2394
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2395
+ wasm.metadata_baseUrl(retptr);
2396
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2397
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2398
+ deferred1_0 = r0;
2399
+ deferred1_1 = r1;
2400
+ return getStringFromWasm0(r0, r1);
2401
+ } finally {
2402
+ wasm.__wbindgen_add_to_stack_pointer(16);
2403
+ wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
2404
+ }
1033
2405
  }
1034
2406
  /**
1035
- * Invert the field element.
1036
- * @returns {Field}
2407
+ * @returns {Metadata}
1037
2408
  */
1038
- inverse() {
1039
- const ret = wasm.field_inverse(this.__wbg_ptr);
1040
- return Field.__wrap(ret);
2409
+ static bond_public() {
2410
+ const ret = wasm.metadata_bond_public();
2411
+ return Metadata.__wrap(ret);
1041
2412
  }
1042
2413
  /**
1043
- * Get the zero element of the field.
1044
- * @returns {Field}
2414
+ * @returns {Metadata}
1045
2415
  */
1046
- static zero() {
1047
- const ret = wasm.field_zero();
1048
- return Field.__wrap(ret);
2416
+ static bond_validator() {
2417
+ const ret = wasm.metadata_bond_validator();
2418
+ return Metadata.__wrap(ret);
1049
2419
  }
1050
2420
  /**
1051
- * Get the one element of the field.
1052
- * @returns {Field}
2421
+ * @returns {Metadata}
1053
2422
  */
1054
- static one() {
1055
- const ret = wasm.field_one();
1056
- return Field.__wrap(ret);
2423
+ static claim_unbond_public() {
2424
+ const ret = wasm.metadata_claim_unbond_public();
2425
+ return Metadata.__wrap(ret);
1057
2426
  }
1058
2427
  /**
1059
- * Double the field element.
1060
- * @returns {Field}
2428
+ * @returns {Metadata}
1061
2429
  */
1062
- double() {
1063
- const ret = wasm.field_double(this.__wbg_ptr);
1064
- return Field.__wrap(ret);
2430
+ static fee_private() {
2431
+ const ret = wasm.metadata_fee_private();
2432
+ return Metadata.__wrap(ret);
1065
2433
  }
1066
2434
  /**
1067
- * Check if one field element equals another.
1068
- * @param {Field} other
1069
- * @returns {boolean}
2435
+ * @returns {Metadata}
1070
2436
  */
1071
- equals(other) {
1072
- _assertClass(other, Field);
1073
- const ret = wasm.field_equals(this.__wbg_ptr, other.__wbg_ptr);
1074
- return ret !== 0;
2437
+ static fee_public() {
2438
+ const ret = wasm.metadata_fee_public();
2439
+ return Metadata.__wrap(ret);
1075
2440
  }
1076
- }
1077
-
1078
- const GraphKeyFinalization = (typeof FinalizationRegistry === 'undefined')
1079
- ? { register: () => {}, unregister: () => {} }
1080
- : new FinalizationRegistry(ptr => wasm.__wbg_graphkey_free(ptr >>> 0, 1));
1081
-
1082
- class GraphKey {
1083
-
1084
- static __wrap(ptr) {
1085
- ptr = ptr >>> 0;
1086
- const obj = Object.create(GraphKey.prototype);
1087
- obj.__wbg_ptr = ptr;
1088
- GraphKeyFinalization.register(obj, obj.__wbg_ptr, obj);
1089
- return obj;
2441
+ /**
2442
+ * @returns {Metadata}
2443
+ */
2444
+ static inclusion() {
2445
+ const ret = wasm.metadata_inclusion();
2446
+ return Metadata.__wrap(ret);
1090
2447
  }
1091
-
1092
- __destroy_into_raw() {
1093
- const ptr = this.__wbg_ptr;
1094
- this.__wbg_ptr = 0;
1095
- GraphKeyFinalization.unregister(this);
1096
- return ptr;
2448
+ /**
2449
+ * @returns {Metadata}
2450
+ */
2451
+ static join() {
2452
+ const ret = wasm.metadata_join();
2453
+ return Metadata.__wrap(ret);
1097
2454
  }
1098
-
1099
- free() {
1100
- const ptr = this.__destroy_into_raw();
1101
- wasm.__wbg_graphkey_free(ptr, 0);
2455
+ /**
2456
+ * @returns {Metadata}
2457
+ */
2458
+ static set_validator_state() {
2459
+ const ret = wasm.metadata_set_validator_state();
2460
+ return Metadata.__wrap(ret);
1102
2461
  }
1103
2462
  /**
1104
- * Create a new graph key from a view key.
1105
- *
1106
- * @param {ViewKey} view_key View key
1107
- * @returns {GraphKey} Graph key
1108
- * @param {ViewKey} view_key
1109
- * @returns {GraphKey}
2463
+ * @returns {Metadata}
1110
2464
  */
1111
- static from_view_key(view_key) {
1112
- _assertClass(view_key, ViewKey);
1113
- const ret = wasm.graphkey_from_view_key(view_key.__wbg_ptr);
1114
- return GraphKey.__wrap(ret);
2465
+ static split() {
2466
+ const ret = wasm.metadata_split();
2467
+ return Metadata.__wrap(ret);
1115
2468
  }
1116
2469
  /**
1117
- * Create a new graph key from a string representation of a graph key
1118
- *
1119
- * @param {string} graph_key String representation of a graph key
1120
- * @returns {GraphKey} Graph key
1121
- * @param {string} graph_key
1122
- * @returns {GraphKey}
2470
+ * @returns {Metadata}
1123
2471
  */
1124
- static from_string(graph_key) {
1125
- const ptr0 = passStringToWasm0(graph_key, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
1126
- const len0 = WASM_VECTOR_LEN;
1127
- const ret = wasm.graphkey_from_string(ptr0, len0);
1128
- return GraphKey.__wrap(ret);
2472
+ static transfer_private() {
2473
+ const ret = wasm.metadata_transfer_private();
2474
+ return Metadata.__wrap(ret);
1129
2475
  }
1130
2476
  /**
1131
- * Get a string representation of a graph key
1132
- *
1133
- * @returns {string} String representation of a graph key
1134
- * @returns {string}
2477
+ * @returns {Metadata}
1135
2478
  */
1136
- to_string() {
1137
- let deferred1_0;
1138
- let deferred1_1;
1139
- try {
1140
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1141
- wasm.graphkey_to_string(retptr, this.__wbg_ptr);
1142
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1143
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1144
- deferred1_0 = r0;
1145
- deferred1_1 = r1;
1146
- return getStringFromWasm0(r0, r1);
1147
- } finally {
1148
- wasm.__wbindgen_add_to_stack_pointer(16);
1149
- wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
1150
- }
2479
+ static transfer_private_to_public() {
2480
+ const ret = wasm.metadata_transfer_private_to_public();
2481
+ return Metadata.__wrap(ret);
2482
+ }
2483
+ /**
2484
+ * @returns {Metadata}
2485
+ */
2486
+ static transfer_public() {
2487
+ const ret = wasm.metadata_transfer_public();
2488
+ return Metadata.__wrap(ret);
1151
2489
  }
1152
2490
  /**
1153
- * Get the sk_tag of the graph key. Used to determine ownership of records.
1154
- * @returns {Field}
2491
+ * @returns {Metadata}
1155
2492
  */
1156
- sk_tag() {
1157
- const ret = wasm.graphkey_sk_tag(this.__wbg_ptr);
1158
- return Field.__wrap(ret);
2493
+ static transfer_public_as_signer() {
2494
+ const ret = wasm.metadata_transfer_public_as_signer();
2495
+ return Metadata.__wrap(ret);
2496
+ }
2497
+ /**
2498
+ * @returns {Metadata}
2499
+ */
2500
+ static transfer_public_to_private() {
2501
+ const ret = wasm.metadata_transfer_public_to_private();
2502
+ return Metadata.__wrap(ret);
2503
+ }
2504
+ /**
2505
+ * @returns {Metadata}
2506
+ */
2507
+ static unbond_public() {
2508
+ const ret = wasm.metadata_unbond_public();
2509
+ return Metadata.__wrap(ret);
1159
2510
  }
1160
2511
  }
1161
2512
 
1162
- const GroupFinalization = (typeof FinalizationRegistry === 'undefined')
2513
+ const OfflineQueryFinalization = (typeof FinalizationRegistry === 'undefined')
1163
2514
  ? { register: () => {}, unregister: () => {} }
1164
- : new FinalizationRegistry(ptr => wasm.__wbg_group_free(ptr >>> 0, 1));
2515
+ : new FinalizationRegistry(ptr => wasm.__wbg_offlinequery_free(ptr >>> 0, 1));
1165
2516
  /**
1166
- * Elliptic curve element.
2517
+ * An offline query object used to insert the global state root and state paths needed to create
2518
+ * a valid inclusion proof offline.
1167
2519
  */
1168
- class Group {
2520
+ class OfflineQuery {
1169
2521
 
1170
2522
  static __wrap(ptr) {
1171
2523
  ptr = ptr >>> 0;
1172
- const obj = Object.create(Group.prototype);
2524
+ const obj = Object.create(OfflineQuery.prototype);
1173
2525
  obj.__wbg_ptr = ptr;
1174
- GroupFinalization.register(obj, obj.__wbg_ptr, obj);
2526
+ OfflineQueryFinalization.register(obj, obj.__wbg_ptr, obj);
1175
2527
  return obj;
1176
2528
  }
1177
2529
 
1178
2530
  __destroy_into_raw() {
1179
2531
  const ptr = this.__wbg_ptr;
1180
2532
  this.__wbg_ptr = 0;
1181
- GroupFinalization.unregister(this);
2533
+ OfflineQueryFinalization.unregister(this);
1182
2534
  return ptr;
1183
2535
  }
1184
2536
 
1185
2537
  free() {
1186
2538
  const ptr = this.__destroy_into_raw();
1187
- wasm.__wbg_group_free(ptr, 0);
2539
+ wasm.__wbg_offlinequery_free(ptr, 0);
1188
2540
  }
1189
2541
  /**
1190
- * Creates a group object from a string representation of a group.
1191
- * @param {string} group
1192
- * @returns {Group}
2542
+ * Creates a new offline query object. The state root is required to be passed in as a string
2543
+ * @param {number} block_height
2544
+ * @param {string} state_root
1193
2545
  */
1194
- static fromString(group) {
2546
+ constructor(block_height, state_root) {
1195
2547
  try {
1196
2548
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1197
- const ptr0 = passStringToWasm0(group, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
2549
+ const ptr0 = passStringToWasm0(state_root, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
1198
2550
  const len0 = WASM_VECTOR_LEN;
1199
- wasm.group_fromString(retptr, ptr0, len0);
2551
+ wasm.offlinequery_new(retptr, block_height, ptr0, len0);
1200
2552
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1201
2553
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1202
2554
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1203
2555
  if (r2) {
1204
2556
  throw takeObject(r1);
1205
2557
  }
1206
- return Group.__wrap(r0);
2558
+ this.__wbg_ptr = r0 >>> 0;
2559
+ OfflineQueryFinalization.register(this, this.__wbg_ptr, this);
2560
+ return this;
2561
+ } finally {
2562
+ wasm.__wbindgen_add_to_stack_pointer(16);
2563
+ }
2564
+ }
2565
+ /**
2566
+ * Add a new block height to the offline query object.
2567
+ * @param {number} block_height
2568
+ */
2569
+ addBlockHeight(block_height) {
2570
+ wasm.offlinequery_addBlockHeight(this.__wbg_ptr, block_height);
2571
+ }
2572
+ /**
2573
+ * Add a new state path to the offline query object.
2574
+ *
2575
+ * @param {string} commitment: The commitment corresponding to a record inpout
2576
+ * @param {string} state_path: The state path corresponding to the commitment
2577
+ * @param {string} commitment
2578
+ * @param {string} state_path
2579
+ */
2580
+ addStatePath(commitment, state_path) {
2581
+ try {
2582
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2583
+ const ptr0 = passStringToWasm0(commitment, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
2584
+ const len0 = WASM_VECTOR_LEN;
2585
+ const ptr1 = passStringToWasm0(state_path, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
2586
+ const len1 = WASM_VECTOR_LEN;
2587
+ wasm.offlinequery_addStatePath(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
2588
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2589
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2590
+ if (r1) {
2591
+ throw takeObject(r0);
2592
+ }
1207
2593
  } finally {
1208
2594
  wasm.__wbindgen_add_to_stack_pointer(16);
1209
2595
  }
1210
2596
  }
1211
2597
  /**
1212
- * Returns the string representation of the group.
2598
+ * Get a json string representation of the offline query object
1213
2599
  * @returns {string}
1214
2600
  */
1215
2601
  toString() {
@@ -1217,7 +2603,7 @@ class Group {
1217
2603
  let deferred1_1;
1218
2604
  try {
1219
2605
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1220
- wasm.group_toString(retptr, this.__wbg_ptr);
2606
+ wasm.offlinequery_toString(retptr, this.__wbg_ptr);
1221
2607
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1222
2608
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1223
2609
  deferred1_0 = r0;
@@ -1229,336 +2615,453 @@ class Group {
1229
2615
  }
1230
2616
  }
1231
2617
  /**
1232
- * Get the x-coordinate of the group element.
1233
- * @returns {Field}
1234
- */
1235
- toXCoordinate() {
1236
- const ret = wasm.group_toXCoordinate(this.__wbg_ptr);
1237
- return Field.__wrap(ret);
1238
- }
1239
- /**
1240
- * Create a plaintext element from a group element.
1241
- * @returns {Plaintext}
1242
- */
1243
- toPlaintext() {
1244
- const ret = wasm.group_toPlaintext(this.__wbg_ptr);
1245
- return Plaintext.__wrap(ret);
1246
- }
1247
- /**
1248
- * Generate a random group element.
1249
- * @returns {Group}
2618
+ * Create an offline query object from a json string representation
2619
+ * @param {string} s
2620
+ * @returns {OfflineQuery}
1250
2621
  */
1251
- static random() {
1252
- const ret = wasm.group_random();
1253
- return Group.__wrap(ret);
2622
+ static fromString(s) {
2623
+ try {
2624
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2625
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
2626
+ const len0 = WASM_VECTOR_LEN;
2627
+ wasm.offlinequery_fromString(retptr, ptr0, len0);
2628
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2629
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2630
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2631
+ if (r2) {
2632
+ throw takeObject(r1);
2633
+ }
2634
+ return OfflineQuery.__wrap(r0);
2635
+ } finally {
2636
+ wasm.__wbindgen_add_to_stack_pointer(16);
2637
+ }
1254
2638
  }
1255
- /**
1256
- * Add two group elements.
1257
- * @param {Group} other
1258
- * @returns {Group}
1259
- */
1260
- add(other) {
1261
- _assertClass(other, Group);
1262
- const ret = wasm.group_add(this.__wbg_ptr, other.__wbg_ptr);
1263
- return Group.__wrap(ret);
2639
+ }
2640
+
2641
+ const Pedersen128Finalization = (typeof FinalizationRegistry === 'undefined')
2642
+ ? { register: () => {}, unregister: () => {} }
2643
+ : new FinalizationRegistry(ptr => wasm.__wbg_pedersen128_free(ptr >>> 0, 1));
2644
+
2645
+ class Pedersen128 {
2646
+
2647
+ static __wrap(ptr) {
2648
+ ptr = ptr >>> 0;
2649
+ const obj = Object.create(Pedersen128.prototype);
2650
+ obj.__wbg_ptr = ptr;
2651
+ Pedersen128Finalization.register(obj, obj.__wbg_ptr, obj);
2652
+ return obj;
1264
2653
  }
1265
- /**
1266
- * Subtract two group elements (equivalently: add the inverse of an element).
1267
- * @param {Group} other
1268
- * @returns {Group}
1269
- */
1270
- subtract(other) {
1271
- _assertClass(other, Group);
1272
- const ret = wasm.group_subtract(this.__wbg_ptr, other.__wbg_ptr);
1273
- return Group.__wrap(ret);
2654
+
2655
+ __destroy_into_raw() {
2656
+ const ptr = this.__wbg_ptr;
2657
+ this.__wbg_ptr = 0;
2658
+ Pedersen128Finalization.unregister(this);
2659
+ return ptr;
1274
2660
  }
1275
- /**
1276
- * Multiply a group element by a scalar element.
1277
- * @param {Scalar} scalar
1278
- * @returns {Group}
1279
- */
1280
- scalarMultiply(scalar) {
1281
- _assertClass(scalar, Scalar);
1282
- const ret = wasm.group_scalarMultiply(this.__wbg_ptr, scalar.__wbg_ptr);
1283
- return Group.__wrap(ret);
2661
+
2662
+ free() {
2663
+ const ptr = this.__destroy_into_raw();
2664
+ wasm.__wbg_pedersen128_free(ptr, 0);
1284
2665
  }
1285
2666
  /**
1286
- * Double the group element.
1287
- * @returns {Group}
2667
+ * Create a Pedersen hasher for a given (up to) 128-bit input.
1288
2668
  */
1289
- double() {
1290
- const ret = wasm.group_double(this.__wbg_ptr);
1291
- return Group.__wrap(ret);
2669
+ constructor() {
2670
+ const ret = wasm.pedersen128_new();
2671
+ this.__wbg_ptr = ret >>> 0;
2672
+ Pedersen128Finalization.register(this, this.__wbg_ptr, this);
2673
+ return this;
1292
2674
  }
1293
2675
  /**
1294
- * Get the inverse of the group element. This is the reflection of the point about the axis
1295
- * of symmetry i.e. (x,y) -> (x, -y).
1296
- * @returns {Group}
2676
+ * Create a Pedersen hasher for a given (up to) 128-bit input with a custom domain separator.
2677
+ * @param {string} domain_separator
2678
+ * @returns {Pedersen128}
1297
2679
  */
1298
- inverse() {
1299
- const ret = wasm.group_inverse(this.__wbg_ptr);
1300
- return Group.__wrap(ret);
2680
+ static setup(domain_separator) {
2681
+ const ptr0 = passStringToWasm0(domain_separator, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
2682
+ const len0 = WASM_VECTOR_LEN;
2683
+ const ret = wasm.pedersen128_setup(ptr0, len0);
2684
+ return Pedersen128.__wrap(ret);
1301
2685
  }
1302
2686
  /**
1303
- * Check if one group element equals another.
1304
- * @param {Group} other
1305
- * @returns {boolean}
2687
+ * Returns the Pedersen hash for a given (up to) 128-bit input.
2688
+ * @param {Array<any>} input
2689
+ * @returns {Field}
1306
2690
  */
1307
- equals(other) {
1308
- _assertClass(other, Group);
1309
- const ret = wasm.group_equals(this.__wbg_ptr, other.__wbg_ptr);
1310
- return ret !== 0;
2691
+ hash(input) {
2692
+ try {
2693
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2694
+ wasm.pedersen128_hash(retptr, this.__wbg_ptr, addHeapObject(input));
2695
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2696
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2697
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2698
+ if (r2) {
2699
+ throw takeObject(r1);
2700
+ }
2701
+ return Field.__wrap(r0);
2702
+ } finally {
2703
+ wasm.__wbindgen_add_to_stack_pointer(16);
2704
+ }
1311
2705
  }
1312
2706
  /**
1313
- * Get the group identity element under the group operation (i.e. the point at infinity.)
1314
- * @returns {Group}
2707
+ * Returns a Pedersen commitment for the given (up to) 128-bit input and randomizer.
2708
+ * @param {Array<any>} input
2709
+ * @param {Scalar} randomizer
2710
+ * @returns {Field}
1315
2711
  */
1316
- static zero() {
1317
- const ret = wasm.group_zero();
1318
- return Group.__wrap(ret);
2712
+ commit(input, randomizer) {
2713
+ try {
2714
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2715
+ _assertClass(randomizer, Scalar);
2716
+ var ptr0 = randomizer.__destroy_into_raw();
2717
+ wasm.pedersen128_commit(retptr, this.__wbg_ptr, addHeapObject(input), ptr0);
2718
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2719
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2720
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2721
+ if (r2) {
2722
+ throw takeObject(r1);
2723
+ }
2724
+ return Field.__wrap(r0);
2725
+ } finally {
2726
+ wasm.__wbindgen_add_to_stack_pointer(16);
2727
+ }
1319
2728
  }
1320
2729
  /**
1321
- * Get the generator of the group.
2730
+ * Returns a Pedersen commitment for the given (up to) 128-bit input and randomizer.
2731
+ * @param {Array<any>} input
2732
+ * @param {Scalar} randomizer
1322
2733
  * @returns {Group}
1323
2734
  */
1324
- static generator() {
1325
- const ret = wasm.group_generator();
1326
- return Group.__wrap(ret);
2735
+ commitToGroup(input, randomizer) {
2736
+ try {
2737
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2738
+ _assertClass(randomizer, Scalar);
2739
+ var ptr0 = randomizer.__destroy_into_raw();
2740
+ wasm.pedersen128_commitToGroup(retptr, this.__wbg_ptr, addHeapObject(input), ptr0);
2741
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2742
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2743
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2744
+ if (r2) {
2745
+ throw takeObject(r1);
2746
+ }
2747
+ return Group.__wrap(r0);
2748
+ } finally {
2749
+ wasm.__wbindgen_add_to_stack_pointer(16);
2750
+ }
1327
2751
  }
1328
- }
1329
-
1330
- const KeyPairFinalization = (typeof FinalizationRegistry === 'undefined')
1331
- ? { register: () => {}, unregister: () => {} }
1332
- : new FinalizationRegistry(ptr => wasm.__wbg_keypair_free(ptr >>> 0, 1));
1333
- /**
1334
- * Key pair object containing both the function proving and verifying keys
1335
- */
1336
- class KeyPair {
2752
+ }
2753
+
2754
+ const Pedersen64Finalization = (typeof FinalizationRegistry === 'undefined')
2755
+ ? { register: () => {}, unregister: () => {} }
2756
+ : new FinalizationRegistry(ptr => wasm.__wbg_pedersen64_free(ptr >>> 0, 1));
2757
+
2758
+ class Pedersen64 {
1337
2759
 
1338
2760
  static __wrap(ptr) {
1339
2761
  ptr = ptr >>> 0;
1340
- const obj = Object.create(KeyPair.prototype);
2762
+ const obj = Object.create(Pedersen64.prototype);
1341
2763
  obj.__wbg_ptr = ptr;
1342
- KeyPairFinalization.register(obj, obj.__wbg_ptr, obj);
2764
+ Pedersen64Finalization.register(obj, obj.__wbg_ptr, obj);
1343
2765
  return obj;
1344
2766
  }
1345
2767
 
1346
2768
  __destroy_into_raw() {
1347
2769
  const ptr = this.__wbg_ptr;
1348
2770
  this.__wbg_ptr = 0;
1349
- KeyPairFinalization.unregister(this);
2771
+ Pedersen64Finalization.unregister(this);
1350
2772
  return ptr;
1351
2773
  }
1352
2774
 
1353
2775
  free() {
1354
2776
  const ptr = this.__destroy_into_raw();
1355
- wasm.__wbg_keypair_free(ptr, 0);
2777
+ wasm.__wbg_pedersen64_free(ptr, 0);
1356
2778
  }
1357
2779
  /**
1358
- * Create new key pair from proving and verifying keys
1359
- *
1360
- * @param {ProvingKey} proving_key Proving key corresponding to a function in an Aleo program
1361
- * @param {VerifyingKey} verifying_key Verifying key corresponding to a function in an Aleo program
1362
- * @returns {KeyPair} Key pair object containing both the function proving and verifying keys
1363
- * @param {ProvingKey} proving_key
1364
- * @param {VerifyingKey} verifying_key
2780
+ * Create a Pedersen hasher for a given (up to) 64-bit input.
1365
2781
  */
1366
- constructor(proving_key, verifying_key) {
1367
- _assertClass(proving_key, ProvingKey);
1368
- var ptr0 = proving_key.__destroy_into_raw();
1369
- _assertClass(verifying_key, VerifyingKey);
1370
- var ptr1 = verifying_key.__destroy_into_raw();
1371
- const ret = wasm.keypair_new(ptr0, ptr1);
2782
+ constructor() {
2783
+ const ret = wasm.pedersen64_new();
1372
2784
  this.__wbg_ptr = ret >>> 0;
1373
- KeyPairFinalization.register(this, this.__wbg_ptr, this);
2785
+ Pedersen64Finalization.register(this, this.__wbg_ptr, this);
1374
2786
  return this;
1375
2787
  }
1376
2788
  /**
1377
- * Get the proving key. This method will remove the proving key from the key pair
1378
- *
1379
- * @returns {ProvingKey}
1380
- * @returns {ProvingKey}
2789
+ * Create a Pedersen64 hasher for a given (up to) 64-bit input with a custom domain separator.
2790
+ * @param {string} domain_separator
2791
+ * @returns {Pedersen64}
1381
2792
  */
1382
- provingKey() {
2793
+ static setup(domain_separator) {
2794
+ const ptr0 = passStringToWasm0(domain_separator, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
2795
+ const len0 = WASM_VECTOR_LEN;
2796
+ const ret = wasm.pedersen64_setup(ptr0, len0);
2797
+ return Pedersen64.__wrap(ret);
2798
+ }
2799
+ /**
2800
+ * Returns the Pedersen hash for a given (up to) 64-bit input.
2801
+ * @param {Array<any>} input
2802
+ * @returns {Field}
2803
+ */
2804
+ hash(input) {
1383
2805
  try {
1384
2806
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1385
- wasm.keypair_provingKey(retptr, this.__wbg_ptr);
2807
+ wasm.pedersen64_hash(retptr, this.__wbg_ptr, addHeapObject(input));
1386
2808
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1387
2809
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1388
2810
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1389
2811
  if (r2) {
1390
2812
  throw takeObject(r1);
1391
2813
  }
1392
- return ProvingKey.__wrap(r0);
2814
+ return Field.__wrap(r0);
1393
2815
  } finally {
1394
2816
  wasm.__wbindgen_add_to_stack_pointer(16);
1395
2817
  }
1396
2818
  }
1397
2819
  /**
1398
- * Get the verifying key. This method will remove the verifying key from the key pair
1399
- *
1400
- * @returns {VerifyingKey}
1401
- * @returns {VerifyingKey}
2820
+ * Returns a Pedersen commitment for the given (up to) 64-bit input and randomizer.
2821
+ * @param {Array<any>} input
2822
+ * @param {Scalar} randomizer
2823
+ * @returns {Field}
1402
2824
  */
1403
- verifyingKey() {
2825
+ commit(input, randomizer) {
1404
2826
  try {
1405
2827
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1406
- wasm.keypair_verifyingKey(retptr, this.__wbg_ptr);
2828
+ _assertClass(randomizer, Scalar);
2829
+ var ptr0 = randomizer.__destroy_into_raw();
2830
+ wasm.pedersen64_commit(retptr, this.__wbg_ptr, addHeapObject(input), ptr0);
1407
2831
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1408
2832
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1409
2833
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1410
2834
  if (r2) {
1411
2835
  throw takeObject(r1);
1412
2836
  }
1413
- return VerifyingKey.__wrap(r0);
2837
+ return Field.__wrap(r0);
2838
+ } finally {
2839
+ wasm.__wbindgen_add_to_stack_pointer(16);
2840
+ }
2841
+ }
2842
+ /**
2843
+ * Returns a Pedersen commitment for the given (up to) 64-bit input and randomizer.
2844
+ * @param {Array<any>} input
2845
+ * @param {Scalar} randomizer
2846
+ * @returns {Group}
2847
+ */
2848
+ commitToGroup(input, randomizer) {
2849
+ try {
2850
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2851
+ _assertClass(randomizer, Scalar);
2852
+ var ptr0 = randomizer.__destroy_into_raw();
2853
+ wasm.pedersen64_commitToGroup(retptr, this.__wbg_ptr, addHeapObject(input), ptr0);
2854
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2855
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2856
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2857
+ if (r2) {
2858
+ throw takeObject(r1);
2859
+ }
2860
+ return Group.__wrap(r0);
1414
2861
  } finally {
1415
2862
  wasm.__wbindgen_add_to_stack_pointer(16);
1416
2863
  }
1417
2864
  }
1418
2865
  }
1419
2866
 
1420
- const MetadataFinalization = (typeof FinalizationRegistry === 'undefined')
2867
+ const PlaintextFinalization = (typeof FinalizationRegistry === 'undefined')
1421
2868
  ? { register: () => {}, unregister: () => {} }
1422
- : new FinalizationRegistry(ptr => wasm.__wbg_metadata_free(ptr >>> 0, 1));
1423
-
1424
- class Metadata {
2869
+ : new FinalizationRegistry(ptr => wasm.__wbg_plaintext_free(ptr >>> 0, 1));
2870
+ /**
2871
+ * SnarkVM Plaintext object. Plaintext is a fundamental monadic type used to represent Aleo
2872
+ * primitive types (boolean, field, group, i8, i16, i32, i64, i128, u8, u16, u32, u64, u128,
2873
+ * scalar, and signature), struct types, and array types.
2874
+ *
2875
+ * In the context of a web or NodeJS application, this type is useful for turning an Aleo type into
2876
+ * a JS value, object, or array that might be necessary for performing computations within the
2877
+ * application.
2878
+ *
2879
+ * @example
2880
+ * // Get the bond state of an existing address.
2881
+ * const bondState = await fetch(https://api.explorer.provable.com/v1/mainnet/program/credits.aleo/mapping/bond_state/aleo12zlythl7htjdtjjjz3ahdj4vl6wk3zuzm37s80l86qpx8fyx95fqnxcn2f);
2882
+ * // Convert the bond state to a Plaintext object.
2883
+ * const bondStatePlaintext = Plaintext.fromString(bond_state);
2884
+ * // Convert the Plaintext object to a JS object.
2885
+ * const bondStateObject = bond_state_plaintext.toObject();
2886
+ * // Check if the bond state matches the expected object.
2887
+ * const expectedObject = { validator: "aleo12zlythl7htjdtjjjz3ahdj4vl6wk3zuzm37s80l86qpx8fyx95fqnxcn2f", microcredits: 100000000u64 };
2888
+ * assert( JSON.stringify(bondStateObject) === JSON.stringify(expectedObject) );
2889
+ */
2890
+ class Plaintext {
1425
2891
 
1426
2892
  static __wrap(ptr) {
1427
2893
  ptr = ptr >>> 0;
1428
- const obj = Object.create(Metadata.prototype);
2894
+ const obj = Object.create(Plaintext.prototype);
1429
2895
  obj.__wbg_ptr = ptr;
1430
- MetadataFinalization.register(obj, obj.__wbg_ptr, obj);
2896
+ PlaintextFinalization.register(obj, obj.__wbg_ptr, obj);
1431
2897
  return obj;
1432
2898
  }
1433
2899
 
1434
2900
  __destroy_into_raw() {
1435
2901
  const ptr = this.__wbg_ptr;
1436
2902
  this.__wbg_ptr = 0;
1437
- MetadataFinalization.unregister(this);
2903
+ PlaintextFinalization.unregister(this);
1438
2904
  return ptr;
1439
2905
  }
1440
2906
 
1441
2907
  free() {
1442
2908
  const ptr = this.__destroy_into_raw();
1443
- wasm.__wbg_metadata_free(ptr, 0);
2909
+ wasm.__wbg_plaintext_free(ptr, 0);
1444
2910
  }
1445
2911
  /**
1446
- * @returns {string}
2912
+ * Find plaintext member if the plaintext is a struct. Returns `null` if the plaintext is not
2913
+ * a struct or the member does not exist.
2914
+ *
2915
+ * @param {string} name The name of the plaintext member to find.
2916
+ *
2917
+ * @returns {Plaintext} The plaintext member.
2918
+ * @param {string} name
2919
+ * @returns {Plaintext}
1447
2920
  */
1448
- get name() {
1449
- let deferred1_0;
1450
- let deferred1_1;
2921
+ find(name) {
1451
2922
  try {
1452
2923
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1453
- wasm.__wbg_get_metadata_name(retptr, this.__wbg_ptr);
2924
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
2925
+ const len0 = WASM_VECTOR_LEN;
2926
+ wasm.plaintext_find(retptr, this.__wbg_ptr, ptr0, len0);
1454
2927
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1455
2928
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1456
- deferred1_0 = r0;
1457
- deferred1_1 = r1;
1458
- return getStringFromWasm0(r0, r1);
2929
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2930
+ if (r2) {
2931
+ throw takeObject(r1);
2932
+ }
2933
+ return Plaintext.__wrap(r0);
1459
2934
  } finally {
1460
2935
  wasm.__wbindgen_add_to_stack_pointer(16);
1461
- wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
1462
2936
  }
1463
2937
  }
1464
2938
  /**
1465
- * @param {string} arg0
1466
- */
1467
- set name(arg0) {
1468
- const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
1469
- const len0 = WASM_VECTOR_LEN;
1470
- wasm.__wbg_set_metadata_name(this.__wbg_ptr, ptr0, len0);
1471
- }
1472
- /**
1473
- * @returns {string}
2939
+ * Encrypt a plaintext with an address and randomizer.
2940
+ * @param {Address} address
2941
+ * @param {Scalar} randomizer
2942
+ * @returns {Ciphertext}
1474
2943
  */
1475
- get locator() {
1476
- let deferred1_0;
1477
- let deferred1_1;
2944
+ encrypt(address, randomizer) {
1478
2945
  try {
1479
2946
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1480
- wasm.__wbg_get_metadata_locator(retptr, this.__wbg_ptr);
2947
+ _assertClass(address, Address);
2948
+ _assertClass(randomizer, Scalar);
2949
+ wasm.plaintext_encrypt(retptr, this.__wbg_ptr, address.__wbg_ptr, randomizer.__wbg_ptr);
1481
2950
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1482
2951
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1483
- deferred1_0 = r0;
1484
- deferred1_1 = r1;
1485
- return getStringFromWasm0(r0, r1);
2952
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2953
+ if (r2) {
2954
+ throw takeObject(r1);
2955
+ }
2956
+ return Ciphertext.__wrap(r0);
1486
2957
  } finally {
1487
2958
  wasm.__wbindgen_add_to_stack_pointer(16);
1488
- wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
1489
2959
  }
1490
2960
  }
1491
2961
  /**
1492
- * @param {string} arg0
1493
- */
1494
- set locator(arg0) {
1495
- const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
1496
- const len0 = WASM_VECTOR_LEN;
1497
- wasm.__wbg_set_metadata_locator(this.__wbg_ptr, ptr0, len0);
1498
- }
1499
- /**
1500
- * @returns {string}
2962
+ * Encrypt a plaintext with a transition view key.
2963
+ * @param {Field} transition_view_key
2964
+ * @returns {Ciphertext}
1501
2965
  */
1502
- get prover() {
1503
- let deferred1_0;
1504
- let deferred1_1;
2966
+ encryptSymmetric(transition_view_key) {
1505
2967
  try {
1506
2968
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1507
- wasm.__wbg_get_metadata_prover(retptr, this.__wbg_ptr);
2969
+ _assertClass(transition_view_key, Field);
2970
+ wasm.plaintext_encryptSymmetric(retptr, this.__wbg_ptr, transition_view_key.__wbg_ptr);
1508
2971
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1509
2972
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1510
- deferred1_0 = r0;
1511
- deferred1_1 = r1;
1512
- return getStringFromWasm0(r0, r1);
2973
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2974
+ if (r2) {
2975
+ throw takeObject(r1);
2976
+ }
2977
+ return Ciphertext.__wrap(r0);
1513
2978
  } finally {
1514
2979
  wasm.__wbindgen_add_to_stack_pointer(16);
1515
- wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
1516
2980
  }
1517
2981
  }
1518
2982
  /**
1519
- * @param {string} arg0
2983
+ * Creates a plaintext object from a string representation of a plaintext.
2984
+ *
2985
+ * @param {string} plaintext The string representation of the plaintext.
2986
+ *
2987
+ * @returns {Plaintext} The plaintext object.
2988
+ * @param {string} plaintext
2989
+ * @returns {Plaintext}
1520
2990
  */
1521
- set prover(arg0) {
1522
- const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
1523
- const len0 = WASM_VECTOR_LEN;
1524
- wasm.__wbg_set_metadata_prover(this.__wbg_ptr, ptr0, len0);
2991
+ static fromString(plaintext) {
2992
+ try {
2993
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2994
+ const ptr0 = passStringToWasm0(plaintext, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
2995
+ const len0 = WASM_VECTOR_LEN;
2996
+ wasm.plaintext_fromString(retptr, ptr0, len0);
2997
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2998
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2999
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3000
+ if (r2) {
3001
+ throw takeObject(r1);
3002
+ }
3003
+ return Plaintext.__wrap(r0);
3004
+ } finally {
3005
+ wasm.__wbindgen_add_to_stack_pointer(16);
3006
+ }
1525
3007
  }
1526
3008
  /**
1527
- * @returns {string}
3009
+ * Get a plaintext object from a series of bytes.
3010
+ *
3011
+ * @param {Uint8Array} bytes A left endian byte array representing the plaintext.
3012
+ *
3013
+ * @returns {Plaintext} The plaintext object.
3014
+ * @param {Uint8Array} bytes
3015
+ * @returns {Plaintext}
1528
3016
  */
1529
- get verifier() {
1530
- let deferred1_0;
1531
- let deferred1_1;
3017
+ static fromBytesLe(bytes) {
1532
3018
  try {
1533
3019
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1534
- wasm.__wbg_get_metadata_verifier(retptr, this.__wbg_ptr);
3020
+ wasm.plaintext_fromBytesLe(retptr, addHeapObject(bytes));
1535
3021
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1536
3022
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1537
- deferred1_0 = r0;
1538
- deferred1_1 = r1;
1539
- return getStringFromWasm0(r0, r1);
3023
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3024
+ if (r2) {
3025
+ throw takeObject(r1);
3026
+ }
3027
+ return Plaintext.__wrap(r0);
1540
3028
  } finally {
1541
3029
  wasm.__wbindgen_add_to_stack_pointer(16);
1542
- wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
1543
3030
  }
1544
3031
  }
1545
3032
  /**
1546
- * @param {string} arg0
3033
+ * Generate a random plaintext element from a series of bytes.
3034
+ *
3035
+ * @param {Uint8Array} bytes A left endian byte array representing the plaintext.
3036
+ * @returns {Uint8Array}
1547
3037
  */
1548
- set verifier(arg0) {
1549
- const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
1550
- const len0 = WASM_VECTOR_LEN;
1551
- wasm.__wbg_set_metadata_verifier(this.__wbg_ptr, ptr0, len0);
3038
+ toBytesLe() {
3039
+ try {
3040
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3041
+ wasm.plaintext_toBytesLe(retptr, this.__wbg_ptr);
3042
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3043
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3044
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3045
+ if (r2) {
3046
+ throw takeObject(r1);
3047
+ }
3048
+ return takeObject(r0);
3049
+ } finally {
3050
+ wasm.__wbindgen_add_to_stack_pointer(16);
3051
+ }
1552
3052
  }
1553
3053
  /**
3054
+ * Returns the string representation of the plaintext.
3055
+ *
3056
+ * @returns {string} The string representation of the plaintext.
1554
3057
  * @returns {string}
1555
3058
  */
1556
- get verifyingKey() {
3059
+ toString() {
1557
3060
  let deferred1_0;
1558
3061
  let deferred1_1;
1559
3062
  try {
1560
3063
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1561
- wasm.__wbg_get_metadata_verifyingKey(retptr, this.__wbg_ptr);
3064
+ wasm.plaintext_toString(retptr, this.__wbg_ptr);
1562
3065
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1563
3066
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1564
3067
  deferred1_0 = r0;
@@ -1570,22 +3073,17 @@ class Metadata {
1570
3073
  }
1571
3074
  }
1572
3075
  /**
1573
- * @param {string} arg0
1574
- */
1575
- set verifyingKey(arg0) {
1576
- const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
1577
- const len0 = WASM_VECTOR_LEN;
1578
- wasm.__wbg_set_metadata_verifyingKey(this.__wbg_ptr, ptr0, len0);
1579
- }
1580
- /**
3076
+ * Gives the type of the plaintext.
3077
+ *
3078
+ * @returns {string} The type of the plaintext.
1581
3079
  * @returns {string}
1582
3080
  */
1583
- static baseUrl() {
3081
+ plaintextType() {
1584
3082
  let deferred1_0;
1585
3083
  let deferred1_1;
1586
3084
  try {
1587
3085
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1588
- wasm.metadata_baseUrl(retptr);
3086
+ wasm.plaintext_plaintextType(retptr, this.__wbg_ptr);
1589
3087
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1590
3088
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1591
3089
  deferred1_0 = r0;
@@ -1597,487 +3095,439 @@ class Metadata {
1597
3095
  }
1598
3096
  }
1599
3097
  /**
1600
- * @returns {Metadata}
1601
- */
1602
- static bond_public() {
1603
- const ret = wasm.metadata_bond_public();
1604
- return Metadata.__wrap(ret);
1605
- }
1606
- /**
1607
- * @returns {Metadata}
1608
- */
1609
- static bond_validator() {
1610
- const ret = wasm.metadata_bond_validator();
1611
- return Metadata.__wrap(ret);
1612
- }
1613
- /**
1614
- * @returns {Metadata}
1615
- */
1616
- static claim_unbond_public() {
1617
- const ret = wasm.metadata_claim_unbond_public();
1618
- return Metadata.__wrap(ret);
1619
- }
1620
- /**
1621
- * @returns {Metadata}
1622
- */
1623
- static fee_private() {
1624
- const ret = wasm.metadata_fee_private();
1625
- return Metadata.__wrap(ret);
1626
- }
1627
- /**
1628
- * @returns {Metadata}
1629
- */
1630
- static fee_public() {
1631
- const ret = wasm.metadata_fee_public();
1632
- return Metadata.__wrap(ret);
1633
- }
1634
- /**
1635
- * @returns {Metadata}
1636
- */
1637
- static inclusion() {
1638
- const ret = wasm.metadata_inclusion();
1639
- return Metadata.__wrap(ret);
1640
- }
1641
- /**
1642
- * @returns {Metadata}
1643
- */
1644
- static join() {
1645
- const ret = wasm.metadata_join();
1646
- return Metadata.__wrap(ret);
1647
- }
1648
- /**
1649
- * @returns {Metadata}
1650
- */
1651
- static set_validator_state() {
1652
- const ret = wasm.metadata_set_validator_state();
1653
- return Metadata.__wrap(ret);
1654
- }
1655
- /**
1656
- * @returns {Metadata}
1657
- */
1658
- static split() {
1659
- const ret = wasm.metadata_split();
1660
- return Metadata.__wrap(ret);
1661
- }
1662
- /**
1663
- * @returns {Metadata}
1664
- */
1665
- static transfer_private() {
1666
- const ret = wasm.metadata_transfer_private();
1667
- return Metadata.__wrap(ret);
1668
- }
1669
- /**
1670
- * @returns {Metadata}
1671
- */
1672
- static transfer_private_to_public() {
1673
- const ret = wasm.metadata_transfer_private_to_public();
1674
- return Metadata.__wrap(ret);
1675
- }
1676
- /**
1677
- * @returns {Metadata}
1678
- */
1679
- static transfer_public() {
1680
- const ret = wasm.metadata_transfer_public();
1681
- return Metadata.__wrap(ret);
1682
- }
1683
- /**
1684
- * @returns {Metadata}
1685
- */
1686
- static transfer_public_as_signer() {
1687
- const ret = wasm.metadata_transfer_public_as_signer();
1688
- return Metadata.__wrap(ret);
1689
- }
1690
- /**
1691
- * @returns {Metadata}
1692
- */
1693
- static transfer_public_to_private() {
1694
- const ret = wasm.metadata_transfer_public_to_private();
1695
- return Metadata.__wrap(ret);
1696
- }
1697
- /**
1698
- * @returns {Metadata}
3098
+ * Attempt to convert the plaintext to a JS object.
3099
+ *
3100
+ * @returns {Object} The JS object representation of the plaintext.
3101
+ * @returns {any}
1699
3102
  */
1700
- static unbond_public() {
1701
- const ret = wasm.metadata_unbond_public();
1702
- return Metadata.__wrap(ret);
3103
+ toObject() {
3104
+ try {
3105
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3106
+ wasm.plaintext_toObject(retptr, this.__wbg_ptr);
3107
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3108
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3109
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3110
+ if (r2) {
3111
+ throw takeObject(r1);
3112
+ }
3113
+ return takeObject(r0);
3114
+ } finally {
3115
+ wasm.__wbindgen_add_to_stack_pointer(16);
3116
+ }
1703
3117
  }
1704
3118
  }
1705
3119
 
1706
- const OfflineQueryFinalization = (typeof FinalizationRegistry === 'undefined')
3120
+ const Poseidon2Finalization = (typeof FinalizationRegistry === 'undefined')
1707
3121
  ? { register: () => {}, unregister: () => {} }
1708
- : new FinalizationRegistry(ptr => wasm.__wbg_offlinequery_free(ptr >>> 0, 1));
1709
- /**
1710
- * An offline query object used to insert the global state root and state paths needed to create
1711
- * a valid inclusion proof offline.
1712
- */
1713
- class OfflineQuery {
3122
+ : new FinalizationRegistry(ptr => wasm.__wbg_poseidon2_free(ptr >>> 0, 1));
3123
+
3124
+ class Poseidon2 {
1714
3125
 
1715
3126
  static __wrap(ptr) {
1716
3127
  ptr = ptr >>> 0;
1717
- const obj = Object.create(OfflineQuery.prototype);
3128
+ const obj = Object.create(Poseidon2.prototype);
1718
3129
  obj.__wbg_ptr = ptr;
1719
- OfflineQueryFinalization.register(obj, obj.__wbg_ptr, obj);
3130
+ Poseidon2Finalization.register(obj, obj.__wbg_ptr, obj);
1720
3131
  return obj;
1721
3132
  }
1722
3133
 
1723
3134
  __destroy_into_raw() {
1724
3135
  const ptr = this.__wbg_ptr;
1725
3136
  this.__wbg_ptr = 0;
1726
- OfflineQueryFinalization.unregister(this);
3137
+ Poseidon2Finalization.unregister(this);
1727
3138
  return ptr;
1728
3139
  }
1729
3140
 
1730
3141
  free() {
1731
3142
  const ptr = this.__destroy_into_raw();
1732
- wasm.__wbg_offlinequery_free(ptr, 0);
3143
+ wasm.__wbg_poseidon2_free(ptr, 0);
1733
3144
  }
1734
3145
  /**
1735
- * Creates a new offline query object. The state root is required to be passed in as a string
1736
- * @param {number} block_height
1737
- * @param {string} state_root
3146
+ * Create a Poseidon hasher with an input rate of 2.
1738
3147
  */
1739
- constructor(block_height, state_root) {
3148
+ constructor() {
3149
+ const ret = wasm.poseidon2_new();
3150
+ this.__wbg_ptr = ret >>> 0;
3151
+ Poseidon2Finalization.register(this, this.__wbg_ptr, this);
3152
+ return this;
3153
+ }
3154
+ /**
3155
+ * Create a Poseidon hasher with an input rate of 2 and a custom domain separator.
3156
+ * @param {string} domain_separator
3157
+ * @returns {Poseidon2}
3158
+ */
3159
+ static setup(domain_separator) {
1740
3160
  try {
1741
3161
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1742
- const ptr0 = passStringToWasm0(state_root, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
3162
+ const ptr0 = passStringToWasm0(domain_separator, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
1743
3163
  const len0 = WASM_VECTOR_LEN;
1744
- wasm.offlinequery_new(retptr, block_height, ptr0, len0);
3164
+ wasm.poseidon2_setup(retptr, ptr0, len0);
1745
3165
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1746
3166
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1747
3167
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1748
3168
  if (r2) {
1749
3169
  throw takeObject(r1);
1750
3170
  }
1751
- this.__wbg_ptr = r0 >>> 0;
1752
- OfflineQueryFinalization.register(this, this.__wbg_ptr, this);
1753
- return this;
3171
+ return Poseidon2.__wrap(r0);
1754
3172
  } finally {
1755
3173
  wasm.__wbindgen_add_to_stack_pointer(16);
1756
3174
  }
1757
3175
  }
1758
3176
  /**
1759
- * Add a new block height to the offline query object.
1760
- * @param {number} block_height
3177
+ * Returns the Poseidon hash with an input rate of 2.
3178
+ * @param {Array<any>} input
3179
+ * @returns {Field}
1761
3180
  */
1762
- addBlockHeight(block_height) {
1763
- wasm.offlinequery_addBlockHeight(this.__wbg_ptr, block_height);
3181
+ hash(input) {
3182
+ try {
3183
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3184
+ wasm.poseidon2_hash(retptr, this.__wbg_ptr, addHeapObject(input));
3185
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3186
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3187
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3188
+ if (r2) {
3189
+ throw takeObject(r1);
3190
+ }
3191
+ return Field.__wrap(r0);
3192
+ } finally {
3193
+ wasm.__wbindgen_add_to_stack_pointer(16);
3194
+ }
1764
3195
  }
1765
3196
  /**
1766
- * Add a new state path to the offline query object.
1767
- *
1768
- * @param {string} commitment: The commitment corresponding to a record inpout
1769
- * @param {string} state_path: The state path corresponding to the commitment
1770
- * @param {string} commitment
1771
- * @param {string} state_path
3197
+ * Returns the extended Poseidon hash with an input rate of 2.
3198
+ * @param {Array<any>} input
3199
+ * @param {number} num_outputs
3200
+ * @returns {Array<any>}
1772
3201
  */
1773
- addStatePath(commitment, state_path) {
3202
+ hashMany(input, num_outputs) {
1774
3203
  try {
1775
3204
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1776
- const ptr0 = passStringToWasm0(commitment, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
1777
- const len0 = WASM_VECTOR_LEN;
1778
- const ptr1 = passStringToWasm0(state_path, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
1779
- const len1 = WASM_VECTOR_LEN;
1780
- wasm.offlinequery_addStatePath(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
3205
+ wasm.poseidon2_hashMany(retptr, this.__wbg_ptr, addHeapObject(input), num_outputs);
1781
3206
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1782
3207
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1783
- if (r1) {
1784
- throw takeObject(r0);
3208
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3209
+ if (r2) {
3210
+ throw takeObject(r1);
1785
3211
  }
3212
+ return takeObject(r0);
1786
3213
  } finally {
1787
3214
  wasm.__wbindgen_add_to_stack_pointer(16);
1788
3215
  }
1789
3216
  }
1790
3217
  /**
1791
- * Get a json string representation of the offline query object
1792
- * @returns {string}
3218
+ * Returns the Poseidon hash with an input rate of 2 on the scalar field.
3219
+ * @param {Array<any>} input
3220
+ * @returns {Scalar}
1793
3221
  */
1794
- toString() {
1795
- let deferred1_0;
1796
- let deferred1_1;
3222
+ hashToScalar(input) {
1797
3223
  try {
1798
3224
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1799
- wasm.offlinequery_toString(retptr, this.__wbg_ptr);
3225
+ wasm.poseidon2_hashToScalar(retptr, this.__wbg_ptr, addHeapObject(input));
1800
3226
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1801
3227
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1802
- deferred1_0 = r0;
1803
- deferred1_1 = r1;
1804
- return getStringFromWasm0(r0, r1);
3228
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3229
+ if (r2) {
3230
+ throw takeObject(r1);
3231
+ }
3232
+ return Scalar.__wrap(r0);
1805
3233
  } finally {
1806
3234
  wasm.__wbindgen_add_to_stack_pointer(16);
1807
- wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
1808
3235
  }
1809
3236
  }
1810
3237
  /**
1811
- * Create an offline query object from a json string representation
1812
- * @param {string} s
1813
- * @returns {OfflineQuery}
3238
+ * Returns the Poseidon hash with an input rate of 2 on the affine curve.
3239
+ * @param {Array<any>} input
3240
+ * @returns {Group}
1814
3241
  */
1815
- static fromString(s) {
3242
+ hashToGroup(input) {
1816
3243
  try {
1817
3244
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1818
- const ptr0 = passStringToWasm0(s, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
1819
- const len0 = WASM_VECTOR_LEN;
1820
- wasm.offlinequery_fromString(retptr, ptr0, len0);
3245
+ wasm.poseidon2_hashToGroup(retptr, this.__wbg_ptr, addHeapObject(input));
1821
3246
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1822
3247
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1823
3248
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1824
3249
  if (r2) {
1825
3250
  throw takeObject(r1);
1826
3251
  }
1827
- return OfflineQuery.__wrap(r0);
3252
+ return Group.__wrap(r0);
1828
3253
  } finally {
1829
3254
  wasm.__wbindgen_add_to_stack_pointer(16);
1830
3255
  }
1831
3256
  }
1832
3257
  }
1833
3258
 
1834
- const PlaintextFinalization = (typeof FinalizationRegistry === 'undefined')
3259
+ const Poseidon4Finalization = (typeof FinalizationRegistry === 'undefined')
1835
3260
  ? { register: () => {}, unregister: () => {} }
1836
- : new FinalizationRegistry(ptr => wasm.__wbg_plaintext_free(ptr >>> 0, 1));
1837
- /**
1838
- * SnarkVM Plaintext object. Plaintext is a fundamental monadic type used to represent Aleo
1839
- * primitive types (boolean, field, group, i8, i16, i32, i64, i128, u8, u16, u32, u64, u128,
1840
- * scalar, and signature), struct types, and array types.
1841
- *
1842
- * In the context of a web or NodeJS application, this type is useful for turning an Aleo type into
1843
- * a JS value, object, or array that might be necessary for performing computations within the
1844
- * application.
1845
- *
1846
- * @example
1847
- * // Get the bond state of an existing address.
1848
- * const bondState = await fetch(https://api.explorer.provable.com/v1/mainnet/program/credits.aleo/mapping/bond_state/aleo12zlythl7htjdtjjjz3ahdj4vl6wk3zuzm37s80l86qpx8fyx95fqnxcn2f);
1849
- * // Convert the bond state to a Plaintext object.
1850
- * const bondStatePlaintext = Plaintext.fromString(bond_state);
1851
- * // Convert the Plaintext object to a JS object.
1852
- * const bondStateObject = bond_state_plaintext.toObject();
1853
- * // Check if the bond state matches the expected object.
1854
- * const expectedObject = { validator: "aleo12zlythl7htjdtjjjz3ahdj4vl6wk3zuzm37s80l86qpx8fyx95fqnxcn2f", microcredits: 100000000u64 };
1855
- * assert( JSON.stringify(bondStateObject) === JSON.stringify(expectedObject) );
1856
- */
1857
- class Plaintext {
3261
+ : new FinalizationRegistry(ptr => wasm.__wbg_poseidon4_free(ptr >>> 0, 1));
3262
+
3263
+ class Poseidon4 {
1858
3264
 
1859
3265
  static __wrap(ptr) {
1860
3266
  ptr = ptr >>> 0;
1861
- const obj = Object.create(Plaintext.prototype);
3267
+ const obj = Object.create(Poseidon4.prototype);
1862
3268
  obj.__wbg_ptr = ptr;
1863
- PlaintextFinalization.register(obj, obj.__wbg_ptr, obj);
3269
+ Poseidon4Finalization.register(obj, obj.__wbg_ptr, obj);
1864
3270
  return obj;
1865
3271
  }
1866
3272
 
1867
3273
  __destroy_into_raw() {
1868
3274
  const ptr = this.__wbg_ptr;
1869
3275
  this.__wbg_ptr = 0;
1870
- PlaintextFinalization.unregister(this);
3276
+ Poseidon4Finalization.unregister(this);
1871
3277
  return ptr;
1872
3278
  }
1873
3279
 
1874
3280
  free() {
1875
3281
  const ptr = this.__destroy_into_raw();
1876
- wasm.__wbg_plaintext_free(ptr, 0);
3282
+ wasm.__wbg_poseidon4_free(ptr, 0);
1877
3283
  }
1878
3284
  /**
1879
- * Find plaintext member if the plaintext is a struct. Returns `null` if the plaintext is not
1880
- * a struct or the member does not exist.
1881
- *
1882
- * @param {string} name The name of the plaintext member to find.
1883
- *
1884
- * @returns {Plaintext} The plaintext member.
1885
- * @param {string} name
1886
- * @returns {Plaintext}
3285
+ * Create a Poseidon hasher with an input rate of 4.
1887
3286
  */
1888
- find(name) {
3287
+ constructor() {
3288
+ const ret = wasm.poseidon4_new();
3289
+ this.__wbg_ptr = ret >>> 0;
3290
+ Poseidon4Finalization.register(this, this.__wbg_ptr, this);
3291
+ return this;
3292
+ }
3293
+ /**
3294
+ * Create a Poseidon hasher with an input rate of 4 and a custom domain separator.
3295
+ * @param {string} domain_separator
3296
+ * @returns {Poseidon4}
3297
+ */
3298
+ static setup(domain_separator) {
1889
3299
  try {
1890
3300
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1891
- const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
3301
+ const ptr0 = passStringToWasm0(domain_separator, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
1892
3302
  const len0 = WASM_VECTOR_LEN;
1893
- wasm.plaintext_find(retptr, this.__wbg_ptr, ptr0, len0);
3303
+ wasm.poseidon4_setup(retptr, ptr0, len0);
1894
3304
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1895
3305
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1896
3306
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1897
3307
  if (r2) {
1898
3308
  throw takeObject(r1);
1899
3309
  }
1900
- return Plaintext.__wrap(r0);
3310
+ return Poseidon4.__wrap(r0);
1901
3311
  } finally {
1902
3312
  wasm.__wbindgen_add_to_stack_pointer(16);
1903
3313
  }
1904
3314
  }
1905
3315
  /**
1906
- * Encrypt a plaintext with an address and randomizer.
1907
- * @param {Address} address
1908
- * @param {Scalar} randomizer
1909
- * @returns {Ciphertext}
3316
+ * Returns the Poseidon hash with an input rate of 4.
3317
+ * @param {Array<any>} input
3318
+ * @returns {Field}
1910
3319
  */
1911
- encrypt(address, randomizer) {
3320
+ hash(input) {
1912
3321
  try {
1913
3322
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1914
- _assertClass(address, Address);
1915
- _assertClass(randomizer, Scalar);
1916
- wasm.plaintext_encrypt(retptr, this.__wbg_ptr, address.__wbg_ptr, randomizer.__wbg_ptr);
3323
+ wasm.poseidon4_hash(retptr, this.__wbg_ptr, addHeapObject(input));
1917
3324
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1918
3325
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1919
3326
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1920
3327
  if (r2) {
1921
3328
  throw takeObject(r1);
1922
3329
  }
1923
- return Ciphertext.__wrap(r0);
3330
+ return Field.__wrap(r0);
1924
3331
  } finally {
1925
3332
  wasm.__wbindgen_add_to_stack_pointer(16);
1926
3333
  }
1927
3334
  }
1928
3335
  /**
1929
- * Encrypt a plaintext with a transition view key.
1930
- * @param {Field} transition_view_key
1931
- * @returns {Ciphertext}
3336
+ * Returns the extended Poseidon hash with an input rate of 4.
3337
+ * @param {Array<any>} input
3338
+ * @param {number} num_outputs
3339
+ * @returns {Array<any>}
1932
3340
  */
1933
- encryptSymmetric(transition_view_key) {
3341
+ hashMany(input, num_outputs) {
1934
3342
  try {
1935
3343
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1936
- _assertClass(transition_view_key, Field);
1937
- wasm.plaintext_encryptSymmetric(retptr, this.__wbg_ptr, transition_view_key.__wbg_ptr);
3344
+ wasm.poseidon4_hashMany(retptr, this.__wbg_ptr, addHeapObject(input), num_outputs);
1938
3345
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1939
3346
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1940
3347
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1941
3348
  if (r2) {
1942
3349
  throw takeObject(r1);
1943
3350
  }
1944
- return Ciphertext.__wrap(r0);
3351
+ return takeObject(r0);
1945
3352
  } finally {
1946
3353
  wasm.__wbindgen_add_to_stack_pointer(16);
1947
3354
  }
1948
3355
  }
1949
3356
  /**
1950
- * Creates a plaintext object from a string representation of a plaintext.
1951
- *
1952
- * @param {string} plaintext The string representation of the plaintext.
1953
- *
1954
- * @returns {Plaintext} The plaintext object.
1955
- * @param {string} plaintext
1956
- * @returns {Plaintext}
3357
+ * Returns the Poseidon hash with an input rate of 4 on the scalar field.
3358
+ * @param {Array<any>} input
3359
+ * @returns {Scalar}
1957
3360
  */
1958
- static fromString(plaintext) {
3361
+ hashToScalar(input) {
1959
3362
  try {
1960
3363
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1961
- const ptr0 = passStringToWasm0(plaintext, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
1962
- const len0 = WASM_VECTOR_LEN;
1963
- wasm.plaintext_fromString(retptr, ptr0, len0);
3364
+ wasm.poseidon4_hashToScalar(retptr, this.__wbg_ptr, addHeapObject(input));
1964
3365
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1965
3366
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1966
3367
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1967
3368
  if (r2) {
1968
3369
  throw takeObject(r1);
1969
3370
  }
1970
- return Plaintext.__wrap(r0);
3371
+ return Scalar.__wrap(r0);
1971
3372
  } finally {
1972
3373
  wasm.__wbindgen_add_to_stack_pointer(16);
1973
3374
  }
1974
3375
  }
1975
3376
  /**
1976
- * Get a plaintext object from a series of bytes.
1977
- *
1978
- * @param {Uint8Array} bytes A left endian byte array representing the plaintext.
1979
- *
1980
- * @returns {Plaintext} The plaintext object.
1981
- * @param {Uint8Array} bytes
1982
- * @returns {Plaintext}
3377
+ * Returns the Poseidon hash with an input rate of 4 on the affine curve.
3378
+ * @param {Array<any>} input
3379
+ * @returns {Group}
1983
3380
  */
1984
- static fromBytesLe(bytes) {
3381
+ hashToGroup(input) {
1985
3382
  try {
1986
3383
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1987
- wasm.plaintext_fromBytesLe(retptr, addHeapObject(bytes));
3384
+ wasm.poseidon4_hashToGroup(retptr, this.__wbg_ptr, addHeapObject(input));
1988
3385
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1989
3386
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1990
3387
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1991
3388
  if (r2) {
1992
3389
  throw takeObject(r1);
1993
3390
  }
1994
- return Plaintext.__wrap(r0);
3391
+ return Group.__wrap(r0);
1995
3392
  } finally {
1996
3393
  wasm.__wbindgen_add_to_stack_pointer(16);
1997
3394
  }
1998
3395
  }
3396
+ }
3397
+
3398
+ const Poseidon8Finalization = (typeof FinalizationRegistry === 'undefined')
3399
+ ? { register: () => {}, unregister: () => {} }
3400
+ : new FinalizationRegistry(ptr => wasm.__wbg_poseidon8_free(ptr >>> 0, 1));
3401
+
3402
+ class Poseidon8 {
3403
+
3404
+ static __wrap(ptr) {
3405
+ ptr = ptr >>> 0;
3406
+ const obj = Object.create(Poseidon8.prototype);
3407
+ obj.__wbg_ptr = ptr;
3408
+ Poseidon8Finalization.register(obj, obj.__wbg_ptr, obj);
3409
+ return obj;
3410
+ }
3411
+
3412
+ __destroy_into_raw() {
3413
+ const ptr = this.__wbg_ptr;
3414
+ this.__wbg_ptr = 0;
3415
+ Poseidon8Finalization.unregister(this);
3416
+ return ptr;
3417
+ }
3418
+
3419
+ free() {
3420
+ const ptr = this.__destroy_into_raw();
3421
+ wasm.__wbg_poseidon8_free(ptr, 0);
3422
+ }
1999
3423
  /**
2000
- * Generate a random plaintext element from a series of bytes.
2001
- *
2002
- * @param {Uint8Array} bytes A left endian byte array representing the plaintext.
2003
- * @returns {Uint8Array}
3424
+ * Create a Poseidon hasher with an input rate of 8.
2004
3425
  */
2005
- toBytesLe() {
3426
+ constructor() {
3427
+ const ret = wasm.poseidon8_new();
3428
+ this.__wbg_ptr = ret >>> 0;
3429
+ Poseidon8Finalization.register(this, this.__wbg_ptr, this);
3430
+ return this;
3431
+ }
3432
+ /**
3433
+ * Create a Poseidon hasher with an input rate of 8 and a custom domain separator.
3434
+ * @param {string} domain_separator
3435
+ * @returns {Poseidon8}
3436
+ */
3437
+ static setup(domain_separator) {
2006
3438
  try {
2007
3439
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2008
- wasm.plaintext_toBytesLe(retptr, this.__wbg_ptr);
3440
+ const ptr0 = passStringToWasm0(domain_separator, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
3441
+ const len0 = WASM_VECTOR_LEN;
3442
+ wasm.poseidon8_setup(retptr, ptr0, len0);
2009
3443
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2010
3444
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2011
3445
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2012
3446
  if (r2) {
2013
3447
  throw takeObject(r1);
2014
3448
  }
2015
- return takeObject(r0);
3449
+ return Poseidon8.__wrap(r0);
2016
3450
  } finally {
2017
3451
  wasm.__wbindgen_add_to_stack_pointer(16);
2018
3452
  }
2019
3453
  }
2020
3454
  /**
2021
- * Returns the string representation of the plaintext.
2022
- *
2023
- * @returns {string} The string representation of the plaintext.
2024
- * @returns {string}
3455
+ * Returns the Poseidon hash with an input rate of 8.
3456
+ * @param {Array<any>} input
3457
+ * @returns {Field}
2025
3458
  */
2026
- toString() {
2027
- let deferred1_0;
2028
- let deferred1_1;
3459
+ hash(input) {
2029
3460
  try {
2030
3461
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2031
- wasm.plaintext_toString(retptr, this.__wbg_ptr);
3462
+ wasm.poseidon8_hash(retptr, this.__wbg_ptr, addHeapObject(input));
2032
3463
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2033
3464
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2034
- deferred1_0 = r0;
2035
- deferred1_1 = r1;
2036
- return getStringFromWasm0(r0, r1);
3465
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3466
+ if (r2) {
3467
+ throw takeObject(r1);
3468
+ }
3469
+ return Field.__wrap(r0);
2037
3470
  } finally {
2038
3471
  wasm.__wbindgen_add_to_stack_pointer(16);
2039
- wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
2040
3472
  }
2041
3473
  }
2042
3474
  /**
2043
- * Gives the type of the plaintext.
2044
- *
2045
- * @returns {string} The type of the plaintext.
2046
- * @returns {string}
3475
+ * Returns the extended Poseidon hash with an input rate of 8.
3476
+ * @param {Array<any>} input
3477
+ * @param {number} num_outputs
3478
+ * @returns {Array<any>}
2047
3479
  */
2048
- plaintextType() {
2049
- let deferred1_0;
2050
- let deferred1_1;
3480
+ hashMany(input, num_outputs) {
2051
3481
  try {
2052
3482
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2053
- wasm.plaintext_plaintextType(retptr, this.__wbg_ptr);
3483
+ wasm.poseidon8_hashMany(retptr, this.__wbg_ptr, addHeapObject(input), num_outputs);
2054
3484
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2055
3485
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2056
- deferred1_0 = r0;
2057
- deferred1_1 = r1;
2058
- return getStringFromWasm0(r0, r1);
3486
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3487
+ if (r2) {
3488
+ throw takeObject(r1);
3489
+ }
3490
+ return takeObject(r0);
2059
3491
  } finally {
2060
3492
  wasm.__wbindgen_add_to_stack_pointer(16);
2061
- wasm.__wbindgen_export_2(deferred1_0, deferred1_1, 1);
2062
3493
  }
2063
3494
  }
2064
3495
  /**
2065
- * Attempt to convert the plaintext to a JS object.
2066
- *
2067
- * @returns {Object} The JS object representation of the plaintext.
2068
- * @returns {any}
3496
+ * Returns the Poseidon hash with an input rate of 8 on the scalar field.
3497
+ * @param {Array<any>} input
3498
+ * @returns {Scalar}
2069
3499
  */
2070
- toObject() {
3500
+ hashToScalar(input) {
2071
3501
  try {
2072
3502
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2073
- wasm.plaintext_toObject(retptr, this.__wbg_ptr);
3503
+ wasm.poseidon8_hashToScalar(retptr, this.__wbg_ptr, addHeapObject(input));
2074
3504
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2075
3505
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2076
3506
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2077
3507
  if (r2) {
2078
3508
  throw takeObject(r1);
2079
3509
  }
2080
- return takeObject(r0);
3510
+ return Scalar.__wrap(r0);
3511
+ } finally {
3512
+ wasm.__wbindgen_add_to_stack_pointer(16);
3513
+ }
3514
+ }
3515
+ /**
3516
+ * Returns the Poseidon hash with an input rate of 8 on the affine curve.
3517
+ * @param {Array<any>} input
3518
+ * @returns {Group}
3519
+ */
3520
+ hashToGroup(input) {
3521
+ try {
3522
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3523
+ wasm.poseidon8_hashToGroup(retptr, this.__wbg_ptr, addHeapObject(input));
3524
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
3525
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
3526
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
3527
+ if (r2) {
3528
+ throw takeObject(r1);
3529
+ }
3530
+ return Group.__wrap(r0);
2081
3531
  } finally {
2082
3532
  wasm.__wbindgen_add_to_stack_pointer(16);
2083
3533
  }
@@ -4254,7 +5704,29 @@ class Scalar {
4254
5704
  wasm.__wbg_scalar_free(ptr, 0);
4255
5705
  }
4256
5706
  /**
4257
- * Returns the string representation of the group.
5707
+ * Creates a scalar object from a string representation of a scalar element.
5708
+ * @param {string} group
5709
+ * @returns {Scalar}
5710
+ */
5711
+ static fromString(group) {
5712
+ try {
5713
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
5714
+ const ptr0 = passStringToWasm0(group, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
5715
+ const len0 = WASM_VECTOR_LEN;
5716
+ wasm.scalar_fromString(retptr, ptr0, len0);
5717
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
5718
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
5719
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
5720
+ if (r2) {
5721
+ throw takeObject(r1);
5722
+ }
5723
+ return Scalar.__wrap(r0);
5724
+ } finally {
5725
+ wasm.__wbindgen_add_to_stack_pointer(16);
5726
+ }
5727
+ }
5728
+ /**
5729
+ * Returns the string representation of the scalar element.
4258
5730
  * @returns {string}
4259
5731
  */
4260
5732
  toString() {
@@ -4274,24 +5746,54 @@ class Scalar {
4274
5746
  }
4275
5747
  }
4276
5748
  /**
4277
- * Create a plaintext element from a group element.
4278
- * @returns {Plaintext}
5749
+ * Create a scalar element from a Uint8Array of left endian bytes.
5750
+ * @param {Uint8Array} bytes
5751
+ * @returns {Scalar}
4279
5752
  */
4280
- toPlaintext() {
4281
- const ret = wasm.scalar_toPlaintext(this.__wbg_ptr);
4282
- return Plaintext.__wrap(ret);
5753
+ static fromBytesLe(bytes) {
5754
+ try {
5755
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
5756
+ wasm.scalar_fromBytesLe(retptr, addBorrowedObject(bytes));
5757
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
5758
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
5759
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
5760
+ if (r2) {
5761
+ throw takeObject(r1);
5762
+ }
5763
+ return Scalar.__wrap(r0);
5764
+ } finally {
5765
+ wasm.__wbindgen_add_to_stack_pointer(16);
5766
+ heap[stack_pointer++] = undefined;
5767
+ }
4283
5768
  }
4284
5769
  /**
4285
- * Creates a group object from a string representation of a group.
4286
- * @param {string} group
5770
+ * Encode the scalar element as a Uint8Array of left endian bytes.
5771
+ * @returns {Uint8Array}
5772
+ */
5773
+ toBytesLe() {
5774
+ try {
5775
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
5776
+ wasm.scalar_toBytesLe(retptr, this.__wbg_ptr);
5777
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
5778
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
5779
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
5780
+ if (r2) {
5781
+ throw takeObject(r1);
5782
+ }
5783
+ return takeObject(r0);
5784
+ } finally {
5785
+ wasm.__wbindgen_add_to_stack_pointer(16);
5786
+ }
5787
+ }
5788
+ /**
5789
+ * Reconstruct a scalar element from a boolean array representation.
5790
+ * @param {Array<any>} bits
4287
5791
  * @returns {Scalar}
4288
5792
  */
4289
- static fromString(group) {
5793
+ static fromBitsLe(bits) {
4290
5794
  try {
4291
5795
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
4292
- const ptr0 = passStringToWasm0(group, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
4293
- const len0 = WASM_VECTOR_LEN;
4294
- wasm.scalar_fromString(retptr, ptr0, len0);
5796
+ wasm.scalar_fromBitsLe(retptr, addBorrowedObject(bits));
4295
5797
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
4296
5798
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
4297
5799
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -4301,10 +5803,35 @@ class Scalar {
4301
5803
  return Scalar.__wrap(r0);
4302
5804
  } finally {
4303
5805
  wasm.__wbindgen_add_to_stack_pointer(16);
5806
+ heap[stack_pointer++] = undefined;
4304
5807
  }
4305
5808
  }
4306
5809
  /**
4307
- * Generate a random group element.
5810
+ * Get the left endian boolean array representation of the scalar element.
5811
+ * @returns {Array<any>}
5812
+ */
5813
+ toBitsLe() {
5814
+ const ret = wasm.scalar_toBitsLe(this.__wbg_ptr);
5815
+ return takeObject(ret);
5816
+ }
5817
+ /**
5818
+ * Create a plaintext element from a scalar element.
5819
+ * @returns {Plaintext}
5820
+ */
5821
+ toPlaintext() {
5822
+ const ret = wasm.scalar_toPlaintext(this.__wbg_ptr);
5823
+ return Plaintext.__wrap(ret);
5824
+ }
5825
+ /**
5826
+ * Clone the scalar element.
5827
+ * @returns {Scalar}
5828
+ */
5829
+ clone() {
5830
+ const ret = wasm.field_clone(this.__wbg_ptr);
5831
+ return Scalar.__wrap(ret);
5832
+ }
5833
+ /**
5834
+ * Generate a random scalar element.
4308
5835
  * @returns {Scalar}
4309
5836
  */
4310
5837
  static random() {
@@ -4378,7 +5905,7 @@ class Scalar {
4378
5905
  return Scalar.__wrap(ret);
4379
5906
  }
4380
5907
  /**
4381
- * Creates a one valued element of the scalar field.
5908
+ * Get the multiplicative identity of the scalar field.
4382
5909
  * @returns {Scalar}
4383
5910
  */
4384
5911
  static one() {
@@ -4386,7 +5913,7 @@ class Scalar {
4386
5913
  return Scalar.__wrap(ret);
4387
5914
  }
4388
5915
  /**
4389
- * Creates a zero valued element of the scalar field
5916
+ * Get the additive identity of the scalar field.
4390
5917
  * @returns {Scalar}
4391
5918
  */
4392
5919
  static zero() {
@@ -4464,7 +5991,7 @@ class Signature {
4464
5991
  * @returns {Scalar}
4465
5992
  */
4466
5993
  challenge() {
4467
- const ret = wasm.graphkey_sk_tag(this.__wbg_ptr);
5994
+ const ret = wasm.field_clone(this.__wbg_ptr);
4468
5995
  return Scalar.__wrap(ret);
4469
5996
  }
4470
5997
  /**
@@ -5153,6 +6680,16 @@ class Transition {
5153
6680
  const ret = wasm.computekey_pk_sig(this.__wbg_ptr);
5154
6681
  return Group.__wrap(ret);
5155
6682
  }
6683
+ /**
6684
+ * Get the transition view key of the transition.
6685
+ * @param {ViewKey} view_key
6686
+ * @returns {Field}
6687
+ */
6688
+ tvk(view_key) {
6689
+ _assertClass(view_key, ViewKey);
6690
+ const ret = wasm.transition_tvk(this.__wbg_ptr, view_key.__wbg_ptr);
6691
+ return Field.__wrap(ret);
6692
+ }
5156
6693
  /**
5157
6694
  * Get the transition commitment of the transition.
5158
6695
  * @returns {Field}
@@ -5717,7 +7254,7 @@ class ViewKey {
5717
7254
  * @returns {Scalar}
5718
7255
  */
5719
7256
  to_scalar() {
5720
- const ret = wasm.graphkey_sk_tag(this.__wbg_ptr);
7257
+ const ret = wasm.field_clone(this.__wbg_ptr);
5721
7258
  return Scalar.__wrap(ret);
5722
7259
  }
5723
7260
  /**
@@ -5863,6 +7400,10 @@ function __wbg_get_imports() {
5863
7400
  const ret = Field.__wrap(arg0);
5864
7401
  return addHeapObject(ret);
5865
7402
  };
7403
+ imports.wbg.__wbg_field_unwrap = function(arg0) {
7404
+ const ret = Field.__unwrap(takeObject(arg0));
7405
+ return ret;
7406
+ };
5866
7407
  imports.wbg.__wbg_getRandomValues_bcb4912f16000dc4 = function() { return handleError(function (arg0, arg1) {
5867
7408
  getObject(arg0).getRandomValues(getObject(arg1));
5868
7409
  }, arguments) };
@@ -5912,7 +7453,7 @@ function __wbg_get_imports() {
5912
7453
  const ret = getObject(arg0).length;
5913
7454
  return ret;
5914
7455
  };
5915
- imports.wbg.__wbg_log_9f90a4b62aac5c63 = function(arg0, arg1) {
7456
+ imports.wbg.__wbg_log_1af7ae7bd9c6ae19 = function(arg0, arg1) {
5916
7457
  console.log(getStringFromWasm0(arg0, arg1));
5917
7458
  };
5918
7459
  imports.wbg.__wbg_msCrypto_0a36e2ec3a343d26 = function(arg0) {
@@ -5930,7 +7471,7 @@ function __wbg_get_imports() {
5930
7471
  const a = state0.a;
5931
7472
  state0.a = 0;
5932
7473
  try {
5933
- return __wbg_adapter_417(a, state0.b, arg0, arg1);
7474
+ return __wbg_adapter_491(a, state0.b, arg0, arg1);
5934
7475
  } finally {
5935
7476
  state0.a = a;
5936
7477
  }
@@ -6109,7 +7650,7 @@ function __wbg_get_imports() {
6109
7650
  const ret = Signature.__wrap(arg0);
6110
7651
  return addHeapObject(ret);
6111
7652
  };
6112
- imports.wbg.__wbg_spawnWorker_5909de4ce646c497 = function(arg0, arg1, arg2, arg3) {
7653
+ imports.wbg.__wbg_spawnWorker_a8e0ffb747e264de = function(arg0, arg1, arg2, arg3) {
6113
7654
  const ret = spawnWorker(getObject(arg0), getObject(arg1), getObject(arg2), arg3 >>> 0);
6114
7655
  return addHeapObject(ret);
6115
7656
  };
@@ -6215,6 +7756,11 @@ function __wbg_get_imports() {
6215
7756
  const ret = BigInt.asUintN(64, arg0);
6216
7757
  return addHeapObject(ret);
6217
7758
  };
7759
+ imports.wbg.__wbindgen_boolean_get = function(arg0) {
7760
+ const v = getObject(arg0);
7761
+ const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
7762
+ return ret;
7763
+ };
6218
7764
  imports.wbg.__wbindgen_cb_drop = function(arg0) {
6219
7765
  const obj = takeObject(arg0).original;
6220
7766
  if (obj.cnt-- == 1) {
@@ -6224,12 +7770,12 @@ function __wbg_get_imports() {
6224
7770
  const ret = false;
6225
7771
  return ret;
6226
7772
  };
6227
- imports.wbg.__wbindgen_closure_wrapper5894 = function(arg0, arg1, arg2) {
6228
- const ret = makeMutClosure(arg0, arg1, 519, __wbg_adapter_38);
7773
+ imports.wbg.__wbindgen_closure_wrapper6041 = function(arg0, arg1, arg2) {
7774
+ const ret = makeMutClosure(arg0, arg1, 519, __wbg_adapter_40);
6229
7775
  return addHeapObject(ret);
6230
7776
  };
6231
- imports.wbg.__wbindgen_closure_wrapper5900 = function(arg0, arg1, arg2) {
6232
- const ret = makeMutClosure(arg0, arg1, 519, __wbg_adapter_38);
7777
+ imports.wbg.__wbindgen_closure_wrapper6047 = function(arg0, arg1, arg2) {
7778
+ const ret = makeMutClosure(arg0, arg1, 519, __wbg_adapter_40);
6233
7779
  return addHeapObject(ret);
6234
7780
  };
6235
7781
  imports.wbg.__wbindgen_is_function = function(arg0) {
@@ -6384,5 +7930,5 @@ async function initThreadPool(threads) {
6384
7930
  await initThreadPool$1(new URL("worker.js", import.meta.url), threads);
6385
7931
  }
6386
7932
 
6387
- export { Address, Ciphertext, ComputeKey, Execution, ExecutionResponse, Field, GraphKey, Group, KeyPair, Metadata, OfflineQuery, Plaintext, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager, ProvingKey, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, VerifyingKey, ViewKey, initSync, initThreadPool, runRayonThread, verifyFunctionExecution };
7933
+ export { Address, BHP1024, BHP256, BHP512, BHP768, Ciphertext, ComputeKey, Execution, ExecutionResponse, Field, GraphKey, Group, KeyPair, Metadata, OfflineQuery, Pedersen128, Pedersen64, Plaintext, Poseidon2, Poseidon4, Poseidon8, PrivateKey, PrivateKeyCiphertext, Program, ProgramManager, ProvingKey, RecordCiphertext, RecordPlaintext, Scalar, Signature, Transaction, Transition, VerifyingKey, ViewKey, initSync, initThreadPool, runRayonThread, verifyFunctionExecution };
6388
7934
  //# sourceMappingURL=index.js.map