node-tkms 0.12.8 → 0.13.0-rc.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.d.ts +34 -34
- package/kms_lib.js +186 -185
- package/kms_lib_bg.wasm +0 -0
- package/package.json +1 -1
package/kms_lib.d.ts
CHANGED
|
@@ -5,9 +5,33 @@
|
|
|
5
5
|
* happens on the KMS side. It's just here for completeness and tests.
|
|
6
6
|
*/
|
|
7
7
|
export function ml_kem_pke_encrypt(msg: Uint8Array, their_pk: PublicEncKeyMlKem512): Uint8Array;
|
|
8
|
+
/**
|
|
9
|
+
* Instantiate a new client.
|
|
10
|
+
*
|
|
11
|
+
* * `server_addrs` - a list of KMS server ID with EIP-55 addresses,
|
|
12
|
+
* the elements in the list can be created using [new_server_id_addr].
|
|
13
|
+
*
|
|
14
|
+
* * `client_address_hex` - the client (wallet) address in hex,
|
|
15
|
+
* must be prefixed with "0x".
|
|
16
|
+
*
|
|
17
|
+
* * `fhe_parameter` - the parameter choice, which can be either `"test"` or `"default"`.
|
|
18
|
+
* The "default" parameter choice is selected if no matching string is found.
|
|
19
|
+
*/
|
|
20
|
+
export function new_client(server_addrs: ServerIdAddr[], client_address_hex: string, fhe_parameter: string): Client;
|
|
21
|
+
export function ml_kem_pke_keygen(): PrivateEncKeyMlKem512;
|
|
22
|
+
export function ml_kem_pke_get_pk(sk: PrivateEncKeyMlKem512): PublicEncKeyMlKem512;
|
|
23
|
+
export function u8vec_to_private_sig_key(v: Uint8Array): PrivateSigKey;
|
|
24
|
+
export function public_sig_key_to_u8vec(pk: PublicSigKey): Uint8Array;
|
|
25
|
+
/**
|
|
26
|
+
* This function is *not* used by relayer-sdk because the decryption
|
|
27
|
+
* is handled by [process_user_decryption_resp].
|
|
28
|
+
* It's just here for completeness and tests.
|
|
29
|
+
*/
|
|
30
|
+
export function ml_kem_pke_decrypt(ct: Uint8Array, my_sk: PrivateEncKeyMlKem512): Uint8Array;
|
|
8
31
|
export function u8vec_to_public_sig_key(v: Uint8Array): PublicSigKey;
|
|
32
|
+
export function u8vec_to_ml_kem_pke_pk(v: Uint8Array): PublicEncKeyMlKem512;
|
|
9
33
|
export function ml_kem_pke_pk_len(): number;
|
|
10
|
-
export function
|
|
34
|
+
export function get_server_addrs(client: Client): ServerIdAddr[];
|
|
11
35
|
/**
|
|
12
36
|
* Process the user_decryption response from JavaScript objects.
|
|
13
37
|
* The returned result is a byte array representing a plaintext of any length,
|
|
@@ -70,7 +94,15 @@ export function u8vec_to_private_sig_key(v: Uint8Array): PrivateSigKey;
|
|
|
70
94
|
* It is insecure if `verify = false`!
|
|
71
95
|
*/
|
|
72
96
|
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[];
|
|
97
|
+
/**
|
|
98
|
+
* Create a new [ServerIdAddr] structure that holds an ID and an address
|
|
99
|
+
* which must be a valid EIP-55 address, notably prefixed with "0x".
|
|
100
|
+
*/
|
|
101
|
+
export function new_server_id_addr(id: number, addr: string): ServerIdAddr;
|
|
102
|
+
export function ml_kem_pke_sk_len(): number;
|
|
73
103
|
export function private_sig_key_to_u8vec(sk: PrivateSigKey): Uint8Array;
|
|
104
|
+
export function u8vec_to_ml_kem_pke_sk(v: Uint8Array): PrivateEncKeyMlKem512;
|
|
105
|
+
export function get_client_address(client: Client): string;
|
|
74
106
|
/**
|
|
75
107
|
* Process the user_decryption response from Rust objects.
|
|
76
108
|
* Consider using [process_user_decryption_resp_from_js]
|
|
@@ -95,41 +127,9 @@ export function private_sig_key_to_u8vec(sk: PrivateSigKey): Uint8Array;
|
|
|
95
127
|
* It is insecure if `verify = false`!
|
|
96
128
|
*/
|
|
97
129
|
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[];
|
|
98
|
-
/**
|
|
99
|
-
* Create a new [ServerIdAddr] structure that holds an ID and an address
|
|
100
|
-
* which must be a valid EIP-55 address, notably prefixed with "0x".
|
|
101
|
-
*/
|
|
102
|
-
export function new_server_id_addr(id: number, addr: string): ServerIdAddr;
|
|
103
|
-
export function ml_kem_pke_pk_to_u8vec(pk: PublicEncKeyMlKem512): Uint8Array;
|
|
104
130
|
export function get_client_secret_key(client: Client): PrivateSigKey | undefined;
|
|
105
|
-
export function
|
|
106
|
-
export function ml_kem_pke_keygen(): PrivateEncKeyMlKem512;
|
|
107
|
-
export function get_client_address(client: Client): string;
|
|
131
|
+
export function ml_kem_pke_pk_to_u8vec(pk: PublicEncKeyMlKem512): Uint8Array;
|
|
108
132
|
export function ml_kem_pke_sk_to_u8vec(sk: PrivateEncKeyMlKem512): Uint8Array;
|
|
109
|
-
export function get_server_addrs(client: Client): ServerIdAddr[];
|
|
110
|
-
export function u8vec_to_ml_kem_pke_pk(v: Uint8Array): PublicEncKeyMlKem512;
|
|
111
|
-
export function u8vec_to_ml_kem_pke_sk(v: Uint8Array): PrivateEncKeyMlKem512;
|
|
112
|
-
export function ml_kem_pke_sk_len(): number;
|
|
113
|
-
/**
|
|
114
|
-
* This function is *not* used by relayer-sdk because the decryption
|
|
115
|
-
* is handled by [process_user_decryption_resp].
|
|
116
|
-
* It's just here for completeness and tests.
|
|
117
|
-
*/
|
|
118
|
-
export function ml_kem_pke_decrypt(ct: Uint8Array, my_sk: PrivateEncKeyMlKem512): Uint8Array;
|
|
119
|
-
/**
|
|
120
|
-
* Instantiate a new client.
|
|
121
|
-
*
|
|
122
|
-
* * `server_addrs` - a list of KMS server ID with EIP-55 addresses,
|
|
123
|
-
* the elements in the list can be created using [new_server_id_addr].
|
|
124
|
-
*
|
|
125
|
-
* * `client_address_hex` - the client (wallet) address in hex,
|
|
126
|
-
* must be prefixed with "0x".
|
|
127
|
-
*
|
|
128
|
-
* * `fhe_parameter` - the parameter choice, which can be either `"test"` or `"default"`.
|
|
129
|
-
* The "default" parameter choice is selected if no matching string is found.
|
|
130
|
-
*/
|
|
131
|
-
export function new_client(server_addrs: ServerIdAddr[], client_address_hex: string, fhe_parameter: string): Client;
|
|
132
|
-
export function ml_kem_pke_get_pk(sk: PrivateEncKeyMlKem512): PublicEncKeyMlKem512;
|
|
133
133
|
export class CiphertextHandle {
|
|
134
134
|
private constructor();
|
|
135
135
|
free(): void;
|
package/kms_lib.js
CHANGED
|
@@ -205,31 +205,67 @@ module.exports.ml_kem_pke_encrypt = function(msg, their_pk) {
|
|
|
205
205
|
return v2;
|
|
206
206
|
};
|
|
207
207
|
|
|
208
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
209
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
210
|
+
for (let i = 0; i < array.length; i++) {
|
|
211
|
+
const add = addToExternrefTable0(array[i]);
|
|
212
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
213
|
+
}
|
|
214
|
+
WASM_VECTOR_LEN = array.length;
|
|
215
|
+
return ptr;
|
|
216
|
+
}
|
|
217
|
+
|
|
208
218
|
function takeFromExternrefTable0(idx) {
|
|
209
219
|
const value = wasm.__wbindgen_export_4.get(idx);
|
|
210
220
|
wasm.__externref_table_dealloc(idx);
|
|
211
221
|
return value;
|
|
212
222
|
}
|
|
213
223
|
/**
|
|
214
|
-
*
|
|
215
|
-
*
|
|
224
|
+
* Instantiate a new client.
|
|
225
|
+
*
|
|
226
|
+
* * `server_addrs` - a list of KMS server ID with EIP-55 addresses,
|
|
227
|
+
* the elements in the list can be created using [new_server_id_addr].
|
|
228
|
+
*
|
|
229
|
+
* * `client_address_hex` - the client (wallet) address in hex,
|
|
230
|
+
* must be prefixed with "0x".
|
|
231
|
+
*
|
|
232
|
+
* * `fhe_parameter` - the parameter choice, which can be either `"test"` or `"default"`.
|
|
233
|
+
* The "default" parameter choice is selected if no matching string is found.
|
|
234
|
+
* @param {ServerIdAddr[]} server_addrs
|
|
235
|
+
* @param {string} client_address_hex
|
|
236
|
+
* @param {string} fhe_parameter
|
|
237
|
+
* @returns {Client}
|
|
216
238
|
*/
|
|
217
|
-
module.exports.
|
|
218
|
-
const ptr0 =
|
|
239
|
+
module.exports.new_client = function(server_addrs, client_address_hex, fhe_parameter) {
|
|
240
|
+
const ptr0 = passArrayJsValueToWasm0(server_addrs, wasm.__wbindgen_malloc);
|
|
219
241
|
const len0 = WASM_VECTOR_LEN;
|
|
220
|
-
const
|
|
242
|
+
const ptr1 = passStringToWasm0(client_address_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
243
|
+
const len1 = WASM_VECTOR_LEN;
|
|
244
|
+
const ptr2 = passStringToWasm0(fhe_parameter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
245
|
+
const len2 = WASM_VECTOR_LEN;
|
|
246
|
+
const ret = wasm.new_client(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
221
247
|
if (ret[2]) {
|
|
222
248
|
throw takeFromExternrefTable0(ret[1]);
|
|
223
249
|
}
|
|
224
|
-
return
|
|
250
|
+
return Client.__wrap(ret[0]);
|
|
225
251
|
};
|
|
226
252
|
|
|
227
253
|
/**
|
|
228
|
-
* @returns {
|
|
254
|
+
* @returns {PrivateEncKeyMlKem512}
|
|
229
255
|
*/
|
|
230
|
-
module.exports.
|
|
231
|
-
const ret = wasm.
|
|
232
|
-
return ret
|
|
256
|
+
module.exports.ml_kem_pke_keygen = function() {
|
|
257
|
+
const ret = wasm.ml_kem_pke_keygen();
|
|
258
|
+
return PrivateEncKeyMlKem512.__wrap(ret);
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* @param {PrivateEncKeyMlKem512} sk
|
|
263
|
+
* @returns {PublicEncKeyMlKem512}
|
|
264
|
+
*/
|
|
265
|
+
module.exports.ml_kem_pke_get_pk = function(sk) {
|
|
266
|
+
_assertClass(sk, PrivateEncKeyMlKem512);
|
|
267
|
+
const ret = wasm.ml_kem_pke_get_pk(sk.__wbg_ptr);
|
|
268
|
+
return PublicEncKeyMlKem512.__wrap(ret);
|
|
233
269
|
};
|
|
234
270
|
|
|
235
271
|
/**
|
|
@@ -246,6 +282,72 @@ module.exports.u8vec_to_private_sig_key = function(v) {
|
|
|
246
282
|
return PrivateSigKey.__wrap(ret[0]);
|
|
247
283
|
};
|
|
248
284
|
|
|
285
|
+
/**
|
|
286
|
+
* @param {PublicSigKey} pk
|
|
287
|
+
* @returns {Uint8Array}
|
|
288
|
+
*/
|
|
289
|
+
module.exports.public_sig_key_to_u8vec = function(pk) {
|
|
290
|
+
_assertClass(pk, PublicSigKey);
|
|
291
|
+
const ret = wasm.public_sig_key_to_u8vec(pk.__wbg_ptr);
|
|
292
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
293
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
294
|
+
return v1;
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* This function is *not* used by relayer-sdk because the decryption
|
|
299
|
+
* is handled by [process_user_decryption_resp].
|
|
300
|
+
* It's just here for completeness and tests.
|
|
301
|
+
* @param {Uint8Array} ct
|
|
302
|
+
* @param {PrivateEncKeyMlKem512} my_sk
|
|
303
|
+
* @returns {Uint8Array}
|
|
304
|
+
*/
|
|
305
|
+
module.exports.ml_kem_pke_decrypt = function(ct, my_sk) {
|
|
306
|
+
const ptr0 = passArray8ToWasm0(ct, wasm.__wbindgen_malloc);
|
|
307
|
+
const len0 = WASM_VECTOR_LEN;
|
|
308
|
+
_assertClass(my_sk, PrivateEncKeyMlKem512);
|
|
309
|
+
const ret = wasm.ml_kem_pke_decrypt(ptr0, len0, my_sk.__wbg_ptr);
|
|
310
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
311
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
312
|
+
return v2;
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* @param {Uint8Array} v
|
|
317
|
+
* @returns {PublicSigKey}
|
|
318
|
+
*/
|
|
319
|
+
module.exports.u8vec_to_public_sig_key = function(v) {
|
|
320
|
+
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
321
|
+
const len0 = WASM_VECTOR_LEN;
|
|
322
|
+
const ret = wasm.u8vec_to_public_sig_key(ptr0, len0);
|
|
323
|
+
if (ret[2]) {
|
|
324
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
325
|
+
}
|
|
326
|
+
return PublicSigKey.__wrap(ret[0]);
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* @param {Uint8Array} v
|
|
331
|
+
* @returns {PublicEncKeyMlKem512}
|
|
332
|
+
*/
|
|
333
|
+
module.exports.u8vec_to_ml_kem_pke_pk = function(v) {
|
|
334
|
+
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
335
|
+
const len0 = WASM_VECTOR_LEN;
|
|
336
|
+
const ret = wasm.u8vec_to_ml_kem_pke_pk(ptr0, len0);
|
|
337
|
+
if (ret[2]) {
|
|
338
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
339
|
+
}
|
|
340
|
+
return PublicEncKeyMlKem512.__wrap(ret[0]);
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* @returns {number}
|
|
345
|
+
*/
|
|
346
|
+
module.exports.ml_kem_pke_pk_len = function() {
|
|
347
|
+
const ret = wasm.ml_kem_pke_pk_len();
|
|
348
|
+
return ret >>> 0;
|
|
349
|
+
};
|
|
350
|
+
|
|
249
351
|
function getArrayJsValueFromWasm0(ptr, len) {
|
|
250
352
|
ptr = ptr >>> 0;
|
|
251
353
|
const mem = getDataViewMemory0();
|
|
@@ -256,6 +358,18 @@ function getArrayJsValueFromWasm0(ptr, len) {
|
|
|
256
358
|
wasm.__externref_drop_slice(ptr, len);
|
|
257
359
|
return result;
|
|
258
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* @param {Client} client
|
|
363
|
+
* @returns {ServerIdAddr[]}
|
|
364
|
+
*/
|
|
365
|
+
module.exports.get_server_addrs = function(client) {
|
|
366
|
+
_assertClass(client, Client);
|
|
367
|
+
const ret = wasm.get_server_addrs(client.__wbg_ptr);
|
|
368
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
369
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
370
|
+
return v1;
|
|
371
|
+
};
|
|
372
|
+
|
|
259
373
|
/**
|
|
260
374
|
* Process the user_decryption response from JavaScript objects.
|
|
261
375
|
* The returned result is a byte array representing a plaintext of any length,
|
|
@@ -338,6 +452,31 @@ module.exports.process_user_decryption_resp_from_js = function(client, request,
|
|
|
338
452
|
return v1;
|
|
339
453
|
};
|
|
340
454
|
|
|
455
|
+
/**
|
|
456
|
+
* Create a new [ServerIdAddr] structure that holds an ID and an address
|
|
457
|
+
* which must be a valid EIP-55 address, notably prefixed with "0x".
|
|
458
|
+
* @param {number} id
|
|
459
|
+
* @param {string} addr
|
|
460
|
+
* @returns {ServerIdAddr}
|
|
461
|
+
*/
|
|
462
|
+
module.exports.new_server_id_addr = function(id, addr) {
|
|
463
|
+
const ptr0 = passStringToWasm0(addr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
464
|
+
const len0 = WASM_VECTOR_LEN;
|
|
465
|
+
const ret = wasm.new_server_id_addr(id, ptr0, len0);
|
|
466
|
+
if (ret[2]) {
|
|
467
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
468
|
+
}
|
|
469
|
+
return ServerIdAddr.__wrap(ret[0]);
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* @returns {number}
|
|
474
|
+
*/
|
|
475
|
+
module.exports.ml_kem_pke_sk_len = function() {
|
|
476
|
+
const ret = wasm.ml_kem_pke_sk_len();
|
|
477
|
+
return ret >>> 0;
|
|
478
|
+
};
|
|
479
|
+
|
|
341
480
|
/**
|
|
342
481
|
* @param {PrivateSigKey} sk
|
|
343
482
|
* @returns {Uint8Array}
|
|
@@ -353,15 +492,38 @@ module.exports.private_sig_key_to_u8vec = function(sk) {
|
|
|
353
492
|
return v1;
|
|
354
493
|
};
|
|
355
494
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
495
|
+
/**
|
|
496
|
+
* @param {Uint8Array} v
|
|
497
|
+
* @returns {PrivateEncKeyMlKem512}
|
|
498
|
+
*/
|
|
499
|
+
module.exports.u8vec_to_ml_kem_pke_sk = function(v) {
|
|
500
|
+
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
501
|
+
const len0 = WASM_VECTOR_LEN;
|
|
502
|
+
const ret = wasm.u8vec_to_ml_kem_pke_sk(ptr0, len0);
|
|
503
|
+
if (ret[2]) {
|
|
504
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
361
505
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
506
|
+
return PrivateEncKeyMlKem512.__wrap(ret[0]);
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* @param {Client} client
|
|
511
|
+
* @returns {string}
|
|
512
|
+
*/
|
|
513
|
+
module.exports.get_client_address = function(client) {
|
|
514
|
+
let deferred1_0;
|
|
515
|
+
let deferred1_1;
|
|
516
|
+
try {
|
|
517
|
+
_assertClass(client, Client);
|
|
518
|
+
const ret = wasm.get_client_address(client.__wbg_ptr);
|
|
519
|
+
deferred1_0 = ret[0];
|
|
520
|
+
deferred1_1 = ret[1];
|
|
521
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
522
|
+
} finally {
|
|
523
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
|
|
365
527
|
/**
|
|
366
528
|
* Process the user_decryption response from Rust objects.
|
|
367
529
|
* Consider using [process_user_decryption_resp_from_js]
|
|
@@ -419,20 +581,13 @@ module.exports.process_user_decryption_resp = function(client, request, eip712_d
|
|
|
419
581
|
};
|
|
420
582
|
|
|
421
583
|
/**
|
|
422
|
-
*
|
|
423
|
-
*
|
|
424
|
-
* @param {number} id
|
|
425
|
-
* @param {string} addr
|
|
426
|
-
* @returns {ServerIdAddr}
|
|
584
|
+
* @param {Client} client
|
|
585
|
+
* @returns {PrivateSigKey | undefined}
|
|
427
586
|
*/
|
|
428
|
-
module.exports.
|
|
429
|
-
|
|
430
|
-
const
|
|
431
|
-
|
|
432
|
-
if (ret[2]) {
|
|
433
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
434
|
-
}
|
|
435
|
-
return ServerIdAddr.__wrap(ret[0]);
|
|
587
|
+
module.exports.get_client_secret_key = function(client) {
|
|
588
|
+
_assertClass(client, Client);
|
|
589
|
+
const ret = wasm.get_client_secret_key(client.__wbg_ptr);
|
|
590
|
+
return ret === 0 ? undefined : PrivateSigKey.__wrap(ret);
|
|
436
591
|
};
|
|
437
592
|
|
|
438
593
|
/**
|
|
@@ -450,54 +605,6 @@ module.exports.ml_kem_pke_pk_to_u8vec = function(pk) {
|
|
|
450
605
|
return v1;
|
|
451
606
|
};
|
|
452
607
|
|
|
453
|
-
/**
|
|
454
|
-
* @param {Client} client
|
|
455
|
-
* @returns {PrivateSigKey | undefined}
|
|
456
|
-
*/
|
|
457
|
-
module.exports.get_client_secret_key = function(client) {
|
|
458
|
-
_assertClass(client, Client);
|
|
459
|
-
const ret = wasm.get_client_secret_key(client.__wbg_ptr);
|
|
460
|
-
return ret === 0 ? undefined : PrivateSigKey.__wrap(ret);
|
|
461
|
-
};
|
|
462
|
-
|
|
463
|
-
/**
|
|
464
|
-
* @param {PublicSigKey} pk
|
|
465
|
-
* @returns {Uint8Array}
|
|
466
|
-
*/
|
|
467
|
-
module.exports.public_sig_key_to_u8vec = function(pk) {
|
|
468
|
-
_assertClass(pk, PublicSigKey);
|
|
469
|
-
const ret = wasm.public_sig_key_to_u8vec(pk.__wbg_ptr);
|
|
470
|
-
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
471
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
472
|
-
return v1;
|
|
473
|
-
};
|
|
474
|
-
|
|
475
|
-
/**
|
|
476
|
-
* @returns {PrivateEncKeyMlKem512}
|
|
477
|
-
*/
|
|
478
|
-
module.exports.ml_kem_pke_keygen = function() {
|
|
479
|
-
const ret = wasm.ml_kem_pke_keygen();
|
|
480
|
-
return PrivateEncKeyMlKem512.__wrap(ret);
|
|
481
|
-
};
|
|
482
|
-
|
|
483
|
-
/**
|
|
484
|
-
* @param {Client} client
|
|
485
|
-
* @returns {string}
|
|
486
|
-
*/
|
|
487
|
-
module.exports.get_client_address = function(client) {
|
|
488
|
-
let deferred1_0;
|
|
489
|
-
let deferred1_1;
|
|
490
|
-
try {
|
|
491
|
-
_assertClass(client, Client);
|
|
492
|
-
const ret = wasm.get_client_address(client.__wbg_ptr);
|
|
493
|
-
deferred1_0 = ret[0];
|
|
494
|
-
deferred1_1 = ret[1];
|
|
495
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
496
|
-
} finally {
|
|
497
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
498
|
-
}
|
|
499
|
-
};
|
|
500
|
-
|
|
501
608
|
/**
|
|
502
609
|
* @param {PrivateEncKeyMlKem512} sk
|
|
503
610
|
* @returns {Uint8Array}
|
|
@@ -513,112 +620,6 @@ module.exports.ml_kem_pke_sk_to_u8vec = function(sk) {
|
|
|
513
620
|
return v1;
|
|
514
621
|
};
|
|
515
622
|
|
|
516
|
-
/**
|
|
517
|
-
* @param {Client} client
|
|
518
|
-
* @returns {ServerIdAddr[]}
|
|
519
|
-
*/
|
|
520
|
-
module.exports.get_server_addrs = function(client) {
|
|
521
|
-
_assertClass(client, Client);
|
|
522
|
-
const ret = wasm.get_server_addrs(client.__wbg_ptr);
|
|
523
|
-
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
524
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
525
|
-
return v1;
|
|
526
|
-
};
|
|
527
|
-
|
|
528
|
-
/**
|
|
529
|
-
* @param {Uint8Array} v
|
|
530
|
-
* @returns {PublicEncKeyMlKem512}
|
|
531
|
-
*/
|
|
532
|
-
module.exports.u8vec_to_ml_kem_pke_pk = function(v) {
|
|
533
|
-
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
534
|
-
const len0 = WASM_VECTOR_LEN;
|
|
535
|
-
const ret = wasm.u8vec_to_ml_kem_pke_pk(ptr0, len0);
|
|
536
|
-
if (ret[2]) {
|
|
537
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
538
|
-
}
|
|
539
|
-
return PublicEncKeyMlKem512.__wrap(ret[0]);
|
|
540
|
-
};
|
|
541
|
-
|
|
542
|
-
/**
|
|
543
|
-
* @param {Uint8Array} v
|
|
544
|
-
* @returns {PrivateEncKeyMlKem512}
|
|
545
|
-
*/
|
|
546
|
-
module.exports.u8vec_to_ml_kem_pke_sk = function(v) {
|
|
547
|
-
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
548
|
-
const len0 = WASM_VECTOR_LEN;
|
|
549
|
-
const ret = wasm.u8vec_to_ml_kem_pke_sk(ptr0, len0);
|
|
550
|
-
if (ret[2]) {
|
|
551
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
552
|
-
}
|
|
553
|
-
return PrivateEncKeyMlKem512.__wrap(ret[0]);
|
|
554
|
-
};
|
|
555
|
-
|
|
556
|
-
/**
|
|
557
|
-
* @returns {number}
|
|
558
|
-
*/
|
|
559
|
-
module.exports.ml_kem_pke_sk_len = function() {
|
|
560
|
-
const ret = wasm.ml_kem_pke_sk_len();
|
|
561
|
-
return ret >>> 0;
|
|
562
|
-
};
|
|
563
|
-
|
|
564
|
-
/**
|
|
565
|
-
* This function is *not* used by relayer-sdk because the decryption
|
|
566
|
-
* is handled by [process_user_decryption_resp].
|
|
567
|
-
* It's just here for completeness and tests.
|
|
568
|
-
* @param {Uint8Array} ct
|
|
569
|
-
* @param {PrivateEncKeyMlKem512} my_sk
|
|
570
|
-
* @returns {Uint8Array}
|
|
571
|
-
*/
|
|
572
|
-
module.exports.ml_kem_pke_decrypt = function(ct, my_sk) {
|
|
573
|
-
const ptr0 = passArray8ToWasm0(ct, wasm.__wbindgen_malloc);
|
|
574
|
-
const len0 = WASM_VECTOR_LEN;
|
|
575
|
-
_assertClass(my_sk, PrivateEncKeyMlKem512);
|
|
576
|
-
const ret = wasm.ml_kem_pke_decrypt(ptr0, len0, my_sk.__wbg_ptr);
|
|
577
|
-
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
578
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
579
|
-
return v2;
|
|
580
|
-
};
|
|
581
|
-
|
|
582
|
-
/**
|
|
583
|
-
* Instantiate a new client.
|
|
584
|
-
*
|
|
585
|
-
* * `server_addrs` - a list of KMS server ID with EIP-55 addresses,
|
|
586
|
-
* the elements in the list can be created using [new_server_id_addr].
|
|
587
|
-
*
|
|
588
|
-
* * `client_address_hex` - the client (wallet) address in hex,
|
|
589
|
-
* must be prefixed with "0x".
|
|
590
|
-
*
|
|
591
|
-
* * `fhe_parameter` - the parameter choice, which can be either `"test"` or `"default"`.
|
|
592
|
-
* The "default" parameter choice is selected if no matching string is found.
|
|
593
|
-
* @param {ServerIdAddr[]} server_addrs
|
|
594
|
-
* @param {string} client_address_hex
|
|
595
|
-
* @param {string} fhe_parameter
|
|
596
|
-
* @returns {Client}
|
|
597
|
-
*/
|
|
598
|
-
module.exports.new_client = function(server_addrs, client_address_hex, fhe_parameter) {
|
|
599
|
-
const ptr0 = passArrayJsValueToWasm0(server_addrs, wasm.__wbindgen_malloc);
|
|
600
|
-
const len0 = WASM_VECTOR_LEN;
|
|
601
|
-
const ptr1 = passStringToWasm0(client_address_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
602
|
-
const len1 = WASM_VECTOR_LEN;
|
|
603
|
-
const ptr2 = passStringToWasm0(fhe_parameter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
604
|
-
const len2 = WASM_VECTOR_LEN;
|
|
605
|
-
const ret = wasm.new_client(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
606
|
-
if (ret[2]) {
|
|
607
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
608
|
-
}
|
|
609
|
-
return Client.__wrap(ret[0]);
|
|
610
|
-
};
|
|
611
|
-
|
|
612
|
-
/**
|
|
613
|
-
* @param {PrivateEncKeyMlKem512} sk
|
|
614
|
-
* @returns {PublicEncKeyMlKem512}
|
|
615
|
-
*/
|
|
616
|
-
module.exports.ml_kem_pke_get_pk = function(sk) {
|
|
617
|
-
_assertClass(sk, PrivateEncKeyMlKem512);
|
|
618
|
-
const ret = wasm.ml_kem_pke_get_pk(sk.__wbg_ptr);
|
|
619
|
-
return PublicEncKeyMlKem512.__wrap(ret);
|
|
620
|
-
};
|
|
621
|
-
|
|
622
623
|
const CiphertextHandleFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
623
624
|
? { register: () => {}, unregister: () => {} }
|
|
624
625
|
: new FinalizationRegistry(ptr => wasm.__wbg_ciphertexthandle_free(ptr >>> 0, 1));
|
package/kms_lib_bg.wasm
CHANGED
|
Binary file
|