node-tkms 0.13.0-rc.2 → 0.13.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 +36 -36
- package/kms_lib.js +213 -213
- package/kms_lib_bg.wasm +0 -0
- package/package.json +1 -1
package/kms_lib.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
export function
|
|
4
|
-
export function
|
|
3
|
+
export function get_server_addrs(client: Client): ServerIdAddr[];
|
|
4
|
+
export function u8vec_to_ml_kem_pke_pk(v: Uint8Array): PublicEncKeyMlKem512;
|
|
5
5
|
export function ml_kem_pke_sk_to_u8vec(sk: PrivateEncKeyMlKem512): Uint8Array;
|
|
6
|
+
export function u8vec_to_private_sig_key(v: Uint8Array): PrivateSigKey;
|
|
7
|
+
export function get_client_secret_key(client: Client): PrivateSigKey | undefined;
|
|
8
|
+
export function u8vec_to_ml_kem_pke_sk(v: Uint8Array): PrivateEncKeyMlKem512;
|
|
6
9
|
/**
|
|
7
10
|
* Process the user_decryption response from Rust objects.
|
|
8
11
|
* Consider using [process_user_decryption_resp_from_js]
|
|
@@ -27,14 +30,43 @@ export function ml_kem_pke_sk_to_u8vec(sk: PrivateEncKeyMlKem512): Uint8Array;
|
|
|
27
30
|
* It is insecure if `verify = false`!
|
|
28
31
|
*/
|
|
29
32
|
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[];
|
|
33
|
+
export function private_sig_key_to_u8vec(sk: PrivateSigKey): Uint8Array;
|
|
34
|
+
/**
|
|
35
|
+
* This function is *not* used by relayer-sdk because the encryption
|
|
36
|
+
* happens on the KMS side. It's just here for completeness and tests.
|
|
37
|
+
*/
|
|
38
|
+
export function ml_kem_pke_encrypt(msg: Uint8Array, their_pk: PublicEncKeyMlKem512): Uint8Array;
|
|
39
|
+
export function u8vec_to_public_sig_key(v: Uint8Array): PublicSigKey;
|
|
40
|
+
/**
|
|
41
|
+
* Instantiate a new client.
|
|
42
|
+
*
|
|
43
|
+
* * `server_addrs` - a list of KMS server ID with EIP-55 addresses,
|
|
44
|
+
* the elements in the list can be created using [new_server_id_addr].
|
|
45
|
+
*
|
|
46
|
+
* * `client_address_hex` - the client (wallet) address in hex,
|
|
47
|
+
* must be prefixed with "0x".
|
|
48
|
+
*
|
|
49
|
+
* * `fhe_parameter` - the parameter choice, which can be either `"test"` or `"default"`.
|
|
50
|
+
* The "default" parameter choice is selected if no matching string is found.
|
|
51
|
+
*/
|
|
52
|
+
export function new_client(server_addrs: ServerIdAddr[], client_address_hex: string, fhe_parameter: string): Client;
|
|
53
|
+
export function get_client_address(client: Client): string;
|
|
30
54
|
export function ml_kem_pke_get_pk(sk: PrivateEncKeyMlKem512): PublicEncKeyMlKem512;
|
|
31
|
-
export function u8vec_to_ml_kem_pke_pk(v: Uint8Array): PublicEncKeyMlKem512;
|
|
32
55
|
/**
|
|
33
56
|
* Create a new [ServerIdAddr] structure that holds an ID and an address
|
|
34
57
|
* which must be a valid EIP-55 address, notably prefixed with "0x".
|
|
35
58
|
*/
|
|
36
59
|
export function new_server_id_addr(id: number, addr: string): ServerIdAddr;
|
|
37
|
-
export function
|
|
60
|
+
export function ml_kem_pke_sk_len(): number;
|
|
61
|
+
export function ml_kem_pke_keygen(): PrivateEncKeyMlKem512;
|
|
62
|
+
export function public_sig_key_to_u8vec(pk: PublicSigKey): Uint8Array;
|
|
63
|
+
export function ml_kem_pke_pk_len(): number;
|
|
64
|
+
/**
|
|
65
|
+
* This function is *not* used by relayer-sdk because the decryption
|
|
66
|
+
* is handled by [process_user_decryption_resp].
|
|
67
|
+
* It's just here for completeness and tests.
|
|
68
|
+
*/
|
|
69
|
+
export function ml_kem_pke_decrypt(ct: Uint8Array, my_sk: PrivateEncKeyMlKem512): Uint8Array;
|
|
38
70
|
export function ml_kem_pke_pk_to_u8vec(pk: PublicEncKeyMlKem512): Uint8Array;
|
|
39
71
|
/**
|
|
40
72
|
* Process the user_decryption response from JavaScript objects.
|
|
@@ -98,38 +130,6 @@ export function ml_kem_pke_pk_to_u8vec(pk: PublicEncKeyMlKem512): Uint8Array;
|
|
|
98
130
|
* It is insecure if `verify = false`!
|
|
99
131
|
*/
|
|
100
132
|
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[];
|
|
101
|
-
export function ml_kem_pke_pk_len(): number;
|
|
102
|
-
export function get_client_secret_key(client: Client): PrivateSigKey | undefined;
|
|
103
|
-
export function get_server_addrs(client: Client): ServerIdAddr[];
|
|
104
|
-
export function u8vec_to_public_sig_key(v: Uint8Array): PublicSigKey;
|
|
105
|
-
export function u8vec_to_private_sig_key(v: Uint8Array): PrivateSigKey;
|
|
106
|
-
export function ml_kem_pke_keygen(): PrivateEncKeyMlKem512;
|
|
107
|
-
/**
|
|
108
|
-
* This function is *not* used by relayer-sdk because the encryption
|
|
109
|
-
* happens on the KMS side. It's just here for completeness and tests.
|
|
110
|
-
*/
|
|
111
|
-
export function ml_kem_pke_encrypt(msg: Uint8Array, their_pk: PublicEncKeyMlKem512): Uint8Array;
|
|
112
|
-
/**
|
|
113
|
-
* Instantiate a new client.
|
|
114
|
-
*
|
|
115
|
-
* * `server_addrs` - a list of KMS server ID with EIP-55 addresses,
|
|
116
|
-
* the elements in the list can be created using [new_server_id_addr].
|
|
117
|
-
*
|
|
118
|
-
* * `client_address_hex` - the client (wallet) address in hex,
|
|
119
|
-
* must be prefixed with "0x".
|
|
120
|
-
*
|
|
121
|
-
* * `fhe_parameter` - the parameter choice, which can be either `"test"` or `"default"`.
|
|
122
|
-
* The "default" parameter choice is selected if no matching string is found.
|
|
123
|
-
*/
|
|
124
|
-
export function new_client(server_addrs: ServerIdAddr[], client_address_hex: string, fhe_parameter: string): Client;
|
|
125
|
-
export function public_sig_key_to_u8vec(pk: PublicSigKey): Uint8Array;
|
|
126
|
-
/**
|
|
127
|
-
* This function is *not* used by relayer-sdk because the decryption
|
|
128
|
-
* is handled by [process_user_decryption_resp].
|
|
129
|
-
* It's just here for completeness and tests.
|
|
130
|
-
*/
|
|
131
|
-
export function ml_kem_pke_decrypt(ct: Uint8Array, my_sk: PrivateEncKeyMlKem512): Uint8Array;
|
|
132
|
-
export function private_sig_key_to_u8vec(sk: PrivateSigKey): Uint8Array;
|
|
133
133
|
export class CiphertextHandle {
|
|
134
134
|
private constructor();
|
|
135
135
|
free(): void;
|
package/kms_lib.js
CHANGED
|
@@ -176,37 +176,54 @@ function _assertClass(instance, klass) {
|
|
|
176
176
|
throw new Error(`expected instance of ${klass.name}`);
|
|
177
177
|
}
|
|
178
178
|
}
|
|
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
|
+
}
|
|
179
190
|
/**
|
|
180
191
|
* @param {Client} client
|
|
181
|
-
* @returns {
|
|
192
|
+
* @returns {ServerIdAddr[]}
|
|
182
193
|
*/
|
|
183
|
-
module.exports.
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
deferred1_0 = ret[0];
|
|
190
|
-
deferred1_1 = ret[1];
|
|
191
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
192
|
-
} finally {
|
|
193
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
194
|
-
}
|
|
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;
|
|
195
200
|
};
|
|
196
201
|
|
|
197
|
-
|
|
198
|
-
*
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
};
|
|
202
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
203
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
204
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
205
|
+
WASM_VECTOR_LEN = arg.length;
|
|
206
|
+
return ptr;
|
|
207
|
+
}
|
|
204
208
|
|
|
205
209
|
function takeFromExternrefTable0(idx) {
|
|
206
210
|
const value = wasm.__wbindgen_export_4.get(idx);
|
|
207
211
|
wasm.__externref_table_dealloc(idx);
|
|
208
212
|
return value;
|
|
209
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* @param {Uint8Array} v
|
|
216
|
+
* @returns {PublicEncKeyMlKem512}
|
|
217
|
+
*/
|
|
218
|
+
module.exports.u8vec_to_ml_kem_pke_pk = function(v) {
|
|
219
|
+
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
220
|
+
const len0 = WASM_VECTOR_LEN;
|
|
221
|
+
const ret = wasm.u8vec_to_ml_kem_pke_pk(ptr0, len0);
|
|
222
|
+
if (ret[2]) {
|
|
223
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
224
|
+
}
|
|
225
|
+
return PublicEncKeyMlKem512.__wrap(ret[0]);
|
|
226
|
+
};
|
|
210
227
|
|
|
211
228
|
function getArrayU8FromWasm0(ptr, len) {
|
|
212
229
|
ptr = ptr >>> 0;
|
|
@@ -227,6 +244,44 @@ module.exports.ml_kem_pke_sk_to_u8vec = function(sk) {
|
|
|
227
244
|
return v1;
|
|
228
245
|
};
|
|
229
246
|
|
|
247
|
+
/**
|
|
248
|
+
* @param {Uint8Array} v
|
|
249
|
+
* @returns {PrivateSigKey}
|
|
250
|
+
*/
|
|
251
|
+
module.exports.u8vec_to_private_sig_key = function(v) {
|
|
252
|
+
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
253
|
+
const len0 = WASM_VECTOR_LEN;
|
|
254
|
+
const ret = wasm.u8vec_to_private_sig_key(ptr0, len0);
|
|
255
|
+
if (ret[2]) {
|
|
256
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
257
|
+
}
|
|
258
|
+
return PrivateSigKey.__wrap(ret[0]);
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* @param {Client} client
|
|
263
|
+
* @returns {PrivateSigKey | undefined}
|
|
264
|
+
*/
|
|
265
|
+
module.exports.get_client_secret_key = function(client) {
|
|
266
|
+
_assertClass(client, Client);
|
|
267
|
+
const ret = wasm.get_client_secret_key(client.__wbg_ptr);
|
|
268
|
+
return ret === 0 ? undefined : PrivateSigKey.__wrap(ret);
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* @param {Uint8Array} v
|
|
273
|
+
* @returns {PrivateEncKeyMlKem512}
|
|
274
|
+
*/
|
|
275
|
+
module.exports.u8vec_to_ml_kem_pke_sk = function(v) {
|
|
276
|
+
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
277
|
+
const len0 = WASM_VECTOR_LEN;
|
|
278
|
+
const ret = wasm.u8vec_to_ml_kem_pke_sk(ptr0, len0);
|
|
279
|
+
if (ret[2]) {
|
|
280
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
281
|
+
}
|
|
282
|
+
return PrivateEncKeyMlKem512.__wrap(ret[0]);
|
|
283
|
+
};
|
|
284
|
+
|
|
230
285
|
function passArrayJsValueToWasm0(array, malloc) {
|
|
231
286
|
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
232
287
|
for (let i = 0; i < array.length; i++) {
|
|
@@ -236,17 +291,6 @@ function passArrayJsValueToWasm0(array, malloc) {
|
|
|
236
291
|
WASM_VECTOR_LEN = array.length;
|
|
237
292
|
return ptr;
|
|
238
293
|
}
|
|
239
|
-
|
|
240
|
-
function getArrayJsValueFromWasm0(ptr, len) {
|
|
241
|
-
ptr = ptr >>> 0;
|
|
242
|
-
const mem = getDataViewMemory0();
|
|
243
|
-
const result = [];
|
|
244
|
-
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
245
|
-
result.push(wasm.__wbindgen_export_4.get(mem.getUint32(i, true)));
|
|
246
|
-
}
|
|
247
|
-
wasm.__externref_drop_slice(ptr, len);
|
|
248
|
-
return result;
|
|
249
|
-
}
|
|
250
294
|
/**
|
|
251
295
|
* Process the user_decryption response from Rust objects.
|
|
252
296
|
* Consider using [process_user_decryption_resp_from_js]
|
|
@@ -304,33 +348,107 @@ module.exports.process_user_decryption_resp = function(client, request, eip712_d
|
|
|
304
348
|
};
|
|
305
349
|
|
|
306
350
|
/**
|
|
307
|
-
* @param {
|
|
308
|
-
* @returns {
|
|
351
|
+
* @param {PrivateSigKey} sk
|
|
352
|
+
* @returns {Uint8Array}
|
|
309
353
|
*/
|
|
310
|
-
module.exports.
|
|
311
|
-
_assertClass(sk,
|
|
312
|
-
const ret = wasm.
|
|
313
|
-
|
|
354
|
+
module.exports.private_sig_key_to_u8vec = function(sk) {
|
|
355
|
+
_assertClass(sk, PrivateSigKey);
|
|
356
|
+
const ret = wasm.private_sig_key_to_u8vec(sk.__wbg_ptr);
|
|
357
|
+
if (ret[3]) {
|
|
358
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
359
|
+
}
|
|
360
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
361
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
362
|
+
return v1;
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* This function is *not* used by relayer-sdk because the encryption
|
|
367
|
+
* happens on the KMS side. It's just here for completeness and tests.
|
|
368
|
+
* @param {Uint8Array} msg
|
|
369
|
+
* @param {PublicEncKeyMlKem512} their_pk
|
|
370
|
+
* @returns {Uint8Array}
|
|
371
|
+
*/
|
|
372
|
+
module.exports.ml_kem_pke_encrypt = function(msg, their_pk) {
|
|
373
|
+
const ptr0 = passArray8ToWasm0(msg, wasm.__wbindgen_malloc);
|
|
374
|
+
const len0 = WASM_VECTOR_LEN;
|
|
375
|
+
_assertClass(their_pk, PublicEncKeyMlKem512);
|
|
376
|
+
const ret = wasm.ml_kem_pke_encrypt(ptr0, len0, their_pk.__wbg_ptr);
|
|
377
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
378
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
379
|
+
return v2;
|
|
314
380
|
};
|
|
315
381
|
|
|
316
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
317
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
318
|
-
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
319
|
-
WASM_VECTOR_LEN = arg.length;
|
|
320
|
-
return ptr;
|
|
321
|
-
}
|
|
322
382
|
/**
|
|
323
383
|
* @param {Uint8Array} v
|
|
324
|
-
* @returns {
|
|
384
|
+
* @returns {PublicSigKey}
|
|
325
385
|
*/
|
|
326
|
-
module.exports.
|
|
386
|
+
module.exports.u8vec_to_public_sig_key = function(v) {
|
|
327
387
|
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
328
388
|
const len0 = WASM_VECTOR_LEN;
|
|
329
|
-
const ret = wasm.
|
|
389
|
+
const ret = wasm.u8vec_to_public_sig_key(ptr0, len0);
|
|
330
390
|
if (ret[2]) {
|
|
331
391
|
throw takeFromExternrefTable0(ret[1]);
|
|
332
392
|
}
|
|
333
|
-
return
|
|
393
|
+
return PublicSigKey.__wrap(ret[0]);
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Instantiate a new client.
|
|
398
|
+
*
|
|
399
|
+
* * `server_addrs` - a list of KMS server ID with EIP-55 addresses,
|
|
400
|
+
* the elements in the list can be created using [new_server_id_addr].
|
|
401
|
+
*
|
|
402
|
+
* * `client_address_hex` - the client (wallet) address in hex,
|
|
403
|
+
* must be prefixed with "0x".
|
|
404
|
+
*
|
|
405
|
+
* * `fhe_parameter` - the parameter choice, which can be either `"test"` or `"default"`.
|
|
406
|
+
* The "default" parameter choice is selected if no matching string is found.
|
|
407
|
+
* @param {ServerIdAddr[]} server_addrs
|
|
408
|
+
* @param {string} client_address_hex
|
|
409
|
+
* @param {string} fhe_parameter
|
|
410
|
+
* @returns {Client}
|
|
411
|
+
*/
|
|
412
|
+
module.exports.new_client = function(server_addrs, client_address_hex, fhe_parameter) {
|
|
413
|
+
const ptr0 = passArrayJsValueToWasm0(server_addrs, wasm.__wbindgen_malloc);
|
|
414
|
+
const len0 = WASM_VECTOR_LEN;
|
|
415
|
+
const ptr1 = passStringToWasm0(client_address_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
416
|
+
const len1 = WASM_VECTOR_LEN;
|
|
417
|
+
const ptr2 = passStringToWasm0(fhe_parameter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
418
|
+
const len2 = WASM_VECTOR_LEN;
|
|
419
|
+
const ret = wasm.new_client(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
420
|
+
if (ret[2]) {
|
|
421
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
422
|
+
}
|
|
423
|
+
return Client.__wrap(ret[0]);
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* @param {Client} client
|
|
428
|
+
* @returns {string}
|
|
429
|
+
*/
|
|
430
|
+
module.exports.get_client_address = function(client) {
|
|
431
|
+
let deferred1_0;
|
|
432
|
+
let deferred1_1;
|
|
433
|
+
try {
|
|
434
|
+
_assertClass(client, Client);
|
|
435
|
+
const ret = wasm.get_client_address(client.__wbg_ptr);
|
|
436
|
+
deferred1_0 = ret[0];
|
|
437
|
+
deferred1_1 = ret[1];
|
|
438
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
439
|
+
} finally {
|
|
440
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* @param {PrivateEncKeyMlKem512} sk
|
|
446
|
+
* @returns {PublicEncKeyMlKem512}
|
|
447
|
+
*/
|
|
448
|
+
module.exports.ml_kem_pke_get_pk = function(sk) {
|
|
449
|
+
_assertClass(sk, PrivateEncKeyMlKem512);
|
|
450
|
+
const ret = wasm.ml_kem_pke_get_pk(sk.__wbg_ptr);
|
|
451
|
+
return PublicEncKeyMlKem512.__wrap(ret);
|
|
334
452
|
};
|
|
335
453
|
|
|
336
454
|
/**
|
|
@@ -351,17 +469,57 @@ module.exports.new_server_id_addr = function(id, addr) {
|
|
|
351
469
|
};
|
|
352
470
|
|
|
353
471
|
/**
|
|
354
|
-
* @
|
|
472
|
+
* @returns {number}
|
|
473
|
+
*/
|
|
474
|
+
module.exports.ml_kem_pke_sk_len = function() {
|
|
475
|
+
const ret = wasm.ml_kem_pke_sk_len();
|
|
476
|
+
return ret >>> 0;
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
/**
|
|
355
480
|
* @returns {PrivateEncKeyMlKem512}
|
|
356
481
|
*/
|
|
357
|
-
module.exports.
|
|
358
|
-
const
|
|
482
|
+
module.exports.ml_kem_pke_keygen = function() {
|
|
483
|
+
const ret = wasm.ml_kem_pke_keygen();
|
|
484
|
+
return PrivateEncKeyMlKem512.__wrap(ret);
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* @param {PublicSigKey} pk
|
|
489
|
+
* @returns {Uint8Array}
|
|
490
|
+
*/
|
|
491
|
+
module.exports.public_sig_key_to_u8vec = function(pk) {
|
|
492
|
+
_assertClass(pk, PublicSigKey);
|
|
493
|
+
const ret = wasm.public_sig_key_to_u8vec(pk.__wbg_ptr);
|
|
494
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
495
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
496
|
+
return v1;
|
|
497
|
+
};
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* @returns {number}
|
|
501
|
+
*/
|
|
502
|
+
module.exports.ml_kem_pke_pk_len = function() {
|
|
503
|
+
const ret = wasm.ml_kem_pke_pk_len();
|
|
504
|
+
return ret >>> 0;
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* This function is *not* used by relayer-sdk because the decryption
|
|
509
|
+
* is handled by [process_user_decryption_resp].
|
|
510
|
+
* It's just here for completeness and tests.
|
|
511
|
+
* @param {Uint8Array} ct
|
|
512
|
+
* @param {PrivateEncKeyMlKem512} my_sk
|
|
513
|
+
* @returns {Uint8Array}
|
|
514
|
+
*/
|
|
515
|
+
module.exports.ml_kem_pke_decrypt = function(ct, my_sk) {
|
|
516
|
+
const ptr0 = passArray8ToWasm0(ct, wasm.__wbindgen_malloc);
|
|
359
517
|
const len0 = WASM_VECTOR_LEN;
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
return
|
|
518
|
+
_assertClass(my_sk, PrivateEncKeyMlKem512);
|
|
519
|
+
const ret = wasm.ml_kem_pke_decrypt(ptr0, len0, my_sk.__wbg_ptr);
|
|
520
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
521
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
522
|
+
return v2;
|
|
365
523
|
};
|
|
366
524
|
|
|
367
525
|
/**
|
|
@@ -461,164 +619,6 @@ module.exports.process_user_decryption_resp_from_js = function(client, request,
|
|
|
461
619
|
return v1;
|
|
462
620
|
};
|
|
463
621
|
|
|
464
|
-
/**
|
|
465
|
-
* @returns {number}
|
|
466
|
-
*/
|
|
467
|
-
module.exports.ml_kem_pke_pk_len = function() {
|
|
468
|
-
const ret = wasm.ml_kem_pke_pk_len();
|
|
469
|
-
return ret >>> 0;
|
|
470
|
-
};
|
|
471
|
-
|
|
472
|
-
/**
|
|
473
|
-
* @param {Client} client
|
|
474
|
-
* @returns {PrivateSigKey | undefined}
|
|
475
|
-
*/
|
|
476
|
-
module.exports.get_client_secret_key = function(client) {
|
|
477
|
-
_assertClass(client, Client);
|
|
478
|
-
const ret = wasm.get_client_secret_key(client.__wbg_ptr);
|
|
479
|
-
return ret === 0 ? undefined : PrivateSigKey.__wrap(ret);
|
|
480
|
-
};
|
|
481
|
-
|
|
482
|
-
/**
|
|
483
|
-
* @param {Client} client
|
|
484
|
-
* @returns {ServerIdAddr[]}
|
|
485
|
-
*/
|
|
486
|
-
module.exports.get_server_addrs = function(client) {
|
|
487
|
-
_assertClass(client, Client);
|
|
488
|
-
const ret = wasm.get_server_addrs(client.__wbg_ptr);
|
|
489
|
-
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
490
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
491
|
-
return v1;
|
|
492
|
-
};
|
|
493
|
-
|
|
494
|
-
/**
|
|
495
|
-
* @param {Uint8Array} v
|
|
496
|
-
* @returns {PublicSigKey}
|
|
497
|
-
*/
|
|
498
|
-
module.exports.u8vec_to_public_sig_key = function(v) {
|
|
499
|
-
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
500
|
-
const len0 = WASM_VECTOR_LEN;
|
|
501
|
-
const ret = wasm.u8vec_to_public_sig_key(ptr0, len0);
|
|
502
|
-
if (ret[2]) {
|
|
503
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
504
|
-
}
|
|
505
|
-
return PublicSigKey.__wrap(ret[0]);
|
|
506
|
-
};
|
|
507
|
-
|
|
508
|
-
/**
|
|
509
|
-
* @param {Uint8Array} v
|
|
510
|
-
* @returns {PrivateSigKey}
|
|
511
|
-
*/
|
|
512
|
-
module.exports.u8vec_to_private_sig_key = function(v) {
|
|
513
|
-
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
514
|
-
const len0 = WASM_VECTOR_LEN;
|
|
515
|
-
const ret = wasm.u8vec_to_private_sig_key(ptr0, len0);
|
|
516
|
-
if (ret[2]) {
|
|
517
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
518
|
-
}
|
|
519
|
-
return PrivateSigKey.__wrap(ret[0]);
|
|
520
|
-
};
|
|
521
|
-
|
|
522
|
-
/**
|
|
523
|
-
* @returns {PrivateEncKeyMlKem512}
|
|
524
|
-
*/
|
|
525
|
-
module.exports.ml_kem_pke_keygen = function() {
|
|
526
|
-
const ret = wasm.ml_kem_pke_keygen();
|
|
527
|
-
return PrivateEncKeyMlKem512.__wrap(ret);
|
|
528
|
-
};
|
|
529
|
-
|
|
530
|
-
/**
|
|
531
|
-
* This function is *not* used by relayer-sdk because the encryption
|
|
532
|
-
* happens on the KMS side. It's just here for completeness and tests.
|
|
533
|
-
* @param {Uint8Array} msg
|
|
534
|
-
* @param {PublicEncKeyMlKem512} their_pk
|
|
535
|
-
* @returns {Uint8Array}
|
|
536
|
-
*/
|
|
537
|
-
module.exports.ml_kem_pke_encrypt = function(msg, their_pk) {
|
|
538
|
-
const ptr0 = passArray8ToWasm0(msg, wasm.__wbindgen_malloc);
|
|
539
|
-
const len0 = WASM_VECTOR_LEN;
|
|
540
|
-
_assertClass(their_pk, PublicEncKeyMlKem512);
|
|
541
|
-
const ret = wasm.ml_kem_pke_encrypt(ptr0, len0, their_pk.__wbg_ptr);
|
|
542
|
-
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
543
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
544
|
-
return v2;
|
|
545
|
-
};
|
|
546
|
-
|
|
547
|
-
/**
|
|
548
|
-
* Instantiate a new client.
|
|
549
|
-
*
|
|
550
|
-
* * `server_addrs` - a list of KMS server ID with EIP-55 addresses,
|
|
551
|
-
* the elements in the list can be created using [new_server_id_addr].
|
|
552
|
-
*
|
|
553
|
-
* * `client_address_hex` - the client (wallet) address in hex,
|
|
554
|
-
* must be prefixed with "0x".
|
|
555
|
-
*
|
|
556
|
-
* * `fhe_parameter` - the parameter choice, which can be either `"test"` or `"default"`.
|
|
557
|
-
* The "default" parameter choice is selected if no matching string is found.
|
|
558
|
-
* @param {ServerIdAddr[]} server_addrs
|
|
559
|
-
* @param {string} client_address_hex
|
|
560
|
-
* @param {string} fhe_parameter
|
|
561
|
-
* @returns {Client}
|
|
562
|
-
*/
|
|
563
|
-
module.exports.new_client = function(server_addrs, client_address_hex, fhe_parameter) {
|
|
564
|
-
const ptr0 = passArrayJsValueToWasm0(server_addrs, wasm.__wbindgen_malloc);
|
|
565
|
-
const len0 = WASM_VECTOR_LEN;
|
|
566
|
-
const ptr1 = passStringToWasm0(client_address_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
567
|
-
const len1 = WASM_VECTOR_LEN;
|
|
568
|
-
const ptr2 = passStringToWasm0(fhe_parameter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
569
|
-
const len2 = WASM_VECTOR_LEN;
|
|
570
|
-
const ret = wasm.new_client(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
571
|
-
if (ret[2]) {
|
|
572
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
573
|
-
}
|
|
574
|
-
return Client.__wrap(ret[0]);
|
|
575
|
-
};
|
|
576
|
-
|
|
577
|
-
/**
|
|
578
|
-
* @param {PublicSigKey} pk
|
|
579
|
-
* @returns {Uint8Array}
|
|
580
|
-
*/
|
|
581
|
-
module.exports.public_sig_key_to_u8vec = function(pk) {
|
|
582
|
-
_assertClass(pk, PublicSigKey);
|
|
583
|
-
const ret = wasm.public_sig_key_to_u8vec(pk.__wbg_ptr);
|
|
584
|
-
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
585
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
586
|
-
return v1;
|
|
587
|
-
};
|
|
588
|
-
|
|
589
|
-
/**
|
|
590
|
-
* This function is *not* used by relayer-sdk because the decryption
|
|
591
|
-
* is handled by [process_user_decryption_resp].
|
|
592
|
-
* It's just here for completeness and tests.
|
|
593
|
-
* @param {Uint8Array} ct
|
|
594
|
-
* @param {PrivateEncKeyMlKem512} my_sk
|
|
595
|
-
* @returns {Uint8Array}
|
|
596
|
-
*/
|
|
597
|
-
module.exports.ml_kem_pke_decrypt = function(ct, my_sk) {
|
|
598
|
-
const ptr0 = passArray8ToWasm0(ct, wasm.__wbindgen_malloc);
|
|
599
|
-
const len0 = WASM_VECTOR_LEN;
|
|
600
|
-
_assertClass(my_sk, PrivateEncKeyMlKem512);
|
|
601
|
-
const ret = wasm.ml_kem_pke_decrypt(ptr0, len0, my_sk.__wbg_ptr);
|
|
602
|
-
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
603
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
604
|
-
return v2;
|
|
605
|
-
};
|
|
606
|
-
|
|
607
|
-
/**
|
|
608
|
-
* @param {PrivateSigKey} sk
|
|
609
|
-
* @returns {Uint8Array}
|
|
610
|
-
*/
|
|
611
|
-
module.exports.private_sig_key_to_u8vec = function(sk) {
|
|
612
|
-
_assertClass(sk, PrivateSigKey);
|
|
613
|
-
const ret = wasm.private_sig_key_to_u8vec(sk.__wbg_ptr);
|
|
614
|
-
if (ret[3]) {
|
|
615
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
616
|
-
}
|
|
617
|
-
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
618
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
619
|
-
return v1;
|
|
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
|