node-tkms 0.12.5 → 0.13.0-rc.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
@@ -1,60 +1,9 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- export function get_server_addrs(client: Client): ServerIdAddr[];
4
3
  export function ml_kem_pke_sk_to_u8vec(sk: PrivateEncKeyMlKem512): Uint8Array;
5
- export function get_client_address(client: Client): string;
6
- export function u8vec_to_public_sig_key(v: Uint8Array): PublicSigKey;
7
- export function private_sig_key_to_u8vec(sk: PrivateSigKey): Uint8Array;
8
- export function public_sig_key_to_u8vec(pk: PublicSigKey): Uint8Array;
9
- /**
10
- * This function is *not* used by relayer-sdk because the decryption
11
- * is handled by [process_user_decryption_resp].
12
- * It's just here for completeness and tests.
13
- */
14
- export function ml_kem_pke_decrypt(ct: Uint8Array, my_sk: PrivateEncKeyMlKem512): Uint8Array;
15
4
  export function ml_kem_pke_sk_len(): number;
16
- export function ml_kem_pke_pk_len(): number;
17
- /**
18
- * This function is *not* used by relayer-sdk because the encryption
19
- * happens on the KMS side. It's just here for completeness and tests.
20
- */
21
- export function ml_kem_pke_encrypt(msg: Uint8Array, their_pk: PublicEncKeyMlKem512): Uint8Array;
22
- /**
23
- * Create a new [ServerIdAddr] structure that holds an ID and an address
24
- * which must be a valid EIP-55 address, notably prefixed with "0x".
25
- */
26
- export function new_server_id_addr(id: number, addr: string): ServerIdAddr;
27
- export function u8vec_to_ml_kem_pke_sk(v: Uint8Array): PrivateEncKeyMlKem512;
28
- export function ml_kem_pke_get_pk(sk: PrivateEncKeyMlKem512): PublicEncKeyMlKem512;
29
- export function ml_kem_pke_pk_to_u8vec(pk: PublicEncKeyMlKem512): Uint8Array;
30
- export function u8vec_to_private_sig_key(v: Uint8Array): PrivateSigKey;
31
- /**
32
- * Process the user_decryption response from Rust objects.
33
- * Consider using [process_user_decryption_resp_from_js]
34
- * when using the JS API.
35
- * The result is a byte array representing a plaintext of any length.
36
- *
37
- * * `client` - client that wants to perform user_decryption.
38
- *
39
- * * `request` - the initial user_decryption request.
40
- * Must be given if `verify` is true.
41
- *
42
- * * `eip712_domain` - the EIP-712 domain.
43
- * Must be given if `verify` is true.
44
- *
45
- * * `agg_resp` - the vector of user_decryption responses.
46
- *
47
- * * `enc_pk` - The ephemeral public key.
48
- *
49
- * * `enc_sk` - The ephemeral secret key.
50
- *
51
- * * `verify` - Whether to perform signature verification for the response.
52
- * It is insecure if `verify = false`!
53
- */
54
- export function process_user_decryption_resp(client: Client, request: ParsedUserDecryptionRequest | null | undefined, eip712_domain: Eip712DomainMsg | null | undefined, agg_resp: UserDecryptionResponse[], enc_pk: PublicEncKeyMlKem512, enc_sk: PrivateEncKeyMlKem512, verify: boolean): TypedPlaintext[];
55
- export function get_client_secret_key(client: Client): PrivateSigKey | undefined;
56
- export function ml_kem_pke_keygen(): PrivateEncKeyMlKem512;
57
5
  export function u8vec_to_ml_kem_pke_pk(v: Uint8Array): PublicEncKeyMlKem512;
6
+ export function ml_kem_pke_pk_to_u8vec(pk: PublicEncKeyMlKem512): Uint8Array;
58
7
  /**
59
8
  * Process the user_decryption response from JavaScript objects.
60
9
  * The returned result is a byte array representing a plaintext of any length,
@@ -117,6 +66,46 @@ export function u8vec_to_ml_kem_pke_pk(v: Uint8Array): PublicEncKeyMlKem512;
117
66
  * It is insecure if `verify = false`!
118
67
  */
