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 +37 -37
- package/kms_lib.js +211 -211
- 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;
|
|
@@ -501,8 +501,8 @@ export interface InitOutput {
|
|
|
501
501
|
readonly __externref_table_alloc: () => number;
|
|
502
502
|
readonly __wbindgen_export_4: WebAssembly.Table;
|
|
503
503
|
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
504
|
-
readonly __externref_table_dealloc: (a: number) => void;
|
|
505
504
|
readonly __externref_drop_slice: (a: number, b: number) => void;
|
|
505
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
506
506
|
readonly __wbindgen_start: () => void;
|
|
507
507
|
}
|
|
508
508
|
|
package/kms_lib.js
CHANGED
|
@@ -172,30 +172,34 @@ function _assertClass(instance, klass) {
|
|
|
172
172
|
throw new Error(`expected instance of ${klass.name}`);
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
+
|
|
176
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
177
|
+
ptr = ptr >>> 0;
|
|
178
|
+
const mem = getDataViewMemory0();
|
|
179
|
+
const result = [];
|
|
180
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
181
|
+
result.push(wasm.__wbindgen_export_4.get(mem.getUint32(i, true)));
|
|
182
|
+
}
|
|
183
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
184
|
+
return result;
|
|
185
|
+
}
|
|
175
186
|
/**
|
|
176
187
|
* @param {Client} client
|
|
177
|
-
* @returns {
|
|
188
|
+
* @returns {ServerIdAddr[]}
|
|
178
189
|
*/
|
|
179
|
-
export function
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
deferred1_0 = ret[0];
|
|
186
|
-
deferred1_1 = ret[1];
|
|
187
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
188
|
-
} finally {
|
|
189
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
190
|
-
}
|
|
190
|
+
export function get_server_addrs(client) {
|
|
191
|
+
_assertClass(client, Client);
|
|
192
|
+
const ret = wasm.get_server_addrs(client.__wbg_ptr);
|
|
193
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
194
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
195
|
+
return v1;
|
|
191
196
|
}
|
|
192
197
|
|
|
193
|
-
|
|
194
|
-
*
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
return ret >>> 0;
|
|
198
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
199
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
200
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
201
|
+
WASM_VECTOR_LEN = arg.length;
|
|
202
|
+
return ptr;
|
|
199
203
|
}
|
|
200
204
|
|
|
201
205
|
function takeFromExternrefTable0(idx) {
|
|
@@ -203,6 +207,19 @@ function takeFromExternrefTable0(idx) {
|
|
|
203
207
|
wasm.__externref_table_dealloc(idx);
|
|
204
208
|
return value;
|
|
205
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* @param {Uint8Array} v
|
|
212
|
+
* @returns {PublicEncKeyMlKem512}
|
|
213
|
+
*/
|
|
214
|
+
export function u8vec_to_ml_kem_pke_pk(v) {
|
|
215
|
+
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
216
|
+
const len0 = WASM_VECTOR_LEN;
|
|
217
|
+
const ret = wasm.u8vec_to_ml_kem_pke_pk(ptr0, len0);
|
|
218
|
+
if (ret[2]) {
|
|
219
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
220
|
+
}
|
|
221
|
+
return PublicEncKeyMlKem512.__wrap(ret[0]);
|
|
222
|
+
}
|
|
206
223
|
|
|
207
224
|
function getArrayU8FromWasm0(ptr, len) {
|
|
208
225
|
ptr = ptr >>> 0;
|
|
@@ -223,6 +240,44 @@ export function ml_kem_pke_sk_to_u8vec(sk) {
|
|
|
223
240
|
return v1;
|
|
224
241
|
}
|
|
225
242
|
|
|
243
|
+
/**
|
|
244
|
+
* @param {Uint8Array} v
|
|
245
|
+
* @returns {PrivateSigKey}
|
|
246
|
+
*/
|
|
247
|
+
export function u8vec_to_private_sig_key(v) {
|
|
248
|
+
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
249
|
+
const len0 = WASM_VECTOR_LEN;
|
|
250
|
+
const ret = wasm.u8vec_to_private_sig_key(ptr0, len0);
|
|
251
|
+
if (ret[2]) {
|
|
252
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
253
|
+
}
|
|
254
|
+
return PrivateSigKey.__wrap(ret[0]);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* @param {Client} client
|
|
259
|
+
* @returns {PrivateSigKey | undefined}
|
|
260
|
+
*/
|
|
261
|
+
export function get_client_secret_key(client) {
|
|
262
|
+
_assertClass(client, Client);
|
|
263
|
+
const ret = wasm.get_client_secret_key(client.__wbg_ptr);
|
|
264
|
+
return ret === 0 ? undefined : PrivateSigKey.__wrap(ret);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* @param {Uint8Array} v
|
|
269
|
+
* @returns {PrivateEncKeyMlKem512}
|
|
270
|
+
*/
|
|
271
|
+
export function u8vec_to_ml_kem_pke_sk(v) {
|
|
272
|
+
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
273
|
+
const len0 = WASM_VECTOR_LEN;
|
|
274
|
+
const ret = wasm.u8vec_to_ml_kem_pke_sk(ptr0, len0);
|
|
275
|
+
if (ret[2]) {
|
|
276
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
277
|
+
}
|
|
278
|
+
return PrivateEncKeyMlKem512.__wrap(ret[0]);
|
|
279
|
+
}
|
|
280
|
+
|
|
226
281
|
function passArrayJsValueToWasm0(array, malloc) {
|
|
227
282
|
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
228
283
|
for (let i = 0; i < array.length; i++) {
|
|
@@ -232,17 +287,6 @@ function passArrayJsValueToWasm0(array, malloc) {
|
|
|
232
287
|
WASM_VECTOR_LEN = array.length;
|
|
233
288
|
return ptr;
|
|
234
289
|
}
|
|
235
|
-
|
|
236
|
-
function getArrayJsValueFromWasm0(ptr, len) {
|
|
237
|
-
ptr = ptr >>> 0;
|
|
238
|
-
const mem = getDataViewMemory0();
|
|
239
|
-
const result = [];
|
|
240
|
-
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
241
|
-
result.push(wasm.__wbindgen_export_4.get(mem.getUint32(i, true)));
|
|
242
|
-
}
|
|
243
|
-
wasm.__externref_drop_slice(ptr, len);
|
|
244
|
-
return result;
|
|
245
|
-
}
|
|
246
290
|
/**
|
|
247
291
|
* Process the user_decryption response from Rust objects.
|
|
248
292
|
* Consider using [process_user_decryption_resp_from_js]
|
|
@@ -300,33 +344,107 @@ export function process_user_decryption_resp(client, request, eip712_domain, agg
|
|
|
300
344
|
}
|
|
301
345
|
|
|
302
346
|
/**
|
|
303
|
-
* @param {
|
|
304
|
-
* @returns {
|
|
347
|
+
* @param {PrivateSigKey} sk
|
|
348
|
+
* @returns {Uint8Array}
|
|
305
349
|
*/
|
|
306
|
-
export function
|
|
307
|
-
_assertClass(sk,
|
|
308
|
-
const ret = wasm.
|
|
309
|
-
|
|
350
|
+
export function private_sig_key_to_u8vec(sk) {
|
|
351
|
+
_assertClass(sk, PrivateSigKey);
|
|
352
|
+
const ret = wasm.private_sig_key_to_u8vec(sk.__wbg_ptr);
|
|
353
|
+
if (ret[3]) {
|
|
354
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
355
|
+
}
|
|
356
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
357
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
358
|
+
return v1;
|
|
310
359
|
}
|
|
311
360
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
361
|
+
/**
|
|
362
|
+
* This function is *not* used by relayer-sdk because the encryption
|
|
363
|
+
* happens on the KMS side. It's just here for completeness and tests.
|
|
364
|
+
* @param {Uint8Array} msg
|
|
365
|
+
* @param {PublicEncKeyMlKem512} their_pk
|
|
366
|
+
* @returns {Uint8Array}
|
|
367
|
+
*/
|
|
368
|
+
export function ml_kem_pke_encrypt(msg, their_pk) {
|
|
369
|
+
const ptr0 = passArray8ToWasm0(msg, wasm.__wbindgen_malloc);
|
|
370
|
+
const len0 = WASM_VECTOR_LEN;
|
|
371
|
+
_assertClass(their_pk, PublicEncKeyMlKem512);
|
|
372
|
+
const ret = wasm.ml_kem_pke_encrypt(ptr0, len0, their_pk.__wbg_ptr);
|
|
373
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
374
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
375
|
+
return v2;
|
|
317
376
|
}
|
|
377
|
+
|
|
318
378
|
/**
|
|
319
379
|
* @param {Uint8Array} v
|
|
320
|
-
* @returns {
|
|
380
|
+
* @returns {PublicSigKey}
|
|
321
381
|
*/
|
|
322
|
-
export function
|
|
382
|
+
export function u8vec_to_public_sig_key(v) {
|
|
323
383
|
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
324
384
|
const len0 = WASM_VECTOR_LEN;
|
|
325
|
-
const ret = wasm.
|
|
385
|
+
const ret = wasm.u8vec_to_public_sig_key(ptr0, len0);
|
|
326
386
|
if (ret[2]) {
|
|
327
387
|
throw takeFromExternrefTable0(ret[1]);
|
|
328
388
|
}
|
|
329
|
-
return
|
|
389
|
+
return PublicSigKey.__wrap(ret[0]);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Instantiate a new client.
|
|
394
|
+
*
|
|
395
|
+
* * `server_addrs` - a list of KMS server ID with EIP-55 addresses,
|
|
396
|
+
* the elements in the list can be created using [new_server_id_addr].
|
|
397
|
+
*
|
|
398
|
+
* * `client_address_hex` - the client (wallet) address in hex,
|
|
399
|
+
* must be prefixed with "0x".
|
|
400
|
+
*
|
|
401
|
+
* * `fhe_parameter` - the parameter choice, which can be either `"test"` or `"default"`.
|
|
402
|
+
* The "default" parameter choice is selected if no matching string is found.
|
|
403
|
+
* @param {ServerIdAddr[]} server_addrs
|
|
404
|
+
* @param {string} client_address_hex
|
|
405
|
+
* @param {string} fhe_parameter
|
|
406
|
+
* @returns {Client}
|
|
407
|
+
*/
|
|
408
|
+
export function new_client(server_addrs, client_address_hex, fhe_parameter) {
|
|
409
|
+
const ptr0 = passArrayJsValueToWasm0(server_addrs, wasm.__wbindgen_malloc);
|
|
410
|
+
const len0 = WASM_VECTOR_LEN;
|
|
411
|
+
const ptr1 = passStringToWasm0(client_address_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
412
|
+
const len1 = WASM_VECTOR_LEN;
|
|
413
|
+
const ptr2 = passStringToWasm0(fhe_parameter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
414
|
+
const len2 = WASM_VECTOR_LEN;
|
|
415
|
+
const ret = wasm.new_client(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
416
|
+
if (ret[2]) {
|
|
417
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
418
|
+
}
|
|
419
|
+
return Client.__wrap(ret[0]);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* @param {Client} client
|
|
424
|
+
* @returns {string}
|
|
425
|
+
*/
|
|
426
|
+
export function get_client_address(client) {
|
|
427
|
+
let deferred1_0;
|
|
428
|
+
let deferred1_1;
|
|
429
|
+
try {
|
|
430
|
+
_assertClass(client, Client);
|
|
431
|
+
const ret = wasm.get_client_address(client.__wbg_ptr);
|
|
432
|
+
deferred1_0 = ret[0];
|
|
433
|
+
deferred1_1 = ret[1];
|
|
434
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
435
|
+
} finally {
|
|
436
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* @param {PrivateEncKeyMlKem512} sk
|
|
442
|
+
* @returns {PublicEncKeyMlKem512}
|
|
443
|
+
*/
|
|
444
|
+
export function ml_kem_pke_get_pk(sk) {
|
|
445
|
+
_assertClass(sk, PrivateEncKeyMlKem512);
|
|
446
|
+
const ret = wasm.ml_kem_pke_get_pk(sk.__wbg_ptr);
|
|
447
|
+
return PublicEncKeyMlKem512.__wrap(ret);
|
|
330
448
|
}
|
|
331
449
|
|
|
332
450
|
/**
|
|
@@ -347,17 +465,57 @@ export function new_server_id_addr(id, addr) {
|
|
|
347
465
|
}
|
|
348
466
|
|
|
349
467
|
/**
|
|
350
|
-
* @
|
|
468
|
+
* @returns {number}
|
|
469
|
+
*/
|
|
470
|
+
export function ml_kem_pke_sk_len() {
|
|
471
|
+
const ret = wasm.ml_kem_pke_sk_len();
|
|
472
|
+
return ret >>> 0;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
/**
|
|
351
476
|
* @returns {PrivateEncKeyMlKem512}
|
|
352
477
|
*/
|
|
353
|
-
export function
|
|
354
|
-
const
|
|
478
|
+
export function ml_kem_pke_keygen() {
|
|
479
|
+
const ret = wasm.ml_kem_pke_keygen();
|
|
480
|
+
return PrivateEncKeyMlKem512.__wrap(ret);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* @param {PublicSigKey} pk
|
|
485
|
+
* @returns {Uint8Array}
|
|
486
|
+
*/
|
|
487
|
+
export function public_sig_key_to_u8vec(pk) {
|
|
488
|
+
_assertClass(pk, PublicSigKey);
|
|
489
|
+
const ret = wasm.public_sig_key_to_u8vec(pk.__wbg_ptr);
|
|
490
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
491
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
492
|
+
return v1;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* @returns {number}
|
|
497
|
+
*/
|
|
498
|
+
export function ml_kem_pke_pk_len() {
|
|
499
|
+
const ret = wasm.ml_kem_pke_pk_len();
|
|
500
|
+
return ret >>> 0;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* This function is *not* used by relayer-sdk because the decryption
|
|
505
|
+
* is handled by [process_user_decryption_resp].
|
|
506
|
+
* It's just here for completeness and tests.
|
|
507
|
+
* @param {Uint8Array} ct
|
|
508
|
+
* @param {PrivateEncKeyMlKem512} my_sk
|
|
509
|
+
* @returns {Uint8Array}
|
|
510
|
+
*/
|
|
511
|
+
export function ml_kem_pke_decrypt(ct, my_sk) {
|
|
512
|
+
const ptr0 = passArray8ToWasm0(ct, wasm.__wbindgen_malloc);
|
|
355
513
|
const len0 = WASM_VECTOR_LEN;
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
return
|
|
514
|
+
_assertClass(my_sk, PrivateEncKeyMlKem512);
|
|
515
|
+
const ret = wasm.ml_kem_pke_decrypt(ptr0, len0, my_sk.__wbg_ptr);
|
|
516
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
517
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
518
|
+
return v2;
|
|
361
519
|
}
|
|
362
520
|
|
|
363
521
|
/**
|
|
@@ -457,164 +615,6 @@ export function process_user_decryption_resp_from_js(client, request, eip712_dom
|
|
|
457
615
|
return v1;
|
|
458
616
|
}
|
|
459
617
|
|
|
460
|
-
/**
|
|
461
|
-
* @returns {number}
|
|
462
|
-
*/
|
|
463
|
-
export function ml_kem_pke_pk_len() {
|
|
464
|
-
const ret = wasm.ml_kem_pke_pk_len();
|
|
465
|
-
return ret >>> 0;
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
/**
|
|
469
|
-
* @param {Client} client
|
|
470
|
-
* @returns {PrivateSigKey | undefined}
|
|
471
|
-
*/
|
|
472
|
-
export function get_client_secret_key(client) {
|
|
473
|
-
_assertClass(client, Client);
|
|
474
|
-
const ret = wasm.get_client_secret_key(client.__wbg_ptr);
|
|
475
|
-
return ret === 0 ? undefined : PrivateSigKey.__wrap(ret);
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
/**
|
|
479
|
-
* @param {Client} client
|
|
480
|
-
* @returns {ServerIdAddr[]}
|
|
481
|
-
*/
|
|
482
|
-
export function get_server_addrs(client) {
|
|
483
|
-
_assertClass(client, Client);
|
|
484
|
-
const ret = wasm.get_server_addrs(client.__wbg_ptr);
|
|
485
|
-
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
486
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
487
|
-
return v1;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
/**
|
|
491
|
-
* @param {Uint8Array} v
|
|
492
|
-
* @returns {PublicSigKey}
|
|
493
|
-
*/
|
|
494
|
-
export function u8vec_to_public_sig_key(v) {
|
|
495
|
-
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
496
|
-
const len0 = WASM_VECTOR_LEN;
|
|
497
|
-
const ret = wasm.u8vec_to_public_sig_key(ptr0, len0);
|
|
498
|
-
if (ret[2]) {
|
|
499
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
500
|
-
}
|
|
501
|
-
return PublicSigKey.__wrap(ret[0]);
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
/**
|
|
505
|
-
* @param {Uint8Array} v
|
|
506
|
-
* @returns {PrivateSigKey}
|
|
507
|
-
*/
|
|
508
|
-
export function u8vec_to_private_sig_key(v) {
|
|
509
|
-
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
510
|
-
const len0 = WASM_VECTOR_LEN;
|
|
511
|
-
const ret = wasm.u8vec_to_private_sig_key(ptr0, len0);
|
|
512
|
-
if (ret[2]) {
|
|
513
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
514
|
-
}
|
|
515
|
-
return PrivateSigKey.__wrap(ret[0]);
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
/**
|
|
519
|
-
* @returns {PrivateEncKeyMlKem512}
|
|
520
|
-
*/
|
|
521
|
-
export function ml_kem_pke_keygen() {
|
|
522
|
-
const ret = wasm.ml_kem_pke_keygen();
|
|
523
|
-
return PrivateEncKeyMlKem512.__wrap(ret);
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
/**
|
|
527
|
-
* This function is *not* used by relayer-sdk because the encryption
|
|
528
|
-
* happens on the KMS side. It's just here for completeness and tests.
|
|
529
|
-
* @param {Uint8Array} msg
|
|
530
|
-
* @param {PublicEncKeyMlKem512} their_pk
|
|
531
|
-
* @returns {Uint8Array}
|
|
532
|
-
*/
|
|
533
|
-
export function ml_kem_pke_encrypt(msg, their_pk) {
|
|
534
|
-
const ptr0 = passArray8ToWasm0(msg, wasm.__wbindgen_malloc);
|
|
535
|
-
const len0 = WASM_VECTOR_LEN;
|
|
536
|
-
_assertClass(their_pk, PublicEncKeyMlKem512);
|
|
537
|
-
const ret = wasm.ml_kem_pke_encrypt(ptr0, len0, their_pk.__wbg_ptr);
|
|
538
|
-
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
539
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
540
|
-
return v2;
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
/**
|
|
544
|
-
* Instantiate a new client.
|
|
545
|
-
*
|
|
546
|
-
* * `server_addrs` - a list of KMS server ID with EIP-55 addresses,
|
|
547
|
-
* the elements in the list can be created using [new_server_id_addr].
|
|
548
|
-
*
|
|
549
|
-
* * `client_address_hex` - the client (wallet) address in hex,
|
|
550
|
-
* must be prefixed with "0x".
|
|
551
|
-
*
|
|
552
|
-
* * `fhe_parameter` - the parameter choice, which can be either `"test"` or `"default"`.
|
|
553
|
-
* The "default" parameter choice is selected if no matching string is found.
|
|
554
|
-
* @param {ServerIdAddr[]} server_addrs
|
|
555
|
-
* @param {string} client_address_hex
|
|
556
|
-
* @param {string} fhe_parameter
|
|
557
|
-
* @returns {Client}
|
|
558
|
-
*/
|
|
559
|
-
export function new_client(server_addrs, client_address_hex, fhe_parameter) {
|
|
560
|
-
const ptr0 = passArrayJsValueToWasm0(server_addrs, wasm.__wbindgen_malloc);
|
|
561
|
-
const len0 = WASM_VECTOR_LEN;
|
|
562
|
-
const ptr1 = passStringToWasm0(client_address_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
563
|
-
const len1 = WASM_VECTOR_LEN;
|
|
564
|
-
const ptr2 = passStringToWasm0(fhe_parameter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
565
|
-
const len2 = WASM_VECTOR_LEN;
|
|
566
|
-
const ret = wasm.new_client(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
567
|
-
if (ret[2]) {
|
|
568
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
569
|
-
}
|
|
570
|
-
return Client.__wrap(ret[0]);
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
/**
|
|
574
|
-
* @param {PublicSigKey} pk
|
|
575
|
-
* @returns {Uint8Array}
|
|
576
|
-
*/
|
|
577
|
-
export function public_sig_key_to_u8vec(pk) {
|
|
578
|
-
_assertClass(pk, PublicSigKey);
|
|
579
|
-
const ret = wasm.public_sig_key_to_u8vec(pk.__wbg_ptr);
|
|
580
|
-
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
581
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
582
|
-
return v1;
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
/**
|
|
586
|
-
* This function is *not* used by relayer-sdk because the decryption
|
|
587
|
-
* is handled by [process_user_decryption_resp].
|
|
588
|
-
* It's just here for completeness and tests.
|
|
589
|
-
* @param {Uint8Array} ct
|
|
590
|
-
* @param {PrivateEncKeyMlKem512} my_sk
|
|
591
|
-
* @returns {Uint8Array}
|
|
592
|
-
*/
|
|
593
|
-
export function ml_kem_pke_decrypt(ct, my_sk) {
|
|
594
|
-
const ptr0 = passArray8ToWasm0(ct, wasm.__wbindgen_malloc);
|
|
595
|
-
const len0 = WASM_VECTOR_LEN;
|
|
596
|
-
_assertClass(my_sk, PrivateEncKeyMlKem512);
|
|
597
|
-
const ret = wasm.ml_kem_pke_decrypt(ptr0, len0, my_sk.__wbg_ptr);
|
|
598
|
-
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
599
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
600
|
-
return v2;
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
/**
|
|
604
|
-
* @param {PrivateSigKey} sk
|
|
605
|
-
* @returns {Uint8Array}
|
|
606
|
-
*/
|
|
607
|
-
export function private_sig_key_to_u8vec(sk) {
|
|
608
|
-
_assertClass(sk, PrivateSigKey);
|
|
609
|
-
const ret = wasm.private_sig_key_to_u8vec(sk.__wbg_ptr);
|
|
610
|
-
if (ret[3]) {
|
|
611
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
612
|
-
}
|
|
613
|
-
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
614
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
615
|
-
return v1;
|
|
616
|
-
}
|
|
617
|
-
|
|
618
618
|
const CiphertextHandleFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
619
619
|
? { register: () => {}, unregister: () => {} }
|
|
620
620
|
: new FinalizationRegistry(ptr => wasm.__wbg_ciphertexthandle_free(ptr >>> 0, 1));
|
package/kms_lib_bg.wasm
CHANGED
|
Binary file
|