tkms 0.12.7 → 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 +40 -40
- package/kms_lib.js +219 -218
- package/kms_lib_bg.wasm +0 -0
- package/package.json +1 -1
package/kms_lib.d.ts
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* This function is *not* used by relayer-sdk because the encryption
|
|
5
|
+
* happens on the KMS side. It's just here for completeness and tests.
|
|
6
|
+
*/
|
|
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;
|
|
31
|
+
export function u8vec_to_public_sig_key(v: Uint8Array): PublicSigKey;
|
|
32
|
+
export function u8vec_to_ml_kem_pke_pk(v: Uint8Array): PublicEncKeyMlKem512;
|
|
33
|
+
export function ml_kem_pke_pk_len(): number;
|
|
34
|
+
export function get_server_addrs(client: Client): ServerIdAddr[];
|
|
3
35
|
/**
|
|
4
36
|
* Process the user_decryption response from JavaScript objects.
|
|
5
37
|
* The returned result is a byte array representing a plaintext of any length,
|
|
@@ -62,32 +94,15 @@
|
|
|
62
94
|
* It is insecure if `verify = false`!
|
|
63
95
|
*/
|
|
64
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[];
|
|
65
|
-
export function ml_kem_pke_keygen(): PrivateEncKeyMlKem512;
|
|
66
97
|
/**
|
|
67
98
|
* Create a new [ServerIdAddr] structure that holds an ID and an address
|
|
68
99
|
* which must be a valid EIP-55 address, notably prefixed with "0x".
|
|
69
100
|
*/
|
|
70
101
|
export function new_server_id_addr(id: number, addr: string): ServerIdAddr;
|
|
71
|
-
export function private_sig_key_to_u8vec(sk: PrivateSigKey): Uint8Array;
|
|
72
|
-
export function ml_kem_pke_get_pk(sk: PrivateEncKeyMlKem512): PublicEncKeyMlKem512;
|
|
73
|
-
export function u8vec_to_ml_kem_pke_pk(v: Uint8Array): PublicEncKeyMlKem512;
|
|
74
102
|
export function ml_kem_pke_sk_len(): number;
|
|
75
|
-
|
|
76
|
-
* This function is *not* used by relayer-sdk because the decryption
|
|
77
|
-
* is handled by [process_user_decryption_resp].
|
|
78
|
-
* It's just here for completeness and tests.
|
|
79
|
-
*/
|
|
80
|
-
export function ml_kem_pke_decrypt(ct: Uint8Array, my_sk: PrivateEncKeyMlKem512): Uint8Array;
|
|
81
|
-
export function u8vec_to_public_sig_key(v: Uint8Array): PublicSigKey;
|
|
82
|
-
export function ml_kem_pke_sk_to_u8vec(sk: PrivateEncKeyMlKem512): Uint8Array;
|
|
83
|
-
export function ml_kem_pke_pk_to_u8vec(pk: PublicEncKeyMlKem512): Uint8Array;
|
|
103
|
+
export function private_sig_key_to_u8vec(sk: PrivateSigKey): Uint8Array;
|
|
84
104
|
export function u8vec_to_ml_kem_pke_sk(v: Uint8Array): PrivateEncKeyMlKem512;
|
|
85
|
-
export function
|
|
86
|
-
/**
|
|
87
|
-
* This function is *not* used by relayer-sdk because the encryption
|
|
88
|
-
* happens on the KMS side. It's just here for completeness and tests.
|
|
89
|
-
*/
|
|
90
|
-
export function ml_kem_pke_encrypt(msg: Uint8Array, their_pk: PublicEncKeyMlKem512): Uint8Array;
|
|
105
|
+
export function get_client_address(client: Client): string;
|
|
91
106
|
/**
|
|
92
107
|
* Process the user_decryption response from Rust objects.
|
|
93
108
|
* Consider using [process_user_decryption_resp_from_js]
|
|
@@ -112,24 +127,9 @@ export function ml_kem_pke_encrypt(msg: Uint8Array, their_pk: PublicEncKeyMlKem5
|
|
|
112
127
|
* It is insecure if `verify = false`!
|
|
113
128
|
*/
|
|
114
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[];
|
|
115
|
-
export function public_sig_key_to_u8vec(pk: PublicSigKey): Uint8Array;
|
|
116
|
-
export function get_server_addrs(client: Client): ServerIdAddr[];
|
|
117
|
-
export function u8vec_to_private_sig_key(v: Uint8Array): PrivateSigKey;
|
|
118
|
-
export function get_client_address(client: Client): string;
|
|
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
130
|
export function get_client_secret_key(client: Client): PrivateSigKey | undefined;
|
|
131
|
+
export function ml_kem_pke_pk_to_u8vec(pk: PublicEncKeyMlKem512): Uint8Array;
|
|
132
|
+
export function ml_kem_pke_sk_to_u8vec(sk: PrivateEncKeyMlKem512): Uint8Array;
|
|
133
133
|
export class CiphertextHandle {
|
|
134
134
|
private constructor();
|
|
135
135
|
free(): void;
|
|
@@ -391,6 +391,8 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
391
391
|
export interface InitOutput {
|
|
392
392
|
readonly memory: WebAssembly.Memory;
|
|
393
393
|
readonly __wbg_client_free: (a: number, b: number) => void;
|
|
394
|
+
readonly __wbg_ciphertexthandle_free: (a: number, b: number) => void;
|
|
395
|
+
readonly __wbg_parseduserdecryptionrequest_free: (a: number, b: number) => void;
|
|
394
396
|
readonly __wbg_privateenckeymlkem512_free: (a: number, b: number) => void;
|
|
395
397
|
readonly __wbg_publicenckeymlkem512_free: (a: number, b: number) => void;
|
|
396
398
|
readonly __wbg_serveridaddr_free: (a: number, b: number) => void;
|
|
@@ -415,8 +417,6 @@ export interface InitOutput {
|
|
|
415
417
|
readonly u8vec_to_ml_kem_pke_sk: (a: number, b: number) => [number, number, number];
|
|
416
418
|
readonly u8vec_to_private_sig_key: (a: number, b: number) => [number, number, number];
|
|
417
419
|
readonly u8vec_to_public_sig_key: (a: number, b: number) => [number, number, number];
|
|
418
|
-
readonly __wbg_ciphertexthandle_free: (a: number, b: number) => void;
|
|
419
|
-
readonly __wbg_parseduserdecryptionrequest_free: (a: number, b: number) => void;
|
|
420
420
|
readonly __wbg_privatesigkey_free: (a: number, b: number) => void;
|
|
421
421
|
readonly __wbg_publicsigkey_free: (a: number, b: number) => void;
|
|
422
422
|
readonly __wbg_eip712domainmsg_free: (a: number, b: number) => void;
|
|
@@ -425,13 +425,11 @@ export interface InitOutput {
|
|
|
425
425
|
readonly __wbg_get_eip712domainmsg_salt: (a: number) => [number, number];
|
|
426
426
|
readonly __wbg_get_eip712domainmsg_verifying_contract: (a: number) => [number, number];
|
|
427
427
|
readonly __wbg_get_eip712domainmsg_version: (a: number) => [number, number];
|
|
428
|
-
readonly __wbg_get_requestid_request_id: (a: number) => [number, number];
|
|
429
428
|
readonly __wbg_get_typedciphertext_ciphertext: (a: number) => [number, number];
|
|
430
429
|
readonly __wbg_get_typedciphertext_ciphertext_format: (a: number) => number;
|
|
431
430
|
readonly __wbg_get_typedciphertext_external_handle: (a: number) => [number, number];
|
|
432
431
|
readonly __wbg_get_typedciphertext_fhe_type: (a: number) => number;
|
|
433
432
|
readonly __wbg_get_typedplaintext_fhe_type: (a: number) => number;
|
|
434
|
-
readonly __wbg_get_userdecryptionrequest_client_address: (a: number) => [number, number];
|
|
435
433
|
readonly __wbg_get_userdecryptionrequest_context_id: (a: number) => number;
|
|
436
434
|
readonly __wbg_get_userdecryptionrequest_domain: (a: number) => number;
|
|
437
435
|
readonly __wbg_get_userdecryptionrequest_epoch_id: (a: number) => number;
|
|
@@ -468,6 +466,8 @@ export interface InitOutput {
|
|
|
468
466
|
readonly __wbg_userdecryptionrequest_free: (a: number, b: number) => void;
|
|
469
467
|
readonly __wbg_userdecryptionresponse_free: (a: number, b: number) => void;
|
|
470
468
|
readonly __wbg_userdecryptionresponsepayload_free: (a: number, b: number) => void;
|
|
469
|
+
readonly __wbg_get_requestid_request_id: (a: number) => [number, number];
|
|
470
|
+
readonly __wbg_get_userdecryptionrequest_client_address: (a: number) => [number, number];
|
|
471
471
|
readonly __wbg_set_typedsigncryptedciphertext_fhe_type: (a: number, b: number) => void;
|
|
472
472
|
readonly __wbg_set_typedsigncryptedciphertext_packing_factor: (a: number, b: number) => void;
|
|
473
473
|
readonly __wbg_set_requestid_request_id: (a: number, b: number, c: number) => void;
|
package/kms_lib.js
CHANGED
|
@@ -167,17 +167,182 @@ function debugString(val) {
|
|
|
167
167
|
return className;
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
171
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
172
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
173
|
+
WASM_VECTOR_LEN = arg.length;
|
|
174
|
+
return ptr;
|
|
175
|
+
}
|
|
176
|
+
|
|
170
177
|
function _assertClass(instance, klass) {
|
|
171
178
|
if (!(instance instanceof klass)) {
|
|
172
179
|
throw new Error(`expected instance of ${klass.name}`);
|
|
173
180
|
}
|
|
174
181
|
}
|
|
175
182
|
|
|
183
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
184
|
+
ptr = ptr >>> 0;
|
|
185
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* This function is *not* used by relayer-sdk because the encryption
|
|
189
|
+
* happens on the KMS side. It's just here for completeness and tests.
|
|
190
|
+
* @param {Uint8Array} msg
|
|
191
|
+
* @param {PublicEncKeyMlKem512} their_pk
|
|
192
|
+
* @returns {Uint8Array}
|
|
193
|
+
*/
|
|
194
|
+
export function ml_kem_pke_encrypt(msg, their_pk) {
|
|
195
|
+
const ptr0 = passArray8ToWasm0(msg, wasm.__wbindgen_malloc);
|
|
196
|
+
const len0 = WASM_VECTOR_LEN;
|
|
197
|
+
_assertClass(their_pk, PublicEncKeyMlKem512);
|
|
198
|
+
const ret = wasm.ml_kem_pke_encrypt(ptr0, len0, their_pk.__wbg_ptr);
|
|
199
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
200
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
201
|
+
return v2;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
205
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
206
|
+
for (let i = 0; i < array.length; i++) {
|
|
207
|
+
const add = addToExternrefTable0(array[i]);
|
|
208
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
209
|
+
}
|
|
210
|
+
WASM_VECTOR_LEN = array.length;
|
|
211
|
+
return ptr;
|
|
212
|
+
}
|
|
213
|
+
|
|
176
214
|
function takeFromExternrefTable0(idx) {
|
|
177
215
|
const value = wasm.__wbindgen_export_4.get(idx);
|
|
178
216
|
wasm.__externref_table_dealloc(idx);
|
|
179
217
|
return value;
|
|
180
218
|
}
|
|
219
|
+
/**
|
|
220
|
+
* Instantiate a new client.
|
|
221
|
+
*
|
|
222
|
+
* * `server_addrs` - a list of KMS server ID with EIP-55 addresses,
|
|
223
|
+
* the elements in the list can be created using [new_server_id_addr].
|
|
224
|
+
*
|
|
225
|
+
* * `client_address_hex` - the client (wallet) address in hex,
|
|
226
|
+
* must be prefixed with "0x".
|
|
227
|
+
*
|
|
228
|
+
* * `fhe_parameter` - the parameter choice, which can be either `"test"` or `"default"`.
|
|
229
|
+
* The "default" parameter choice is selected if no matching string is found.
|
|
230
|
+
* @param {ServerIdAddr[]} server_addrs
|
|
231
|
+
* @param {string} client_address_hex
|
|
232
|
+
* @param {string} fhe_parameter
|
|
233
|
+
* @returns {Client}
|
|
234
|
+
*/
|
|
235
|
+
export function new_client(server_addrs, client_address_hex, fhe_parameter) {
|
|
236
|
+
const ptr0 = passArrayJsValueToWasm0(server_addrs, wasm.__wbindgen_malloc);
|
|
237
|
+
const len0 = WASM_VECTOR_LEN;
|
|
238
|
+
const ptr1 = passStringToWasm0(client_address_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
239
|
+
const len1 = WASM_VECTOR_LEN;
|
|
240
|
+
const ptr2 = passStringToWasm0(fhe_parameter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
241
|
+
const len2 = WASM_VECTOR_LEN;
|
|
242
|
+
const ret = wasm.new_client(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
243
|
+
if (ret[2]) {
|
|
244
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
245
|
+
}
|
|
246
|
+
return Client.__wrap(ret[0]);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* @returns {PrivateEncKeyMlKem512}
|
|
251
|
+
*/
|
|
252
|
+
export function ml_kem_pke_keygen() {
|
|
253
|
+
const ret = wasm.ml_kem_pke_keygen();
|
|
254
|
+
return PrivateEncKeyMlKem512.__wrap(ret);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* @param {PrivateEncKeyMlKem512} sk
|
|
259
|
+
* @returns {PublicEncKeyMlKem512}
|
|
260
|
+
*/
|
|
261
|
+
export function ml_kem_pke_get_pk(sk) {
|
|
262
|
+
_assertClass(sk, PrivateEncKeyMlKem512);
|
|
263
|
+
const ret = wasm.ml_kem_pke_get_pk(sk.__wbg_ptr);
|
|
264
|
+
return PublicEncKeyMlKem512.__wrap(ret);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* @param {Uint8Array} v
|
|
269
|
+
* @returns {PrivateSigKey}
|
|
270
|
+
*/
|
|
271
|
+
export function u8vec_to_private_sig_key(v) {
|
|
272
|
+
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
273
|
+
const len0 = WASM_VECTOR_LEN;
|
|
274
|
+
const ret = wasm.u8vec_to_private_sig_key(ptr0, len0);
|
|
275
|
+
if (ret[2]) {
|
|
276
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
277
|
+
}
|
|
278
|
+
return PrivateSigKey.__wrap(ret[0]);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* @param {PublicSigKey} pk
|
|
283
|
+
* @returns {Uint8Array}
|
|
284
|
+
*/
|
|
285
|
+
export function public_sig_key_to_u8vec(pk) {
|
|
286
|
+
_assertClass(pk, PublicSigKey);
|
|
287
|
+
const ret = wasm.public_sig_key_to_u8vec(pk.__wbg_ptr);
|
|
288
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
289
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
290
|
+
return v1;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* This function is *not* used by relayer-sdk because the decryption
|
|
295
|
+
* is handled by [process_user_decryption_resp].
|
|
296
|
+
* It's just here for completeness and tests.
|
|
297
|
+
* @param {Uint8Array} ct
|
|
298
|
+
* @param {PrivateEncKeyMlKem512} my_sk
|
|
299
|
+
* @returns {Uint8Array}
|
|
300
|
+
*/
|
|
301
|
+
export function ml_kem_pke_decrypt(ct, my_sk) {
|
|
302
|
+
const ptr0 = passArray8ToWasm0(ct, wasm.__wbindgen_malloc);
|
|
303
|
+
const len0 = WASM_VECTOR_LEN;
|
|
304
|
+
_assertClass(my_sk, PrivateEncKeyMlKem512);
|
|
305
|
+
const ret = wasm.ml_kem_pke_decrypt(ptr0, len0, my_sk.__wbg_ptr);
|
|
306
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
307
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
308
|
+
return v2;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* @param {Uint8Array} v
|
|
313
|
+
* @returns {PublicSigKey}
|
|
314
|
+
*/
|
|
315
|
+
export function u8vec_to_public_sig_key(v) {
|
|
316
|
+
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
317
|
+
const len0 = WASM_VECTOR_LEN;
|
|
318
|
+
const ret = wasm.u8vec_to_public_sig_key(ptr0, len0);
|
|
319
|
+
if (ret[2]) {
|
|
320
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
321
|
+
}
|
|
322
|
+
return PublicSigKey.__wrap(ret[0]);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* @param {Uint8Array} v
|
|
327
|
+
* @returns {PublicEncKeyMlKem512}
|
|
328
|
+
*/
|
|
329
|
+
export function u8vec_to_ml_kem_pke_pk(v) {
|
|
330
|
+
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
331
|
+
const len0 = WASM_VECTOR_LEN;
|
|
332
|
+
const ret = wasm.u8vec_to_ml_kem_pke_pk(ptr0, len0);
|
|
333
|
+
if (ret[2]) {
|
|
334
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
335
|
+
}
|
|
336
|
+
return PublicEncKeyMlKem512.__wrap(ret[0]);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* @returns {number}
|
|
341
|
+
*/
|
|
342
|
+
export function ml_kem_pke_pk_len() {
|
|
343
|
+
const ret = wasm.ml_kem_pke_pk_len();
|
|
344
|
+
return ret >>> 0;
|
|
345
|
+
}
|
|
181
346
|
|
|
182
347
|
function getArrayJsValueFromWasm0(ptr, len) {
|
|
183
348
|
ptr = ptr >>> 0;
|
|
@@ -189,6 +354,18 @@ function getArrayJsValueFromWasm0(ptr, len) {
|
|
|
189
354
|
wasm.__externref_drop_slice(ptr, len);
|
|
190
355
|
return result;
|
|
191
356
|
}
|
|
357
|
+
/**
|
|
358
|
+
* @param {Client} client
|
|
359
|
+
* @returns {ServerIdAddr[]}
|
|
360
|
+
*/
|
|
361
|
+
export function get_server_addrs(client) {
|
|
362
|
+
_assertClass(client, Client);
|
|
363
|
+
const ret = wasm.get_server_addrs(client.__wbg_ptr);
|
|
364
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
365
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
366
|
+
return v1;
|
|
367
|
+
}
|
|
368
|
+
|
|
192
369
|
/**
|
|
193
370
|
* Process the user_decryption response from JavaScript objects.
|
|
194
371
|
* The returned result is a byte array representing a plaintext of any length,
|
|
@@ -271,14 +448,6 @@ export function process_user_decryption_resp_from_js(client, request, eip712_dom
|
|
|
271
448
|
return v1;
|
|
272
449
|
}
|
|
273
450
|
|
|
274
|
-
/**
|
|
275
|
-
* @returns {PrivateEncKeyMlKem512}
|
|
276
|
-
*/
|
|
277
|
-
export function ml_kem_pke_keygen() {
|
|
278
|
-
const ret = wasm.ml_kem_pke_keygen();
|
|
279
|
-
return PrivateEncKeyMlKem512.__wrap(ret);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
451
|
/**
|
|
283
452
|
* Create a new [ServerIdAddr] structure that holds an ID and an address
|
|
284
453
|
* which must be a valid EIP-55 address, notably prefixed with "0x".
|
|
@@ -296,55 +465,6 @@ export function new_server_id_addr(id, addr) {
|
|
|
296
465
|
return ServerIdAddr.__wrap(ret[0]);
|
|
297
466
|
}
|
|
298
467
|
|
|
299
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
300
|
-
ptr = ptr >>> 0;
|
|
301
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* @param {PrivateSigKey} sk
|
|
305
|
-
* @returns {Uint8Array}
|
|
306
|
-
*/
|
|
307
|
-
export function private_sig_key_to_u8vec(sk) {
|
|
308
|
-
_assertClass(sk, PrivateSigKey);
|
|
309
|
-
const ret = wasm.private_sig_key_to_u8vec(sk.__wbg_ptr);
|
|
310
|
-
if (ret[3]) {
|
|
311
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
312
|
-
}
|
|
313
|
-
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
314
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
315
|
-
return v1;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* @param {PrivateEncKeyMlKem512} sk
|
|
320
|
-
* @returns {PublicEncKeyMlKem512}
|
|
321
|
-
*/
|
|
322
|
-
export function ml_kem_pke_get_pk(sk) {
|
|
323
|
-
_assertClass(sk, PrivateEncKeyMlKem512);
|
|
324
|
-
const ret = wasm.ml_kem_pke_get_pk(sk.__wbg_ptr);
|
|
325
|
-
return PublicEncKeyMlKem512.__wrap(ret);
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
329
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
330
|
-
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
331
|
-
WASM_VECTOR_LEN = arg.length;
|
|
332
|
-
return ptr;
|
|
333
|
-
}
|
|
334
|
-
/**
|
|
335
|
-
* @param {Uint8Array} v
|
|
336
|
-
* @returns {PublicEncKeyMlKem512}
|
|
337
|
-
*/
|
|
338
|
-
export function u8vec_to_ml_kem_pke_pk(v) {
|
|
339
|
-
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
340
|
-
const len0 = WASM_VECTOR_LEN;
|
|
341
|
-
const ret = wasm.u8vec_to_ml_kem_pke_pk(ptr0, len0);
|
|
342
|
-
if (ret[2]) {
|
|
343
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
344
|
-
}
|
|
345
|
-
return PublicEncKeyMlKem512.__wrap(ret[0]);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
468
|
/**
|
|
349
469
|
* @returns {number}
|
|
350
470
|
*/
|
|
@@ -354,59 +474,12 @@ export function ml_kem_pke_sk_len() {
|
|
|
354
474
|
}
|
|
355
475
|
|
|
356
476
|
/**
|
|
357
|
-
*
|
|
358
|
-
* is handled by [process_user_decryption_resp].
|
|
359
|
-
* It's just here for completeness and tests.
|
|
360
|
-
* @param {Uint8Array} ct
|
|
361
|
-
* @param {PrivateEncKeyMlKem512} my_sk
|
|
362
|
-
* @returns {Uint8Array}
|
|
363
|
-
*/
|
|
364
|
-
export function ml_kem_pke_decrypt(ct, my_sk) {
|
|
365
|
-
const ptr0 = passArray8ToWasm0(ct, wasm.__wbindgen_malloc);
|
|
366
|
-
const len0 = WASM_VECTOR_LEN;
|
|
367
|
-
_assertClass(my_sk, PrivateEncKeyMlKem512);
|
|
368
|
-
const ret = wasm.ml_kem_pke_decrypt(ptr0, len0, my_sk.__wbg_ptr);
|
|
369
|
-
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
370
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
371
|
-
return v2;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* @param {Uint8Array} v
|
|
376
|
-
* @returns {PublicSigKey}
|
|
377
|
-
*/
|
|
378
|
-
export function u8vec_to_public_sig_key(v) {
|
|
379
|
-
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
380
|
-
const len0 = WASM_VECTOR_LEN;
|
|
381
|
-
const ret = wasm.u8vec_to_public_sig_key(ptr0, len0);
|
|
382
|
-
if (ret[2]) {
|
|
383
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
384
|
-
}
|
|
385
|
-
return PublicSigKey.__wrap(ret[0]);
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
/**
|
|
389
|
-
* @param {PrivateEncKeyMlKem512} sk
|
|
390
|
-
* @returns {Uint8Array}
|
|
391
|
-
*/
|
|
392
|
-
export function ml_kem_pke_sk_to_u8vec(sk) {
|
|
393
|
-
_assertClass(sk, PrivateEncKeyMlKem512);
|
|
394
|
-
const ret = wasm.ml_kem_pke_sk_to_u8vec(sk.__wbg_ptr);
|
|
395
|
-
if (ret[3]) {
|
|
396
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
397
|
-
}
|
|
398
|
-
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
399
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
400
|
-
return v1;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
/**
|
|
404
|
-
* @param {PublicEncKeyMlKem512} pk
|
|
477
|
+
* @param {PrivateSigKey} sk
|
|
405
478
|
* @returns {Uint8Array}
|
|
406
479
|
*/
|
|
407
|
-
export function
|
|
408
|
-
_assertClass(
|
|
409
|
-
const ret = wasm.
|
|
480
|
+
export function private_sig_key_to_u8vec(sk) {
|
|
481
|
+
_assertClass(sk, PrivateSigKey);
|
|
482
|
+
const ret = wasm.private_sig_key_to_u8vec(sk.__wbg_ptr);
|
|
410
483
|
if (ret[3]) {
|
|
411
484
|
throw takeFromExternrefTable0(ret[2]);
|
|
412
485
|
}
|
|
@@ -430,39 +503,23 @@ export function u8vec_to_ml_kem_pke_sk(v) {
|
|
|
430
503
|
}
|
|
431
504
|
|
|
432
505
|
/**
|
|
433
|
-
* @
|
|
434
|
-
|
|
435
|
-
export function ml_kem_pke_pk_len() {
|
|
436
|
-
const ret = wasm.ml_kem_pke_pk_len();
|
|
437
|
-
return ret >>> 0;
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
/**
|
|
441
|
-
* This function is *not* used by relayer-sdk because the encryption
|
|
442
|
-
* happens on the KMS side. It's just here for completeness and tests.
|
|
443
|
-
* @param {Uint8Array} msg
|
|
444
|
-
* @param {PublicEncKeyMlKem512} their_pk
|
|
445
|
-
* @returns {Uint8Array}
|
|
506
|
+
* @param {Client} client
|
|
507
|
+
* @returns {string}
|
|
446
508
|
*/
|
|
447
|
-
export function
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
459
|
-
for (let i = 0; i < array.length; i++) {
|
|
460
|
-
const add = addToExternrefTable0(array[i]);
|
|
461
|
-
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
509
|
+
export function get_client_address(client) {
|
|
510
|
+
let deferred1_0;
|
|
511
|
+
let deferred1_1;
|
|
512
|
+
try {
|
|
513
|
+
_assertClass(client, Client);
|
|
514
|
+
const ret = wasm.get_client_address(client.__wbg_ptr);
|
|
515
|
+
deferred1_0 = ret[0];
|
|
516
|
+
deferred1_1 = ret[1];
|
|
517
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
518
|
+
} finally {
|
|
519
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
462
520
|
}
|
|
463
|
-
WASM_VECTOR_LEN = array.length;
|
|
464
|
-
return ptr;
|
|
465
521
|
}
|
|
522
|
+
|
|
466
523
|
/**
|
|
467
524
|
* Process the user_decryption response from Rust objects.
|
|
468
525
|
* Consider using [process_user_decryption_resp_from_js]
|
|
@@ -519,100 +576,44 @@ export function process_user_decryption_resp(client, request, eip712_domain, agg
|
|
|
519
576
|
return v4;
|
|
520
577
|
}
|
|
521
578
|
|
|
522
|
-
/**
|
|
523
|
-
* @param {PublicSigKey} pk
|
|
524
|
-
* @returns {Uint8Array}
|
|
525
|
-
*/
|
|
526
|
-
export function public_sig_key_to_u8vec(pk) {
|
|
527
|
-
_assertClass(pk, PublicSigKey);
|
|
528
|
-
const ret = wasm.public_sig_key_to_u8vec(pk.__wbg_ptr);
|
|
529
|
-
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
530
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
531
|
-
return v1;
|
|
532
|
-
}
|
|
533
|
-
|
|
534
579
|
/**
|
|
535
580
|
* @param {Client} client
|
|
536
|
-
* @returns {
|
|
581
|
+
* @returns {PrivateSigKey | undefined}
|
|
537
582
|
*/
|
|
538
|
-
export function
|
|
583
|
+
export function get_client_secret_key(client) {
|
|
539
584
|
_assertClass(client, Client);
|
|
540
|
-
const ret = wasm.
|
|
541
|
-
|
|
542
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
543
|
-
return v1;
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
/**
|
|
547
|
-
* @param {Uint8Array} v
|
|
548
|
-
* @returns {PrivateSigKey}
|
|
549
|
-
*/
|
|
550
|
-
export function u8vec_to_private_sig_key(v) {
|
|
551
|
-
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
552
|
-
const len0 = WASM_VECTOR_LEN;
|
|
553
|
-
const ret = wasm.u8vec_to_private_sig_key(ptr0, len0);
|
|
554
|
-
if (ret[2]) {
|
|
555
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
556
|
-
}
|
|
557
|
-
return PrivateSigKey.__wrap(ret[0]);
|
|
585
|
+
const ret = wasm.get_client_secret_key(client.__wbg_ptr);
|
|
586
|
+
return ret === 0 ? undefined : PrivateSigKey.__wrap(ret);
|
|
558
587
|
}
|
|
559
588
|
|
|
560
589
|
/**
|
|
561
|
-
* @param {
|
|
562
|
-
* @returns {
|
|
590
|
+
* @param {PublicEncKeyMlKem512} pk
|
|
591
|
+
* @returns {Uint8Array}
|
|
563
592
|
*/
|
|
564
|
-
export function
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
const ret = wasm.get_client_address(client.__wbg_ptr);
|
|
570
|
-
deferred1_0 = ret[0];
|
|
571
|
-
deferred1_1 = ret[1];
|
|
572
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
573
|
-
} finally {
|
|
574
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
593
|
+
export function ml_kem_pke_pk_to_u8vec(pk) {
|
|
594
|
+
_assertClass(pk, PublicEncKeyMlKem512);
|
|
595
|
+
const ret = wasm.ml_kem_pke_pk_to_u8vec(pk.__wbg_ptr);
|
|
596
|
+
if (ret[3]) {
|
|
597
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
575
598
|
}
|
|
599
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
600
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
601
|
+
return v1;
|
|
576
602
|
}
|
|
577
603
|
|
|
578
604
|
/**
|
|
579
|
-
*
|
|
580
|
-
*
|
|
581
|
-
* * `server_addrs` - a list of KMS server ID with EIP-55 addresses,
|
|
582
|
-
* the elements in the list can be created using [new_server_id_addr].
|
|
583
|
-
*
|
|
584
|
-
* * `client_address_hex` - the client (wallet) address in hex,
|
|
585
|
-
* must be prefixed with "0x".
|
|
586
|
-
*
|
|
587
|
-
* * `fhe_parameter` - the parameter choice, which can be either `"test"` or `"default"`.
|
|
588
|
-
* The "default" parameter choice is selected if no matching string is found.
|
|
589
|
-
* @param {ServerIdAddr[]} server_addrs
|
|
590
|
-
* @param {string} client_address_hex
|
|
591
|
-
* @param {string} fhe_parameter
|
|
592
|
-
* @returns {Client}
|
|
605
|
+
* @param {PrivateEncKeyMlKem512} sk
|
|
606
|
+
* @returns {Uint8Array}
|
|
593
607
|
*/
|
|
594
|
-
export function
|
|
595
|
-
|
|
596
|
-
const
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
const ptr2 = passStringToWasm0(fhe_parameter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
600
|
-
const len2 = WASM_VECTOR_LEN;
|
|
601
|
-
const ret = wasm.new_client(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
602
|
-
if (ret[2]) {
|
|
603
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
608
|
+
export function ml_kem_pke_sk_to_u8vec(sk) {
|
|
609
|
+
_assertClass(sk, PrivateEncKeyMlKem512);
|
|
610
|
+
const ret = wasm.ml_kem_pke_sk_to_u8vec(sk.__wbg_ptr);
|
|
611
|
+
if (ret[3]) {
|
|
612
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
604
613
|
}
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
/**
|
|
609
|
-
* @param {Client} client
|
|
610
|
-
* @returns {PrivateSigKey | undefined}
|
|
611
|
-
*/
|
|
612
|
-
export function get_client_secret_key(client) {
|
|
613
|
-
_assertClass(client, Client);
|
|
614
|
-
const ret = wasm.get_client_secret_key(client.__wbg_ptr);
|
|
615
|
-
return ret === 0 ? undefined : PrivateSigKey.__wrap(ret);
|
|
614
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
615
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
616
|
+
return v1;
|
|
616
617
|
}
|
|
617
618
|
|
|
618
619
|
const CiphertextHandleFinalization = (typeof FinalizationRegistry === 'undefined')
|
package/kms_lib_bg.wasm
CHANGED
|
Binary file
|