node-tkms 0.11.0-rc9 → 0.11.1

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,131 @@ 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
1476
+ */
1477
+ set extra_data(arg0) {
1478
+ const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
1479
+ const len0 = WASM_VECTOR_LEN;
1480
+ wasm.__wbg_set_eip712domainmsg_verifying_contract(this.__wbg_ptr, ptr0, len0);
1481
+ }
1482
+ /**
1483
+ * MPC context ID which is used to identify the context to use for this request.
1484
+ *
1485
+ * NOTE: at the moment this can be None since we do not fully support multiple contexts.
1486
+ * See <https://github.com/zama-ai/kms-internal/issues/2530>
1487
+ * @returns {RequestId | undefined}
1488
+ */
1489
+ get context_id() {
1490
+ const ret = wasm.__wbg_get_userdecryptionrequest_context_id(this.__wbg_ptr);
1491
+ return ret === 0 ? undefined : RequestId.__wrap(ret);
1492
+ }
1493
+ /**
1494
+ * MPC context ID which is used to identify the context to use for this request.
1495
+ *
1496
+ * NOTE: at the moment this can be None since we do not fully support multiple contexts.
1497
+ * See <https://github.com/zama-ai/kms-internal/issues/2530>
1498
+ * @param {RequestId | null} [arg0]
1499
+ */
1500
+ set context_id(arg0) {
1501
+ let ptr0 = 0;
1502
+ if (!isLikeNone(arg0)) {
1503
+ _assertClass(arg0, RequestId);
1504
+ ptr0 = arg0.__destroy_into_raw();
1505
+ }
1506
+ wasm.__wbg_set_userdecryptionrequest_context_id(this.__wbg_ptr, ptr0);
1507
+ }
1508
+ /**
1509
+ * The epoch number placeholder (zama-ai/kms-internal#2743).
1510
+ * @returns {RequestId | undefined}
1511
+ */
1512
+ get epoch_id() {
1513
+ const ret = wasm.__wbg_get_userdecryptionrequest_epoch_id(this.__wbg_ptr);
1514
+ return ret === 0 ? undefined : RequestId.__wrap(ret);
1515
+ }
1516
+ /**
1517
+ * The epoch number placeholder (zama-ai/kms-internal#2743).
1518
+ * @param {RequestId | null} [arg0]
1358
1519
  */
1359
- set request_id(arg0) {
1360
- const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1361
- const len0 = WASM_VECTOR_LEN;
1362
- wasm.__wbg_set_eip712domainmsg_name(this.__wbg_ptr, ptr0, len0);
1520
+ set epoch_id(arg0) {
1521
+ let ptr0 = 0;
1522
+ if (!isLikeNone(arg0)) {
1523
+ _assertClass(arg0, RequestId);
1524
+ ptr0 = arg0.__destroy_into_raw();
1525
+ }
1526
+ wasm.__wbg_set_userdecryptionrequest_epoch_id(this.__wbg_ptr, ptr0);
1363
1527
  }
1364
1528
  }
1365
- module.exports.RequestId = RequestId;
1529
+ module.exports.UserDecryptionRequest = UserDecryptionRequest;
1366
1530
 
1367
- const TypedCiphertextFinalization = (typeof FinalizationRegistry === 'undefined')
1531
+ const UserDecryptionResponseFinalization = (typeof FinalizationRegistry === 'undefined')
1368
1532
  ? { register: () => {}, unregister: () => {} }
