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