119
68
  export function process_user_decryption_resp_from_js(client: Client, request: any, eip712_domain: any, agg_resp: any, enc_pk: PublicEncKeyMlKem512, enc_sk: PrivateEncKeyMlKem512, verify: boolean): TypedPlaintext[];
69
+ export function ml_kem_pke_pk_len(): number;
70
+ /**
71
+ * This function is *not* used by relayer-sdk because the decryption
72
+ * is handled by [process_user_decryption_resp].
73
+ * It's just here for completeness and tests.
74
+ */
75
+ export function ml_kem_pke_decrypt(ct: Uint8Array, my_sk: PrivateEncKeyMlKem512): Uint8Array;
76
+ export function ml_kem_pke_get_pk(sk: PrivateEncKeyMlKem512): PublicEncKeyMlKem512;
77
+ /**
78
+ * This function is *not* used by relayer-sdk because the encryption
79
+ * happens on the KMS side. It's just here for completeness and tests.
80
+ */
81
+ export function ml_kem_pke_encrypt(msg: Uint8Array, their_pk: PublicEncKeyMlKem512): Uint8Array;
82
+ /**
83
+ * Process the user_decryption response from Rust objects.
84
+ * Consider using [process_user_decryption_resp_from_js]
85
+ * when using the JS API.
86
+ * The result is a byte array representing a plaintext of any length.
87
+ *
88
+ * * `client` - client that wants to perform user_decryption.
89
+ *
90
+ * * `request` - the initial user_decryption request.
91
+ * Must be given if `verify` is true.
92
+ *
93
+ * * `eip712_domain` - the EIP-712 domain.
94
+ * Must be given if `verify` is true.
95
+ *
96
+ * * `agg_resp` - the vector of user_decryption responses.
97
+ *
98
+ * * `enc_pk` - The ephemeral public key.
99
+ *
100
+ * * `enc_sk` - The ephemeral secret key.
101
+ *
102
+ * * `verify` - Whether to perform signature verification for the response.
103
+ * It is insecure if `verify = false`!
104
+ */
105
+ export function process_user_decryption_resp(client: Client, request: ParsedUserDecryptionRequest | null | undefined, eip712_domain: Eip712DomainMsg | null | undefined, agg_resp: UserDecryptionResponse[], enc_pk: PublicEncKeyMlKem512, enc_sk: PrivateEncKeyMlKem512, verify: boolean): TypedPlaintext[];
106
+ export function get_client_secret_key(client: Client): PrivateSigKey | undefined;
107
+ export function get_server_addrs(client: Client): ServerIdAddr[];
108
+ export function ml_kem_pke_keygen(): PrivateEncKeyMlKem512;
120
109
  /**
121
110
  * Instantiate a new client.
122
111
  *
@@ -130,6 +119,17 @@ export function process_user_decryption_resp_from_js(client: Client, request: an
130
119
  * The "default" parameter choice is selected if no matching string is found.
131
120
  */
132
121
  export function new_client(server_addrs: ServerIdAddr[], client_address_hex: string, fhe_parameter: string): Client;
122
+ export function public_sig_key_to_u8vec(pk: PublicSigKey): Uint8Array;
123
+ export function private_sig_key_to_u8vec(sk: PrivateSigKey): Uint8Array;
124
+ export function get_client_address(client: Client): string;
125
+ export function u8vec_to_public_sig_key(v: Uint8Array): PublicSigKey;
126
+ export function u8vec_to_private_sig_key(v: Uint8Array): PrivateSigKey;
127
+ /**
128
+ * Create a new [ServerIdAddr] structure that holds an ID and an address
129
+ * which must be a valid EIP-55 address, notably prefixed with "0x".
130
+ */
131
+ export function new_server_id_addr(id: number, addr: string): ServerIdAddr;
132
+ export function u8vec_to_ml_kem_pke_sk(v: Uint8Array): PrivateEncKeyMlKem512;
133
133
  export class CiphertextHandle {
134
134
  private constructor();
135
135
  free(): void;
package/kms_lib.js CHANGED
@@ -177,28 +177,6 @@ function _assertClass(instance, klass) {
177
177
  }
178
178
  }
