tkms 0.11.0-rc14 → 0.11.0-rc17
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 +36 -21
- package/kms_lib.js +96 -26
- package/kms_lib_bg.wasm +0 -0
- package/package.json +1 -1
package/kms_lib.d.ts
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
+
export function ml_kem_pke_ct_pk_len(): number;
|
|
4
|
+
export function ml_kem_pke_sk_len(): number;
|
|
3
5
|
export function public_sig_key_to_u8vec(pk: PublicSigKey): Uint8Array;
|
|
4
6
|
export function u8vec_to_public_sig_key(v: Uint8Array): PublicSigKey;
|
|
5
7
|
export function private_sig_key_to_u8vec(sk: PrivateSigKey): Uint8Array;
|
|
6
8
|
export function u8vec_to_private_sig_key(v: Uint8Array): PrivateSigKey;
|
|
9
|
+
/**
|
|
10
|
+
* Create a new [ServerIdAddr] structure that holds an ID and an address
|
|
11
|
+
* which must be a valid EIP-55 address, notably prefixed with "0x".
|
|
12
|
+
*/
|
|
13
|
+
export function new_server_id_addr(id: number, addr: string): ServerIdAddr;
|
|
7
14
|
/**
|
|
8
15
|
* Instantiate a new client.
|
|
9
16
|
*
|
|
10
|
-
* * `server_addrs` - a list of KMS server EIP-55 addresses,
|
|
11
|
-
*
|
|
17
|
+
* * `server_addrs` - a list of KMS server ID with EIP-55 addresses,
|
|
18
|
+
* the elements in the list can be created using [new_server_id_addr].
|
|
12
19
|
*
|
|
13
20
|
* * `client_address_hex` - the client (wallet) address in hex,
|
|
14
21
|
* must be prefixed with "0x".
|
|
@@ -16,18 +23,18 @@ export function u8vec_to_private_sig_key(v: Uint8Array): PrivateSigKey;
|
|
|
16
23
|
* * `fhe_parameter` - the parameter choice, which can be either `"test"` or `"default"`.
|
|
17
24
|
* The "default" parameter choice is selected if no matching string is found.
|
|
18
25
|
*/
|
|
19
|
-
export function new_client(server_addrs:
|
|
20
|
-
export function get_server_addrs(client: Client):
|
|
26
|
+
export function new_client(server_addrs: ServerIdAddr[], client_address_hex: string, fhe_parameter: string): Client;
|
|
27
|
+
export function get_server_addrs(client: Client): ServerIdAddr[];
|
|
21
28
|
export function get_client_secret_key(client: Client): PrivateSigKey | undefined;
|
|
22
29
|
export function get_client_address(client: Client): string;
|
|
23
|
-
export function
|
|
24
|
-
export function
|
|
25
|
-
export function
|
|
26
|
-
export function
|
|
27
|
-
export function
|
|
28
|
-
export function
|
|
29
|
-
export function
|
|
30
|
-
export function
|
|
30
|
+
export function ml_kem_pke_keygen(): PrivateEncKey;
|
|
31
|
+
export function ml_kem_pke_get_pk(sk: PrivateEncKey): PublicEncKey;
|
|
32
|
+
export function ml_kem_pke_pk_to_u8vec(pk: PublicEncKey): Uint8Array;
|
|
33
|
+
export function ml_kem_pke_sk_to_u8vec(sk: PrivateEncKey): Uint8Array;
|
|
34
|
+
export function u8vec_to_ml_kem_pke_pk(v: Uint8Array): PublicEncKey;
|
|
35
|
+
export function u8vec_to_ml_kem_pke_sk(v: Uint8Array): PrivateEncKey;
|
|
36
|
+
export function ml_kem_pke_encrypt(msg: Uint8Array, their_pk: PublicEncKey): CryptoBoxCt;
|
|
37
|
+
export function ml_kem_pke_decrypt(ct: CryptoBoxCt, my_sk: PrivateEncKey): Uint8Array;
|
|
31
38
|
/**
|
|
32
39
|
* Process the user_decryption response from JavaScript objects.
|
|
33
40
|
* The returned result is a byte array representing a plaintext of any length,
|
|
@@ -179,6 +186,10 @@ export class RequestId {
|
|
|
179
186
|
free(): void;
|
|
180
187
|
request_id: string;
|
|
181
188
|
}
|
|
189
|
+
export class ServerIdAddr {
|
|
190
|
+
private constructor();
|
|
191
|
+
free(): void;
|
|
192
|
+
}
|
|
182
193
|
export class TypedCiphertext {
|
|
183
194
|
private constructor();
|
|
184
195
|
free(): void;
|
|
@@ -284,7 +295,7 @@ export class UserDecryptionResponse {
|
|
|
284
295
|
signature: Uint8Array;
|
|
285
296
|
/**
|
|
286
297
|
* This is the external signature created from the Eip712 domain
|
|
287
|
-
* on the structure, where userDecryptedShare is
|
|
298
|
+
* on the structure, where userDecryptedShare is bc2wrap::serialize(&payload)
|
|
288
299
|
* struct UserDecryptResponseVerification {
|
|
289
300
|
* bytes publicKey;
|
|
290
301
|
* uint256\[\] ctHandles;
|
|
@@ -340,23 +351,27 @@ export interface InitOutput {
|
|
|
340
351
|
readonly __wbg_client_free: (a: number, b: number) => void;
|
|
341
352
|
readonly __wbg_ciphertexthandle_free: (a: number, b: number) => void;
|
|
342
353
|
readonly __wbg_parseduserdecryptionrequest_free: (a: number, b: number) => void;
|
|
354
|
+
readonly ml_kem_pke_ct_pk_len: () => number;
|
|
355
|
+
readonly ml_kem_pke_sk_len: () => number;
|
|
343
356
|
readonly public_sig_key_to_u8vec: (a: number) => [number, number];
|
|
344
357
|
readonly u8vec_to_public_sig_key: (a: number, b: number) => [number, number, number];
|
|
345
358
|
readonly private_sig_key_to_u8vec: (a: number) => [number, number, number, number];
|
|
346
359
|
readonly u8vec_to_private_sig_key: (a: number, b: number) => [number, number, number];
|
|
360
|
+
readonly __wbg_serveridaddr_free: (a: number, b: number) => void;
|
|
361
|
+
readonly new_server_id_addr: (a: number, b: number, c: number) => [number, number, number];
|
|
347
362
|
readonly new_client: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
348
363
|
readonly get_server_addrs: (a: number) => [number, number];
|
|
349
364
|
readonly get_client_secret_key: (a: number) => number;
|
|
350
365
|
readonly get_client_address: (a: number) => [number, number];
|
|
351
366
|
readonly __wbg_cryptoboxct_free: (a: number, b: number) => void;
|
|
352
|
-
readonly
|
|
353
|
-
readonly
|
|
354
|
-
readonly
|
|
355
|
-
readonly
|
|
356
|
-
readonly
|
|
357
|
-
readonly
|
|
358
|
-
readonly
|
|
359
|
-
readonly
|
|
367
|
+
readonly ml_kem_pke_keygen: () => number;
|
|
368
|
+
readonly ml_kem_pke_get_pk: (a: number) => number;
|
|
369
|
+
readonly ml_kem_pke_pk_to_u8vec: (a: number) => [number, number, number, number];
|
|
370
|
+
readonly ml_kem_pke_sk_to_u8vec: (a: number) => [number, number, number, number];
|
|
371
|
+
readonly u8vec_to_ml_kem_pke_pk: (a: number, b: number) => [number, number, number];
|
|
372
|
+
readonly u8vec_to_ml_kem_pke_sk: (a: number, b: number) => [number, number, number];
|
|
373
|
+
readonly ml_kem_pke_encrypt: (a: number, b: number, c: number) => number;
|
|
374
|
+
readonly ml_kem_pke_decrypt: (a: number, b: number) => [number, number];
|
|
360
375
|
readonly process_user_decryption_resp_from_js: (a: number, b: any, c: any, d: any, e: number, f: number, g: number) => [number, number, number, number];
|
|
361
376
|
readonly process_user_decryption_resp: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number, number];
|
|
362
377
|
readonly __wbg_publicenckey_free: (a: number, b: number) => void;
|
package/kms_lib.js
CHANGED
|
@@ -166,6 +166,21 @@ function debugString(val) {
|
|
|
166
166
|
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
167
167
|
return className;
|
|
168
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* @returns {number}
|
|
171
|
+
*/
|
|
172
|
+
export function ml_kem_pke_ct_pk_len() {
|
|
173
|
+
const ret = wasm.ml_kem_pke_ct_pk_len();
|
|
174
|
+
return ret >>> 0;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* @returns {number}
|
|
179
|
+
*/
|
|
180
|
+
export function ml_kem_pke_sk_len() {
|
|
181
|
+
const ret = wasm.ml_kem_pke_sk_len();
|
|
182
|
+
return ret >>> 0;
|
|
183
|
+
}
|
|
169
184
|
|
|
170
185
|
function _assertClass(instance, klass) {
|
|
171
186
|
if (!(instance instanceof klass)) {
|
|
@@ -244,6 +259,23 @@ export function u8vec_to_private_sig_key(v) {
|
|
|
244
259
|
return PrivateSigKey.__wrap(ret[0]);
|
|
245
260
|
}
|
|
246
261
|
|
|
262
|
+
/**
|
|
263
|
+
* Create a new [ServerIdAddr] structure that holds an ID and an address
|
|
264
|
+
* which must be a valid EIP-55 address, notably prefixed with "0x".
|
|
265
|
+
* @param {number} id
|
|
266
|
+
* @param {string} addr
|
|
267
|
+
* @returns {ServerIdAddr}
|
|
268
|
+
*/
|
|
269
|
+
export function new_server_id_addr(id, addr) {
|
|
270
|
+
const ptr0 = passStringToWasm0(addr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
271
|
+
const len0 = WASM_VECTOR_LEN;
|
|
272
|
+
const ret = wasm.new_server_id_addr(id, ptr0, len0);
|
|
273
|
+
if (ret[2]) {
|
|
274
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
275
|
+
}
|
|
276
|
+
return ServerIdAddr.__wrap(ret[0]);
|
|
277
|
+
}
|
|
278
|
+
|
|
247
279
|
function passArrayJsValueToWasm0(array, malloc) {
|
|
248
280
|
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
249
281
|
for (let i = 0; i < array.length; i++) {
|
|
@@ -256,15 +288,15 @@ function passArrayJsValueToWasm0(array, malloc) {
|
|
|
256
288
|
/**
|
|
257
289
|
* Instantiate a new client.
|
|
258
290
|
*
|
|
259
|
-
* * `server_addrs` - a list of KMS server EIP-55 addresses,
|
|
260
|
-
*
|
|
291
|
+
* * `server_addrs` - a list of KMS server ID with EIP-55 addresses,
|
|
292
|
+
* the elements in the list can be created using [new_server_id_addr].
|
|
261
293
|
*
|
|
262
294
|
* * `client_address_hex` - the client (wallet) address in hex,
|
|
263
295
|
* must be prefixed with "0x".
|
|
264
296
|
*
|
|
265
297
|
* * `fhe_parameter` - the parameter choice, which can be either `"test"` or `"default"`.
|
|
266
298
|
* The "default" parameter choice is selected if no matching string is found.
|
|
267
|
-
* @param {
|
|
299
|
+
* @param {ServerIdAddr[]} server_addrs
|
|
268
300
|
* @param {string} client_address_hex
|
|
269
301
|
* @param {string} fhe_parameter
|
|
270
302
|
* @returns {Client}
|
|
@@ -295,7 +327,7 @@ function getArrayJsValueFromWasm0(ptr, len) {
|
|
|
295
327
|
}
|
|
296
328
|
/**
|
|
297
329
|
* @param {Client} client
|
|
298
|
-
* @returns {
|
|
330
|
+
* @returns {ServerIdAddr[]}
|
|
299
331
|
*/
|
|
300
332
|
export function get_server_addrs(client) {
|
|
301
333
|
_assertClass(client, Client);
|
|
@@ -336,8 +368,8 @@ export function get_client_address(client) {
|
|
|
336
368
|
/**
|
|
337
369
|
* @returns {PrivateEncKey}
|
|
338
370
|
*/
|
|
339
|
-
export function
|
|
340
|
-
const ret = wasm.
|
|
371
|
+
export function ml_kem_pke_keygen() {
|
|
372
|
+
const ret = wasm.ml_kem_pke_keygen();
|
|
341
373
|
return PrivateEncKey.__wrap(ret);
|
|
342
374
|
}
|
|
343
375
|
|
|
@@ -345,9 +377,9 @@ export function cryptobox_keygen() {
|
|
|
345
377
|
* @param {PrivateEncKey} sk
|
|
346
378
|
* @returns {PublicEncKey}
|
|
347
379
|
*/
|
|
348
|
-
export function
|
|
380
|
+
export function ml_kem_pke_get_pk(sk) {
|
|
349
381
|
_assertClass(sk, PrivateEncKey);
|
|
350
|
-
const ret = wasm.
|
|
382
|
+
const ret = wasm.ml_kem_pke_get_pk(sk.__wbg_ptr);
|
|
351
383
|
return PublicEncKey.__wrap(ret);
|
|
352
384
|
}
|
|
353
385
|
|
|
@@ -355,9 +387,9 @@ export function cryptobox_get_pk(sk) {
|
|
|
355
387
|
* @param {PublicEncKey} pk
|
|
356
388
|
* @returns {Uint8Array}
|
|
357
389
|
*/
|
|
358
|
-
export function
|
|
390
|
+
export function ml_kem_pke_pk_to_u8vec(pk) {
|
|
359
391
|
_assertClass(pk, PublicEncKey);
|
|
360
|
-
const ret = wasm.
|
|
392
|
+
const ret = wasm.ml_kem_pke_pk_to_u8vec(pk.__wbg_ptr);
|
|
361
393
|
if (ret[3]) {
|
|
362
394
|
throw takeFromExternrefTable0(ret[2]);
|
|
363
395
|
}
|
|
@@ -370,9 +402,9 @@ export function cryptobox_pk_to_u8vec(pk) {
|
|
|
370
402
|
* @param {PrivateEncKey} sk
|
|
371
403
|
* @returns {Uint8Array}
|
|
372
404
|
*/
|
|
373
|
-
export function
|
|
405
|
+
export function ml_kem_pke_sk_to_u8vec(sk) {
|
|
374
406
|
_assertClass(sk, PrivateEncKey);
|
|
375
|
-
const ret = wasm.
|
|
407
|
+
const ret = wasm.ml_kem_pke_sk_to_u8vec(sk.__wbg_ptr);
|
|
376
408
|
if (ret[3]) {
|
|
377
409
|
throw takeFromExternrefTable0(ret[2]);
|
|
378
410
|
}
|
|
@@ -385,10 +417,10 @@ export function cryptobox_sk_to_u8vec(sk) {
|
|
|
385
417
|
* @param {Uint8Array} v
|
|
386
418
|
* @returns {PublicEncKey}
|
|
387
419
|
*/
|
|
388
|
-
export function
|
|
420
|
+
export function u8vec_to_ml_kem_pke_pk(v) {
|
|
389
421
|
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
390
422
|
const len0 = WASM_VECTOR_LEN;
|
|
391
|
-
const ret = wasm.
|
|
423
|
+
const ret = wasm.u8vec_to_ml_kem_pke_pk(ptr0, len0);
|
|
392
424
|
if (ret[2]) {
|
|
393
425
|
throw takeFromExternrefTable0(ret[1]);
|
|
394
426
|
}
|
|
@@ -399,10 +431,10 @@ export function u8vec_to_cryptobox_pk(v) {
|
|
|
399
431
|
* @param {Uint8Array} v
|
|
400
432
|
* @returns {PrivateEncKey}
|
|
401
433
|
*/
|
|
402
|
-
export function
|
|
434
|
+
export function u8vec_to_ml_kem_pke_sk(v) {
|
|
403
435
|
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
404
436
|
const len0 = WASM_VECTOR_LEN;
|
|
405
|
-
const ret = wasm.
|
|
437
|
+
const ret = wasm.u8vec_to_ml_kem_pke_sk(ptr0, len0);
|
|
406
438
|
if (ret[2]) {
|
|
407
439
|
throw takeFromExternrefTable0(ret[1]);
|
|
408
440
|
}
|
|
@@ -412,29 +444,25 @@ export function u8vec_to_cryptobox_sk(v) {
|
|
|
412
444
|
/**
|
|
413
445
|
* @param {Uint8Array} msg
|
|
414
446
|
* @param {PublicEncKey} their_pk
|
|
415
|
-
* @param {PrivateEncKey} my_sk
|
|
416
447
|
* @returns {CryptoBoxCt}
|
|
417
448
|
*/
|
|
418
|
-
export function
|
|
449
|
+
export function ml_kem_pke_encrypt(msg, their_pk) {
|
|
419
450
|
const ptr0 = passArray8ToWasm0(msg, wasm.__wbindgen_malloc);
|
|
420
451
|
const len0 = WASM_VECTOR_LEN;
|
|
421
452
|
_assertClass(their_pk, PublicEncKey);
|
|
422
|
-
|
|
423
|
-
const ret = wasm.cryptobox_encrypt(ptr0, len0, their_pk.__wbg_ptr, my_sk.__wbg_ptr);
|
|
453
|
+
const ret = wasm.ml_kem_pke_encrypt(ptr0, len0, their_pk.__wbg_ptr);
|
|
424
454
|
return CryptoBoxCt.__wrap(ret);
|
|
425
455
|
}
|
|
426
456
|
|
|
427
457
|
/**
|
|
428
458
|
* @param {CryptoBoxCt} ct
|
|
429
459
|
* @param {PrivateEncKey} my_sk
|
|
430
|
-
* @param {PublicEncKey} their_pk
|
|
431
460
|
* @returns {Uint8Array}
|
|
432
461
|
*/
|
|
433
|
-
export function
|
|
462
|
+
export function ml_kem_pke_decrypt(ct, my_sk) {
|
|
434
463
|
_assertClass(ct, CryptoBoxCt);
|
|
435
464
|
_assertClass(my_sk, PrivateEncKey);
|
|
436
|
-
|
|
437
|
-
const ret = wasm.cryptobox_decrypt(ct.__wbg_ptr, my_sk.__wbg_ptr, their_pk.__wbg_ptr);
|
|
465
|
+
const ret = wasm.ml_kem_pke_decrypt(ct.__wbg_ptr, my_sk.__wbg_ptr);
|
|
438
466
|
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
439
467
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
440
468
|
return v1;
|
|
@@ -975,6 +1003,40 @@ export class RequestId {
|
|
|
975
1003
|
}
|
|
976
1004
|
}
|
|
977
1005
|
|
|
1006
|
+
const ServerIdAddrFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1007
|
+
? { register: () => {}, unregister: () => {} }
|
|
1008
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_serveridaddr_free(ptr >>> 0, 1));
|
|
1009
|
+
|
|
1010
|
+
export class ServerIdAddr {
|
|
1011
|
+
|
|
1012
|
+
static __wrap(ptr) {
|
|
1013
|
+
ptr = ptr >>> 0;
|
|
1014
|
+
const obj = Object.create(ServerIdAddr.prototype);
|
|
1015
|
+
obj.__wbg_ptr = ptr;
|
|
1016
|
+
ServerIdAddrFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1017
|
+
return obj;
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
static __unwrap(jsValue) {
|
|
1021
|
+
if (!(jsValue instanceof ServerIdAddr)) {
|
|
1022
|
+
return 0;
|
|
1023
|
+
}
|
|
1024
|
+
return jsValue.__destroy_into_raw();
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
__destroy_into_raw() {
|
|
1028
|
+
const ptr = this.__wbg_ptr;
|
|
1029
|
+
this.__wbg_ptr = 0;
|
|
1030
|
+
ServerIdAddrFinalization.unregister(this);
|
|
1031
|
+
return ptr;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
free() {
|
|
1035
|
+
const ptr = this.__destroy_into_raw();
|
|
1036
|
+
wasm.__wbg_serveridaddr_free(ptr, 0);
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
|
|
978
1040
|
const TypedCiphertextFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
979
1041
|
? { register: () => {}, unregister: () => {} }
|
|
980
1042
|
: new FinalizationRegistry(ptr => wasm.__wbg_typedciphertext_free(ptr >>> 0, 1));
|
|
@@ -1445,7 +1507,7 @@ export class UserDecryptionResponse {
|
|
|
1445
1507
|
}
|
|
1446
1508
|
/**
|
|
1447
1509
|
* This is the external signature created from the Eip712 domain
|
|
1448
|
-
* on the structure, where userDecryptedShare is
|
|
1510
|
+
* on the structure, where userDecryptedShare is bc2wrap::serialize(&payload)
|
|
1449
1511
|
* struct UserDecryptResponseVerification {
|
|
1450
1512
|
* bytes publicKey;
|
|
1451
1513
|
* uint256\[\] ctHandles;
|
|
@@ -1461,7 +1523,7 @@ export class UserDecryptionResponse {
|
|
|
1461
1523
|
}
|
|
1462
1524
|
/**
|
|
1463
1525
|
* This is the external signature created from the Eip712 domain
|
|
1464
|
-
* on the structure, where userDecryptedShare is
|
|
1526
|
+
* on the structure, where userDecryptedShare is bc2wrap::serialize(&payload)
|
|
1465
1527
|
* struct UserDecryptResponseVerification {
|
|
1466
1528
|
* bytes publicKey;
|
|
1467
1529
|
* uint256\[\] ctHandles;
|
|
@@ -1798,6 +1860,14 @@ function __wbg_get_imports() {
|
|
|
1798
1860
|
const ret = module.require;
|
|
1799
1861
|
return ret;
|
|
1800
1862
|
}, arguments) };
|
|
1863
|
+
imports.wbg.__wbg_serveridaddr_new = function(arg0) {
|
|
1864
|
+
const ret = ServerIdAddr.__wrap(arg0);
|
|
1865
|
+
return ret;
|
|
1866
|
+
};
|
|
1867
|
+
imports.wbg.__wbg_serveridaddr_unwrap = function(arg0) {
|
|
1868
|
+
const ret = ServerIdAddr.__unwrap(arg0);
|
|
1869
|
+
return ret;
|
|
1870
|
+
};
|
|
1801
1871
|
imports.wbg.__wbg_set_65595bdd868b3009 = function(arg0, arg1, arg2) {
|
|
1802
1872
|
arg0.set(arg1, arg2 >>> 0);
|
|
1803
1873
|
};
|
package/kms_lib_bg.wasm
CHANGED
|
Binary file
|