tkms 0.11.0-rc9 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/kms_lib.js CHANGED
@@ -166,6 +166,21 @@ function debugString(val) {
166
166
  // TODO we could test for more things here, like `Set`s and `Map`s.
167
167
  return className;
168
168
  }
169
+ /**
170
+ * @returns {number}
171
+ */
172
+ export function ml_kem_pke_pk_len() {
173
+ const ret = wasm.ml_kem_pke_pk_len();
174
+ return ret >>> 0;
175
+ }
176
+
177
+ /**
178
+ * @returns {number}
179
+ */
180
+ export function ml_kem_pke_sk_len() {
181
+ const ret = wasm.ml_kem_pke_sk_len();
182
+ return ret >>> 0;
183
+ }
169
184
 
170
185
  function _assertClass(instance, klass) {
171
186
  if (!(instance instanceof klass)) {
@@ -244,6 +259,23 @@ export function u8vec_to_private_sig_key(v) {
244
259
  return PrivateSigKey.__wrap(ret[0]);
245
260
  }
246
261
 
262
+ /**
263
+ * Create a new [ServerIdAddr] structure that holds an ID and an address
264
+ * which must be a valid EIP-55 address, notably prefixed with "0x".
265
+ * @param {number} id
266
+ * @param {string} addr
267
+ * @returns {ServerIdAddr}
268
+ */
269
+ export function new_server_id_addr(id, addr) {
270
+ const ptr0 = passStringToWasm0(addr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
271
+ const len0 = WASM_VECTOR_LEN;
272
+ const ret = wasm.new_server_id_addr(id, ptr0, len0);
273
+ if (ret[2]) {
274
+ throw takeFromExternrefTable0(ret[1]);
275
+ }
276
+ return ServerIdAddr.__wrap(ret[0]);
277
+ }
278
+
247
279
  function passArrayJsValueToWasm0(array, malloc) {
248
280
  const ptr = malloc(array.length * 4, 4) >>> 0;
249
281
  for (let i = 0; i < array.length; i++) {
@@ -256,15 +288,15 @@ function passArrayJsValueToWasm0(array, malloc) {
256
288
  /**
257
289
  * Instantiate a new client.
258
290
  *
259
- * * `server_addrs` - a list of KMS server EIP-55 addresses,
260
- * must be prefixed with "0x".
291
+ * * `server_addrs` - a list of KMS server ID with EIP-55 addresses,
292
+ * the elements in the list can be created using [new_server_id_addr].
261
293
  *
262
294
  * * `client_address_hex` - the client (wallet) address in hex,
263
295
  * must be prefixed with "0x".
264
296
  *
265
297
  * * `fhe_parameter` - the parameter choice, which can be either `"test"` or `"default"`.
266
298
  * The "default" parameter choice is selected if no matching string is found.
267
- * @param {string[]} server_addrs
299
+ * @param {ServerIdAddr[]} server_addrs
268
300
  * @param {string} client_address_hex
269
301
  * @param {string} fhe_parameter
270
302
  * @returns {Client}
@@ -295,7 +327,7 @@ function getArrayJsValueFromWasm0(ptr, len) {
295
327
  }
296
328
  /**
297
329
  * @param {Client} client
298
- * @returns {string[]}
330
+ * @returns {ServerIdAddr[]}
299
331
  */
300
332
  export function get_server_addrs(client) {
301
333
  _assertClass(client, Client);
@@ -334,30 +366,30 @@ export function get_client_address(client) {
334
366
  }
335
367
 
336
368
  /**
337
- * @returns {PrivateEncKey}
369
+ * @returns {PrivateEncKeyMlKem512}
338
370
  */
339
- export function cryptobox_keygen() {
340
- const ret = wasm.cryptobox_keygen();
341
- return PrivateEncKey.__wrap(ret);
371
+ export function ml_kem_pke_keygen() {
372
+ const ret = wasm.ml_kem_pke_keygen();
373
+ return PrivateEncKeyMlKem512.__wrap(ret);
342
374
  }
343
375
 
344
376
  /**
345
- * @param {PrivateEncKey} sk
346
- * @returns {PublicEncKey}
377
+ * @param {PrivateEncKeyMlKem512} sk
378
+ * @returns {PublicEncKeyMlKem512}
347
379
  */
348
- export function cryptobox_get_pk(sk) {
349
- _assertClass(sk, PrivateEncKey);
350
- const ret = wasm.cryptobox_get_pk(sk.__wbg_ptr);
351
- return PublicEncKey.__wrap(ret);
380
+ export function ml_kem_pke_get_pk(sk) {
381
+ _assertClass(sk, PrivateEncKeyMlKem512);
382
+ const ret = wasm.ml_kem_pke_get_pk(sk.__wbg_ptr);
383
+ return PublicEncKeyMlKem512.__wrap(ret);
352
384
  }
353
385
 
354
386
  /**
355
- * @param {PublicEncKey} pk
387
+ * @param {PublicEncKeyMlKem512} pk
356
388
  * @returns {Uint8Array}
357
389
  */
358
- export function cryptobox_pk_to_u8vec(pk) {
359
- _assertClass(pk, PublicEncKey);
360
- const ret = wasm.cryptobox_pk_to_u8vec(pk.__wbg_ptr);
390
+ export function ml_kem_pke_pk_to_u8vec(pk) {
391
+ _assertClass(pk, PublicEncKeyMlKem512);
392
+ const ret = wasm.ml_kem_pke_pk_to_u8vec(pk.__wbg_ptr);
361
393
  if (ret[3]) {
362
394
  throw takeFromExternrefTable0(ret[2]);
363
395
  }
@@ -367,12 +399,12 @@ export function cryptobox_pk_to_u8vec(pk) {
367
399
  }
368
400
 
369
401
  /**
370
- * @param {PrivateEncKey} sk
402
+ * @param {PrivateEncKeyMlKem512} sk
371
403
  * @returns {Uint8Array}
372
404
  */
373
- export function cryptobox_sk_to_u8vec(sk) {
374
- _assertClass(sk, PrivateEncKey);
375
- const ret = wasm.cryptobox_sk_to_u8vec(sk.__wbg_ptr);
405
+ export function ml_kem_pke_sk_to_u8vec(sk) {
406
+ _assertClass(sk, PrivateEncKeyMlKem512);
407
+ const ret = wasm.ml_kem_pke_sk_to_u8vec(sk.__wbg_ptr);
376
408
  if (ret[3]) {
377
409
  throw takeFromExternrefTable0(ret[2]);
378
410
  }
@@ -383,71 +415,75 @@ export function cryptobox_sk_to_u8vec(sk) {
383
415
 
384
416
  /**
385
417
  * @param {Uint8Array} v
386
- * @returns {PublicEncKey}
418
+ * @returns {PublicEncKeyMlKem512}
387
419
  */
388
- export function u8vec_to_cryptobox_pk(v) {
420
+ export function u8vec_to_ml_kem_pke_pk(v) {
389
421
  const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
390
422
  const len0 = WASM_VECTOR_LEN;
391
- const ret = wasm.u8vec_to_cryptobox_pk(ptr0, len0);
423
+ const ret = wasm.u8vec_to_ml_kem_pke_pk(ptr0, len0);
392
424
  if (ret[2]) {
393
425
  throw takeFromExternrefTable0(ret[1]);
394
426
  }
395
- return PublicEncKey.__wrap(ret[0]);
427
+ return PublicEncKeyMlKem512.__wrap(ret[0]);
396
428
  }
397
429
 
398
430
  /**
399
431
  * @param {Uint8Array} v
400
- * @returns {PrivateEncKey}
432
+ * @returns {PrivateEncKeyMlKem512}
401
433
  */
402
- export function u8vec_to_cryptobox_sk(v) {
434
+ export function u8vec_to_ml_kem_pke_sk(v) {
403
435
  const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
404
436
  const len0 = WASM_VECTOR_LEN;
405
- const ret = wasm.u8vec_to_cryptobox_sk(ptr0, len0);
437
+ const ret = wasm.u8vec_to_ml_kem_pke_sk(ptr0, len0);
406
438
  if (ret[2]) {
407
439
  throw takeFromExternrefTable0(ret[1]);
408
440
  }
409
- return PrivateEncKey.__wrap(ret[0]);
441
+ return PrivateEncKeyMlKem512.__wrap(ret[0]);
410
442
  }
411
443
 
412
444
  /**
445
+ * This function is *not* used by relayer-sdk because the encryption
446
+ * happens on the KMS side. It's just here for completeness and tests.
413
447
  * @param {Uint8Array} msg
414
- * @param {PublicEncKey} their_pk
415
- * @param {PrivateEncKey} my_sk
416
- * @returns {CryptoBoxCt}
448
+ * @param {PublicEncKeyMlKem512} their_pk
449
+ * @returns {Uint8Array}
417
450
  */
418
- export function cryptobox_encrypt(msg, their_pk, my_sk) {
451
+ export function ml_kem_pke_encrypt(msg, their_pk) {
419
452
  const ptr0 = passArray8ToWasm0(msg, wasm.__wbindgen_malloc);
420
453
  const len0 = WASM_VECTOR_LEN;
421
- _assertClass(their_pk, PublicEncKey);
422
- _assertClass(my_sk, PrivateEncKey);
423
- const ret = wasm.cryptobox_encrypt(ptr0, len0, their_pk.__wbg_ptr, my_sk.__wbg_ptr);
424
- return CryptoBoxCt.__wrap(ret);
454
+ _assertClass(their_pk, PublicEncKeyMlKem512);
455
+ const ret = wasm.ml_kem_pke_encrypt(ptr0, len0, their_pk.__wbg_ptr);
456
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
457
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
458
+ return v2;
425
459
  }
426
460
 
427
461
  /**
428
- * @param {CryptoBoxCt} ct
429
- * @param {PrivateEncKey} my_sk
430
- * @param {PublicEncKey} their_pk
462
+ * This function is *not* used by relayer-sdk because the decryption
463
+ * is handled by [process_user_decryption_resp].
464
+ * It's just here for completeness and tests.
465
+ * @param {Uint8Array} ct
466
+ * @param {PrivateEncKeyMlKem512} my_sk
431
467
  * @returns {Uint8Array}
432
468
  */
433
- export function cryptobox_decrypt(ct, my_sk, their_pk) {
434
- _assertClass(ct, CryptoBoxCt);
435
- _assertClass(my_sk, PrivateEncKey);
436
- _assertClass(their_pk, PublicEncKey);
437
- const ret = wasm.cryptobox_decrypt(ct.__wbg_ptr, my_sk.__wbg_ptr, their_pk.__wbg_ptr);
438
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
469
+ export function ml_kem_pke_decrypt(ct, my_sk) {
470
+ const ptr0 = passArray8ToWasm0(ct, wasm.__wbindgen_malloc);
471
+ const len0 = WASM_VECTOR_LEN;
472
+ _assertClass(my_sk, PrivateEncKeyMlKem512);
473
+ const ret = wasm.ml_kem_pke_decrypt(ptr0, len0, my_sk.__wbg_ptr);
474
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
439
475
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
440
- return v1;
476
+ return v2;
441
477
  }
442
478
 
443
479
  /**
444
- * Process the reencryption response from JavaScript objects.
480
+ * Process the user_decryption response from JavaScript objects.
445
481
  * The returned result is a byte array representing a plaintext of any length,
446
482
  * postprocessing is returned to turn it into an integer.
447
483
  *
448
- * * `client` - client that wants to perform reencryption.
484
+ * * `client` - client that wants to perform user_decryption.
449
485
  *
450
- * * `request` - the initial reencryption request JS object.
486
+ * * `request` - the initial user_decryption request JS object.
451
487
  * It can be set to null if `verify` is false.
452
488
  * Otherwise the caller needs to give the following JS object.
453
489
  * Note that `client_address` and `eip712_verifying_contract` follow EIP-55.
@@ -488,7 +524,8 @@ export function cryptobox_decrypt(ct, my_sk, their_pk) {
488
524
  * [
489
525
  * {
490
526
  * signature: '69e7e040cab157aa819015b321c012dccb1545ffefd325b359b492653f0347517e28e66c572cdc299e259024329859ff9fcb0096e1ce072af0b6e1ca1fe25ec6',
491
- * payload: '0100000029...'
527
+ * payload: '0100000029...',
528
+ * extra_data: '01234...',
492
529
  * }
493
530
  * ]
494
531
  * ```
@@ -503,16 +540,16 @@ export function cryptobox_decrypt(ct, my_sk, their_pk) {
503
540
  * @param {any} request
504
541
  * @param {any} eip712_domain
505
542
  * @param {any} agg_resp
506
- * @param {PublicEncKey} enc_pk
507
- * @param {PrivateEncKey} enc_sk
543
+ * @param {PublicEncKeyMlKem512} enc_pk
544
+ * @param {PrivateEncKeyMlKem512} enc_sk
508
545
  * @param {boolean} verify
509
546
  * @returns {TypedPlaintext[]}
510
547
  */
511
- export function process_reencryption_resp_from_js(client, request, eip712_domain, agg_resp, enc_pk, enc_sk, verify) {
548
+ export function process_user_decryption_resp_from_js(client, request, eip712_domain, agg_resp, enc_pk, enc_sk, verify) {
512
549
  _assertClass(client, Client);
513
- _assertClass(enc_pk, PublicEncKey);
514
- _assertClass(enc_sk, PrivateEncKey);
515
- const ret = wasm.process_reencryption_resp_from_js(client.__wbg_ptr, request, eip712_domain, agg_resp, enc_pk.__wbg_ptr, enc_sk.__wbg_ptr, verify);
550
+ _assertClass(enc_pk, PublicEncKeyMlKem512);
551
+ _assertClass(enc_sk, PrivateEncKeyMlKem512);
552
+ const ret = wasm.process_user_decryption_resp_from_js(client.__wbg_ptr, request, eip712_domain, agg_resp, enc_pk.__wbg_ptr, enc_sk.__wbg_ptr, verify);
516
553
  if (ret[3]) {
517
554
  throw takeFromExternrefTable0(ret[2]);
518
555
  }
@@ -522,20 +559,20 @@ export function process_reencryption_resp_from_js(client, request, eip712_domain
522
559
  }
523
560
 
524
561
  /**
525
- * Process the reencryption response from Rust objects.
526
- * Consider using [process_reencryption_resp_from_js]
562
+ * Process the user_decryption response from Rust objects.
563
+ * Consider using [process_user_decryption_resp_from_js]
527
564
  * when using the JS API.
528
565
  * The result is a byte array representing a plaintext of any length.
529
566
  *
530
- * * `client` - client that wants to perform reencryption.
567
+ * * `client` - client that wants to perform user_decryption.
531
568
  *
532
- * * `request` - the initial reencryption request.
569
+ * * `request` - the initial user_decryption request.
533
570
  * Must be given if `verify` is true.
534
571
  *
535
572
  * * `eip712_domain` - the EIP-712 domain.
536
573
  * Must be given if `verify` is true.
537
574
  *
538
- * * `agg_resp` - the vector of reencryption responses.
575
+ * * `agg_resp` - the vector of user_decryption responses.
539
576
  *
540
577
  * * `enc_pk` - The ephemeral public key.
541
578
  *
@@ -544,19 +581,19 @@ export function process_reencryption_resp_from_js(client, request, eip712_domain
544
581
  * * `verify` - Whether to perform signature verification for the response.
545
582
  * It is insecure if `verify = false`!
546
583
  * @param {Client} client
547
- * @param {ParsedReencryptionRequest | null | undefined} request
584
+ * @param {ParsedUserDecryptionRequest | null | undefined} request
548
585
  * @param {Eip712DomainMsg | null | undefined} eip712_domain
549
- * @param {ReencryptionResponse[]} agg_resp
550
- * @param {PublicEncKey} enc_pk
551
- * @param {PrivateEncKey} enc_sk
586
+ * @param {UserDecryptionResponse[]} agg_resp
587
+ * @param {PublicEncKeyMlKem512} enc_pk
588
+ * @param {PrivateEncKeyMlKem512} enc_sk
552
589
  * @param {boolean} verify
553
590
  * @returns {TypedPlaintext[]}
554
591
  */
555
- export function process_reencryption_resp(client, request, eip712_domain, agg_resp, enc_pk, enc_sk, verify) {
592
+ export function process_user_decryption_resp(client, request, eip712_domain, agg_resp, enc_pk, enc_sk, verify) {
556
593
  _assertClass(client, Client);
557
594
  let ptr0 = 0;
558
595
  if (!isLikeNone(request)) {
559
- _assertClass(request, ParsedReencryptionRequest);
596
+ _assertClass(request, ParsedUserDecryptionRequest);
560
597
  ptr0 = request.__destroy_into_raw();
561
598
  }
562
599
  let ptr1 = 0;
@@ -566,9 +603,9 @@ export function process_reencryption_resp(client, request, eip712_domain, agg_re
566
603
  }
567
604
  const ptr2 = passArrayJsValueToWasm0(agg_resp, wasm.__wbindgen_malloc);
568
605
  const len2 = WASM_VECTOR_LEN;
569
- _assertClass(enc_pk, PublicEncKey);
570
- _assertClass(enc_sk, PrivateEncKey);
571
- const ret = wasm.process_reencryption_resp(client.__wbg_ptr, ptr0, ptr1, ptr2, len2, enc_pk.__wbg_ptr, enc_sk.__wbg_ptr, verify);
606
+ _assertClass(enc_pk, PublicEncKeyMlKem512);
607
+ _assertClass(enc_sk, PrivateEncKeyMlKem512);
608
+ const ret = wasm.process_user_decryption_resp(client.__wbg_ptr, ptr0, ptr1, ptr2, len2, enc_pk.__wbg_ptr, enc_sk.__wbg_ptr, verify);
572
609
  if (ret[3]) {
573
610
  throw takeFromExternrefTable0(ret[2]);
574
611
  }
@@ -629,40 +666,13 @@ export class Client {
629
666
  }
630
667
  }
631
668
 
632
- const CryptoBoxCtFinalization = (typeof FinalizationRegistry === 'undefined')
633
- ? { register: () => {}, unregister: () => {} }
634
- : new FinalizationRegistry(ptr => wasm.__wbg_cryptoboxct_free(ptr >>> 0, 1));
635
-
636
- export class CryptoBoxCt {
637
-
638
- static __wrap(ptr) {
639
- ptr = ptr >>> 0;
640
- const obj = Object.create(CryptoBoxCt.prototype);
641
- obj.__wbg_ptr = ptr;
642
- CryptoBoxCtFinalization.register(obj, obj.__wbg_ptr, obj);
643
- return obj;
644
- }
645
-
646
- __destroy_into_raw() {
647
- const ptr = this.__wbg_ptr;
648
- this.__wbg_ptr = 0;
649
- CryptoBoxCtFinalization.unregister(this);
650
- return ptr;
651
- }
652
-
653
- free() {
654
- const ptr = this.__destroy_into_raw();
655
- wasm.__wbg_cryptoboxct_free(ptr, 0);
656
- }
657
- }
658
-
659
669
  const Eip712DomainMsgFinalization = (typeof FinalizationRegistry === 'undefined')
660
670
  ? { register: () => {}, unregister: () => {} }
661
671
  : new FinalizationRegistry(ptr => wasm.__wbg_eip712domainmsg_free(ptr >>> 0, 1));
662
672
  /**
663
- * <https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator>
664
- * eventually chain_id, verifying_contract and salt will be parsed in to
665
- * solidity types
673
+ * Eip712 domain information.
674
+ * Any constraints specified in the [standard](<https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator>) _must_ be fulfilled.
675
+ * Furthermore, be aware that all parameters will eventually be parsed into Solidity types.
666
676
  */
667
677
  export class Eip712DomainMsg {
668
678
 
@@ -793,51 +803,51 @@ export class Eip712DomainMsg {
793
803
  }
794
804
  }
795
805
 
796
- const ParsedReencryptionRequestFinalization = (typeof FinalizationRegistry === 'undefined')
806
+ const ParsedUserDecryptionRequestFinalization = (typeof FinalizationRegistry === 'undefined')
797
807
  ? { register: () => {}, unregister: () => {} }
798
- : new FinalizationRegistry(ptr => wasm.__wbg_parsedreencryptionrequest_free(ptr >>> 0, 1));
808
+ : new FinalizationRegistry(ptr => wasm.__wbg_parseduserdecryptionrequest_free(ptr >>> 0, 1));
799
809
  /**
800
810
  * Validity of this struct is not checked.
801
811
  */
802
- export class ParsedReencryptionRequest {
812
+ export class ParsedUserDecryptionRequest {
803
813
 
804
814
  __destroy_into_raw() {
805
815
  const ptr = this.__wbg_ptr;
806
816
  this.__wbg_ptr = 0;
807
- ParsedReencryptionRequestFinalization.unregister(this);
817
+ ParsedUserDecryptionRequestFinalization.unregister(this);
808
818
  return ptr;
809
819
  }
810
820
 
811
821
  free() {
812
822
  const ptr = this.__destroy_into_raw();
813
- wasm.__wbg_parsedreencryptionrequest_free(ptr, 0);
823
+ wasm.__wbg_parseduserdecryptionrequest_free(ptr, 0);
814
824
  }
815
825
  }
816
826
 
817
- const PrivateEncKeyFinalization = (typeof FinalizationRegistry === 'undefined')
827
+ const PrivateEncKeyMlKem512Finalization = (typeof FinalizationRegistry === 'undefined')
818
828
  ? { register: () => {}, unregister: () => {} }
819
- : new FinalizationRegistry(ptr => wasm.__wbg_privateenckey_free(ptr >>> 0, 1));
829
+ : new FinalizationRegistry(ptr => wasm.__wbg_privateenckeymlkem512_free(ptr >>> 0, 1));
820
830
 
821
- export class PrivateEncKey {
831
+ export class PrivateEncKeyMlKem512 {
822
832
 
823
833
  static __wrap(ptr) {
824
834
  ptr = ptr >>> 0;
825
- const obj = Object.create(PrivateEncKey.prototype);
835
+ const obj = Object.create(PrivateEncKeyMlKem512.prototype);
826
836
  obj.__wbg_ptr = ptr;
827
- PrivateEncKeyFinalization.register(obj, obj.__wbg_ptr, obj);
837
+ PrivateEncKeyMlKem512Finalization.register(obj, obj.__wbg_ptr, obj);
828
838
  return obj;
829
839
  }
830
840
 
831
841
  __destroy_into_raw() {
832
842
  const ptr = this.__wbg_ptr;
833
843
  this.__wbg_ptr = 0;
834
- PrivateEncKeyFinalization.unregister(this);
844
+ PrivateEncKeyMlKem512Finalization.unregister(this);
835
845
  return ptr;
836
846
  }
837
847
 
838
848
  free() {
839
849
  const ptr = this.__destroy_into_raw();
840
- wasm.__wbg_privateenckey_free(ptr, 0);
850
+ wasm.__wbg_privateenckeymlkem512_free(ptr, 0);
841
851
  }
842
852
  }
843
853
 
@@ -868,30 +878,30 @@ export class PrivateSigKey {
868
878
  }
869
879
  }
870
880
 
871
- const PublicEncKeyFinalization = (typeof FinalizationRegistry === 'undefined')
881
+ const PublicEncKeyMlKem512Finalization = (typeof FinalizationRegistry === 'undefined')
872
882
  ? { register: () => {}, unregister: () => {} }
873
- : new FinalizationRegistry(ptr => wasm.__wbg_publicenckey_free(ptr >>> 0, 1));
883
+ : new FinalizationRegistry(ptr => wasm.__wbg_publicenckeymlkem512_free(ptr >>> 0, 1));
874
884
 
875
- export class PublicEncKey {
885
+ export class PublicEncKeyMlKem512 {
876
886
 
877
887
  static __wrap(ptr) {
878
888
  ptr = ptr >>> 0;
879
- const obj = Object.create(PublicEncKey.prototype);
889
+ const obj = Object.create(PublicEncKeyMlKem512.prototype);
880
890
  obj.__wbg_ptr = ptr;
881
- PublicEncKeyFinalization.register(obj, obj.__wbg_ptr, obj);
891
+ PublicEncKeyMlKem512Finalization.register(obj, obj.__wbg_ptr, obj);
882
892
  return obj;
883
893
  }
884
894
 
885
895
  __destroy_into_raw() {
886
896
  const ptr = this.__wbg_ptr;
887
897
  this.__wbg_ptr = 0;
888
- PublicEncKeyFinalization.unregister(this);
898
+ PublicEncKeyMlKem512Finalization.unregister(this);
889
899
  return ptr;
890
900
  }
891
901
 
892
902
  free() {
893
903
  const ptr = this.__destroy_into_raw();
894
- wasm.__wbg_publicenckey_free(ptr, 0);
904
+ wasm.__wbg_publicenckeymlkem512_free(ptr, 0);
895
905
  }
896
906
  }
897
907
 
@@ -922,96 +932,43 @@ export class PublicSigKey {
922
932
  }
923
933
  }
924
934
 
925
- const ReencryptionRequestFinalization = (typeof FinalizationRegistry === 'undefined')
935
+ const RequestIdFinalization = (typeof FinalizationRegistry === 'undefined')
926
936
  ? { register: () => {}, unregister: () => {} }
927
- : new FinalizationRegistry(ptr => wasm.__wbg_reencryptionrequest_free(ptr >>> 0, 1));
937
+ : new FinalizationRegistry(ptr => wasm.__wbg_requestid_free(ptr >>> 0, 1));
938
+ /**
939
+ * / A unique 32 Byte / 256 Bit ID, to be used to identify a request and
940
+ * / for retrieving the computed result later on.
941
+ * / Must be encoded in lower-case hex. The string must NOT contain a `0x` prefix.
942
+ */
943
+ export class RequestId {
928
944
 
929
- export class ReencryptionRequest {
945
+ static __wrap(ptr) {
946
+ ptr = ptr >>> 0;
947
+ const obj = Object.create(RequestId.prototype);
948
+ obj.__wbg_ptr = ptr;
949
+ RequestIdFinalization.register(obj, obj.__wbg_ptr, obj);
950
+ return obj;
951
+ }
930
952
 
931
953
  __destroy_into_raw() {
932
954
  const ptr = this.__wbg_ptr;
933
955
  this.__wbg_ptr = 0;
934
- ReencryptionRequestFinalization.unregister(this);
956
+ RequestIdFinalization.unregister(this);
935
957
  return ptr;
936
958
  }
937
959
 
938
960
  free() {
939
961
  const ptr = this.__destroy_into_raw();
940
- wasm.__wbg_reencryptionrequest_free(ptr, 0);
941
- }
942
- /**
943
- * The 32 Byte / 256 Bit ID of the user decryption request, without `0x`
944
- * prefix. Future queries for the result must use this request ID.
945
- * @returns {RequestId | undefined}
946
- */
947
- get request_id() {
948
- const ret = wasm.__wbg_get_reencryptionrequest_request_id(this.__wbg_ptr);
949
- return ret === 0 ? undefined : RequestId.__wrap(ret);
950
- }
951
- /**
952
- * The 32 Byte / 256 Bit ID of the user decryption request, without `0x`
953
- * prefix. Future queries for the result must use this request ID.
954
- * @param {RequestId | null} [arg0]
955
- */
956
- set request_id(arg0) {
957
- let ptr0 = 0;
958
- if (!isLikeNone(arg0)) {
959
- _assertClass(arg0, RequestId);
960
- ptr0 = arg0.__destroy_into_raw();
961
- }
962
- wasm.__wbg_set_reencryptionrequest_request_id(this.__wbg_ptr, ptr0);
963
- }
964
- /**
965
- * The list of ciphertexts to reencrypt.
966
- * @returns {TypedCiphertext[]}
967
- */
968
- get typed_ciphertexts() {
969
- const ret = wasm.__wbg_get_reencryptionrequest_typed_ciphertexts(this.__wbg_ptr);
970
- var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
971
- wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
972
- return v1;
973
- }
974
- /**
975
- * The list of ciphertexts to reencrypt.
976
- * @param {TypedCiphertext[]} arg0
977
- */
978
- set typed_ciphertexts(arg0) {
979
- const ptr0 = passArrayJsValueToWasm0(arg0, wasm.__wbindgen_malloc);
980
- const len0 = WASM_VECTOR_LEN;
981
- wasm.__wbg_set_reencryptionrequest_typed_ciphertexts(this.__wbg_ptr, ptr0, len0);
982
- }
983
- /**
984
- * The 32 Byte / 256 Bit key id to use for decryption. This is the request_id
985
- * used for key generation
986
- * @returns {RequestId | undefined}
987
- */
988
- get key_id() {
989
- const ret = wasm.__wbg_get_reencryptionrequest_key_id(this.__wbg_ptr);
990
- return ret === 0 ? undefined : RequestId.__wrap(ret);
991
- }
992
- /**
993
- * The 32 Byte / 256 Bit key id to use for decryption. This is the request_id
994
- * used for key generation
995
- * @param {RequestId | null} [arg0]
996
- */
997
- set key_id(arg0) {
998
- let ptr0 = 0;
999
- if (!isLikeNone(arg0)) {
1000
- _assertClass(arg0, RequestId);
1001
- ptr0 = arg0.__destroy_into_raw();
1002
- }
1003
- wasm.__wbg_set_reencryptionrequest_key_id(this.__wbg_ptr, ptr0);
962
+ wasm.__wbg_requestid_free(ptr, 0);
1004
963
  }
1005
964
  /**
1006
- * The client's (blockchain wallet) address,
1007
- * encoded using EIP-55.
1008
965
  * @returns {string}
1009
966
  */
1010
- get client_address() {
967
+ get request_id() {
1011
968
  let deferred1_0;
1012
969
  let deferred1_1;
1013
970
  try {
1014
- const ret = wasm.__wbg_get_reencryptionrequest_client_address(this.__wbg_ptr);
971
+ const ret = wasm.__wbg_get_requestid_request_id(this.__wbg_ptr);
1015
972
  deferred1_0 = ret[0];
1016
973
  deferred1_1 = ret[1];
1017
974
  return getStringFromWasm0(ret[0], ret[1]);
@@ -1020,66 +977,65 @@ export class ReencryptionRequest {
1020
977
  }
1021
978
  }
1022
979
  /**
1023
- * The client's (blockchain wallet) address,
1024
- * encoded using EIP-55.
1025
980
  * @param {string} arg0
1026
981
  */
1027
- set client_address(arg0) {
982
+ set request_id(arg0) {
1028
983
  const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1029
984
  const len0 = WASM_VECTOR_LEN;
1030
- wasm.__wbg_set_eip712domainmsg_version(this.__wbg_ptr, ptr0, len0);
985
+ wasm.__wbg_set_eip712domainmsg_name(this.__wbg_ptr, ptr0, len0);
1031
986
  }
1032
- /**
1033
- * Encoding of the user's public encryption key for this request.
1034
- * Encoding using the default encoding of libsodium, i.e. the 32 bytes of a
1035
- * Montgomery point.
1036
- * @returns {Uint8Array}
1037
- */
1038
- get enc_key() {
1039
- const ret = wasm.__wbg_get_reencryptionrequest_enc_key(this.__wbg_ptr);
1040
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1041
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1042
- return v1;
987
+ }
988
+
989
+ const ServerIdAddrFinalization = (typeof FinalizationRegistry === 'undefined')
990
+ ? { register: () => {}, unregister: () => {} }
991
+ : new FinalizationRegistry(ptr => wasm.__wbg_serveridaddr_free(ptr >>> 0, 1));
992
+
993
+ export class ServerIdAddr {
994
+
995
+ static __wrap(ptr) {
996
+ ptr = ptr >>> 0;
997
+ const obj = Object.create(ServerIdAddr.prototype);
998
+ obj.__wbg_ptr = ptr;
999
+ ServerIdAddrFinalization.register(obj, obj.__wbg_ptr, obj);
1000
+ return obj;
1043
1001
  }
1044
- /**
1045
- * Encoding of the user's public encryption key for this request.
1046
- * Encoding using the default encoding of libsodium, i.e. the 32 bytes of a
1047
- * Montgomery point.
1048
- * @param {Uint8Array} arg0
1049
- */
1050
- set enc_key(arg0) {
1051
- const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
1052
- const len0 = WASM_VECTOR_LEN;
1053
- wasm.__wbg_set_eip712domainmsg_chain_id(this.__wbg_ptr, ptr0, len0);
1002
+
1003
+ static __unwrap(jsValue) {
1004
+ if (!(jsValue instanceof ServerIdAddr)) {
1005
+ return 0;
1006
+ }
1007
+ return jsValue.__destroy_into_raw();
1054
1008
  }
1055
- /**
1056
- * @returns {Eip712DomainMsg | undefined}
1057
- */
1058
- get domain() {
1059
- const ret = wasm.__wbg_get_reencryptionrequest_domain(this.__wbg_ptr);
1060
- return ret === 0 ? undefined : Eip712DomainMsg.__wrap(ret);
1009
+
1010
+ __destroy_into_raw() {
1011
+ const ptr = this.__wbg_ptr;
1012
+ this.__wbg_ptr = 0;
1013
+ ServerIdAddrFinalization.unregister(this);
1014
+ return ptr;
1061
1015
  }
1062
- /**
1063
- * @param {Eip712DomainMsg | null} [arg0]
1064
- */
1065
- set domain(arg0) {
1066
- let ptr0 = 0;
1067
- if (!isLikeNone(arg0)) {
1068
- _assertClass(arg0, Eip712DomainMsg);
1069
- ptr0 = arg0.__destroy_into_raw();
1070
- }
1071
- wasm.__wbg_set_reencryptionrequest_domain(this.__wbg_ptr, ptr0);
1016
+
1017
+ free() {
1018
+ const ptr = this.__destroy_into_raw();
1019
+ wasm.__wbg_serveridaddr_free(ptr, 0);
1072
1020
  }
1073
1021
  }
1074
1022
 
1075
- const ReencryptionResponseFinalization = (typeof FinalizationRegistry === 'undefined')
1023
+ const TypedCiphertextFinalization = (typeof FinalizationRegistry === 'undefined')
1076
1024
  ? { register: () => {}, unregister: () => {} }
1077
- : new FinalizationRegistry(ptr => wasm.__wbg_reencryptionresponse_free(ptr >>> 0, 1));
1025
+ : new FinalizationRegistry(ptr => wasm.__wbg_typedciphertext_free(ptr >>> 0, 1));
1026
+
1027
+ export class TypedCiphertext {
1078
1028
 
1079
- export class ReencryptionResponse {
1029
+ static __wrap(ptr) {
1030
+ ptr = ptr >>> 0;
1031
+ const obj = Object.create(TypedCiphertext.prototype);
1032
+ obj.__wbg_ptr = ptr;
1033
+ TypedCiphertextFinalization.register(obj, obj.__wbg_ptr, obj);
1034
+ return obj;
1035
+ }
1080
1036
 
1081
1037
  static __unwrap(jsValue) {
1082
- if (!(jsValue instanceof ReencryptionResponse)) {
1038
+ if (!(jsValue instanceof TypedCiphertext)) {
1083
1039
  return 0;
1084
1040
  }
1085
1041
  return jsValue.__destroy_into_raw();
@@ -1088,248 +1044,348 @@ export class ReencryptionResponse {
1088
1044
  __destroy_into_raw() {
1089
1045
  const ptr = this.__wbg_ptr;
1090
1046
  this.__wbg_ptr = 0;
1091
- ReencryptionResponseFinalization.unregister(this);
1047
+ TypedCiphertextFinalization.unregister(this);
1092
1048
  return ptr;
1093
1049
  }
1094
1050
 
1095
1051
  free() {
1096
1052
  const ptr = this.__destroy_into_raw();
1097
- wasm.__wbg_reencryptionresponse_free(ptr, 0);
1053
+ wasm.__wbg_typedciphertext_free(ptr, 0);
1098
1054
  }
1099
1055
  /**
1056
+ * The actual ciphertext to decrypt, taken directly from fhevm.
1100
1057
  * @returns {Uint8Array}
1101
1058
  */
1102
- get signature() {
1103
- const ret = wasm.__wbg_get_reencryptionresponse_signature(this.__wbg_ptr);
1059
+ get ciphertext() {
1060
+ const ret = wasm.__wbg_get_typedciphertext_ciphertext(this.__wbg_ptr);
1104
1061
  var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1105
1062
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1106
1063
  return v1;
1107
1064
  }
1108
1065
  /**
1066
+ * The actual ciphertext to decrypt, taken directly from fhevm.
1109
1067
  * @param {Uint8Array} arg0
1110
1068
  */
1111
- set signature(arg0) {
1069
+ set ciphertext(arg0) {
1112
1070
  const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
1113
1071
  const len0 = WASM_VECTOR_LEN;
1114
1072
  wasm.__wbg_set_eip712domainmsg_name(this.__wbg_ptr, ptr0, len0);
1115
1073
  }
1116
1074
  /**
1117
- * This is the external signature created from the Eip712 domain
1118
- * on the structure, where reencryptedShare is bincode::serialize(&payload)
1119
- * struct UserDecryptResponseVerification {
1120
- * bytes publicKey;
1121
- * uint256\[\] ctHandles;
1122
- * bytes reencryptedShare;
1123
- * }
1075
+ * The type of plaintext encrypted. The type should match FheType from tfhe-rs:
1076
+ * <https://github.com/zama-ai/tfhe-rs/blob/main/tfhe/src/high_level_api/mod.rs>
1077
+ * @returns {number}
1078
+ */
1079
+ get fhe_type() {
1080
+ const ret = wasm.__wbg_get_typedciphertext_fhe_type(this.__wbg_ptr);
1081
+ return ret;
1082
+ }
1083
+ /**
1084
+ * The type of plaintext encrypted. The type should match FheType from tfhe-rs:
1085
+ * <https://github.com/zama-ai/tfhe-rs/blob/main/tfhe/src/high_level_api/mod.rs>
1086
+ * @param {number} arg0
1087
+ */
1088
+ set fhe_type(arg0) {
1089
+ wasm.__wbg_set_typedciphertext_fhe_type(this.__wbg_ptr, arg0);
1090
+ }
1091
+ /**
1092
+ * The external handle of the ciphertext (the handle used in the copro).
1124
1093
  * @returns {Uint8Array}
1125
1094
  */
1126
- get external_signature() {
1127
- const ret = wasm.__wbg_get_reencryptionresponse_external_signature(this.__wbg_ptr);
1095
+ get external_handle() {
1096
+ const ret = wasm.__wbg_get_typedciphertext_external_handle(this.__wbg_ptr);
1128
1097
  var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1129
1098
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1130
1099
  return v1;
1131
1100
  }
1132
1101
  /**
1133
- * This is the external signature created from the Eip712 domain
1134
- * on the structure, where reencryptedShare is bincode::serialize(&payload)
1135
- * struct UserDecryptResponseVerification {
1136
- * bytes publicKey;
1137
- * uint256\[\] ctHandles;
1138
- * bytes reencryptedShare;
1139
- * }
1102
+ * The external handle of the ciphertext (the handle used in the copro).
1140
1103
  * @param {Uint8Array} arg0
1141
1104
  */
1142
- set external_signature(arg0) {
1105
+ set external_handle(arg0) {
1143
1106
  const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
1144
1107
  const len0 = WASM_VECTOR_LEN;
1145
1108
  wasm.__wbg_set_eip712domainmsg_version(this.__wbg_ptr, ptr0, len0);
1146
1109
  }
1147
1110
  /**
1148
- * The actual \[ReencryptionResponsePayload\].
1149
- * @returns {ReencryptionResponsePayload | undefined}
1111
+ * The ciphertext format, see CiphertextFormat documentation for details.
1112
+ * CiphertextFormat::default() is used if unspecified.
1113
+ * @returns {number}
1150
1114
  */
1151
- get payload() {
1152
- const ret = wasm.__wbg_get_reencryptionresponse_payload(this.__wbg_ptr);
1153
- return ret === 0 ? undefined : ReencryptionResponsePayload.__wrap(ret);
1115
+ get ciphertext_format() {
1116
+ const ret = wasm.__wbg_get_typedciphertext_ciphertext_format(this.__wbg_ptr);
1117
+ return ret;
1154
1118
  }
1155
1119
  /**
1156
- * The actual \[ReencryptionResponsePayload\].
1157
- * @param {ReencryptionResponsePayload | null} [arg0]
1120
+ * The ciphertext format, see CiphertextFormat documentation for details.
1121
+ * CiphertextFormat::default() is used if unspecified.
1122
+ * @param {number} arg0
1158
1123
  */
1159
- set payload(arg0) {
1160
- let ptr0 = 0;
1161
- if (!isLikeNone(arg0)) {
1162
- _assertClass(arg0, ReencryptionResponsePayload);
1163
- ptr0 = arg0.__destroy_into_raw();
1164
- }
1165
- wasm.__wbg_set_reencryptionresponse_payload(this.__wbg_ptr, ptr0);
1124
+ set ciphertext_format(arg0) {
1125
+ wasm.__wbg_set_typedciphertext_ciphertext_format(this.__wbg_ptr, arg0);
1166
1126
  }
1167
1127
  }
1168
1128
 
1169
- const ReencryptionResponsePayloadFinalization = (typeof FinalizationRegistry === 'undefined')
1129
+ const TypedPlaintextFinalization = (typeof FinalizationRegistry === 'undefined')
1170
1130
  ? { register: () => {}, unregister: () => {} }
1171
- : new FinalizationRegistry(ptr => wasm.__wbg_reencryptionresponsepayload_free(ptr >>> 0, 1));
1131
+ : new FinalizationRegistry(ptr => wasm.__wbg_typedplaintext_free(ptr >>> 0, 1));
1172
1132
 
1173
- export class ReencryptionResponsePayload {
1133
+ export class TypedPlaintext {
1174
1134
 
1175
1135
  static __wrap(ptr) {
1176
1136
  ptr = ptr >>> 0;
1177
- const obj = Object.create(ReencryptionResponsePayload.prototype);
1137
+ const obj = Object.create(TypedPlaintext.prototype);
1178
1138
  obj.__wbg_ptr = ptr;
1179
- ReencryptionResponsePayloadFinalization.register(obj, obj.__wbg_ptr, obj);
1139
+ TypedPlaintextFinalization.register(obj, obj.__wbg_ptr, obj);
1180
1140
  return obj;
1181
1141
  }
1182
1142
 
1183
1143
  __destroy_into_raw() {
1184
1144
  const ptr = this.__wbg_ptr;
1185
1145
  this.__wbg_ptr = 0;
1186
- ReencryptionResponsePayloadFinalization.unregister(this);
1146
+ TypedPlaintextFinalization.unregister(this);
1187
1147
  return ptr;
1188
1148
  }
1189
1149
 
1190
1150
  free() {
1191
1151
  const ptr = this.__destroy_into_raw();
1192
- wasm.__wbg_reencryptionresponsepayload_free(ptr, 0);
1152
+ wasm.__wbg_typedplaintext_free(ptr, 0);
1193
1153
  }
1194
1154
  /**
1195
- * The server's signature verification key, Encoded using SEC1.
1196
- * Needed to validate the response, but MUST also be linked to a list of
1197
- * trusted keys.
1155
+ * The actual plaintext in bytes.
1198
1156
  * @returns {Uint8Array}
1199
1157
  */
1200
- get verification_key() {
1201
- const ret = wasm.__wbg_get_reencryptionresponsepayload_verification_key(this.__wbg_ptr);
1158
+ get bytes() {
1159
+ const ret = wasm.__wbg_get_typedplaintext_bytes(this.__wbg_ptr);
1202
1160
  var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1203
1161
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1204
1162
  return v1;
1205
1163
  }
1206
1164
  /**
1207
- * The server's signature verification key, Encoded using SEC1.
1208
- * Needed to validate the response, but MUST also be linked to a list of
1209
- * trusted keys.
1165
+ * The actual plaintext in bytes.
1210
1166
  * @param {Uint8Array} arg0
1211
1167
  */
1212
- set verification_key(arg0) {
1168
+ set bytes(arg0) {
1213
1169
  const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
1214
1170
  const len0 = WASM_VECTOR_LEN;
1215
1171
  wasm.__wbg_set_eip712domainmsg_name(this.__wbg_ptr, ptr0, len0);
1216
1172
  }
1217
1173
  /**
1218
- * This is needed to ensure the response corresponds to the request.
1219
- * It is the digest of UserDecryptionLinker hashed using EIP712
1220
- * under the given domain in the request.
1174
+ * The type of plaintext encrypted. The type should match FheType from tfhe-rs:
1175
+ * <https://github.com/zama-ai/tfhe-rs/blob/main/tfhe/src/high_level_api/mod.rs>
1176
+ * @returns {number}
1177
+ */
1178
+ get fhe_type() {
1179
+ const ret = wasm.__wbg_get_typedplaintext_fhe_type(this.__wbg_ptr);
1180
+ return ret;
1181
+ }
1182
+ /**
1183
+ * The type of plaintext encrypted. The type should match FheType from tfhe-rs:
1184
+ * <https://github.com/zama-ai/tfhe-rs/blob/main/tfhe/src/high_level_api/mod.rs>
1185
+ * @param {number} arg0
1186
+ */
1187
+ set fhe_type(arg0) {
1188
+ wasm.__wbg_set_typedplaintext_fhe_type(this.__wbg_ptr, arg0);
1189
+ }
1190
+ }
1191
+
1192
+ const TypedSigncryptedCiphertextFinalization = (typeof FinalizationRegistry === 'undefined')
1193
+ ? { register: () => {}, unregister: () => {} }
1194
+ : new FinalizationRegistry(ptr => wasm.__wbg_typedsigncryptedciphertext_free(ptr >>> 0, 1));
1195
+
1196
+ export class TypedSigncryptedCiphertext {
1197
+
1198
+ static __wrap(ptr) {
1199
+ ptr = ptr >>> 0;
1200
+ const obj = Object.create(TypedSigncryptedCiphertext.prototype);
1201
+ obj.__wbg_ptr = ptr;
1202
+ TypedSigncryptedCiphertextFinalization.register(obj, obj.__wbg_ptr, obj);
1203
+ return obj;
1204
+ }
1205
+
1206
+ static __unwrap(jsValue) {
1207
+ if (!(jsValue instanceof TypedSigncryptedCiphertext)) {
1208
+ return 0;
1209
+ }
1210
+ return jsValue.__destroy_into_raw();
1211
+ }
1212
+
1213
+ __destroy_into_raw() {
1214
+ const ptr = this.__wbg_ptr;
1215
+ this.__wbg_ptr = 0;
1216
+ TypedSigncryptedCiphertextFinalization.unregister(this);
1217
+ return ptr;
1218
+ }
1219
+
1220
+ free() {
1221
+ const ptr = this.__destroy_into_raw();
1222
+ wasm.__wbg_typedsigncryptedciphertext_free(ptr, 0);
1223
+ }
1224
+ /**
1225
+ * The type of plaintext encrypted. The type should match FheType from tfhe-rs:
1226
+ * <https://github.com/zama-ai/tfhe-rs/blob/main/tfhe/src/high_level_api/mod.rs>
1227
+ * @returns {number}
1228
+ */
1229
+ get fhe_type() {
1230
+ const ret = wasm.__wbg_get_typedciphertext_fhe_type(this.__wbg_ptr);
1231
+ return ret;
1232
+ }
1233
+ /**
1234
+ * The type of plaintext encrypted. The type should match FheType from tfhe-rs:
1235
+ * <https://github.com/zama-ai/tfhe-rs/blob/main/tfhe/src/high_level_api/mod.rs>
1236
+ * @param {number} arg0
1237
+ */
1238
+ set fhe_type(arg0) {
1239
+ wasm.__wbg_set_typedciphertext_fhe_type(this.__wbg_ptr, arg0);
1240
+ }
1241
+ /**
1242
+ * The signcrypted payload, using a hybrid encryption approach in
1243
+ * sign-then-encrypt.
1221
1244
  * @returns {Uint8Array}
1222
1245
  */
1223
- get digest() {
1224
- const ret = wasm.__wbg_get_reencryptionresponsepayload_digest(this.__wbg_ptr);
1246
+ get signcrypted_ciphertext() {
1247
+ const ret = wasm.__wbg_get_typedsigncryptedciphertext_signcrypted_ciphertext(this.__wbg_ptr);
1225
1248
  var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1226
1249
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1227
1250
  return v1;
1228
1251
  }
1229
1252
  /**
1230
- * This is needed to ensure the response corresponds to the request.
1231
- * It is the digest of UserDecryptionLinker hashed using EIP712
1232
- * under the given domain in the request.
1253
+ * The signcrypted payload, using a hybrid encryption approach in
1254
+ * sign-then-encrypt.
1233
1255
  * @param {Uint8Array} arg0
1234
1256
  */
1235
- set digest(arg0) {
1257
+ set signcrypted_ciphertext(arg0) {
1236
1258
  const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
1237
1259
  const len0 = WASM_VECTOR_LEN;
1238
- wasm.__wbg_set_eip712domainmsg_version(this.__wbg_ptr, ptr0, len0);
1260
+ wasm.__wbg_set_eip712domainmsg_name(this.__wbg_ptr, ptr0, len0);
1239
1261
  }
1240
1262
  /**
1241
- * The resulting signcrypted ciphertexts, each ciphertext
1242
- * must be decrypted and then reconstructed with the other shares
1243
- * to produce the final plaintext.
1244
- * @returns {TypedSigncryptedCiphertext[]}
1263
+ * The external handles that were originally in the request.
1264
+ * @returns {Uint8Array}
1245
1265
  */
1246
- get signcrypted_ciphertexts() {
1247
- const ret = wasm.__wbg_get_reencryptionresponsepayload_signcrypted_ciphertexts(this.__wbg_ptr);
1248
- var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
1249
- wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
1266
+ get external_handle() {
1267
+ const ret = wasm.__wbg_get_typedsigncryptedciphertext_external_handle(this.__wbg_ptr);
1268
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1269
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1250
1270
  return v1;
1251
1271
  }
1252
1272
  /**
1253
- * The resulting signcrypted ciphertexts, each ciphertext
1254
- * must be decrypted and then reconstructed with the other shares
1255
- * to produce the final plaintext.
1256
- * @param {TypedSigncryptedCiphertext[]} arg0
1273
+ * The external handles that were originally in the request.
1274
+ * @param {Uint8Array} arg0
1257
1275
  */
1258
- set signcrypted_ciphertexts(arg0) {
1259
- const ptr0 = passArrayJsValueToWasm0(arg0, wasm.__wbindgen_malloc);
1276
+ set external_handle(arg0) {
1277
+ const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
1260
1278
  const len0 = WASM_VECTOR_LEN;
1261
- wasm.__wbg_set_reencryptionresponsepayload_signcrypted_ciphertexts(this.__wbg_ptr, ptr0, len0);
1262
- }
1263
- /**
1264
- * The ID of the MPC party doing the reencryption. Used for polynomial
1265
- * reconstruction.
1266
- * @returns {number}
1267
- */
1268
- get party_id() {
1269
- const ret = wasm.__wbg_get_reencryptionresponsepayload_party_id(this.__wbg_ptr);
1270
- return ret >>> 0;
1271
- }
1272
- /**
1273
- * The ID of the MPC party doing the reencryption. Used for polynomial
1274
- * reconstruction.
1275
- * @param {number} arg0
1276
- */
1277
- set party_id(arg0) {
1278
- wasm.__wbg_set_reencryptionresponsepayload_party_id(this.__wbg_ptr, arg0);
1279
+ wasm.__wbg_set_eip712domainmsg_version(this.__wbg_ptr, ptr0, len0);
1279
1280
  }
1280
1281
  /**
1281
- * The degree of the sharing scheme used.
1282
+ * The packing factor determines whether the decrypted plaintext
1283
+ * has a different way of packing compared to what is specified in the plaintext modulus.
1282
1284
  * @returns {number}
1283
1285
  */
1284
- get degree() {
1285
- const ret = wasm.__wbg_get_reencryptionresponsepayload_degree(this.__wbg_ptr);
1286
+ get packing_factor() {
1287
+ const ret = wasm.__wbg_get_typedciphertext_ciphertext_format(this.__wbg_ptr);
1286
1288
  return ret >>> 0;
1287
1289
  }
1288
1290
  /**
1289
- * The degree of the sharing scheme used.
1291
+ * The packing factor determines whether the decrypted plaintext
1292
+ * has a different way of packing compared to what is specified in the plaintext modulus.
1290
1293
  * @param {number} arg0
1291
1294
  */
1292
- set degree(arg0) {
1293
- wasm.__wbg_set_reencryptionresponsepayload_degree(this.__wbg_ptr, arg0);
1295
+ set packing_factor(arg0) {
1296
+ wasm.__wbg_set_typedciphertext_ciphertext_format(this.__wbg_ptr, arg0);
1294
1297
  }
1295
1298
  }
1296
1299
 
1297
- const RequestIdFinalization = (typeof FinalizationRegistry === 'undefined')
1300
+ const UserDecryptionRequestFinalization = (typeof FinalizationRegistry === 'undefined')
1298
1301
  ? { register: () => {}, unregister: () => {} }
1299
- : new FinalizationRegistry(ptr => wasm.__wbg_requestid_free(ptr >>> 0, 1));
1300
- /**
1301
- * Simple response to return a 32 Byte / 256 Bit ID, to be used to retrieve the
1302
- * computed result later on. This string does NOT contain a `0x` prefix.
1303
- */
1304
- export class RequestId {
1302
+ : new FinalizationRegistry(ptr => wasm.__wbg_userdecryptionrequest_free(ptr >>> 0, 1));
1305
1303
 
1306
- static __wrap(ptr) {
1307
- ptr = ptr >>> 0;
1308
- const obj = Object.create(RequestId.prototype);
1309
- obj.__wbg_ptr = ptr;
1310
- RequestIdFinalization.register(obj, obj.__wbg_ptr, obj);
1311
- return obj;
1312
- }
1304
+ export class UserDecryptionRequest {
1313
1305
 
1314
1306
  __destroy_into_raw() {
1315
1307
  const ptr = this.__wbg_ptr;
1316
1308
  this.__wbg_ptr = 0;
1317
- RequestIdFinalization.unregister(this);
1309
+ UserDecryptionRequestFinalization.unregister(this);
1318
1310
  return ptr;
1319
1311
  }
1320
1312
 
1321
1313
  free() {
1322
1314
  const ptr = this.__destroy_into_raw();
1323
- wasm.__wbg_requestid_free(ptr, 0);
1315
+ wasm.__wbg_userdecryptionrequest_free(ptr, 0);
1324
1316
  }
1325
1317
  /**
1326
- * @returns {string}
1318
+ * The 32 Byte / 256 Bit ID of the user decryption request, without `0x`
1319
+ * prefix. Future queries for the result must use this request ID.
1320
+ * @returns {RequestId | undefined}
1327
1321
  */
1328
1322
  get request_id() {
1323
+ const ret = wasm.__wbg_get_userdecryptionrequest_request_id(this.__wbg_ptr);
1324
+ return ret === 0 ? undefined : RequestId.__wrap(ret);
1325
+ }
1326
+ /**
1327
+ * The 32 Byte / 256 Bit ID of the user decryption request, without `0x`
1328
+ * prefix. Future queries for the result must use this request ID.
1329
+ * @param {RequestId | null} [arg0]
1330
+ */
1331
+ set request_id(arg0) {
1332
+ let ptr0 = 0;
1333
+ if (!isLikeNone(arg0)) {
1334
+ _assertClass(arg0, RequestId);
1335
+ ptr0 = arg0.__destroy_into_raw();
1336
+ }
1337
+ wasm.__wbg_set_userdecryptionrequest_request_id(this.__wbg_ptr, ptr0);
1338
+ }
1339
+ /**
1340
+ * The list of ciphertexts to decrypt for the user.
1341
+ * @returns {TypedCiphertext[]}
1342
+ */
1343
+ get typed_ciphertexts() {
1344
+ const ret = wasm.__wbg_get_userdecryptionrequest_typed_ciphertexts(this.__wbg_ptr);
1345
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
1346
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
1347
+ return v1;
1348
+ }
1349
+ /**
1350
+ * The list of ciphertexts to decrypt for the user.
1351
+ * @param {TypedCiphertext[]} arg0
1352
+ */
1353
+ set typed_ciphertexts(arg0) {
1354
+ const ptr0 = passArrayJsValueToWasm0(arg0, wasm.__wbindgen_malloc);
1355
+ const len0 = WASM_VECTOR_LEN;
1356
+ wasm.__wbg_set_userdecryptionrequest_typed_ciphertexts(this.__wbg_ptr, ptr0, len0);
1357
+ }
1358
+ /**
1359
+ * The 32 Byte / 256 Bit key id to use for decryption. This is the request_id
1360
+ * used for key generation
1361
+ * @returns {RequestId | undefined}
1362
+ */
1363
+ get key_id() {
1364
+ const ret = wasm.__wbg_get_userdecryptionrequest_key_id(this.__wbg_ptr);
1365
+ return ret === 0 ? undefined : RequestId.__wrap(ret);
1366
+ }
1367
+ /**
1368
+ * The 32 Byte / 256 Bit key id to use for decryption. This is the request_id
1369
+ * used for key generation
1370
+ * @param {RequestId | null} [arg0]
1371
+ */
1372
+ set key_id(arg0) {
1373
+ let ptr0 = 0;
1374
+ if (!isLikeNone(arg0)) {
1375
+ _assertClass(arg0, RequestId);
1376
+ ptr0 = arg0.__destroy_into_raw();
1377
+ }
1378
+ wasm.__wbg_set_userdecryptionrequest_key_id(this.__wbg_ptr, ptr0);
1379
+ }
1380
+ /**
1381
+ * The client's (blockchain wallet) address, encoded using EIP-55. I.e. including `0x`.
1382
+ * @returns {string}
1383
+ */
1384
+ get client_address() {
1329
1385
  let deferred1_0;
1330
1386
  let deferred1_1;
1331
1387
  try {
1332
- const ret = wasm.__wbg_get_requestid_request_id(this.__wbg_ptr);
1388
+ const ret = wasm.__wbg_get_userdecryptionrequest_client_address(this.__wbg_ptr);
1333
1389
  deferred1_0 = ret[0];
1334
1390
  deferred1_1 = ret[1];
1335
1391
  return getStringFromWasm0(ret[0], ret[1]);
@@ -1338,291 +1394,316 @@ export class RequestId {
1338
1394
  }
1339
1395
  }
1340
1396
  /**
1397
+ * The client's (blockchain wallet) address, encoded using EIP-55. I.e. including `0x`.
1341
1398
  * @param {string} arg0
1342
1399
  */
1343
- set request_id(arg0) {
1400
+ set client_address(arg0) {
1344
1401
  const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1345
1402
  const len0 = WASM_VECTOR_LEN;
1346
- wasm.__wbg_set_eip712domainmsg_name(this.__wbg_ptr, ptr0, len0);
1347
- }
1348
- }
1349
-
1350
- const TypedCiphertextFinalization = (typeof FinalizationRegistry === 'undefined')
1351
- ? { register: () => {}, unregister: () => {} }
1352
- : new FinalizationRegistry(ptr => wasm.__wbg_typedciphertext_free(ptr >>> 0, 1));
1353
-
1354
- export class TypedCiphertext {
1355
-
1356
- static __wrap(ptr) {
1357
- ptr = ptr >>> 0;
1358
- const obj = Object.create(TypedCiphertext.prototype);
1359
- obj.__wbg_ptr = ptr;
1360
- TypedCiphertextFinalization.register(obj, obj.__wbg_ptr, obj);
1361
- return obj;
1362
- }
1363
-
1364
- static __unwrap(jsValue) {
1365
- if (!(jsValue instanceof TypedCiphertext)) {
1366
- return 0;
1367
- }
1368
- return jsValue.__destroy_into_raw();
1369
- }
1370
-
1371
- __destroy_into_raw() {
1372
- const ptr = this.__wbg_ptr;
1373
- this.__wbg_ptr = 0;
1374
- TypedCiphertextFinalization.unregister(this);
1375
- return ptr;
1376
- }
1377
-
1378
- free() {
1379
- const ptr = this.__destroy_into_raw();
1380
- wasm.__wbg_typedciphertext_free(ptr, 0);
1403
+ wasm.__wbg_set_eip712domainmsg_version(this.__wbg_ptr, ptr0, len0);
1381
1404
  }
1382
1405
  /**
1383
- * The actual ciphertext to decrypt, taken directly from fhevm.
1406
+ * Encoding of the user's public encryption key for this request.
1407
+ * This must be a bincode (v.1) encoded ML-KEM 512 key.
1384
1408
  * @returns {Uint8Array}
1385
1409
  */
1386
- get ciphertext() {
1387
- const ret = wasm.__wbg_get_typedciphertext_ciphertext(this.__wbg_ptr);
1410
+ get enc_key() {
1411
+ const ret = wasm.__wbg_get_userdecryptionrequest_enc_key(this.__wbg_ptr);
1388
1412
  var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1389
1413
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1390
1414
  return v1;
1391
1415
  }
1392
1416
  /**
1393
- * The actual ciphertext to decrypt, taken directly from fhevm.
1417
+ * Encoding of the user's public encryption key for this request.
1418
+ * This must be a bincode (v.1) encoded ML-KEM 512 key.
1394
1419
  * @param {Uint8Array} arg0
1395
1420
  */
1396
- set ciphertext(arg0) {
1421
+ set enc_key(arg0) {
1397
1422
  const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
1398
1423
  const len0 = WASM_VECTOR_LEN;
1399
- wasm.__wbg_set_eip712domainmsg_name(this.__wbg_ptr, ptr0, len0);
1424
+ wasm.__wbg_set_eip712domainmsg_chain_id(this.__wbg_ptr, ptr0, len0);
1400
1425
  }
1401
1426
  /**
1402
- * The type of plaintext encrypted. The type should match FheType from tfhe-rs:
1403
- * <https://github.com/zama-ai/tfhe-rs/blob/main/tfhe/src/high_level_api/mod.rs>
1404
- * @returns {number}
1427
+ * The user's EIP712 domain. This MUST be present. Furthermore, the `verifying_contract` MUST be set and be distinct from `client_address`.
1428
+ * @returns {Eip712DomainMsg | undefined}
1405
1429
  */
1406
- get fhe_type() {
1407
- const ret = wasm.__wbg_get_typedciphertext_fhe_type(this.__wbg_ptr);
1408
- return ret;
1430
+ get domain() {
1431
+ const ret = wasm.__wbg_get_userdecryptionrequest_domain(this.__wbg_ptr);
1432
+ return ret === 0 ? undefined : Eip712DomainMsg.__wrap(ret);
1409
1433
  }
1410
1434
  /**
1411
- * The type of plaintext encrypted. The type should match FheType from tfhe-rs:
1412
- * <https://github.com/zama-ai/tfhe-rs/blob/main/tfhe/src/high_level_api/mod.rs>
1413
- * @param {number} arg0
1435
+ * The user's EIP712 domain. This MUST be present. Furthermore, the `verifying_contract` MUST be set and be distinct from `client_address`.
1436
+ * @param {Eip712DomainMsg | null} [arg0]
1414
1437
  */
1415
- set fhe_type(arg0) {
1416
- wasm.__wbg_set_typedciphertext_fhe_type(this.__wbg_ptr, arg0);
1438
+ set domain(arg0) {
1439
+ let ptr0 = 0;
1440
+ if (!isLikeNone(arg0)) {
1441
+ _assertClass(arg0, Eip712DomainMsg);
1442
+ ptr0 = arg0.__destroy_into_raw();
1443
+ }
1444
+ wasm.__wbg_set_userdecryptionrequest_domain(this.__wbg_ptr, ptr0);
1417
1445
  }
1418
1446
  /**
1419
- * The external handle of the ciphertext (the handle used in the copro).
1447
+ * Extra data from the gateway.
1420
1448
  * @returns {Uint8Array}
1421
1449
  */
1422
- get external_handle() {
1423
- const ret = wasm.__wbg_get_typedciphertext_external_handle(this.__wbg_ptr);
1450
+ get extra_data() {
1451
+ const ret = wasm.__wbg_get_userdecryptionrequest_extra_data(this.__wbg_ptr);
1424
1452
  var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1425
1453
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1426
1454
  return v1;
1427
1455
  }
1428
1456
  /**
1429
- * The external handle of the ciphertext (the handle used in the copro).
1457
+ * Extra data from the gateway.
1430
1458
  * @param {Uint8Array} arg0
1431
1459
  */
1432
- set external_handle(arg0) {
1460
+ set extra_data(arg0) {
1433
1461
  const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
1434
1462
  const len0 = WASM_VECTOR_LEN;
1435
- wasm.__wbg_set_eip712domainmsg_version(this.__wbg_ptr, ptr0, len0);
1436
- }
1437
- /**
1438
- * The ciphertext format, see CiphertextFormat documentation for details.
1439
- * CiphertextFormat::default() is used if unspecified.
1440
- * @returns {number}
1441
- */
1442
- get ciphertext_format() {
1443
- const ret = wasm.__wbg_get_typedciphertext_ciphertext_format(this.__wbg_ptr);
1444
- return ret;
1445
- }
1446
- /**
1447
- * The ciphertext format, see CiphertextFormat documentation for details.
1448
- * CiphertextFormat::default() is used if unspecified.
1449
- * @param {number} arg0
1450
- */
1451
- set ciphertext_format(arg0) {
1452
- wasm.__wbg_set_typedciphertext_ciphertext_format(this.__wbg_ptr, arg0);
1463
+ wasm.__wbg_set_eip712domainmsg_verifying_contract(this.__wbg_ptr, ptr0, len0);
1453
1464
  }
1454
1465
  }
1455
1466
 
1456
- const TypedPlaintextFinalization = (typeof FinalizationRegistry === 'undefined')
1467
+ const UserDecryptionResponseFinalization = (typeof FinalizationRegistry === 'undefined')
1457
1468
  ? { register: () => {}, unregister: () => {} }
1458
- : new FinalizationRegistry(ptr => wasm.__wbg_typedplaintext_free(ptr >>> 0, 1));
1459
- /**
1460
- * The typed plaintext type, which is the result of decryption.
1461
- */
1462
- export class TypedPlaintext {
1469
+ : new FinalizationRegistry(ptr => wasm.__wbg_userdecryptionresponse_free(ptr >>> 0, 1));
1463
1470
 
1464
- static __wrap(ptr) {
1465
- ptr = ptr >>> 0;
1466
- const obj = Object.create(TypedPlaintext.prototype);
1467
- obj.__wbg_ptr = ptr;
1468
- TypedPlaintextFinalization.register(obj, obj.__wbg_ptr, obj);
1469
- return obj;
1471
+ export class UserDecryptionResponse {
1472
+
1473
+ static __unwrap(jsValue) {
1474
+ if (!(jsValue instanceof UserDecryptionResponse)) {
1475
+ return 0;
1476
+ }
1477
+ return jsValue.__destroy_into_raw();
1470
1478
  }
1471
1479
 
1472
1480
  __destroy_into_raw() {
1473
1481
  const ptr = this.__wbg_ptr;
1474
1482
  this.__wbg_ptr = 0;
1475
- TypedPlaintextFinalization.unregister(this);
1483
+ UserDecryptionResponseFinalization.unregister(this);
1476
1484
  return ptr;
1477
1485
  }
1478
1486
 
1479
1487
  free() {
1480
1488
  const ptr = this.__destroy_into_raw();
1481
- wasm.__wbg_typedplaintext_free(ptr, 0);
1489
+ wasm.__wbg_userdecryptionresponse_free(ptr, 0);
1482
1490
  }
1483
1491
  /**
1484
- * The actual plaintext in bytes.
1485
1492
  * @returns {Uint8Array}
1486
1493
  */
1487
- get bytes() {
1488
- const ret = wasm.__wbg_get_typedplaintext_bytes(this.__wbg_ptr);
1494
+ get signature() {
1495
+ const ret = wasm.__wbg_get_userdecryptionresponse_signature(this.__wbg_ptr);
1489
1496
  var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1490
1497
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1491
1498
  return v1;
1492
1499
  }
1493
1500
  /**
1494
- * The actual plaintext in bytes.
1495
1501
  * @param {Uint8Array} arg0
1496
1502
  */
1497
- set bytes(arg0) {
1503
+ set signature(arg0) {
1498
1504
  const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
1499
1505
  const len0 = WASM_VECTOR_LEN;
1500
1506
  wasm.__wbg_set_eip712domainmsg_name(this.__wbg_ptr, ptr0, len0);
1501
1507
  }
1502
1508
  /**
1503
- * The type of plaintext encrypted. The type should match FheType from tfhe-rs:
1504
- * <https://github.com/zama-ai/tfhe-rs/blob/main/tfhe/src/high_level_api/mod.rs>
1505
- * @returns {number}
1509
+ * This is the external signature created from the Eip712 domain
1510
+ * on the structure, where userDecryptedShare is bc2wrap::serialize(&payload)
1511
+ * struct UserDecryptResponseVerification {
1512
+ * bytes publicKey;
1513
+ * uint256\[\] ctHandles;
1514
+ * bytes userDecryptedShare; // serialization of payload
1515
+ * bytes extraData;
1516
+ * }
1517
+ * @returns {Uint8Array}
1506
1518
  */
1507
- get fhe_type() {
1508
- const ret = wasm.__wbg_get_typedplaintext_fhe_type(this.__wbg_ptr);
1509
- return ret;
1519
+ get external_signature() {
1520
+ const ret = wasm.__wbg_get_userdecryptionresponse_external_signature(this.__wbg_ptr);
1521
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1522
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1523
+ return v1;
1510
1524
  }
1511
1525
  /**
1512
- * The type of plaintext encrypted. The type should match FheType from tfhe-rs:
1513
- * <https://github.com/zama-ai/tfhe-rs/blob/main/tfhe/src/high_level_api/mod.rs>
1514
- * @param {number} arg0
1526
+ * This is the external signature created from the Eip712 domain
1527
+ * on the structure, where userDecryptedShare is bc2wrap::serialize(&payload)
1528
+ * struct UserDecryptResponseVerification {
1529
+ * bytes publicKey;
1530
+ * uint256\[\] ctHandles;
1531
+ * bytes userDecryptedShare; // serialization of payload
1532
+ * bytes extraData;
1533
+ * }
1534
+ * @param {Uint8Array} arg0
1515
1535
  */
1516
- set fhe_type(arg0) {
1517
- wasm.__wbg_set_typedplaintext_fhe_type(this.__wbg_ptr, arg0);
1536
+ set external_signature(arg0) {
1537
+ const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
1538
+ const len0 = WASM_VECTOR_LEN;
1539
+ wasm.__wbg_set_eip712domainmsg_version(this.__wbg_ptr, ptr0, len0);
1540
+ }
1541
+ /**
1542
+ * The actual \[UserDecryptionResponsePayload\].
1543
+ * @returns {UserDecryptionResponsePayload | undefined}
1544
+ */
1545
+ get payload() {
1546
+ const ret = wasm.__wbg_get_userdecryptionresponse_payload(this.__wbg_ptr);
1547
+ return ret === 0 ? undefined : UserDecryptionResponsePayload.__wrap(ret);
1548
+ }
1549
+ /**
1550
+ * The actual \[UserDecryptionResponsePayload\].
1551
+ * @param {UserDecryptionResponsePayload | null} [arg0]
1552
+ */
1553
+ set payload(arg0) {
1554
+ let ptr0 = 0;
1555
+ if (!isLikeNone(arg0)) {
1556
+ _assertClass(arg0, UserDecryptionResponsePayload);
1557
+ ptr0 = arg0.__destroy_into_raw();
1558
+ }
1559
+ wasm.__wbg_set_userdecryptionresponse_payload(this.__wbg_ptr, ptr0);
1560
+ }
1561
+ /**
1562
+ * Extra data used in the EIP712 signature - external_signature.
1563
+ * @returns {Uint8Array}
1564
+ */
1565
+ get extra_data() {
1566
+ const ret = wasm.__wbg_get_userdecryptionresponse_extra_data(this.__wbg_ptr);
1567
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1568
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1569
+ return v1;
1570
+ }
1571
+ /**
1572
+ * Extra data used in the EIP712 signature - external_signature.
1573
+ * @param {Uint8Array} arg0
1574
+ */
1575
+ set extra_data(arg0) {
1576
+ const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
1577
+ const len0 = WASM_VECTOR_LEN;
1578
+ wasm.__wbg_set_eip712domainmsg_chain_id(this.__wbg_ptr, ptr0, len0);
1518
1579
  }
1519
1580
  }
1520
1581
 
1521
- const TypedSigncryptedCiphertextFinalization = (typeof FinalizationRegistry === 'undefined')
1582
+ const UserDecryptionResponsePayloadFinalization = (typeof FinalizationRegistry === 'undefined')
1522
1583
  ? { register: () => {}, unregister: () => {} }
1523
- : new FinalizationRegistry(ptr => wasm.__wbg_typedsigncryptedciphertext_free(ptr >>> 0, 1));
1584
+ : new FinalizationRegistry(ptr => wasm.__wbg_userdecryptionresponsepayload_free(ptr >>> 0, 1));
1524
1585
 
1525
- export class TypedSigncryptedCiphertext {
1586
+ export class UserDecryptionResponsePayload {
1526
1587
 
1527
1588
  static __wrap(ptr) {
1528
1589
  ptr = ptr >>> 0;
1529
- const obj = Object.create(TypedSigncryptedCiphertext.prototype);
1590
+ const obj = Object.create(UserDecryptionResponsePayload.prototype);
1530
1591
  obj.__wbg_ptr = ptr;
1531
- TypedSigncryptedCiphertextFinalization.register(obj, obj.__wbg_ptr, obj);
1592
+ UserDecryptionResponsePayloadFinalization.register(obj, obj.__wbg_ptr, obj);
1532
1593
  return obj;
1533
1594
  }
1534
1595
 
1535
- static __unwrap(jsValue) {
1536
- if (!(jsValue instanceof TypedSigncryptedCiphertext)) {
1537
- return 0;
1538
- }
1539
- return jsValue.__destroy_into_raw();
1540
- }
1541
-
1542
1596
  __destroy_into_raw() {
1543
1597
  const ptr = this.__wbg_ptr;
1544
1598
  this.__wbg_ptr = 0;
1545
- TypedSigncryptedCiphertextFinalization.unregister(this);
1599
+ UserDecryptionResponsePayloadFinalization.unregister(this);
1546
1600
  return ptr;
1547
1601
  }
1548
1602
 
1549
1603
  free() {
1550
1604
  const ptr = this.__destroy_into_raw();
1551
- wasm.__wbg_typedsigncryptedciphertext_free(ptr, 0);
1605
+ wasm.__wbg_userdecryptionresponsepayload_free(ptr, 0);
1552
1606
  }
1553
1607
  /**
1554
- * The type of plaintext encrypted. The type should match FheType from tfhe-rs:
1555
- * <https://github.com/zama-ai/tfhe-rs/blob/main/tfhe/src/high_level_api/mod.rs>
1556
- * @returns {number}
1557
- */
1558
- get fhe_type() {
1559
- const ret = wasm.__wbg_get_typedciphertext_fhe_type(this.__wbg_ptr);
1560
- return ret;
1561
- }
1562
- /**
1563
- * The type of plaintext encrypted. The type should match FheType from tfhe-rs:
1564
- * <https://github.com/zama-ai/tfhe-rs/blob/main/tfhe/src/high_level_api/mod.rs>
1565
- * @param {number} arg0
1566
- */
1567
- set fhe_type(arg0) {
1568
- wasm.__wbg_set_typedciphertext_fhe_type(this.__wbg_ptr, arg0);
1569
- }
1570
- /**
1571
- * The signcrypted payload, using a hybrid encryption approach in
1572
- * sign-then-encrypt.
1608
+ * The server's signature verification key, Encoded using SEC1.
1609
+ * Needed to validate the response, but MUST also be linked to a list of
1610
+ * trusted keys.
1573
1611
  * @returns {Uint8Array}
1574
1612
  */
1575
- get signcrypted_ciphertext() {
1576
- const ret = wasm.__wbg_get_typedsigncryptedciphertext_signcrypted_ciphertext(this.__wbg_ptr);
1613
+ get verification_key() {
1614
+ const ret = wasm.__wbg_get_userdecryptionresponsepayload_verification_key(this.__wbg_ptr);
1577
1615
  var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1578
1616
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1579
1617
  return v1;
1580
1618
  }
1581
1619
  /**
1582
- * The signcrypted payload, using a hybrid encryption approach in
1583
- * sign-then-encrypt.
1620
+ * The server's signature verification key, Encoded using SEC1.
1621
+ * Needed to validate the response, but MUST also be linked to a list of
1622
+ * trusted keys.
1584
1623
  * @param {Uint8Array} arg0
1585
1624
  */
1586
- set signcrypted_ciphertext(arg0) {
1625
+ set verification_key(arg0) {
1587
1626
  const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
1588
1627
  const len0 = WASM_VECTOR_LEN;
1589
1628
  wasm.__wbg_set_eip712domainmsg_name(this.__wbg_ptr, ptr0, len0);
1590
1629
  }
1591
1630
  /**
1592
- * The external handles that were originally in the request.
1631
+ * This is needed to ensure the response corresponds to the request.
1632
+ * It is the digest of UserDecryptionLinker hashed using EIP712
1633
+ * under the given domain in the request.
1593
1634
  * @returns {Uint8Array}
1594
1635
  */
1595
- get external_handle() {
1596
- const ret = wasm.__wbg_get_typedsigncryptedciphertext_external_handle(this.__wbg_ptr);
1636
+ get digest() {
1637
+ const ret = wasm.__wbg_get_userdecryptionresponsepayload_digest(this.__wbg_ptr);
1597
1638
  var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1598
1639
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1599
1640
  return v1;
1600
1641
  }
1601
1642
  /**
1602
- * The external handles that were originally in the request.
1643
+ * This is needed to ensure the response corresponds to the request.
1644
+ * It is the digest of UserDecryptionLinker hashed using EIP712
1645
+ * under the given domain in the request.
1603
1646
  * @param {Uint8Array} arg0
1604
1647
  */
1605
- set external_handle(arg0) {
1648
+ set digest(arg0) {
1606
1649
  const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
1607
1650
  const len0 = WASM_VECTOR_LEN;
1608
1651
  wasm.__wbg_set_eip712domainmsg_version(this.__wbg_ptr, ptr0, len0);
1609
1652
  }
1610
1653
  /**
1611
- * The packing factor determines whether the decrypted plaintext
1612
- * has a different way of packing compared to what is specified in the plaintext modulus.
1654
+ * The resulting signcrypted ciphertexts, each ciphertext
1655
+ * must be decrypted and then reconstructed with the other shares
1656
+ * to produce the final plaintext.
1657
+ * @returns {TypedSigncryptedCiphertext[]}
1658
+ */
1659
+ get signcrypted_ciphertexts() {
1660
+ const ret = wasm.__wbg_get_userdecryptionresponsepayload_signcrypted_ciphertexts(this.__wbg_ptr);
1661
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
1662
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
1663
+ return v1;
1664
+ }
1665
+ /**
1666
+ * The resulting signcrypted ciphertexts, each ciphertext
1667
+ * must be decrypted and then reconstructed with the other shares
1668
+ * to produce the final plaintext.
1669
+ * @param {TypedSigncryptedCiphertext[]} arg0
1670
+ */
1671
+ set signcrypted_ciphertexts(arg0) {
1672
+ const ptr0 = passArrayJsValueToWasm0(arg0, wasm.__wbindgen_malloc);
1673
+ const len0 = WASM_VECTOR_LEN;
1674
+ wasm.__wbg_set_userdecryptionresponsepayload_signcrypted_ciphertexts(this.__wbg_ptr, ptr0, len0);
1675
+ }
1676
+ /**
1677
+ * The ID of the MPC party doing the user decryption. Used for polynomial
1678
+ * reconstruction.
1613
1679
  * @returns {number}
1614
1680
  */
1615
- get packing_factor() {
1616
- const ret = wasm.__wbg_get_typedciphertext_ciphertext_format(this.__wbg_ptr);
1681
+ get party_id() {
1682
+ const ret = wasm.__wbg_get_userdecryptionresponsepayload_party_id(this.__wbg_ptr);
1617
1683
  return ret >>> 0;
1618
1684
  }
1619
1685
  /**
1620
- * The packing factor determines whether the decrypted plaintext
1621
- * has a different way of packing compared to what is specified in the plaintext modulus.
1686
+ * The ID of the MPC party doing the user decryption. Used for polynomial
1687
+ * reconstruction.
1622
1688
  * @param {number} arg0
1623
1689
  */
1624
- set packing_factor(arg0) {
1625
- wasm.__wbg_set_typedciphertext_ciphertext_format(this.__wbg_ptr, arg0);
1690
+ set party_id(arg0) {
1691
+ wasm.__wbg_set_userdecryptionresponsepayload_party_id(this.__wbg_ptr, arg0);
1692
+ }
1693
+ /**
1694
+ * The degree of the sharing scheme used.
1695
+ * @returns {number}
1696
+ */
1697
+ get degree() {
1698
+ const ret = wasm.__wbg_get_userdecryptionresponsepayload_degree(this.__wbg_ptr);
1699
+ return ret >>> 0;
1700
+ }
1701
+ /**
1702
+ * The degree of the sharing scheme used.
1703
+ * @param {number} arg0
1704
+ */
1705
+ set degree(arg0) {
1706
+ wasm.__wbg_set_userdecryptionresponsepayload_degree(this.__wbg_ptr, arg0);
1626
1707
  }
1627
1708
  }
1628
1709
 
@@ -1796,14 +1877,18 @@ function __wbg_get_imports() {
1796
1877
  imports.wbg.__wbg_randomFillSync_ab2cfe79ebbf2740 = function() { return handleError(function (arg0, arg1) {
1797
1878
  arg0.randomFillSync(arg1);
1798
1879
  }, arguments) };
1799
- imports.wbg.__wbg_reencryptionresponse_unwrap = function(arg0) {
1800
- const ret = ReencryptionResponse.__unwrap(arg0);
1801
- return ret;
1802
- };
1803
1880
  imports.wbg.__wbg_require_79b1e9274cde3c87 = function() { return handleError(function () {
1804
1881
  const ret = module.require;
1805
1882
  return ret;
1806
1883
  }, arguments) };
1884
+ imports.wbg.__wbg_serveridaddr_new = function(arg0) {
1885
+ const ret = ServerIdAddr.__wrap(arg0);
1886
+ return ret;
1887
+ };
1888
+ imports.wbg.__wbg_serveridaddr_unwrap = function(arg0) {
1889
+ const ret = ServerIdAddr.__unwrap(arg0);
1890
+ return ret;
1891
+ };
1807
1892
  imports.wbg.__wbg_set_65595bdd868b3009 = function(arg0, arg1, arg2) {
1808
1893
  arg0.set(arg1, arg2 >>> 0);
1809
1894
  };
@@ -1854,6 +1939,10 @@ function __wbg_get_imports() {
1854
1939
  const ret = TypedSigncryptedCiphertext.__unwrap(arg0);
1855
1940
  return ret;
1856
1941
  };
1942
+ imports.wbg.__wbg_userdecryptionresponse_unwrap = function(arg0) {
1943
+ const ret = UserDecryptionResponse.__unwrap(arg0);
1944
+ return ret;
1945
+ };
1857
1946
  imports.wbg.__wbg_value_cd1ffa7b1ab794f1 = function(arg0) {
1858
1947
  const ret = arg0.value;
1859
1948
  return ret;