179
179
 
180
- function getArrayJsValueFromWasm0(ptr, len) {
181
- ptr = ptr >>> 0;
182
- const mem = getDataViewMemory0();
183
- const result = [];
184
- for (let i = ptr; i < ptr + 4 * len; i += 4) {
185
- result.push(wasm.__wbindgen_export_4.get(mem.getUint32(i, true)));
186
- }
187
- wasm.__externref_drop_slice(ptr, len);
188
- return result;
189
- }
190
- /**
191
- * @param {Client} client
192
- * @returns {ServerIdAddr[]}
193
- */
194
- module.exports.get_server_addrs = function(client) {
195
- _assertClass(client, Client);
196
- const ret = wasm.get_server_addrs(client.__wbg_ptr);
197
- var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
198
- wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
199
- return v1;
200
- };
201
-
202
180
  function takeFromExternrefTable0(idx) {
203
181
  const value = wasm.__wbindgen_export_4.get(idx);
204
182
  wasm.__externref_table_dealloc(idx);
@@ -225,21 +203,11 @@ module.exports.ml_kem_pke_sk_to_u8vec = function(sk) {
225
203
  };
226
204
 
227
205
  /**
228
- * @param {Client} client
229
- * @returns {string}
206
+ * @returns {number}
230
207
  */
231
- module.exports.get_client_address = function(client) {
232
- let deferred1_0;
233
- let deferred1_1;
234
- try {
235
- _assertClass(client, Client);
236
- const ret = wasm.get_client_address(client.__wbg_ptr);
237
- deferred1_0 = ret[0];
238
- deferred1_1 = ret[1];
239
- return getStringFromWasm0(ret[0], ret[1]);
240
- } finally {
241
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
242
- }
208
+ module.exports.ml_kem_pke_sk_len = function() {
209
+ const ret = wasm.ml_kem_pke_sk_len();
210
+ return ret >>> 0;
243
211
  };
244
212
 
245
213
  function passArray8ToWasm0(arg, malloc) {
@@ -250,25 +218,25 @@ function passArray8ToWasm0(arg, malloc) {
250
218
  }
251
219
  /**
252
220
  * @param {Uint8Array} v
253
- * @returns {PublicSigKey}
221
+ * @returns {PublicEncKeyMlKem512}
254
222
  */
255
- module.exports.u8vec_to_public_sig_key = function(v) {
223
+ module.exports.u8vec_to_ml_kem_pke_pk = function(v) {
256
224
  const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
257
225
  const len0 = WASM_VECTOR_LEN;
258
- const ret = wasm.u8vec_to_public_sig_key(ptr0, len0);
226
+ const ret = wasm.u8vec_to_ml_kem_pke_pk(ptr0, len0);
259
227
  if (ret[2]) {
260
228
  throw takeFromExternrefTable0(ret[1]);
261
229
  }
262
- return PublicSigKey.__wrap(ret[0]);
230
+ return PublicEncKeyMlKem512.__wrap(ret[0]);
263
231
  };
264
232
 
265
233
  /**
266
- * @param {PrivateSigKey} sk
234
+ * @param {PublicEncKeyMlKem512} pk
267
235
  * @returns {Uint8Array}
268
236
  */
269
- module.exports.private_sig_key_to_u8vec = function(sk) {
270
- _assertClass(sk, PrivateSigKey);
271
- const ret = wasm.private_sig_key_to_u8vec(sk.__wbg_ptr);
237
+ module.exports.ml_kem_pke_pk_to_u8vec = function(pk) {
238
+ _assertClass(pk, PublicEncKeyMlKem512);
239
+ const ret = wasm.ml_kem_pke_pk_to_u8vec(pk.__wbg_ptr);
272
240
  if (ret[3]) {
273
241
  throw takeFromExternrefTable0(ret[2]);
274
242
  }
@@ -277,18 +245,106 @@ module.exports.private_sig_key_to_u8vec = function(sk) {
277
245
  return v1;
278
246
  };
279
247
 
248
+ function getArrayJsValueFromWasm0(ptr, len) {
249
+ ptr = ptr >>> 0;
250
+ const mem = getDataViewMemory0();
251
+ const result = [];
252
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
253
+ result.push(wasm.__wbindgen_export_4.get(mem.getUint32(i, true)));
254
+ }
255
+ wasm.__externref_drop_slice(ptr, len);
256
+ return result;
257
+ }
280
258
  /**
281
- * @param {PublicSigKey} pk
282
- * @returns {Uint8Array}
259
+ * Process the user_decryption response from JavaScript objects.
260
+ * The returned result is a byte array representing a plaintext of any length,
261
+ * postprocessing is returned to turn it into an integer.
262
+ *
263
+ * * `client` - client that wants to perform user_decryption.
264
+ *
265
+ * * `request` - the initial user_decryption request JS object.
266
+ * It can be set to null if `verify` is false.
267
+ * Otherwise the caller needs to give the following JS object.
268
+ * Note that `client_address` and `eip712_verifying_contract` follow EIP-55.
269
+ * The signature field is not needed.
270
+ * ```
271
+ * {
272
+ * signature: undefined,
273
+ * client_address: '0x17853A630aAe15AED549B2B874de08B73C0F59c5',
274
+ * enc_key: '2000000000000000df2fcacb774f03187f3802a27259f45c06d33cefa68d9c53426b15ad531aa822',
275
+ * ciphertext_handles: [ '0748b542afe2353c86cb707e3d21044b0be1fd18efc7cbaa6a415af055bfb358' ]
276
+ * eip712_verifying_contract: '0x66f9664f97F2b50F62D13eA064982f936dE76657'
277
+ * }
278
+ * ```
279
+ *
280
+ * * `eip712_domain` - the EIP-712 domain JS object.
281
+ * It can be set to null if `verify` is false.
282
+ * Otherwise the caller needs to give the following JS object.
283
+ * Note that `salt` is optional and `verifying_contract` follows EIP-55,
284
+ * additionally, `chain_id` is an array of u8.
285
+ * ```
286
+ * {
287
+ * name: 'Authorization token',
288
+ * version: '1',
289
+ * chain_id: [
290
+ * 70, 31, 0, 0, 0, 0, 0, 0, 0,
291
+ * 0, 0, 0, 0, 0, 0, 0, 0, 0,
292
+ * 0, 0, 0, 0, 0, 0, 0, 0, 0,
293
+ * 0, 0, 0, 0, 0
294
+ * ],
295
+ * verifying_contract: '0x66f9664f97F2b50F62D13eA064982f936dE76657',
296
+ * salt: []
297
+ * }
298
+ * ```
299
+ *
300
+ * * `agg_resp` - the response JS object from the gateway.
301
+ * It has two fields like so, both are hex encoded byte arrays.
302
+ * ```
303
+ * [
304
+ * {
305
+ * signature: '69e7e040cab157aa819015b321c012dccb1545ffefd325b359b492653f0347517e28e66c572cdc299e259024329859ff9fcb0096e1ce072af0b6e1ca1fe25ec6',
306
+ * payload: '0100000029...',
307
+ * extra_data: '01234...',
308
+ * }
309
+ * ]
310
+ * ```
311
+ *
312
+ * * `enc_pk` - The ephemeral public key.
313
+ *
314
+ * * `enc_sk` - The ephemeral secret key.
315
+ *
316
+ * * `verify` - Whether to perform signature verification for the response.
317
+ * It is insecure if `verify = false`!
318
+ * @param {Client} client
319
+ * @param {any} request
320
+ * @param {any} eip712_domain
321
+ * @param {any} agg_resp
322
+ * @param {PublicEncKeyMlKem512} enc_pk
323
+ * @param {PrivateEncKeyMlKem512} enc_sk
324
+ * @param {boolean} verify
325
+ * @returns {TypedPlaintext[]}
283
326
  */
284
- module.exports.public_sig_key_to_u8vec = function(pk) {
285
- _assertClass(pk, PublicSigKey);
286
- const ret = wasm.public_sig_key_to_u8vec(pk.__wbg_ptr);
287
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
288
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
327
+ module.exports.process_user_decryption_resp_from_js = function(client, request, eip712_domain, agg_resp, enc_pk, enc_sk, verify) {
328
+ _assertClass(client, Client);
329
+ _assertClass(enc_pk, PublicEncKeyMlKem512);
330
+ _assertClass(enc_sk, PrivateEncKeyMlKem512);
331
+ 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);
332
+ if (ret[3]) {
333
+ throw takeFromExternrefTable0(ret[2]);
334
+ }
335
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
336
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
289
337
  return v1;
290
338
  };
291
339
 
340
+ /**
341
+ * @returns {number}
342
+ */
343
+ module.exports.ml_kem_pke_pk_len = function() {
344
+ const ret = wasm.ml_kem_pke_pk_len();
345
+ return ret >>> 0;
346
+ };
347
+
292
348
  /**
293
349
  * This function is *not* used by relayer-sdk because the decryption
294
350
  * is handled by [process_user_decryption_resp].
@@ -308,19 +364,13 @@ module.exports.ml_kem_pke_decrypt = function(ct, my_sk) {
308
364
  };
309
365
 
310
366
  /**
311
- * @returns {number}
312
- */
313
- module.exports.ml_kem_pke_sk_len = function() {
314
- const ret = wasm.ml_kem_pke_sk_len();
315
- return ret >>> 0;
316
- };
317
-
318
- /**
319
- * @returns {number}
367
+ * @param {PrivateEncKeyMlKem512} sk
368
+ * @returns {PublicEncKeyMlKem512}
320
369
  */
321
- module.exports.ml_kem_pke_pk_len = function() {
322
- const ret = wasm.ml_kem_pke_pk_len();
323
- return ret >>> 0;
370
+ module.exports.ml_kem_pke_get_pk = function(sk) {
371
+ _assertClass(sk, PrivateEncKeyMlKem512);
372
+ const ret = wasm.ml_kem_pke_get_pk(sk.__wbg_ptr);
373
+ return PublicEncKeyMlKem512.__wrap(ret);
324
374
  };
325
375
 
326
376
  /**
@@ -340,76 +390,6 @@ module.exports.ml_kem_pke_encrypt = function(msg, their_pk) {
340
390
  return v2;
341
391
  };
342
392
 
343
- /**
344
- * Create a new [ServerIdAddr] structure that holds an ID and an address
345
- * which must be a valid EIP-55 address, notably prefixed with "0x".
346
- * @param {number} id
347
- * @param {string} addr
348
- * @returns {ServerIdAddr}
349
- */
350
- module.exports.new_server_id_addr = function(id, addr) {
351
- const ptr0 = passStringToWasm0(addr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
352
- const len0 = WASM_VECTOR_LEN;
353
- const ret = wasm.new_server_id_addr(id, ptr0, len0);
354
- if (ret[2]) {
355
- throw takeFromExternrefTable0(ret[1]);
356
- }
357
- return ServerIdAddr.__wrap(ret[0]);
358
- };
359
-
360
- /**
361
- * @param {Uint8Array} v
362
- * @returns {PrivateEncKeyMlKem512}
363
- */
364
- module.exports.u8vec_to_ml_kem_pke_sk = function(v) {
365
- const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
366
- const len0 = WASM_VECTOR_LEN;
367
- const ret = wasm.u8vec_to_ml_kem_pke_sk(ptr0, len0);
368
- if (ret[2]) {
369
- throw takeFromExternrefTable0(ret[1]);
370
- }
371
- return PrivateEncKeyMlKem512.__wrap(ret[0]);
372
- };
373
-
374
- /**
375
- * @param {PrivateEncKeyMlKem512} sk
376
- * @returns {PublicEncKeyMlKem512}
377
- */
378
- module.exports.ml_kem_pke_get_pk = function(sk) {
379
- _assertClass(sk, PrivateEncKeyMlKem512);
380
- const ret = wasm.ml_kem_pke_get_pk(sk.__wbg_ptr);
381
- return PublicEncKeyMlKem512.__wrap(ret);
382
- };
383
-
384
- /**
385
- * @param {PublicEncKeyMlKem512} pk
386
- * @returns {Uint8Array}
387
- */
388
- module.exports.ml_kem_pke_pk_to_u8vec = function(pk) {
389
- _assertClass(pk, PublicEncKeyMlKem512);
390
- const ret = wasm.ml_kem_pke_pk_to_u8vec(pk.__wbg_ptr);
391
- if (ret[3]) {
392
- throw takeFromExternrefTable0(ret[2]);
393
- }
394
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
395
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
396
- return v1;
397
- };
398
-
399
- /**
400
- * @param {Uint8Array} v
401
- * @returns {PrivateSigKey}
402
- */
403
- module.exports.u8vec_to_private_sig_key = function(v) {
404
- const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
405
- const len0 = WASM_VECTOR_LEN;
406
- const ret = wasm.u8vec_to_private_sig_key(ptr0, len0);
407
- if (ret[2]) {
408
- throw takeFromExternrefTable0(ret[1]);
409
- }
410
- return PrivateSigKey.__wrap(ret[0]);
411
- };
412
-
413
393
  function passArrayJsValueToWasm0(array, malloc) {
414
394
  const ptr = malloc(array.length * 4, 4) >>> 0;
415
395
  for (let i = 0; i < array.length; i++) {
@@ -486,109 +466,25 @@ module.exports.get_client_secret_key = function(client) {
486
466
  };
487
467
 
488
468
  /**
489
- * @returns {PrivateEncKeyMlKem512}
490
- */
491
- module.exports.ml_kem_pke_keygen = function() {
492
- const ret = wasm.ml_kem_pke_keygen();
493
- return PrivateEncKeyMlKem512.__wrap(ret);
494
- };
495
-
496
- /**
497
- * @param {Uint8Array} v
498
- * @returns {PublicEncKeyMlKem512}
499
- */
500
- module.exports.u8vec_to_ml_kem_pke_pk = function(v) {
501
- const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
502
- const len0 = WASM_VECTOR_LEN;
503
- const ret = wasm.u8vec_to_ml_kem_pke_pk(ptr0, len0);
504
- if (ret[2]) {
505
- throw takeFromExternrefTable0(ret[1]);
506
- }
507
- return PublicEncKeyMlKem512.__wrap(ret[0]);
508
- };
509
-
510
- /**
511
- * Process the user_decryption response from JavaScript objects.
512
- * The returned result is a byte array representing a plaintext of any length,
513
- * postprocessing is returned to turn it into an integer.
514
- *
515
- * * `client` - client that wants to perform user_decryption.
516
- *
517
- * * `request` - the initial user_decryption request JS object.
518
- * It can be set to null if `verify` is false.
519
- * Otherwise the caller needs to give the following JS object.
520
- * Note that `client_address` and `eip712_verifying_contract` follow EIP-55.
521
- * The signature field is not needed.
522
- * ```
523
- * {
524
- * signature: undefined,
525
- * client_address: '0x17853A630aAe15AED549B2B874de08B73C0F59c5',
526
- * enc_key: '2000000000000000df2fcacb774f03187f3802a27259f45c06d33cefa68d9c53426b15ad531aa822',
527
- * ciphertext_handles: [ '0748b542afe2353c86cb707e3d21044b0be1fd18efc7cbaa6a415af055bfb358' ]
528
- * eip712_verifying_contract: '0x66f9664f97F2b50F62D13eA064982f936dE76657'
529
- * }
530
- * ```
531
- *
532
- * * `eip712_domain` - the EIP-712 domain JS object.
533
- * It can be set to null if `verify` is false.
534
- * Otherwise the caller needs to give the following JS object.
535
- * Note that `salt` is optional and `verifying_contract` follows EIP-55,
536
- * additionally, `chain_id` is an array of u8.
537
- * ```
538
- * {
539
- * name: 'Authorization token',
540
- * version: '1',
541
- * chain_id: [
542
- * 70, 31, 0, 0, 0, 0, 0, 0, 0,
543
- * 0, 0, 0, 0, 0, 0, 0, 0, 0,
544
- * 0, 0, 0, 0, 0, 0, 0, 0, 0,
545
- * 0, 0, 0, 0, 0
546
- * ],
547
- * verifying_contract: '0x66f9664f97F2b50F62D13eA064982f936dE76657',
548
- * salt: []
549
- * }
550
- * ```
551
- *
552
- * * `agg_resp` - the response JS object from the gateway.
553
- * It has two fields like so, both are hex encoded byte arrays.
554
- * ```
555
- * [
556
- * {
557
- * signature: '69e7e040cab157aa819015b321c012dccb1545ffefd325b359b492653f0347517e28e66c572cdc299e259024329859ff9fcb0096e1ce072af0b6e1ca1fe25ec6',
558
- * payload: '0100000029...',
559
- * extra_data: '01234...',
560
- * }
561
- * ]
562
- * ```
563
- *
564
- * * `enc_pk` - The ephemeral public key.
565
- *
566
- * * `enc_sk` - The ephemeral secret key.
567
- *
568
- * * `verify` - Whether to perform signature verification for the response.
569
- * It is insecure if `verify = false`!
570
469
  * @param {Client} client
571
- * @param {any} request
572
- * @param {any} eip712_domain
573
- * @param {any} agg_resp
574
- * @param {PublicEncKeyMlKem512} enc_pk
575
- * @param {PrivateEncKeyMlKem512} enc_sk
576
- * @param {boolean} verify
577
- * @returns {TypedPlaintext[]}
470
+ * @returns {ServerIdAddr[]}
578
471
  */
579
- module.exports.process_user_decryption_resp_from_js = function(client, request, eip712_domain, agg_resp, enc_pk, enc_sk, verify) {
472
+ module.exports.get_server_addrs = function(client) {
580
473
  _assertClass(client, Client);
581
- _assertClass(enc_pk, PublicEncKeyMlKem512);
582
- _assertClass(enc_sk, PrivateEncKeyMlKem512);
583
- 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);
584
- if (ret[3]) {
585
- throw takeFromExternrefTable0(ret[2]);
586
- }
474
+ const ret = wasm.get_server_addrs(client.__wbg_ptr);
587
475
  var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
588
476
  wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
589
477
  return v1;
590
478
  };
591
479
 
480
+ /**
481
+ * @returns {PrivateEncKeyMlKem512}
482
+ */
483
+ module.exports.ml_kem_pke_keygen = function() {
484
+ const ret = wasm.ml_kem_pke_keygen();
485
+ return PrivateEncKeyMlKem512.__wrap(ret);
486
+ };
487
+
592
488
  /**
593
489
  * Instantiate a new client.
594
490
  *
@@ -619,6 +515,110 @@ module.exports.new_client = function(server_addrs, client_address_hex, fhe_param
619
515
  return Client.__wrap(ret[0]);
620
516
  };
621
517
 
518
+ /**
519
+ * @param {PublicSigKey} pk
520
+ * @returns {Uint8Array}
521
+ */
522
+ module.exports.public_sig_key_to_u8vec = function(pk) {
523
+ _assertClass(pk, PublicSigKey);
524
+ const ret = wasm.public_sig_key_to_u8vec(pk.__wbg_ptr);
525
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
526
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
527
+ return v1;
528
+ };
529
+
530
+ /**
531
+ * @param {PrivateSigKey} sk
532
+ * @returns {Uint8Array}
533
+ */
534
+ module.exports.private_sig_key_to_u8vec = function(sk) {
535
+ _assertClass(sk, PrivateSigKey);
536
+ const ret = wasm.private_sig_key_to_u8vec(sk.__wbg_ptr);
537
+ if (ret[3]) {
538
+ throw takeFromExternrefTable0(ret[2]);
539
+ }
540
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
541
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
542
+ return v1;
543
+ };
544
+
545
+ /**
546
+ * @param {Client} client
547
+ * @returns {string}
548
+ */
549
+ module.exports.get_client_address = function(client) {
550
+ let deferred1_0;
551
+ let deferred1_1;
552
+ try {
553
+ _assertClass(client, Client);
554
+ const ret = wasm.get_client_address(client.__wbg_ptr);
555
+ deferred1_0 = ret[0];
556
+ deferred1_1 = ret[1];
557
+ return getStringFromWasm0(ret[0], ret[1]);
558
+ } finally {
559
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
560
+ }
561
+ };
562
+
563
+ /**
564
+ * @param {Uint8Array} v
565
+ * @returns {PublicSigKey}
566
+ */
567
+ module.exports.u8vec_to_public_sig_key = function(v) {
568
+ const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
569
+ const len0 = WASM_VECTOR_LEN;
570
+ const ret = wasm.u8vec_to_public_sig_key(ptr0, len0);
571
+ if (ret[2]) {
572
+ throw takeFromExternrefTable0(ret[1]);
573
+ }
574
+ return PublicSigKey.__wrap(ret[0]);
575
+ };
576
+
577
+ /**
578
+ * @param {Uint8Array} v
579
+ * @returns {PrivateSigKey}
580
+ */
581
+ module.exports.u8vec_to_private_sig_key = function(v) {
582
+ const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
583
+ const len0 = WASM_VECTOR_LEN;
584
+ const ret = wasm.u8vec_to_private_sig_key(ptr0, len0);
585
+ if (ret[2]) {
586
+ throw takeFromExternrefTable0(ret[1]);
587
+ }
588
+ return PrivateSigKey.__wrap(ret[0]);
589
+ };
590
+
591
+ /**
592
+ * Create a new [ServerIdAddr] structure that holds an ID and an address
593
+ * which must be a valid EIP-55 address, notably prefixed with "0x".
594
+ * @param {number} id
595
+ * @param {string} addr
596
+ * @returns {ServerIdAddr}
597
+ */
598
+ module.exports.new_server_id_addr = function(id, addr) {
599
+ const ptr0 = passStringToWasm0(addr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
600
+ const len0 = WASM_VECTOR_LEN;
601
+ const ret = wasm.new_server_id_addr(id, ptr0, len0);
602
+ if (ret[2]) {
603
+ throw takeFromExternrefTable0(ret[1]);
604
+ }
605
+ return ServerIdAddr.__wrap(ret[0]);
606
+ };
607
+
608
+ /**
609
+ * @param {Uint8Array} v
610
+ * @returns {PrivateEncKeyMlKem512}
611
+ */
612
+ module.exports.u8vec_to_ml_kem_pke_sk = function(v) {
613
+ const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
614
+ const len0 = WASM_VECTOR_LEN;
615
+ const ret = wasm.u8vec_to_ml_kem_pke_sk(ptr0, len0);
616
+ if (ret[2]) {
617
+ throw takeFromExternrefTable0(ret[1]);
618
+ }
619
+ return PrivateEncKeyMlKem512.__wrap(ret[0]);
620
+ };
621
+
622
622
  const CiphertextHandleFinalization = (typeof FinalizationRegistry === 'undefined')
623
623
  ? { register: () => {}, unregister: () => {} }
624
624
  : new FinalizationRegistry(ptr => wasm.__wbg_ciphertexthandle_free(ptr >>> 0, 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": "0.12.5",
7
+ "version": "v0.13.0-rc.0",
8
8
  "license": "BSD-3-Clause-Clear",
9
9
  "repository": {
10
10
  "type": "git",