1369
- : new FinalizationRegistry(ptr => wasm.__wbg_typedciphertext_free(ptr >>> 0, 1));
1370
-
1371
- class TypedCiphertext {
1533
+ : new FinalizationRegistry(ptr => wasm.__wbg_userdecryptionresponse_free(ptr >>> 0, 1));
1372
1534
 
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
- }
1535
+ class UserDecryptionResponse {
1380
1536
 
1381
1537
  static __unwrap(jsValue) {
1382
- if (!(jsValue instanceof TypedCiphertext)) {
1538
+ if (!(jsValue instanceof UserDecryptionResponse)) {
1383
1539
  return 0;
1384
1540
  }
1385
1541
  return jsValue.__destroy_into_raw();
@@ -1388,263 +1544,234 @@ class TypedCiphertext {
1388
1544
  __destroy_into_raw() {
1389
1545
  const ptr = this.__wbg_ptr;
1390
1546
  this.__wbg_ptr = 0;
1391
- TypedCiphertextFinalization.unregister(this);
1547
+ UserDecryptionResponseFinalization.unregister(this);
1392
1548
  return ptr;
1393
1549
  }
1394
1550
 
1395
1551
  free() {
1396
1552
  const ptr = this.__destroy_into_raw();
1397
- wasm.__wbg_typedciphertext_free(ptr, 0);
1553
+ wasm.__wbg_userdecryptionresponse_free(ptr, 0);
1398
1554
  }
1399
1555
  /**
1400
- * The actual ciphertext to decrypt, taken directly from fhevm.
1401
1556
  * @returns {Uint8Array}
1402
1557
  */
1403
- get ciphertext() {
1404
- const ret = wasm.__wbg_get_typedciphertext_ciphertext(this.__wbg_ptr);
1558
+ get signature() {
1559
+ const ret = wasm.__wbg_get_userdecryptionresponse_signature(this.__wbg_ptr);
1405
1560
  var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1406
1561
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1407
1562
  return v1;
1408
1563
  }
1409
1564
  /**
1410
- * The actual ciphertext to decrypt, taken directly from fhevm.
1411
1565
  * @param {Uint8Array} arg0
1412
1566
  */
1413
- set ciphertext(arg0) {
1567
+ set signature(arg0) {
1414
1568
  const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
1415
1569
  const len0 = WASM_VECTOR_LEN;
1416
1570
  wasm.__wbg_set_eip712domainmsg_name(this.__wbg_ptr, ptr0, len0);
1417
1571
  }
1418
1572
  /**
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).
1573
+ * This is the external signature created from the Eip712 domain
1574
+ * on the structure, where userDecryptedShare is bc2wrap::serialize(&payload)
1575
+ * struct UserDecryptResponseVerification {
1576
+ * bytes publicKey;
1577
+ * uint256\[\] ctHandles;
1578
+ * bytes userDecryptedShare; // serialization of payload
1579
+ * bytes extraData;
1580
+ * }
1437
1581
  * @returns {Uint8Array}
1438
1582
  */
1439
- get external_handle() {
1440
- const ret = wasm.__wbg_get_typedciphertext_external_handle(this.__wbg_ptr);
1583
+ get external_signature() {
1584
+ const ret = wasm.__wbg_get_userdecryptionresponse_external_signature(this.__wbg_ptr);
1441
1585
  var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1442
1586
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1443
1587
  return v1;
1444
1588
  }
1445
1589
  /**
1446
- * The external handle of the ciphertext (the handle used in the copro).
1590
+ * This is the external signature created from the Eip712 domain
1591
+ * on the structure, where userDecryptedShare is bc2wrap::serialize(&payload)
1592
+ * struct UserDecryptResponseVerification {
1593
+ * bytes publicKey;
1594
+ * uint256\[\] ctHandles;
1595
+ * bytes userDecryptedShare; // serialization of payload
1596
+ * bytes extraData;
1597
+ * }
1447
1598
  * @param {Uint8Array} arg0
1448
1599
  */
1449
- set external_handle(arg0) {
1600
+ set external_signature(arg0) {
1450
1601
  const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
1451
1602
  const len0 = WASM_VECTOR_LEN;
1452
1603
  wasm.__wbg_set_eip712domainmsg_version(this.__wbg_ptr, ptr0, len0);
1453
1604
  }
1454
1605
  /**
1455
- * The ciphertext format, see CiphertextFormat documentation for details.
1456
- * CiphertextFormat::default() is used if unspecified.
1457
- * @returns {number}
1606
+ * The actual \[UserDecryptionResponsePayload\].
1607
+ * @returns {UserDecryptionResponsePayload | undefined}
1458
1608
  */
1459
- get ciphertext_format() {
1460
- const ret = wasm.__wbg_get_typedciphertext_ciphertext_format(this.__wbg_ptr);
1461
- return ret;
1609
+ get payload() {
1610
+ const ret = wasm.__wbg_get_userdecryptionresponse_payload(this.__wbg_ptr);
1611
+ return ret === 0 ? undefined : UserDecryptionResponsePayload.__wrap(ret);
1462
1612
  }
1463
1613
  /**
1464
- * The ciphertext format, see CiphertextFormat documentation for details.
1465
- * CiphertextFormat::default() is used if unspecified.
1466
- * @param {number} arg0
1614
+ * The actual \[UserDecryptionResponsePayload\].
1615
+ * @param {UserDecryptionResponsePayload | null} [arg0]
1467
1616
  */
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);
1617
+ set payload(arg0) {
1618
+ let ptr0 = 0;
1619
+ if (!isLikeNone(arg0)) {
1620
+ _assertClass(arg0, UserDecryptionResponsePayload);
1621
+ ptr0 = arg0.__destroy_into_raw();
1622
+ }
1623
+ wasm.__wbg_set_userdecryptionresponse_payload(this.__wbg_ptr, ptr0);
1500
1624
  }
1501
1625
  /**
1502
- * The actual plaintext in bytes.
1626
+ * Extra data used in the EIP712 signature - external_signature.
1503
1627
  * @returns {Uint8Array}
1504
1628
  */
1505
- get bytes() {
1506
- const ret = wasm.__wbg_get_typedplaintext_bytes(this.__wbg_ptr);
1629
+ get extra_data() {
1630
+ const ret = wasm.__wbg_get_userdecryptionresponse_extra_data(this.__wbg_ptr);
1507
1631
  var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1508
1632
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1509
1633
  return v1;
1510
1634
  }
1511
1635
  /**
1512
- * The actual plaintext in bytes.
1636
+ * Extra data used in the EIP712 signature - external_signature.
1513
1637
  * @param {Uint8Array} arg0
1514
1638
  */
1515
- set bytes(arg0) {
1639
+ set extra_data(arg0) {
1516
1640
  const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
1517
1641
  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);
1642
+ wasm.__wbg_set_eip712domainmsg_chain_id(this.__wbg_ptr, ptr0, len0);
1536
1643
  }
1537
1644
  }
1538
- module.exports.TypedPlaintext = TypedPlaintext;
1645
+ module.exports.UserDecryptionResponse = UserDecryptionResponse;
1539
1646
 
1540
- const TypedSigncryptedCiphertextFinalization = (typeof FinalizationRegistry === 'undefined')
1647
+ const UserDecryptionResponsePayloadFinalization = (typeof FinalizationRegistry === 'undefined')
1541
1648
  ? { register: () => {}, unregister: () => {} }
1542
- : new FinalizationRegistry(ptr => wasm.__wbg_typedsigncryptedciphertext_free(ptr >>> 0, 1));
1649
+ : new FinalizationRegistry(ptr => wasm.__wbg_userdecryptionresponsepayload_free(ptr >>> 0, 1));
1543
1650
 
1544
- class TypedSigncryptedCiphertext {
1651
+ class UserDecryptionResponsePayload {
1545
1652
 
1546
1653
  static __wrap(ptr) {
1547
1654
  ptr = ptr >>> 0;
1548
- const obj = Object.create(TypedSigncryptedCiphertext.prototype);
1655
+ const obj = Object.create(UserDecryptionResponsePayload.prototype);
1549
1656
  obj.__wbg_ptr = ptr;
1550
- TypedSigncryptedCiphertextFinalization.register(obj, obj.__wbg_ptr, obj);
1657
+ UserDecryptionResponsePayloadFinalization.register(obj, obj.__wbg_ptr, obj);
1551
1658
  return obj;
1552
1659
  }
1553
1660
 
1554
- static __unwrap(jsValue) {
1555
- if (!(jsValue instanceof TypedSigncryptedCiphertext)) {
1556
- return 0;
1557
- }
1558
- return jsValue.__destroy_into_raw();
1559
- }
1560
-
1561
1661
  __destroy_into_raw() {
1562
1662
  const ptr = this.__wbg_ptr;
1563
1663
  this.__wbg_ptr = 0;
1564
- TypedSigncryptedCiphertextFinalization.unregister(this);
1664
+ UserDecryptionResponsePayloadFinalization.unregister(this);
1565
1665
  return ptr;
1566
1666
  }
1567
1667
 
1568
1668
  free() {
1569
1669
  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);
1670
+ wasm.__wbg_userdecryptionresponsepayload_free(ptr, 0);
1588
1671
  }
1589
1672
  /**
1590
- * The signcrypted payload, using a hybrid encryption approach in
1591
- * sign-then-encrypt.
1673
+ * The server's signature verification key, Encoded using SEC1.
1674
+ * Needed to validate the response, but MUST also be linked to a list of
1675
+ * trusted keys.
1592
1676
  * @returns {Uint8Array}
1593
1677
  */
1594
- get signcrypted_ciphertext() {
1595
- const ret = wasm.__wbg_get_typedsigncryptedciphertext_signcrypted_ciphertext(this.__wbg_ptr);
1678
+ get verification_key() {
1679
+ const ret = wasm.__wbg_get_userdecryptionresponsepayload_verification_key(this.__wbg_ptr);
1596
1680
  var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1597
1681
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1598
1682
  return v1;
1599
1683
  }
1600
1684
  /**
1601
- * The signcrypted payload, using a hybrid encryption approach in
1602
- * sign-then-encrypt.
1685
+ * The server's signature verification key, Encoded using SEC1.
1686
+ * Needed to validate the response, but MUST also be linked to a list of
1687
+ * trusted keys.
1603
1688
  * @param {Uint8Array} arg0
1604
1689
  */
1605
- set signcrypted_ciphertext(arg0) {
1690
+ set verification_key(arg0) {
1606
1691
  const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
1607
1692
  const len0 = WASM_VECTOR_LEN;
1608
1693
  wasm.__wbg_set_eip712domainmsg_name(this.__wbg_ptr, ptr0, len0);
1609
1694
  }
1610
1695
  /**
1611
- * The external handles that were originally in the request.
1696
+ * This is needed to ensure the response corresponds to the request.
1697
+ * It is the digest of UserDecryptionLinker hashed using EIP712
1698
+ * under the given domain in the request.
1612
1699
  * @returns {Uint8Array}
1613
1700
  */
1614
- get external_handle() {
1615
- const ret = wasm.__wbg_get_typedsigncryptedciphertext_external_handle(this.__wbg_ptr);
1701
+ get digest() {
1702
+ const ret = wasm.__wbg_get_userdecryptionresponsepayload_digest(this.__wbg_ptr);
1616
1703
  var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1617
1704
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1618
1705
  return v1;
1619
1706
  }
1620
1707
  /**
1621
- * The external handles that were originally in the request.
1708
+ * This is needed to ensure the response corresponds to the request.
1709
+ * It is the digest of UserDecryptionLinker hashed using EIP712
1710
+ * under the given domain in the request.
1622
1711
  * @param {Uint8Array} arg0
1623
1712
  */
1624
- set external_handle(arg0) {
1713
+ set digest(arg0) {
1625
1714
  const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
1626
1715
  const len0 = WASM_VECTOR_LEN;
1627
1716
  wasm.__wbg_set_eip712domainmsg_version(this.__wbg_ptr, ptr0, len0);
1628
1717
  }
1629
1718
  /**
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.
1719
+ * The resulting signcrypted ciphertexts, each ciphertext
1720
+ * must be decrypted and then reconstructed with the other shares
1721
+ * to produce the final plaintext.
1722
+ * @returns {TypedSigncryptedCiphertext[]}
1723
+ */
1724
+ get signcrypted_ciphertexts() {
1725
+ const ret = wasm.__wbg_get_userdecryptionresponsepayload_signcrypted_ciphertexts(this.__wbg_ptr);
1726
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
1727
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
1728
+ return v1;
1729
+ }
1730
+ /**
1731
+ * The resulting signcrypted ciphertexts, each ciphertext
1732
+ * must be decrypted and then reconstructed with the other shares
1733
+ * to produce the final plaintext.
1734
+ * @param {TypedSigncryptedCiphertext[]} arg0
1735
+ */
1736
+ set signcrypted_ciphertexts(arg0) {
1737
+ const ptr0 = passArrayJsValueToWasm0(arg0, wasm.__wbindgen_malloc);
1738
+ const len0 = WASM_VECTOR_LEN;
1739
+ wasm.__wbg_set_userdecryptionresponsepayload_signcrypted_ciphertexts(this.__wbg_ptr, ptr0, len0);
1740
+ }
1741
+ /**
1742
+ * The ID of the MPC party doing the user decryption. Used for polynomial
1743
+ * reconstruction.
1632
1744
  * @returns {number}
1633
1745
  */
1634
- get packing_factor() {
1635
- const ret = wasm.__wbg_get_typedciphertext_ciphertext_format(this.__wbg_ptr);
1746
+ get party_id() {
1747
+ const ret = wasm.__wbg_get_userdecryptionresponsepayload_party_id(this.__wbg_ptr);
1636
1748
  return ret >>> 0;
1637
1749
  }
1638
1750
  /**
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.
1751
+ * The ID of the MPC party doing the user decryption. Used for polynomial
1752
+ * reconstruction.
1641
1753
  * @param {number} arg0
1642
1754
  */
1643
- set packing_factor(arg0) {
1644
- wasm.__wbg_set_typedciphertext_ciphertext_format(this.__wbg_ptr, arg0);
1755
+ set party_id(arg0) {
1756
+ wasm.__wbg_set_userdecryptionresponsepayload_party_id(this.__wbg_ptr, arg0);
1757
+ }
1758
+ /**
1759
+ * The degree of the sharing scheme used.
1760
+ * @returns {number}
1761
+ */
1762
+ get degree() {
1763
+ const ret = wasm.__wbg_get_userdecryptionresponsepayload_degree(this.__wbg_ptr);
1764
+ return ret >>> 0;
1765
+ }
1766
+ /**
1767
+ * The degree of the sharing scheme used.
1768
+ * @param {number} arg0
1769
+ */
1770
+ set degree(arg0) {
1771
+ wasm.__wbg_set_userdecryptionresponsepayload_degree(this.__wbg_ptr, arg0);
1645
1772
  }
1646
1773
  }
1647
- module.exports.TypedSigncryptedCiphertext = TypedSigncryptedCiphertext;
1774
+ module.exports.UserDecryptionResponsePayload = UserDecryptionResponsePayload;
1648
1775
 
1649
1776
  module.exports.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
1650
1777
  const ret = String(arg1);
@@ -1811,16 +1938,21 @@ module.exports.__wbg_randomFillSync_ab2cfe79ebbf2740 = function() { return handl
1811
1938
  arg0.randomFillSync(arg1);
1812
1939
  }, arguments) };
1813
1940
 
1814
- module.exports.__wbg_reencryptionresponse_unwrap = function(arg0) {
1815
- const ret = ReencryptionResponse.__unwrap(arg0);
1816
- return ret;
1817
- };
1818
-
1819
1941
  module.exports.__wbg_require_79b1e9274cde3c87 = function() { return handleError(function () {
1820
1942
  const ret = module.require;
1821
1943
  return ret;
1822
1944
  }, arguments) };
1823
1945
 
1946
+ module.exports.__wbg_serveridaddr_new = function(arg0) {
1947
+ const ret = ServerIdAddr.__wrap(arg0);
1948
+ return ret;
1949
+ };
1950
+
1951
+ module.exports.__wbg_serveridaddr_unwrap = function(arg0) {
1952
+ const ret = ServerIdAddr.__unwrap(arg0);
1953
+ return ret;
1954
+ };
1955
+
1824
1956
  module.exports.__wbg_set_65595bdd868b3009 = function(arg0, arg1, arg2) {
1825
1957
  arg0.set(arg1, arg2 >>> 0);
1826
1958
  };
@@ -1883,6 +2015,11 @@ module.exports.__wbg_typedsigncryptedciphertext_unwrap = function(arg0) {
1883
2015
  return ret;
1884
2016
  };
1885
2017
 
2018
+ module.exports.__wbg_userdecryptionresponse_unwrap = function(arg0) {
2019
+ const ret = UserDecryptionResponse.__unwrap(arg0);
2020
+ return ret;
2021
+ };
2022
+
1886
2023
  module.exports.__wbg_value_cd1ffa7b1ab794f1 = function(arg0) {
1887
2024
  const ret = arg0.value;
1888
2025
  return ret;