tkms 0.13.0 → 0.13.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 +43 -43
- package/kms_lib.js +250 -250
- package/kms_lib_bg.wasm +0 -0
- package/package.json +1 -1
package/kms_lib.d.ts
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Instantiate a new client.
|
|
5
|
+
*
|
|
6
|
+
* * `server_addrs` - a list of KMS server ID with EIP-55 addresses,
|
|
7
|
+
* the elements in the list can be created using [new_server_id_addr].
|
|
8
|
+
*
|
|
9
|
+
* * `client_address_hex` - the client (wallet) address in hex,
|
|
10
|
+
* must be prefixed with "0x".
|
|
11
|
+
*
|
|
12
|
+
* * `fhe_parameter` - the parameter choice, which can be either `"test"` or `"default"`.
|
|
13
|
+
* The "default" parameter choice is selected if no matching string is found.
|
|
14
|
+
*/
|
|
15
|
+
export function new_client(server_addrs: ServerIdAddr[], client_address_hex: string, fhe_parameter: string): Client;
|
|
16
|
+
/**
|
|
17
|
+
* Create a new [ServerIdAddr] structure that holds an ID and an address
|
|
18
|
+
* which must be a valid EIP-55 address, notably prefixed with "0x".
|
|
19
|
+
*/
|
|
20
|
+
export function new_server_id_addr(id: number, addr: string): ServerIdAddr;
|
|
9
21
|
/**
|
|
10
22
|
* Process the user_decryption response from Rust objects.
|
|
11
23
|
* Consider using [process_user_decryption_resp_from_js]
|
|
@@ -30,43 +42,8 @@ export function u8vec_to_ml_kem_pke_sk(v: Uint8Array): PrivateEncKeyMlKem512;
|
|
|
30
42
|
* It is insecure if `verify = false`!
|
|
31
43
|
*/
|
|
32
44
|
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;
|
|
54
|
-
export function ml_kem_pke_get_pk(sk: PrivateEncKeyMlKem512): PublicEncKeyMlKem512;
|
|
55
|
-
/**
|
|
56
|
-
* Create a new [ServerIdAddr] structure that holds an ID and an address
|
|
57
|
-
* which must be a valid EIP-55 address, notably prefixed with "0x".
|
|
58
|
-
*/
|
|
59
|
-
export function new_server_id_addr(id: number, addr: string): ServerIdAddr;
|
|
60
|
-
export function ml_kem_pke_sk_len(): number;
|
|
61
45
|
export function ml_kem_pke_keygen(): PrivateEncKeyMlKem512;
|
|
62
|
-
export function
|
|
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;
|
|
46
|
+
export function ml_kem_pke_sk_len(): number;
|
|
70
47
|
export function ml_kem_pke_pk_to_u8vec(pk: PublicEncKeyMlKem512): Uint8Array;
|
|
71
48
|
/**
|
|
72
49
|
* Process the user_decryption response from JavaScript objects.
|
|
@@ -130,6 +107,29 @@ export function ml_kem_pke_pk_to_u8vec(pk: PublicEncKeyMlKem512): Uint8Array;
|
|
|
130
107
|
* It is insecure if `verify = false`!
|
|
131
108
|
*/
|
|
132
109
|
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[];
|
|
110
|
+
/**
|
|
111
|
+
* This function is *not* used by relayer-sdk because the decryption
|
|
112
|
+
* is handled by [process_user_decryption_resp].
|
|
113
|
+
* It's just here for completeness and tests.
|
|
114
|
+
*/
|
|
115
|
+
export function ml_kem_pke_decrypt(ct: Uint8Array, my_sk: PrivateEncKeyMlKem512): Uint8Array;
|
|
116
|
+
export function get_client_secret_key(client: Client): PrivateSigKey | undefined;
|
|
117
|
+
/**
|
|
118
|
+
* This function is *not* used by relayer-sdk because the encryption
|
|
119
|
+
* happens on the KMS side. It's just here for completeness and tests.
|
|
120
|
+
*/
|
|
121
|
+
export function ml_kem_pke_encrypt(msg: Uint8Array, their_pk: PublicEncKeyMlKem512): Uint8Array;
|
|
122
|
+
export function u8vec_to_private_sig_key(v: Uint8Array): PrivateSigKey;
|
|
123
|
+
export function public_sig_key_to_u8vec(pk: PublicSigKey): Uint8Array;
|
|
124
|
+
export function u8vec_to_ml_kem_pke_sk(v: Uint8Array): PrivateEncKeyMlKem512;
|
|
125
|
+
export function ml_kem_pke_get_pk(sk: PrivateEncKeyMlKem512): PublicEncKeyMlKem512;
|
|
126
|
+
export function ml_kem_pke_sk_to_u8vec(sk: PrivateEncKeyMlKem512): Uint8Array;
|
|
127
|
+
export function ml_kem_pke_pk_len(): number;
|
|
128
|
+
export function get_client_address(client: Client): string;
|
|
129
|
+
export function u8vec_to_public_sig_key(v: Uint8Array): PublicSigKey;
|
|
130
|
+
export function u8vec_to_ml_kem_pke_pk(v: Uint8Array): PublicEncKeyMlKem512;
|
|
131
|
+
export function get_server_addrs(client: Client): ServerIdAddr[];
|
|
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_drop_slice: (a: number, b: number) => void;
|
|
505
504
|
readonly __externref_table_dealloc: (a: number) => void;
|
|
505
|
+
readonly __externref_drop_slice: (a: number, b: number) => void;
|
|
506
506
|
readonly __wbindgen_start: () => void;
|
|
507
507
|
}
|
|
508
508
|
|
package/kms_lib.js
CHANGED
|
@@ -167,38 +167,13 @@ function debugString(val) {
|
|
|
167
167
|
return className;
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
function
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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)));
|
|
170
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
171
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
172
|
+
for (let i = 0; i < array.length; i++) {
|
|
173
|
+
const add = addToExternrefTable0(array[i]);
|
|
174
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
182
175
|
}
|
|
183
|
-
|
|
184
|
-
return result;
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* @param {Client} client
|
|
188
|
-
* @returns {ServerIdAddr[]}
|
|
189
|
-
*/
|
|
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;
|
|
196
|
-
}
|
|
197
|
-
|
|
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;
|
|
176
|
+
WASM_VECTOR_LEN = array.length;
|
|
202
177
|
return ptr;
|
|
203
178
|
}
|
|
204
179
|
|
|
@@ -208,84 +183,67 @@ function takeFromExternrefTable0(idx) {
|
|
|
208
183
|
return value;
|
|
209
184
|
}
|
|
210
185
|
/**
|
|
211
|
-
*
|
|
212
|
-
*
|
|
186
|
+
* Instantiate a new client.
|
|
187
|
+
*
|
|
188
|
+
* * `server_addrs` - a list of KMS server ID with EIP-55 addresses,
|
|
189
|
+
* the elements in the list can be created using [new_server_id_addr].
|
|
190
|
+
*
|
|
191
|
+
* * `client_address_hex` - the client (wallet) address in hex,
|
|
192
|
+
* must be prefixed with "0x".
|
|
193
|
+
*
|
|
194
|
+
* * `fhe_parameter` - the parameter choice, which can be either `"test"` or `"default"`.
|
|
195
|
+
* The "default" parameter choice is selected if no matching string is found.
|
|
196
|
+
* @param {ServerIdAddr[]} server_addrs
|
|
197
|
+
* @param {string} client_address_hex
|
|
198
|
+
* @param {string} fhe_parameter
|
|
199
|
+
* @returns {Client}
|
|
213
200
|
*/
|
|
214
|
-
export function
|
|
215
|
-
const ptr0 =
|
|
201
|
+
export function new_client(server_addrs, client_address_hex, fhe_parameter) {
|
|
202
|
+
const ptr0 = passArrayJsValueToWasm0(server_addrs, wasm.__wbindgen_malloc);
|
|
216
203
|
const len0 = WASM_VECTOR_LEN;
|
|
217
|
-
const
|
|
204
|
+
const ptr1 = passStringToWasm0(client_address_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
205
|
+
const len1 = WASM_VECTOR_LEN;
|
|
206
|
+
const ptr2 = passStringToWasm0(fhe_parameter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
207
|
+
const len2 = WASM_VECTOR_LEN;
|
|
208
|
+
const ret = wasm.new_client(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
218
209
|
if (ret[2]) {
|
|
219
210
|
throw takeFromExternrefTable0(ret[1]);
|
|
220
211
|
}
|
|
221
|
-
return
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
225
|
-
ptr = ptr >>> 0;
|
|
226
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* @param {PrivateEncKeyMlKem512} sk
|
|
230
|
-
* @returns {Uint8Array}
|
|
231
|
-
*/
|
|
232
|
-
export function ml_kem_pke_sk_to_u8vec(sk) {
|
|
233
|
-
_assertClass(sk, PrivateEncKeyMlKem512);
|
|
234
|
-
const ret = wasm.ml_kem_pke_sk_to_u8vec(sk.__wbg_ptr);
|
|
235
|
-
if (ret[3]) {
|
|
236
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
237
|
-
}
|
|
238
|
-
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
239
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
240
|
-
return v1;
|
|
212
|
+
return Client.__wrap(ret[0]);
|
|
241
213
|
}
|
|
242
214
|
|
|
243
215
|
/**
|
|
244
|
-
*
|
|
245
|
-
*
|
|
216
|
+
* Create a new [ServerIdAddr] structure that holds an ID and an address
|
|
217
|
+
* which must be a valid EIP-55 address, notably prefixed with "0x".
|
|
218
|
+
* @param {number} id
|
|
219
|
+
* @param {string} addr
|
|
220
|
+
* @returns {ServerIdAddr}
|
|
246
221
|
*/
|
|
247
|
-
export function
|
|
248
|
-
const ptr0 =
|
|
222
|
+
export function new_server_id_addr(id, addr) {
|
|
223
|
+
const ptr0 = passStringToWasm0(addr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
249
224
|
const len0 = WASM_VECTOR_LEN;
|
|
250
|
-
const ret = wasm.
|
|
225
|
+
const ret = wasm.new_server_id_addr(id, ptr0, len0);
|
|
251
226
|
if (ret[2]) {
|
|
252
227
|
throw takeFromExternrefTable0(ret[1]);
|
|
253
228
|
}
|
|
254
|
-
return
|
|
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);
|
|
229
|
+
return ServerIdAddr.__wrap(ret[0]);
|
|
265
230
|
}
|
|
266
231
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
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]);
|
|
232
|
+
function _assertClass(instance, klass) {
|
|
233
|
+
if (!(instance instanceof klass)) {
|
|
234
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
277
235
|
}
|
|
278
|
-
return PrivateEncKeyMlKem512.__wrap(ret[0]);
|
|
279
236
|
}
|
|
280
237
|
|
|
281
|
-
function
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
238
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
239
|
+
ptr = ptr >>> 0;
|
|
240
|
+
const mem = getDataViewMemory0();
|
|
241
|
+
const result = [];
|
|
242
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
243
|
+
result.push(wasm.__wbindgen_export_4.get(mem.getUint32(i, true)));
|
|
286
244
|
}
|
|
287
|
-
|
|
288
|
-
return
|
|
245
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
246
|
+
return result;
|
|
289
247
|
}
|
|
290
248
|
/**
|
|
291
249
|
* Process the user_decryption response from Rust objects.
|
|
@@ -343,135 +301,6 @@ export function process_user_decryption_resp(client, request, eip712_domain, agg
|
|
|
343
301
|
return v4;
|
|
344
302
|
}
|
|
345
303
|
|
|
346
|
-
/**
|
|
347
|
-
* @param {PrivateSigKey} sk
|
|
348
|
-
* @returns {Uint8Array}
|
|
349
|
-
*/
|
|
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;
|
|
359
|
-
}
|
|
360
|
-
|
|
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;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* @param {Uint8Array} v
|
|
380
|
-
* @returns {PublicSigKey}
|
|
381
|
-
*/
|
|
382
|
-
export function u8vec_to_public_sig_key(v) {
|
|
383
|
-
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
384
|
-
const len0 = WASM_VECTOR_LEN;
|
|
385
|
-
const ret = wasm.u8vec_to_public_sig_key(ptr0, len0);
|
|
386
|
-
if (ret[2]) {
|
|
387
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
388
|
-
}
|
|
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);
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
/**
|
|
451
|
-
* Create a new [ServerIdAddr] structure that holds an ID and an address
|
|
452
|
-
* which must be a valid EIP-55 address, notably prefixed with "0x".
|
|
453
|
-
* @param {number} id
|
|
454
|
-
* @param {string} addr
|
|
455
|
-
* @returns {ServerIdAddr}
|
|
456
|
-
*/
|
|
457
|
-
export function new_server_id_addr(id, addr) {
|
|
458
|
-
const ptr0 = passStringToWasm0(addr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
459
|
-
const len0 = WASM_VECTOR_LEN;
|
|
460
|
-
const ret = wasm.new_server_id_addr(id, ptr0, len0);
|
|
461
|
-
if (ret[2]) {
|
|
462
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
463
|
-
}
|
|
464
|
-
return ServerIdAddr.__wrap(ret[0]);
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
/**
|
|
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
304
|
/**
|
|
476
305
|
* @returns {PrivateEncKeyMlKem512}
|
|
477
306
|
*/
|
|
@@ -480,44 +309,18 @@ export function ml_kem_pke_keygen() {
|
|
|
480
309
|
return PrivateEncKeyMlKem512.__wrap(ret);
|
|
481
310
|
}
|
|
482
311
|
|
|
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
312
|
/**
|
|
496
313
|
* @returns {number}
|
|
497
314
|
*/
|
|
498
|
-
export function
|
|
499
|
-
const ret = wasm.
|
|
315
|
+
export function ml_kem_pke_sk_len() {
|
|
316
|
+
const ret = wasm.ml_kem_pke_sk_len();
|
|
500
317
|
return ret >>> 0;
|
|
501
318
|
}
|
|
502
319
|
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
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);
|
|
513
|
-
const len0 = WASM_VECTOR_LEN;
|
|
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;
|
|
320
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
321
|
+
ptr = ptr >>> 0;
|
|
322
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
519
323
|
}
|
|
520
|
-
|
|
521
324
|
/**
|
|
522
325
|
* @param {PublicEncKeyMlKem512} pk
|
|
523
326
|
* @returns {Uint8Array}
|
|
@@ -615,6 +418,203 @@ export function process_user_decryption_resp_from_js(client, request, eip712_dom
|
|
|
615
418
|
return v1;
|
|
616
419
|
}
|
|
617
420
|
|
|
421
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
422
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
423
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
424
|
+
WASM_VECTOR_LEN = arg.length;
|
|
425
|
+
return ptr;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* This function is *not* used by relayer-sdk because the decryption
|
|
429
|
+
* is handled by [process_user_decryption_resp].
|
|
430
|
+
* It's just here for completeness and tests.
|
|
431
|
+
* @param {Uint8Array} ct
|
|
432
|
+
* @param {PrivateEncKeyMlKem512} my_sk
|
|
433
|
+
* @returns {Uint8Array}
|
|
434
|
+
*/
|
|
435
|
+
export function ml_kem_pke_decrypt(ct, my_sk) {
|
|
436
|
+
const ptr0 = passArray8ToWasm0(ct, wasm.__wbindgen_malloc);
|
|
437
|
+
const len0 = WASM_VECTOR_LEN;
|
|
438
|
+
_assertClass(my_sk, PrivateEncKeyMlKem512);
|
|
439
|
+
const ret = wasm.ml_kem_pke_decrypt(ptr0, len0, my_sk.__wbg_ptr);
|
|
440
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
441
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
442
|
+
return v2;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* @param {Client} client
|
|
447
|
+
* @returns {PrivateSigKey | undefined}
|
|
448
|
+
*/
|
|
449
|
+
export function get_client_secret_key(client) {
|
|
450
|
+
_assertClass(client, Client);
|
|
451
|
+
const ret = wasm.get_client_secret_key(client.__wbg_ptr);
|
|
452
|
+
return ret === 0 ? undefined : PrivateSigKey.__wrap(ret);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* This function is *not* used by relayer-sdk because the encryption
|
|
457
|
+
* happens on the KMS side. It's just here for completeness and tests.
|
|
458
|
+
* @param {Uint8Array} msg
|
|
459
|
+
* @param {PublicEncKeyMlKem512} their_pk
|
|
460
|
+
* @returns {Uint8Array}
|
|
461
|
+
*/
|
|
462
|
+
export function ml_kem_pke_encrypt(msg, their_pk) {
|
|
463
|
+
const ptr0 = passArray8ToWasm0(msg, wasm.__wbindgen_malloc);
|
|
464
|
+
const len0 = WASM_VECTOR_LEN;
|
|
465
|
+
_assertClass(their_pk, PublicEncKeyMlKem512);
|
|
466
|
+
const ret = wasm.ml_kem_pke_encrypt(ptr0, len0, their_pk.__wbg_ptr);
|
|
467
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
468
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
469
|
+
return v2;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* @param {Uint8Array} v
|
|
474
|
+
* @returns {PrivateSigKey}
|
|
475
|
+
*/
|
|
476
|
+
export function u8vec_to_private_sig_key(v) {
|
|
477
|
+
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
478
|
+
const len0 = WASM_VECTOR_LEN;
|
|
479
|
+
const ret = wasm.u8vec_to_private_sig_key(ptr0, len0);
|
|
480
|
+
if (ret[2]) {
|
|
481
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
482
|
+
}
|
|
483
|
+
return PrivateSigKey.__wrap(ret[0]);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* @param {PublicSigKey} pk
|
|
488
|
+
* @returns {Uint8Array}
|
|
489
|
+
*/
|
|
490
|
+
export function public_sig_key_to_u8vec(pk) {
|
|
491
|
+
_assertClass(pk, PublicSigKey);
|
|
492
|
+
const ret = wasm.public_sig_key_to_u8vec(pk.__wbg_ptr);
|
|
493
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
494
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
495
|
+
return v1;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* @param {Uint8Array} v
|
|
500
|
+
* @returns {PrivateEncKeyMlKem512}
|
|
501
|
+
*/
|
|
502
|
+
export function u8vec_to_ml_kem_pke_sk(v) {
|
|
503
|
+
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
504
|
+
const len0 = WASM_VECTOR_LEN;
|
|
505
|
+
const ret = wasm.u8vec_to_ml_kem_pke_sk(ptr0, len0);
|
|
506
|
+
if (ret[2]) {
|
|
507
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
508
|
+
}
|
|
509
|
+
return PrivateEncKeyMlKem512.__wrap(ret[0]);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* @param {PrivateEncKeyMlKem512} sk
|
|
514
|
+
* @returns {PublicEncKeyMlKem512}
|
|
515
|
+
*/
|
|
516
|
+
export function ml_kem_pke_get_pk(sk) {
|
|
517
|
+
_assertClass(sk, PrivateEncKeyMlKem512);
|
|
518
|
+
const ret = wasm.ml_kem_pke_get_pk(sk.__wbg_ptr);
|
|
519
|
+
return PublicEncKeyMlKem512.__wrap(ret);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* @param {PrivateEncKeyMlKem512} sk
|
|
524
|
+
* @returns {Uint8Array}
|
|
525
|
+
*/
|
|
526
|
+
export function ml_kem_pke_sk_to_u8vec(sk) {
|
|
527
|
+
_assertClass(sk, PrivateEncKeyMlKem512);
|
|
528
|
+
const ret = wasm.ml_kem_pke_sk_to_u8vec(sk.__wbg_ptr);
|
|
529
|
+
if (ret[3]) {
|
|
530
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
531
|
+
}
|
|
532
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
533
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
534
|
+
return v1;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* @returns {number}
|
|
539
|
+
*/
|
|
540
|
+
export function ml_kem_pke_pk_len() {
|
|
541
|
+
const ret = wasm.ml_kem_pke_pk_len();
|
|
542
|
+
return ret >>> 0;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* @param {Client} client
|
|
547
|
+
* @returns {string}
|
|
548
|
+
*/
|
|
549
|
+
export function get_client_address(client) {
|
|
550
|
+
let deferred1_0;
|
|
551
|
+
let deferred1_1;
|
|
552
|
+
try {
|
|
553
|
+
_assertClass(client, Client);
|
|
554
|
+
const ret = wasm.get_client_address(client.__wbg_ptr);
|
|
555
|
+
deferred1_0 = ret[0];
|
|
556
|
+
deferred1_1 = ret[1];
|
|
557
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
558
|
+
} finally {
|
|
559
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* @param {Uint8Array} v
|
|
565
|
+
* @returns {PublicSigKey}
|
|
566
|
+
*/
|
|
567
|
+
export function u8vec_to_public_sig_key(v) {
|
|
568
|
+
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
569
|
+
const len0 = WASM_VECTOR_LEN;
|
|
570
|
+
const ret = wasm.u8vec_to_public_sig_key(ptr0, len0);
|
|
571
|
+
if (ret[2]) {
|
|
572
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
573
|
+
}
|
|
574
|
+
return PublicSigKey.__wrap(ret[0]);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* @param {Uint8Array} v
|
|
579
|
+
* @returns {PublicEncKeyMlKem512}
|
|
580
|
+
*/
|
|
581
|
+
export function u8vec_to_ml_kem_pke_pk(v) {
|
|
582
|
+
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
583
|
+
const len0 = WASM_VECTOR_LEN;
|
|
584
|
+
const ret = wasm.u8vec_to_ml_kem_pke_pk(ptr0, len0);
|
|
585
|
+
if (ret[2]) {
|
|
586
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
587
|
+
}
|
|
588
|
+
return PublicEncKeyMlKem512.__wrap(ret[0]);
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* @param {Client} client
|
|
593
|
+
* @returns {ServerIdAddr[]}
|
|
594
|
+
*/
|
|
595
|
+
export function get_server_addrs(client) {
|
|
596
|
+
_assertClass(client, Client);
|
|
597
|
+
const ret = wasm.get_server_addrs(client.__wbg_ptr);
|
|
598
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
599
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
600
|
+
return v1;
|
|
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
|