node-tkms 0.14.1-1 → 0.15.0-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.d.ts CHANGED
@@ -127,6 +127,27 @@ export class TypedPlaintext {
127
127
  fhe_type: number;
128
128
  }
129
129
 
130
+ /**
131
+ * A single signature together with the scheme that produced it.
132
+ *
133
+ * Used to carry a chain-native signature for one signing scheme when a response
134
+ * may be signed under several schemes at once (e.g. ECDSA/secp256k1 EIP-712 for
135
+ * an EVM, ed25519 for Solana, ML-DSA for post-quantum).
136
+ */
137
+ export class TypedSignature {
138
+ private constructor();
139
+ free(): void;
140
+ [Symbol.dispose](): void;
141
+ /**
142
+ * The signature scheme that produced `signature`.
143
+ */
144
+ scheme: number;
145
+ /**
146
+ * The raw, scheme-specific signature bytes.
147
+ */
148
+ signature: Uint8Array;
149
+ }
150
+
130
151
  export class TypedSigncryptedCiphertext {
131
152
  private constructor();
132
153
  free(): void;
@@ -162,16 +183,12 @@ export class UserDecryptionRequest {
162
183
  client_address: string;
163
184
  /**
164
185
  * MPC context ID which is used to identify the context to use for this request.
165
- *
166
- * NOTE: at the moment this can be None since we do not fully support multiple contexts.
167
- * See <https://github.com/zama-ai/kms-internal/issues/2530>
186
+ * If unset, the server's default context is used.
168
187
  */
169
188
  get context_id(): RequestId | undefined;
170
189
  /**
171
190
  * MPC context ID which is used to identify the context to use for this request.
172
- *
173
- * NOTE: at the moment this can be None since we do not fully support multiple contexts.
174
- * See <https://github.com/zama-ai/kms-internal/issues/2530>
191
+ * If unset, the server's default context is used.
175
192
  */
176
193
  set context_id(value: RequestId | null | undefined);
177
194
  /**
@@ -188,11 +205,13 @@ export class UserDecryptionRequest {
188
205
  */
189
206
  enc_key: Uint8Array;
190
207
  /**
191
- * The epoch number placeholder (zama-ai/kms-internal#2743).
208
+ * The MPC epoch ID identifying which epoch's key material and session to
209
+ * use for this request.
192
210
  */
193
211
  get epoch_id(): RequestId | undefined;
194
212
  /**
195
- * The epoch number placeholder (zama-ai/kms-internal#2743).
213
+ * The MPC epoch ID identifying which epoch's key material and session to
214
+ * use for this request.
196
215
  */
197
216
  set epoch_id(value: RequestId | null | undefined);
198
217
  /**
@@ -219,6 +238,12 @@ export class UserDecryptionRequest {
219
238
  * prefix. Future queries for the result must use this request ID.
220
239
  */
221
240
  set request_id(value: RequestId | null | undefined);
241
+ /**
242
+ * The signature schemes to include in the response `signatures` field.
243
+ * If empty, it defaults to ECDSA256K1, so the response carries a single ECDSA
244
+ * entry.
245
+ */
246
+ signing_schemes: Int32Array;
222
247
  /**
223
248
  * The list of ciphertexts to decrypt for the user.
224
249
  */
@@ -230,7 +255,7 @@ export class UserDecryptionResponse {
230
255
  free(): void;
231
256
  [Symbol.dispose](): void;
232
257
  /**
233
- * This is the external signature created from the Eip712 domain
258
+ * This is the external ECDSA signature created from the Eip712 domain
234
259
  * on the structure, where userDecryptedShare is bc2wrap::serialize(&payload)
235
260
  * struct UserDecryptResponseVerification {
236
261
  * bytes publicKey;
@@ -238,6 +263,7 @@ export class UserDecryptionResponse {
238
263
  * bytes userDecryptedShare; // serialization of payload
239
264
  * bytes extraData;
240
265
  * }
266
+ * DEPRECATED: To be removed in 0.16 TODO(0.16)
241
267
  */
242
268
  external_signature: Uint8Array;
243
269
  /**
@@ -252,7 +278,19 @@ export class UserDecryptionResponse {
252
278
  * The actual \[UserDecryptionResponsePayload\].
253
279
  */
254
280
  set payload(value: UserDecryptionResponsePayload | null | undefined);
281
+ /**
282
+ * DEPRECATED to be removed in 0.16.0 TODO(0.16)
283
+ * The KMS-internal ECDSA/secp256k1 authenticity signature over
284
+ * the serialization of \[UserDecryptionResponsePayload\]. Kept at field 1 (and
285
+ * kept populated) for wire backward-compatibility with clients that predate
286
+ * the multi-scheme `signatures` list.
287
+ */
255
288
  signature: Uint8Array;
289
+ /**
290
+ * Per-scheme KMS signatures, one per scheme requested in the request's
291
+ * `signing_schemes`.
292
+ */
293
+ signatures: TypedSignature[];
256
294
  }
257
295
 
258
296
  export class UserDecryptionResponsePayload {
package/kms_lib.js CHANGED
@@ -509,6 +509,74 @@ class TypedPlaintext {
509
509
  if (Symbol.dispose) TypedPlaintext.prototype[Symbol.dispose] = TypedPlaintext.prototype.free;
510
510
  exports.TypedPlaintext = TypedPlaintext;
511
511
 
512
+ /**
513
+ * A single signature together with the scheme that produced it.
514
+ *
515
+ * Used to carry a chain-native signature for one signing scheme when a response
516
+ * may be signed under several schemes at once (e.g. ECDSA/secp256k1 EIP-712 for
517
+ * an EVM, ed25519 for Solana, ML-DSA for post-quantum).
518
+ */
519
+ class TypedSignature {
520
+ static __wrap(ptr) {
521
+ const obj = Object.create(TypedSignature.prototype);
522
+ obj.__wbg_ptr = ptr;
523
+ TypedSignatureFinalization.register(obj, obj.__wbg_ptr, obj);
524
+ return obj;
525
+ }
526
+ static __unwrap(jsValue) {
527
+ if (!(jsValue instanceof TypedSignature)) {
528
+ return 0;
529
+ }
530
+ return jsValue.__destroy_into_raw();
531
+ }
532
+ __destroy_into_raw() {
533
+ const ptr = this.__wbg_ptr;
534
+ this.__wbg_ptr = 0;
535
+ TypedSignatureFinalization.unregister(this);
536
+ return ptr;
537
+ }
538
+ free() {
539
+ const ptr = this.__destroy_into_raw();
540
+ wasm.__wbg_typedsignature_free(ptr, 0);
541
+ }
542
+ /**
543
+ * The signature scheme that produced `signature`.
544
+ * @returns {number}
545
+ */
546
+ get scheme() {
547
+ const ret = wasm.__wbg_get_typedsignature_scheme(this.__wbg_ptr);
548
+ return ret;
549
+ }
550
+ /**
551
+ * The raw, scheme-specific signature bytes.
552
+ * @returns {Uint8Array}
553
+ */
554
+ get signature() {
555
+ const ret = wasm.__wbg_get_typedsignature_signature(this.__wbg_ptr);
556
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
557
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
558
+ return v1;
559
+ }
560
+ /**
561
+ * The signature scheme that produced `signature`.
562
+ * @param {number} arg0
563
+ */
564
+ set scheme(arg0) {
565
+ wasm.__wbg_set_typedsignature_scheme(this.__wbg_ptr, arg0);
566
+ }
567
+ /**
568
+ * The raw, scheme-specific signature bytes.
569
+ * @param {Uint8Array} arg0
570
+ */
571
+ set signature(arg0) {
572
+ const ptr0 = passArray8ToWasm0(arg0, wasm.__wbindgen_malloc);
573
+ const len0 = WASM_VECTOR_LEN;
574
+ wasm.__wbg_set_typedsignature_signature(this.__wbg_ptr, ptr0, len0);
575
+ }
576
+ }
577
+ if (Symbol.dispose) TypedSignature.prototype[Symbol.dispose] = TypedSignature.prototype.free;
578
+ exports.TypedSignature = TypedSignature;
579
+
512
580
  class TypedSigncryptedCiphertext {
513
581
  static __wrap(ptr) {
514
582
  const obj = Object.create(TypedSigncryptedCiphertext.prototype);
@@ -639,9 +707,7 @@ class UserDecryptionRequest {
639
707
  }
640
708
  /**
641
709
  * MPC context ID which is used to identify the context to use for this request.
642
- *
643
- * NOTE: at the moment this can be None since we do not fully support multiple contexts.
644
- * See <https://github.com/zama-ai/kms-internal/issues/2530>
710
+ * If unset, the server's default context is used.
645
711
  * @returns {RequestId | undefined}
646
712
  */
647
713
  get context_id() {
@@ -668,7 +734,8 @@ class UserDecryptionRequest {
668
734
  return v1;
669
735
  }
670
736
  /**
671
- * The epoch number placeholder (zama-ai/kms-internal#2743).
737
+ * The MPC epoch ID identifying which epoch's key material and session to
738
+ * use for this request.
672
739
  * @returns {RequestId | undefined}
673
740
  */
674
741
  get epoch_id() {
@@ -703,6 +770,18 @@ class UserDecryptionRequest {
703
770
  const ret = wasm.__wbg_get_userdecryptionrequest_request_id(this.__wbg_ptr);
704
771
  return ret === 0 ? undefined : RequestId.__wrap(ret);
705
772
  }
773
+ /**
774
+ * The signature schemes to include in the response `signatures` field.
775
+ * If empty, it defaults to ECDSA256K1, so the response carries a single ECDSA
776
+ * entry.
777
+ * @returns {Int32Array}
778
+ */
779
+ get signing_schemes() {
780
+ const ret = wasm.__wbg_get_userdecryptionrequest_signing_schemes(this.__wbg_ptr);
781
+ var v1 = getArrayI32FromWasm0(ret[0], ret[1]).slice();
782
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
783
+ return v1;
784
+ }
706
785
  /**
707
786
  * The list of ciphertexts to decrypt for the user.
708
787
  * @returns {TypedCiphertext[]}
@@ -724,9 +803,7 @@ class UserDecryptionRequest {
724
803
  }
725
804
  /**
726
805
  * MPC context ID which is used to identify the context to use for this request.
727
- *
728
- * NOTE: at the moment this can be None since we do not fully support multiple contexts.
729
- * See <https://github.com/zama-ai/kms-internal/issues/2530>
806
+ * If unset, the server's default context is used.
730
807
  * @param {RequestId | null} [arg0]
731
808
  */
732
809
  set context_id(arg0) {
@@ -760,7 +837,8 @@ class UserDecryptionRequest {
760
837
  wasm.__wbg_set_userdecryptionrequest_enc_key(this.__wbg_ptr, ptr0, len0);
761
838
  }
762
839
  /**
763
- * The epoch number placeholder (zama-ai/kms-internal#2743).
840
+ * The MPC epoch ID identifying which epoch's key material and session to
841
+ * use for this request.
764
842
  * @param {RequestId | null} [arg0]
765
843
  */
766
844
  set epoch_id(arg0) {
@@ -806,6 +884,17 @@ class UserDecryptionRequest {
806
884
  }
807
885
  wasm.__wbg_set_userdecryptionrequest_request_id(this.__wbg_ptr, ptr0);
808
886
  }
887
+ /**
888
+ * The signature schemes to include in the response `signatures` field.
889
+ * If empty, it defaults to ECDSA256K1, so the response carries a single ECDSA
890
+ * entry.
891
+ * @param {Int32Array} arg0
892
+ */
893
+ set signing_schemes(arg0) {
894
+ const ptr0 = passArray32ToWasm0(arg0, wasm.__wbindgen_malloc);
895
+ const len0 = WASM_VECTOR_LEN;
896
+ wasm.__wbg_set_userdecryptionrequest_signing_schemes(this.__wbg_ptr, ptr0, len0);
897
+ }
809
898
  /**
810
899
  * The list of ciphertexts to decrypt for the user.
811
900
  * @param {TypedCiphertext[]} arg0
@@ -831,7 +920,7 @@ class UserDecryptionResponse {
831
920
  wasm.__wbg_userdecryptionresponse_free(ptr, 0);
832
921
  }
833
922
  /**
834
- * This is the external signature created from the Eip712 domain
923
+ * This is the external ECDSA signature created from the Eip712 domain
835
924
  * on the structure, where userDecryptedShare is bc2wrap::serialize(&payload)
836
925
  * struct UserDecryptResponseVerification {
837
926
  * bytes publicKey;
@@ -839,6 +928,7 @@ class UserDecryptionResponse {
839
928
  * bytes userDecryptedShare; // serialization of payload
840
929
  * bytes extraData;
841
930
  * }
931
+ * DEPRECATED: To be removed in 0.16 TODO(0.16)
842
932
  * @returns {Uint8Array}
843
933
  */
844
934
  get external_signature() {
@@ -866,6 +956,11 @@ class UserDecryptionResponse {
866
956
  return ret === 0 ? undefined : UserDecryptionResponsePayload.__wrap(ret);
867
957
  }
868
958
  /**
959
+ * DEPRECATED to be removed in 0.16.0 TODO(0.16)
960
+ * The KMS-internal ECDSA/secp256k1 authenticity signature over
961
+ * the serialization of \[UserDecryptionResponsePayload\]. Kept at field 1 (and
962
+ * kept populated) for wire backward-compatibility with clients that predate
963
+ * the multi-scheme `signatures` list.
869
964
  * @returns {Uint8Array}
870
965
  */
871
966
  get signature() {
@@ -875,7 +970,18 @@ class UserDecryptionResponse {
875
970
  return v1;
876
971
  }
877
972
  /**
878
- * This is the external signature created from the Eip712 domain
973
+ * Per-scheme KMS signatures, one per scheme requested in the request's
974
+ * `signing_schemes`.
975
+ * @returns {TypedSignature[]}
976
+ */
977
+ get signatures() {
978
+ const ret = wasm.__wbg_get_userdecryptionresponse_signatures(this.__wbg_ptr);
979
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
980
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
981
+ return v1;
982
+ }
983
+ /**
984
+ * This is the external ECDSA signature created from the Eip712 domain
879
985
  * on the structure, where userDecryptedShare is bc2wrap::serialize(&payload)
880
986
  * struct UserDecryptResponseVerification {
881
987
  * bytes publicKey;
@@ -883,6 +989,7 @@ class UserDecryptionResponse {
883
989
  * bytes userDecryptedShare; // serialization of payload
884
990
  * bytes extraData;
885
991
  * }
992
+ * DEPRECATED: To be removed in 0.16 TODO(0.16)
886
993
  * @param {Uint8Array} arg0
887
994
  */
888
995
  set external_signature(arg0) {
@@ -912,6 +1019,11 @@ class UserDecryptionResponse {
912
1019
  wasm.__wbg_set_userdecryptionresponse_payload(this.__wbg_ptr, ptr0);
913
1020
  }
914
1021
  /**
1022
+ * DEPRECATED to be removed in 0.16.0 TODO(0.16)
1023
+ * The KMS-internal ECDSA/secp256k1 authenticity signature over
1024
+ * the serialization of \[UserDecryptionResponsePayload\]. Kept at field 1 (and
1025
+ * kept populated) for wire backward-compatibility with clients that predate
1026
+ * the multi-scheme `signatures` list.
915
1027
  * @param {Uint8Array} arg0
916
1028
  */
917
1029
  set signature(arg0) {
@@ -919,6 +1031,16 @@ class UserDecryptionResponse {
919
1031
  const len0 = WASM_VECTOR_LEN;
920
1032
  wasm.__wbg_set_userdecryptionresponse_signature(this.__wbg_ptr, ptr0, len0);
921
1033
  }
1034
+ /**
1035
+ * Per-scheme KMS signatures, one per scheme requested in the request's
1036
+ * `signing_schemes`.
1037
+ * @param {TypedSignature[]} arg0
1038
+ */
1039
+ set signatures(arg0) {
1040
+ const ptr0 = passArrayJsValueToWasm0(arg0, wasm.__wbindgen_malloc);
1041
+ const len0 = WASM_VECTOR_LEN;
1042
+ wasm.__wbg_set_userdecryptionresponse_signatures(this.__wbg_ptr, ptr0, len0);
1043
+ }
922
1044
  }
923
1045
  if (Symbol.dispose) UserDecryptionResponse.prototype[Symbol.dispose] = UserDecryptionResponse.prototype.free;
924
1046
  exports.UserDecryptionResponse = UserDecryptionResponse;
@@ -1668,6 +1790,14 @@ function __wbg_get_imports() {
1668
1790
  const ret = TypedPlaintext.__wrap(arg0);
1669
1791
  return ret;
1670
1792
  },
1793
+ __wbg_typedsignature_new: function(arg0) {
1794
+ const ret = TypedSignature.__wrap(arg0);
1795
+ return ret;
1796
+ },
1797
+ __wbg_typedsignature_unwrap: function(arg0) {
1798
+ const ret = TypedSignature.__unwrap(arg0);
1799
+ return ret;
1800
+ },
1671
1801
  __wbg_typedsigncryptedciphertext_new: function(arg0) {
1672
1802
  const ret = TypedSigncryptedCiphertext.__wrap(arg0);
1673
1803
  return ret;
@@ -1746,6 +1876,9 @@ const TypedCiphertextFinalization = (typeof FinalizationRegistry === 'undefined'
1746
1876
  const TypedPlaintextFinalization = (typeof FinalizationRegistry === 'undefined')
1747
1877
  ? { register: () => {}, unregister: () => {} }
1748
1878
  : new FinalizationRegistry(ptr => wasm.__wbg_typedplaintext_free(ptr, 1));
1879
+ const TypedSignatureFinalization = (typeof FinalizationRegistry === 'undefined')
1880
+ ? { register: () => {}, unregister: () => {} }
1881
+ : new FinalizationRegistry(ptr => wasm.__wbg_typedsignature_free(ptr, 1));
1749
1882
  const TypedSigncryptedCiphertextFinalization = (typeof FinalizationRegistry === 'undefined')
1750
1883
  ? { register: () => {}, unregister: () => {} }
1751
1884
  : new FinalizationRegistry(ptr => wasm.__wbg_typedsigncryptedciphertext_free(ptr, 1));
@@ -1836,6 +1969,11 @@ function debugString(val) {
1836
1969
  return className;
1837
1970
  }
1838
1971
 
1972
+ function getArrayI32FromWasm0(ptr, len) {
1973
+ ptr = ptr >>> 0;
1974
+ return getInt32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
1975
+ }
1976
+
1839
1977
  function getArrayJsValueFromWasm0(ptr, len) {
1840
1978
  ptr = ptr >>> 0;
1841
1979
  const mem = getDataViewMemory0();
@@ -1860,10 +1998,26 @@ function getDataViewMemory0() {
1860
1998
  return cachedDataViewMemory0;
1861
1999
  }
1862
2000
 
2001
+ let cachedInt32ArrayMemory0 = null;
2002
+ function getInt32ArrayMemory0() {
2003
+ if (cachedInt32ArrayMemory0 === null || cachedInt32ArrayMemory0.byteLength === 0) {
2004
+ cachedInt32ArrayMemory0 = new Int32Array(wasm.memory.buffer);
2005
+ }
2006
+ return cachedInt32ArrayMemory0;
2007
+ }
2008
+
1863
2009
  function getStringFromWasm0(ptr, len) {
1864
2010
  return decodeText(ptr >>> 0, len);
1865
2011
  }
1866
2012
 
2013
+ let cachedUint32ArrayMemory0 = null;
2014
+ function getUint32ArrayMemory0() {
2015
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
2016
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
2017
+ }
2018
+ return cachedUint32ArrayMemory0;
2019
+ }
2020
+
1867
2021
  let cachedUint8ArrayMemory0 = null;
1868
2022
  function getUint8ArrayMemory0() {
1869
2023
  if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
@@ -1885,6 +2039,13 @@ function isLikeNone(x) {
1885
2039
  return x === undefined || x === null;
1886
2040
  }
1887
2041
 
2042
+ function passArray32ToWasm0(arg, malloc) {
2043
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
2044
+ getUint32ArrayMemory0().set(arg, ptr / 4);
2045
+ WASM_VECTOR_LEN = arg.length;
2046
+ return ptr;
2047
+ }
2048
+
1888
2049
  function passArray8ToWasm0(arg, malloc) {
1889
2050
  const ptr = malloc(arg.length * 1, 1) >>> 0;
1890
2051
  getUint8ArrayMemory0().set(arg, ptr / 1);
package/kms_lib_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "Zama"
5
5
  ],
6
6
  "description": "Key Management System for the Zama Protocol.",
7
- "version": "v0.14.1-1",
7
+ "version": "v0.15.0-0",
8
8
  "license": "BSD-3-Clause-Clear",
9
9
  "repository": {
10
10
  "type": "git",
@@ -17,4 +17,4 @@
17
17
  ],
18
18
  "main": "kms_lib.js",
19
19
  "types": "kms_lib.d.ts"
20
- }
20
+ }