tkms 0.13.0-rc.0 → 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 +206 -205
- package/kms_lib_bg.wasm +0 -0
- package/package.json +1 -1
package/kms_lib.d.ts
CHANGED
|
@@ -1,9 +1,37 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
|
|
4
|
-
|
|
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;
|
|
5
32
|
export function u8vec_to_ml_kem_pke_pk(v: Uint8Array): PublicEncKeyMlKem512;
|
|
6
|
-
export function
|
|
33
|
+
export function ml_kem_pke_pk_len(): number;
|
|
34
|
+
export function get_server_addrs(client: Client): ServerIdAddr[];
|
|
7
35
|
/**
|
|
8
36
|
* Process the user_decryption response from JavaScript objects.
|
|
9
37
|
* The returned result is a byte array representing a plaintext of any length,
|
|
@@ -66,19 +94,15 @@ export function ml_kem_pke_pk_to_u8vec(pk: PublicEncKeyMlKem512): Uint8Array;
|
|
|
66
94
|
* It is insecure if `verify = false`!
|
|
67
95
|
*/
|
|
68
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[];
|
|
69
|
-
export function ml_kem_pke_pk_len(): number;
|
|
70
|
-
/**
|
|
71
|
-
* This function is *not* used by relayer-sdk because the decryption
|
|
72
|
-
* is handled by [process_user_decryption_resp].
|
|
73
|
-
* It's just here for completeness and tests.
|
|
74
|
-
*/
|
|
75
|
-
export function ml_kem_pke_decrypt(ct: Uint8Array, my_sk: PrivateEncKeyMlKem512): Uint8Array;
|
|
76
|
-
export function ml_kem_pke_get_pk(sk: PrivateEncKeyMlKem512): PublicEncKeyMlKem512;
|
|
77
97
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
98
|
+
* Create a new [ServerIdAddr] structure that holds an ID and an address
|
|
99
|
+
* which must be a valid EIP-55 address, notably prefixed with "0x".
|
|
80
100
|
*/
|
|
81
|
-
export function
|
|
101
|
+
export function new_server_id_addr(id: number, addr: string): ServerIdAddr;
|
|
102
|
+
export function ml_kem_pke_sk_len(): number;
|
|
103
|
+
export function private_sig_key_to_u8vec(sk: PrivateSigKey): Uint8Array;
|
|
104
|
+
export function u8vec_to_ml_kem_pke_sk(v: Uint8Array): PrivateEncKeyMlKem512;
|
|
105
|
+
export function get_client_address(client: Client): string;
|
|
82
106
|
/**
|
|
83
107
|
* Process the user_decryption response from Rust objects.
|
|
84
108
|
* Consider using [process_user_decryption_resp_from_js]
|
|
@@ -104,32 +128,8 @@ export function ml_kem_pke_encrypt(msg: Uint8Array, their_pk: PublicEncKeyMlKem5
|
|
|
104
128
|
*/
|
|
105
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[];
|
|
106
130
|
export function get_client_secret_key(client: Client): PrivateSigKey | undefined;
|
|
107
|
-
export function
|
|
108
|
-
export function
|
|
109
|
-
/**
|
|
110
|
-
* Instantiate a new client.
|
|
111
|
-
*
|
|
112
|
-
* * `server_addrs` - a list of KMS server ID with EIP-55 addresses,
|
|
113
|
-
* the elements in the list can be created using [new_server_id_addr].
|
|
114
|
-
*
|
|
115
|
-
* * `client_address_hex` - the client (wallet) address in hex,
|
|
116
|
-
* must be prefixed with "0x".
|
|
117
|
-
*
|
|
118
|
-
* * `fhe_parameter` - the parameter choice, which can be either `"test"` or `"default"`.
|
|
119
|
-
* The "default" parameter choice is selected if no matching string is found.
|
|
120
|
-
*/
|
|
121
|
-
export function new_client(server_addrs: ServerIdAddr[], client_address_hex: string, fhe_parameter: string): Client;
|
|
122
|
-
export function public_sig_key_to_u8vec(pk: PublicSigKey): Uint8Array;
|
|
123
|
-
export function private_sig_key_to_u8vec(sk: PrivateSigKey): Uint8Array;
|
|
124
|
-
export function get_client_address(client: Client): string;
|
|
125
|
-
export function u8vec_to_public_sig_key(v: Uint8Array): PublicSigKey;
|
|
126
|
-
export function u8vec_to_private_sig_key(v: Uint8Array): PrivateSigKey;
|
|
127
|
-
/**
|
|
128
|
-
* Create a new [ServerIdAddr] structure that holds an ID and an address
|
|
129
|
-
* which must be a valid EIP-55 address, notably prefixed with "0x".
|
|
130
|
-
*/
|
|
131
|
-
export function new_server_id_addr(id: number, addr: string): ServerIdAddr;
|
|
132
|
-
export function u8vec_to_ml_kem_pke_sk(v: Uint8Array): PrivateEncKeyMlKem512;
|
|
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;
|
package/kms_lib.js
CHANGED
|
@@ -167,51 +167,161 @@ 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
|
+
}
|
|
181
248
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
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);
|
|
185
255
|
}
|
|
256
|
+
|
|
186
257
|
/**
|
|
187
258
|
* @param {PrivateEncKeyMlKem512} sk
|
|
188
|
-
* @returns {
|
|
259
|
+
* @returns {PublicEncKeyMlKem512}
|
|
189
260
|
*/
|
|
190
|
-
export function
|
|
261
|
+
export function ml_kem_pke_get_pk(sk) {
|
|
191
262
|
_assertClass(sk, PrivateEncKeyMlKem512);
|
|
192
|
-
const ret = wasm.
|
|
193
|
-
|
|
194
|
-
|
|
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]);
|
|
195
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);
|
|
196
288
|
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
197
289
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
198
290
|
return v1;
|
|
199
291
|
}
|
|
200
292
|
|
|
201
293
|
/**
|
|
202
|
-
*
|
|
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}
|
|
203
300
|
*/
|
|
204
|
-
export function
|
|
205
|
-
const
|
|
206
|
-
|
|
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;
|
|
207
309
|
}
|
|
208
310
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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]);
|
|
214
323
|
}
|
|
324
|
+
|
|
215
325
|
/**
|
|
216
326
|
* @param {Uint8Array} v
|
|
217
327
|
* @returns {PublicEncKeyMlKem512}
|
|
@@ -227,18 +337,11 @@ export function u8vec_to_ml_kem_pke_pk(v) {
|
|
|
227
337
|
}
|
|
228
338
|
|
|
229
339
|
/**
|
|
230
|
-
* @
|
|
231
|
-
* @returns {Uint8Array}
|
|
340
|
+
* @returns {number}
|
|
232
341
|
*/
|
|
233
|
-
export function
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
if (ret[3]) {
|
|
237
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
238
|
-
}
|
|
239
|
-
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
240
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
241
|
-
return v1;
|
|
342
|
+
export function ml_kem_pke_pk_len() {
|
|
343
|
+
const ret = wasm.ml_kem_pke_pk_len();
|
|
344
|
+
return ret >>> 0;
|
|
242
345
|
}
|
|
243
346
|
|
|
244
347
|
function getArrayJsValueFromWasm0(ptr, len) {
|
|
@@ -251,6 +354,18 @@ function getArrayJsValueFromWasm0(ptr, len) {
|
|
|
251
354
|
wasm.__externref_drop_slice(ptr, len);
|
|
252
355
|
return result;
|
|
253
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
|
+
|
|
254
369
|
/**
|
|
255
370
|
* Process the user_decryption response from JavaScript objects.
|
|
256
371
|
* The returned result is a byte array representing a plaintext of any length,
|
|
@@ -333,68 +448,78 @@ export function process_user_decryption_resp_from_js(client, request, eip712_dom
|
|
|
333
448
|
return v1;
|
|
334
449
|
}
|
|
335
450
|
|
|
451
|
+
/**
|
|
452
|
+
* Create a new [ServerIdAddr] structure that holds an ID and an address
|
|
453
|
+
* which must be a valid EIP-55 address, notably prefixed with "0x".
|
|
454
|
+
* @param {number} id
|
|
455
|
+
* @param {string} addr
|
|
456
|
+
* @returns {ServerIdAddr}
|
|
457
|
+
*/
|
|
458
|
+
export function new_server_id_addr(id, addr) {
|
|
459
|
+
const ptr0 = passStringToWasm0(addr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
460
|
+
const len0 = WASM_VECTOR_LEN;
|
|
461
|
+
const ret = wasm.new_server_id_addr(id, ptr0, len0);
|
|
462
|
+
if (ret[2]) {
|
|
463
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
464
|
+
}
|
|
465
|
+
return ServerIdAddr.__wrap(ret[0]);
|
|
466
|
+
}
|
|
467
|
+
|
|
336
468
|
/**
|
|
337
469
|
* @returns {number}
|
|
338
470
|
*/
|
|
339
|
-
export function
|
|
340
|
-
const ret = wasm.
|
|
471
|
+
export function ml_kem_pke_sk_len() {
|
|
472
|
+
const ret = wasm.ml_kem_pke_sk_len();
|
|
341
473
|
return ret >>> 0;
|
|
342
474
|
}
|
|
343
475
|
|
|
344
476
|
/**
|
|
345
|
-
*
|
|
346
|
-
* is handled by [process_user_decryption_resp].
|
|
347
|
-
* It's just here for completeness and tests.
|
|
348
|
-
* @param {Uint8Array} ct
|
|
349
|
-
* @param {PrivateEncKeyMlKem512} my_sk
|
|
477
|
+
* @param {PrivateSigKey} sk
|
|
350
478
|
* @returns {Uint8Array}
|
|
351
479
|
*/
|
|
352
|
-
export function
|
|
353
|
-
|
|
354
|
-
const
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
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);
|
|
483
|
+
if (ret[3]) {
|
|
484
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
485
|
+
}
|
|
486
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
358
487
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
359
|
-
return
|
|
488
|
+
return v1;
|
|
360
489
|
}
|
|
361
490
|
|
|
362
491
|
/**
|
|
363
|
-
* @param {
|
|
364
|
-
* @returns {
|
|
492
|
+
* @param {Uint8Array} v
|
|
493
|
+
* @returns {PrivateEncKeyMlKem512}
|
|
365
494
|
*/
|
|
366
|
-
export function
|
|
367
|
-
|
|
368
|
-
const
|
|
369
|
-
|
|
495
|
+
export function u8vec_to_ml_kem_pke_sk(v) {
|
|
496
|
+
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
497
|
+
const len0 = WASM_VECTOR_LEN;
|
|
498
|
+
const ret = wasm.u8vec_to_ml_kem_pke_sk(ptr0, len0);
|
|
499
|
+
if (ret[2]) {
|
|
500
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
501
|
+
}
|
|
502
|
+
return PrivateEncKeyMlKem512.__wrap(ret[0]);
|
|
370
503
|
}
|
|
371
504
|
|
|
372
505
|
/**
|
|
373
|
-
*
|
|
374
|
-
*
|
|
375
|
-
* @param {Uint8Array} msg
|
|
376
|
-
* @param {PublicEncKeyMlKem512} their_pk
|
|
377
|
-
* @returns {Uint8Array}
|
|
506
|
+
* @param {Client} client
|
|
507
|
+
* @returns {string}
|
|
378
508
|
*/
|
|
379
|
-
export function
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
391
|
-
for (let i = 0; i < array.length; i++) {
|
|
392
|
-
const add = addToExternrefTable0(array[i]);
|
|
393
|
-
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);
|
|
394
520
|
}
|
|
395
|
-
WASM_VECTOR_LEN = array.length;
|
|
396
|
-
return ptr;
|
|
397
521
|
}
|
|
522
|
+
|
|
398
523
|
/**
|
|
399
524
|
* Process the user_decryption response from Rust objects.
|
|
400
525
|
* Consider using [process_user_decryption_resp_from_js]
|
|
@@ -462,74 +587,27 @@ export function get_client_secret_key(client) {
|
|
|
462
587
|
}
|
|
463
588
|
|
|
464
589
|
/**
|
|
465
|
-
* @param {
|
|
466
|
-
* @returns {ServerIdAddr[]}
|
|
467
|
-
*/
|
|
468
|
-
export function get_server_addrs(client) {
|
|
469
|
-
_assertClass(client, Client);
|
|
470
|
-
const ret = wasm.get_server_addrs(client.__wbg_ptr);
|
|
471
|
-
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
472
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
473
|
-
return v1;
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
/**
|
|
477
|
-
* @returns {PrivateEncKeyMlKem512}
|
|
478
|
-
*/
|
|
479
|
-
export function ml_kem_pke_keygen() {
|
|
480
|
-
const ret = wasm.ml_kem_pke_keygen();
|
|
481
|
-
return PrivateEncKeyMlKem512.__wrap(ret);
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
/**
|
|
485
|
-
* Instantiate a new client.
|
|
486
|
-
*
|
|
487
|
-
* * `server_addrs` - a list of KMS server ID with EIP-55 addresses,
|
|
488
|
-
* the elements in the list can be created using [new_server_id_addr].
|
|
489
|
-
*
|
|
490
|
-
* * `client_address_hex` - the client (wallet) address in hex,
|
|
491
|
-
* must be prefixed with "0x".
|
|
492
|
-
*
|
|
493
|
-
* * `fhe_parameter` - the parameter choice, which can be either `"test"` or `"default"`.
|
|
494
|
-
* The "default" parameter choice is selected if no matching string is found.
|
|
495
|
-
* @param {ServerIdAddr[]} server_addrs
|
|
496
|
-
* @param {string} client_address_hex
|
|
497
|
-
* @param {string} fhe_parameter
|
|
498
|
-
* @returns {Client}
|
|
499
|
-
*/
|
|
500
|
-
export function new_client(server_addrs, client_address_hex, fhe_parameter) {
|
|
501
|
-
const ptr0 = passArrayJsValueToWasm0(server_addrs, wasm.__wbindgen_malloc);
|
|
502
|
-
const len0 = WASM_VECTOR_LEN;
|
|
503
|
-
const ptr1 = passStringToWasm0(client_address_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
504
|
-
const len1 = WASM_VECTOR_LEN;
|
|
505
|
-
const ptr2 = passStringToWasm0(fhe_parameter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
506
|
-
const len2 = WASM_VECTOR_LEN;
|
|
507
|
-
const ret = wasm.new_client(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
508
|
-
if (ret[2]) {
|
|
509
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
510
|
-
}
|
|
511
|
-
return Client.__wrap(ret[0]);
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
/**
|
|
515
|
-
* @param {PublicSigKey} pk
|
|
590
|
+
* @param {PublicEncKeyMlKem512} pk
|
|
516
591
|
* @returns {Uint8Array}
|
|
517
592
|
*/
|
|
518
|
-
export function
|
|
519
|
-
_assertClass(pk,
|
|
520
|
-
const ret = wasm.
|
|
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]);
|
|
598
|
+
}
|
|
521
599
|
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
522
600
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
523
601
|
return v1;
|
|
524
602
|
}
|
|
525
603
|
|
|
526
604
|
/**
|
|
527
|
-
* @param {
|
|
605
|
+
* @param {PrivateEncKeyMlKem512} sk
|
|
528
606
|
* @returns {Uint8Array}
|
|
529
607
|
*/
|
|
530
|
-
export function
|
|
531
|
-
_assertClass(sk,
|
|
532
|
-
const ret = wasm.
|
|
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);
|
|
533
611
|
if (ret[3]) {
|
|
534
612
|
throw takeFromExternrefTable0(ret[2]);
|
|
535
613
|
}
|
|
@@ -538,83 +616,6 @@ export function private_sig_key_to_u8vec(sk) {
|
|
|
538
616
|
return v1;
|
|
539
617
|
}
|
|
540
618
|
|
|
541
|
-
/**
|
|
542
|
-
* @param {Client} client
|
|
543
|
-
* @returns {string}
|
|
544
|
-
*/
|
|
545
|
-
export function get_client_address(client) {
|
|
546
|
-
let deferred1_0;
|
|
547
|
-
let deferred1_1;
|
|
548
|
-
try {
|
|
549
|
-
_assertClass(client, Client);
|
|
550
|
-
const ret = wasm.get_client_address(client.__wbg_ptr);
|
|
551
|
-
deferred1_0 = ret[0];
|
|
552
|
-
deferred1_1 = ret[1];
|
|
553
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
554
|
-
} finally {
|
|
555
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
/**
|
|
560
|
-
* @param {Uint8Array} v
|
|
561
|
-
* @returns {PublicSigKey}
|
|
562
|
-
*/
|
|
563
|
-
export function u8vec_to_public_sig_key(v) {
|
|
564
|
-
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
565
|
-
const len0 = WASM_VECTOR_LEN;
|
|
566
|
-
const ret = wasm.u8vec_to_public_sig_key(ptr0, len0);
|
|
567
|
-
if (ret[2]) {
|
|
568
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
569
|
-
}
|
|
570
|
-
return PublicSigKey.__wrap(ret[0]);
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
/**
|
|
574
|
-
* @param {Uint8Array} v
|
|
575
|
-
* @returns {PrivateSigKey}
|
|
576
|
-
*/
|
|
577
|
-
export function u8vec_to_private_sig_key(v) {
|
|
578
|
-
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
579
|
-
const len0 = WASM_VECTOR_LEN;
|
|
580
|
-
const ret = wasm.u8vec_to_private_sig_key(ptr0, len0);
|
|
581
|
-
if (ret[2]) {
|
|
582
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
583
|
-
}
|
|
584
|
-
return PrivateSigKey.__wrap(ret[0]);
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
/**
|
|
588
|
-
* Create a new [ServerIdAddr] structure that holds an ID and an address
|
|
589
|
-
* which must be a valid EIP-55 address, notably prefixed with "0x".
|
|
590
|
-
* @param {number} id
|
|
591
|
-
* @param {string} addr
|
|
592
|
-
* @returns {ServerIdAddr}
|
|
593
|
-
*/
|
|
594
|
-
export function new_server_id_addr(id, addr) {
|
|
595
|
-
const ptr0 = passStringToWasm0(addr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
596
|
-
const len0 = WASM_VECTOR_LEN;
|
|
597
|
-
const ret = wasm.new_server_id_addr(id, ptr0, len0);
|
|
598
|
-
if (ret[2]) {
|
|
599
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
600
|
-
}
|
|
601
|
-
return ServerIdAddr.__wrap(ret[0]);
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
/**
|
|
605
|
-
* @param {Uint8Array} v
|
|
606
|
-
* @returns {PrivateEncKeyMlKem512}
|
|
607
|
-
*/
|
|
608
|
-
export function u8vec_to_ml_kem_pke_sk(v) {
|
|
609
|
-
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
610
|
-
const len0 = WASM_VECTOR_LEN;
|
|
611
|
-
const ret = wasm.u8vec_to_ml_kem_pke_sk(ptr0, len0);
|
|
612
|
-
if (ret[2]) {
|
|
613
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
614
|
-
}
|
|
615
|
-
return PrivateEncKeyMlKem512.__wrap(ret[0]);
|
|
616
|
-
}
|
|
617
|
-
|
|
618
619
|
const CiphertextHandleFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
619
620
|
? { register: () => {}, unregister: () => {} }
|
|
620
621
|
: new FinalizationRegistry(ptr => wasm.__wbg_ciphertexthandle_free(ptr >>> 0, 1));
|
package/kms_lib_bg.wasm
CHANGED
|
Binary file
|