node-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 +208 -207
- 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
|
@@ -171,51 +171,161 @@ function debugString(val) {
|
|
|
171
171
|
return className;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
175
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
176
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
177
|
+
WASM_VECTOR_LEN = arg.length;
|
|
178
|
+
return ptr;
|
|
179
|
+
}
|
|
180
|
+
|
|
174
181
|
function _assertClass(instance, klass) {
|
|
175
182
|
if (!(instance instanceof klass)) {
|
|
176
183
|
throw new Error(`expected instance of ${klass.name}`);
|
|
177
184
|
}
|
|
178
185
|
}
|
|
179
186
|
|
|
187
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
188
|
+
ptr = ptr >>> 0;
|
|
189
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* This function is *not* used by relayer-sdk because the encryption
|
|
193
|
+
* happens on the KMS side. It's just here for completeness and tests.
|
|
194
|
+
* @param {Uint8Array} msg
|
|
195
|
+
* @param {PublicEncKeyMlKem512} their_pk
|
|
196
|
+
* @returns {Uint8Array}
|
|
197
|
+
*/
|
|
198
|
+
module.exports.ml_kem_pke_encrypt = function(msg, their_pk) {
|
|
199
|
+
const ptr0 = passArray8ToWasm0(msg, wasm.__wbindgen_malloc);
|
|
200
|
+
const len0 = WASM_VECTOR_LEN;
|
|
201
|
+
_assertClass(their_pk, PublicEncKeyMlKem512);
|
|
202
|
+
const ret = wasm.ml_kem_pke_encrypt(ptr0, len0, their_pk.__wbg_ptr);
|
|
203
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
204
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
205
|
+
return v2;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
209
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
210
|
+
for (let i = 0; i < array.length; i++) {
|
|
211
|
+
const add = addToExternrefTable0(array[i]);
|
|
212
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
213
|
+
}
|
|
214
|
+
WASM_VECTOR_LEN = array.length;
|
|
215
|
+
return ptr;
|
|
216
|
+
}
|
|
217
|
+
|
|
180
218
|
function takeFromExternrefTable0(idx) {
|
|
181
219
|
const value = wasm.__wbindgen_export_4.get(idx);
|
|
182
220
|
wasm.__externref_table_dealloc(idx);
|
|
183
221
|
return value;
|
|
184
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Instantiate a new client.
|
|
225
|
+
*
|
|
226
|
+
* * `server_addrs` - a list of KMS server ID with EIP-55 addresses,
|
|
227
|
+
* the elements in the list can be created using [new_server_id_addr].
|
|
228
|
+
*
|
|
229
|
+
* * `client_address_hex` - the client (wallet) address in hex,
|
|
230
|
+
* must be prefixed with "0x".
|
|
231
|
+
*
|
|
232
|
+
* * `fhe_parameter` - the parameter choice, which can be either `"test"` or `"default"`.
|
|
233
|
+
* The "default" parameter choice is selected if no matching string is found.
|
|
234
|
+
* @param {ServerIdAddr[]} server_addrs
|
|
235
|
+
* @param {string} client_address_hex
|
|
236
|
+
* @param {string} fhe_parameter
|
|
237
|
+
* @returns {Client}
|
|
238
|
+
*/
|
|
239
|
+
module.exports.new_client = function(server_addrs, client_address_hex, fhe_parameter) {
|
|
240
|
+
const ptr0 = passArrayJsValueToWasm0(server_addrs, wasm.__wbindgen_malloc);
|
|
241
|
+
const len0 = WASM_VECTOR_LEN;
|
|
242
|
+
const ptr1 = passStringToWasm0(client_address_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
243
|
+
const len1 = WASM_VECTOR_LEN;
|
|
244
|
+
const ptr2 = passStringToWasm0(fhe_parameter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
245
|
+
const len2 = WASM_VECTOR_LEN;
|
|
246
|
+
const ret = wasm.new_client(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
247
|
+
if (ret[2]) {
|
|
248
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
249
|
+
}
|
|
250
|
+
return Client.__wrap(ret[0]);
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* @returns {PrivateEncKeyMlKem512}
|
|
255
|
+
*/
|
|
256
|
+
module.exports.ml_kem_pke_keygen = function() {
|
|
257
|
+
const ret = wasm.ml_kem_pke_keygen();
|
|
258
|
+
return PrivateEncKeyMlKem512.__wrap(ret);
|
|
259
|
+
};
|
|
185
260
|
|
|
186
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
187
|
-
ptr = ptr >>> 0;
|
|
188
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
189
|
-
}
|
|
190
261
|
/**
|
|
191
262
|
* @param {PrivateEncKeyMlKem512} sk
|
|
192
|
-
* @returns {
|
|
263
|
+
* @returns {PublicEncKeyMlKem512}
|
|
193
264
|
*/
|
|
194
|
-
module.exports.
|
|
265
|
+
module.exports.ml_kem_pke_get_pk = function(sk) {
|
|
195
266
|
_assertClass(sk, PrivateEncKeyMlKem512);
|
|
196
|
-
const ret = wasm.
|
|
197
|
-
|
|
198
|
-
|
|
267
|
+
const ret = wasm.ml_kem_pke_get_pk(sk.__wbg_ptr);
|
|
268
|
+
return PublicEncKeyMlKem512.__wrap(ret);
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* @param {Uint8Array} v
|
|
273
|
+
* @returns {PrivateSigKey}
|
|
274
|
+
*/
|
|
275
|
+
module.exports.u8vec_to_private_sig_key = function(v) {
|
|
276
|
+
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
277
|
+
const len0 = WASM_VECTOR_LEN;
|
|
278
|
+
const ret = wasm.u8vec_to_private_sig_key(ptr0, len0);
|
|
279
|
+
if (ret[2]) {
|
|
280
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
199
281
|
}
|
|
282
|
+
return PrivateSigKey.__wrap(ret[0]);
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* @param {PublicSigKey} pk
|
|
287
|
+
* @returns {Uint8Array}
|
|
288
|
+
*/
|
|
289
|
+
module.exports.public_sig_key_to_u8vec = function(pk) {
|
|
290
|
+
_assertClass(pk, PublicSigKey);
|
|
291
|
+
const ret = wasm.public_sig_key_to_u8vec(pk.__wbg_ptr);
|
|
200
292
|
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
201
293
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
202
294
|
return v1;
|
|
203
295
|
};
|
|
204
296
|
|
|
205
297
|
/**
|
|
206
|
-
*
|
|
298
|
+
* This function is *not* used by relayer-sdk because the decryption
|
|
299
|
+
* is handled by [process_user_decryption_resp].
|
|
300
|
+
* It's just here for completeness and tests.
|
|
301
|
+
* @param {Uint8Array} ct
|
|
302
|
+
* @param {PrivateEncKeyMlKem512} my_sk
|
|
303
|
+
* @returns {Uint8Array}
|
|
207
304
|
*/
|
|
208
|
-
module.exports.
|
|
209
|
-
const
|
|
210
|
-
|
|
305
|
+
module.exports.ml_kem_pke_decrypt = function(ct, my_sk) {
|
|
306
|
+
const ptr0 = passArray8ToWasm0(ct, wasm.__wbindgen_malloc);
|
|
307
|
+
const len0 = WASM_VECTOR_LEN;
|
|
308
|
+
_assertClass(my_sk, PrivateEncKeyMlKem512);
|
|
309
|
+
const ret = wasm.ml_kem_pke_decrypt(ptr0, len0, my_sk.__wbg_ptr);
|
|
310
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
311
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
312
|
+
return v2;
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* @param {Uint8Array} v
|
|
317
|
+
* @returns {PublicSigKey}
|
|
318
|
+
*/
|
|
319
|
+
module.exports.u8vec_to_public_sig_key = function(v) {
|
|
320
|
+
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
321
|
+
const len0 = WASM_VECTOR_LEN;
|
|
322
|
+
const ret = wasm.u8vec_to_public_sig_key(ptr0, len0);
|
|
323
|
+
if (ret[2]) {
|
|
324
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
325
|
+
}
|
|
326
|
+
return PublicSigKey.__wrap(ret[0]);
|
|
211
327
|
};
|
|
212
328
|
|
|
213
|
-
function passArray8ToWasm0(arg, malloc) {
|
|
214
|
-
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
215
|
-
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
216
|
-
WASM_VECTOR_LEN = arg.length;
|
|
217
|
-
return ptr;
|
|
218
|
-
}
|
|
219
329
|
/**
|
|
220
330
|
* @param {Uint8Array} v
|
|
221
331
|
* @returns {PublicEncKeyMlKem512}
|
|
@@ -231,18 +341,11 @@ module.exports.u8vec_to_ml_kem_pke_pk = function(v) {
|
|
|
231
341
|
};
|
|
232
342
|
|
|
233
343
|
/**
|
|
234
|
-
* @
|
|
235
|
-
* @returns {Uint8Array}
|
|
344
|
+
* @returns {number}
|
|
236
345
|
*/
|
|
237
|
-
module.exports.
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
if (ret[3]) {
|
|
241
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
242
|
-
}
|
|
243
|
-
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
244
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
245
|
-
return v1;
|
|
346
|
+
module.exports.ml_kem_pke_pk_len = function() {
|
|
347
|
+
const ret = wasm.ml_kem_pke_pk_len();
|
|
348
|
+
return ret >>> 0;
|
|
246
349
|
};
|
|
247
350
|
|
|
248
351
|
function getArrayJsValueFromWasm0(ptr, len) {
|
|
@@ -255,6 +358,18 @@ function getArrayJsValueFromWasm0(ptr, len) {
|
|
|
255
358
|
wasm.__externref_drop_slice(ptr, len);
|
|
256
359
|
return result;
|
|
257
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* @param {Client} client
|
|
363
|
+
* @returns {ServerIdAddr[]}
|
|
364
|
+
*/
|
|
365
|
+
module.exports.get_server_addrs = function(client) {
|
|
366
|
+
_assertClass(client, Client);
|
|
367
|
+
const ret = wasm.get_server_addrs(client.__wbg_ptr);
|
|
368
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
369
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
370
|
+
return v1;
|
|
371
|
+
};
|
|
372
|
+
|
|
258
373
|
/**
|
|
259
374
|
* Process the user_decryption response from JavaScript objects.
|
|
260
375
|
* The returned result is a byte array representing a plaintext of any length,
|
|
@@ -337,68 +452,78 @@ module.exports.process_user_decryption_resp_from_js = function(client, request,
|
|
|
337
452
|
return v1;
|
|
338
453
|
};
|
|
339
454
|
|
|
455
|
+
/**
|
|
456
|
+
* Create a new [ServerIdAddr] structure that holds an ID and an address
|
|
457
|
+
* which must be a valid EIP-55 address, notably prefixed with "0x".
|
|
458
|
+
* @param {number} id
|
|
459
|
+
* @param {string} addr
|
|
460
|
+
* @returns {ServerIdAddr}
|
|
461
|
+
*/
|
|
462
|
+
module.exports.new_server_id_addr = function(id, addr) {
|
|
463
|
+
const ptr0 = passStringToWasm0(addr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
464
|
+
const len0 = WASM_VECTOR_LEN;
|
|
465
|
+
const ret = wasm.new_server_id_addr(id, ptr0, len0);
|
|
466
|
+
if (ret[2]) {
|
|
467
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
468
|
+
}
|
|
469
|
+
return ServerIdAddr.__wrap(ret[0]);
|
|
470
|
+
};
|
|
471
|
+
|
|
340
472
|
/**
|
|
341
473
|
* @returns {number}
|
|
342
474
|
*/
|
|
343
|
-
module.exports.
|
|
344
|
-
const ret = wasm.
|
|
475
|
+
module.exports.ml_kem_pke_sk_len = function() {
|
|
476
|
+
const ret = wasm.ml_kem_pke_sk_len();
|
|
345
477
|
return ret >>> 0;
|
|
346
478
|
};
|
|
347
479
|
|
|
348
480
|
/**
|
|
349
|
-
*
|
|
350
|
-
* is handled by [process_user_decryption_resp].
|
|
351
|
-
* It's just here for completeness and tests.
|
|
352
|
-
* @param {Uint8Array} ct
|
|
353
|
-
* @param {PrivateEncKeyMlKem512} my_sk
|
|
481
|
+
* @param {PrivateSigKey} sk
|
|
354
482
|
* @returns {Uint8Array}
|
|
355
483
|
*/
|
|
356
|
-
module.exports.
|
|
357
|
-
|
|
358
|
-
const
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
484
|
+
module.exports.private_sig_key_to_u8vec = function(sk) {
|
|
485
|
+
_assertClass(sk, PrivateSigKey);
|
|
486
|
+
const ret = wasm.private_sig_key_to_u8vec(sk.__wbg_ptr);
|
|
487
|
+
if (ret[3]) {
|
|
488
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
489
|
+
}
|
|
490
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
362
491
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
363
|
-
return
|
|
492
|
+
return v1;
|
|
364
493
|
};
|
|
365
494
|
|
|
366
495
|
/**
|
|
367
|
-
* @param {
|
|
368
|
-
* @returns {
|
|
496
|
+
* @param {Uint8Array} v
|
|
497
|
+
* @returns {PrivateEncKeyMlKem512}
|
|
369
498
|
*/
|
|
370
|
-
module.exports.
|
|
371
|
-
|
|
372
|
-
const
|
|
373
|
-
|
|
499
|
+
module.exports.u8vec_to_ml_kem_pke_sk = function(v) {
|
|
500
|
+
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
501
|
+
const len0 = WASM_VECTOR_LEN;
|
|
502
|
+
const ret = wasm.u8vec_to_ml_kem_pke_sk(ptr0, len0);
|
|
503
|
+
if (ret[2]) {
|
|
504
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
505
|
+
}
|
|
506
|
+
return PrivateEncKeyMlKem512.__wrap(ret[0]);
|
|
374
507
|
};
|
|
375
508
|
|
|
376
509
|
/**
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
* @param {Uint8Array} msg
|
|
380
|
-
* @param {PublicEncKeyMlKem512} their_pk
|
|
381
|
-
* @returns {Uint8Array}
|
|
510
|
+
* @param {Client} client
|
|
511
|
+
* @returns {string}
|
|
382
512
|
*/
|
|
383
|
-
module.exports.
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
513
|
+
module.exports.get_client_address = function(client) {
|
|
514
|
+
let deferred1_0;
|
|
515
|
+
let deferred1_1;
|
|
516
|
+
try {
|
|
517
|
+
_assertClass(client, Client);
|
|
518
|
+
const ret = wasm.get_client_address(client.__wbg_ptr);
|
|
519
|
+
deferred1_0 = ret[0];
|
|
520
|
+
deferred1_1 = ret[1];
|
|
521
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
522
|
+
} finally {
|
|
523
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
524
|
+
}
|
|
391
525
|
};
|
|
392
526
|
|
|
393
|
-
function passArrayJsValueToWasm0(array, malloc) {
|
|
394
|
-
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
395
|
-
for (let i = 0; i < array.length; i++) {
|
|
396
|
-
const add = addToExternrefTable0(array[i]);
|
|
397
|
-
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
398
|
-
}
|
|
399
|
-
WASM_VECTOR_LEN = array.length;
|
|
400
|
-
return ptr;
|
|
401
|
-
}
|
|
402
527
|
/**
|
|
403
528
|
* Process the user_decryption response from Rust objects.
|
|
404
529
|
* Consider using [process_user_decryption_resp_from_js]
|
|
@@ -466,74 +591,27 @@ module.exports.get_client_secret_key = function(client) {
|
|
|
466
591
|
};
|
|
467
592
|
|
|
468
593
|
/**
|
|
469
|
-
* @param {
|
|
470
|
-
* @returns {ServerIdAddr[]}
|
|
471
|
-
*/
|
|
472
|
-
module.exports.get_server_addrs = function(client) {
|
|
473
|
-
_assertClass(client, Client);
|
|
474
|
-
const ret = wasm.get_server_addrs(client.__wbg_ptr);
|
|
475
|
-
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
476
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
477
|
-
return v1;
|
|
478
|
-
};
|
|
479
|
-
|
|
480
|
-
/**
|
|
481
|
-
* @returns {PrivateEncKeyMlKem512}
|
|
482
|
-
*/
|
|
483
|
-
module.exports.ml_kem_pke_keygen = function() {
|
|
484
|
-
const ret = wasm.ml_kem_pke_keygen();
|
|
485
|
-
return PrivateEncKeyMlKem512.__wrap(ret);
|
|
486
|
-
};
|
|
487
|
-
|
|
488
|
-
/**
|
|
489
|
-
* Instantiate a new client.
|
|
490
|
-
*
|
|
491
|
-
* * `server_addrs` - a list of KMS server ID with EIP-55 addresses,
|
|
492
|
-
* the elements in the list can be created using [new_server_id_addr].
|
|
493
|
-
*
|
|
494
|
-
* * `client_address_hex` - the client (wallet) address in hex,
|
|
495
|
-
* must be prefixed with "0x".
|
|
496
|
-
*
|
|
497
|
-
* * `fhe_parameter` - the parameter choice, which can be either `"test"` or `"default"`.
|
|
498
|
-
* The "default" parameter choice is selected if no matching string is found.
|
|
499
|
-
* @param {ServerIdAddr[]} server_addrs
|
|
500
|
-
* @param {string} client_address_hex
|
|
501
|
-
* @param {string} fhe_parameter
|
|
502
|
-
* @returns {Client}
|
|
503
|
-
*/
|
|
504
|
-
module.exports.new_client = function(server_addrs, client_address_hex, fhe_parameter) {
|
|
505
|
-
const ptr0 = passArrayJsValueToWasm0(server_addrs, wasm.__wbindgen_malloc);
|
|
506
|
-
const len0 = WASM_VECTOR_LEN;
|
|
507
|
-
const ptr1 = passStringToWasm0(client_address_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
508
|
-
const len1 = WASM_VECTOR_LEN;
|
|
509
|
-
const ptr2 = passStringToWasm0(fhe_parameter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
510
|
-
const len2 = WASM_VECTOR_LEN;
|
|
511
|
-
const ret = wasm.new_client(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
512
|
-
if (ret[2]) {
|
|
513
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
514
|
-
}
|
|
515
|
-
return Client.__wrap(ret[0]);
|
|
516
|
-
};
|
|
517
|
-
|
|
518
|
-
/**
|
|
519
|
-
* @param {PublicSigKey} pk
|
|
594
|
+
* @param {PublicEncKeyMlKem512} pk
|
|
520
595
|
* @returns {Uint8Array}
|
|
521
596
|
*/
|
|
522
|
-
module.exports.
|
|
523
|
-
_assertClass(pk,
|
|
524
|
-
const ret = wasm.
|
|
597
|
+
module.exports.ml_kem_pke_pk_to_u8vec = function(pk) {
|
|
598
|
+
_assertClass(pk, PublicEncKeyMlKem512);
|
|
599
|
+
const ret = wasm.ml_kem_pke_pk_to_u8vec(pk.__wbg_ptr);
|
|
600
|
+
if (ret[3]) {
|
|
601
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
602
|
+
}
|
|
525
603
|
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
526
604
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
527
605
|
return v1;
|
|
528
606
|
};
|
|
529
607
|
|
|
530
608
|
/**
|
|
531
|
-
* @param {
|
|
609
|
+
* @param {PrivateEncKeyMlKem512} sk
|
|
532
610
|
* @returns {Uint8Array}
|
|
533
611
|
*/
|
|
534
|
-
module.exports.
|
|
535
|
-
_assertClass(sk,
|
|
536
|
-
const ret = wasm.
|
|
612
|
+
module.exports.ml_kem_pke_sk_to_u8vec = function(sk) {
|
|
613
|
+
_assertClass(sk, PrivateEncKeyMlKem512);
|
|
614
|
+
const ret = wasm.ml_kem_pke_sk_to_u8vec(sk.__wbg_ptr);
|
|
537
615
|
if (ret[3]) {
|
|
538
616
|
throw takeFromExternrefTable0(ret[2]);
|
|
539
617
|
}
|
|
@@ -542,83 +620,6 @@ module.exports.private_sig_key_to_u8vec = function(sk) {
|
|
|
542
620
|
return v1;
|
|
543
621
|
};
|
|
544
622
|
|
|
545
|
-
/**
|
|
546
|
-
* @param {Client} client
|
|
547
|
-
* @returns {string}
|
|
548
|
-
*/
|
|
549
|
-
module.exports.get_client_address = function(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
|
-
module.exports.u8vec_to_public_sig_key = function(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 {PrivateSigKey}
|
|
580
|
-
*/
|
|
581
|
-
module.exports.u8vec_to_private_sig_key = function(v) {
|
|
582
|
-
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
583
|
-
const len0 = WASM_VECTOR_LEN;
|
|
584
|
-
const ret = wasm.u8vec_to_private_sig_key(ptr0, len0);
|
|
585
|
-
if (ret[2]) {
|
|
586
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
587
|
-
}
|
|
588
|
-
return PrivateSigKey.__wrap(ret[0]);
|
|
589
|
-
};
|
|
590
|
-
|
|
591
|
-
/**
|
|
592
|
-
* Create a new [ServerIdAddr] structure that holds an ID and an address
|
|
593
|
-
* which must be a valid EIP-55 address, notably prefixed with "0x".
|
|
594
|
-
* @param {number} id
|
|
595
|
-
* @param {string} addr
|
|
596
|
-
* @returns {ServerIdAddr}
|
|
597
|
-
*/
|
|
598
|
-
module.exports.new_server_id_addr = function(id, addr) {
|
|
599
|
-
const ptr0 = passStringToWasm0(addr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
600
|
-
const len0 = WASM_VECTOR_LEN;
|
|
601
|
-
const ret = wasm.new_server_id_addr(id, ptr0, len0);
|
|
602
|
-
if (ret[2]) {
|
|
603
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
604
|
-
}
|
|
605
|
-
return ServerIdAddr.__wrap(ret[0]);
|
|
606
|
-
};
|
|
607
|
-
|
|
608
|
-
/**
|
|
609
|
-
* @param {Uint8Array} v
|
|
610
|
-
* @returns {PrivateEncKeyMlKem512}
|
|
611
|
-
*/
|
|
612
|
-
module.exports.u8vec_to_ml_kem_pke_sk = function(v) {
|
|
613
|
-
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
614
|
-
const len0 = WASM_VECTOR_LEN;
|
|
615
|
-
const ret = wasm.u8vec_to_ml_kem_pke_sk(ptr0, len0);
|
|
616
|
-
if (ret[2]) {
|
|
617
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
618
|
-
}
|
|
619
|
-
return PrivateEncKeyMlKem512.__wrap(ret[0]);
|
|
620
|
-
};
|
|
621
|
-
|
|
622
623
|
const CiphertextHandleFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
623
624
|
? { register: () => {}, unregister: () => {} }
|
|
624
625
|
: new FinalizationRegistry(ptr => wasm.__wbg_ciphertexthandle_free(ptr >>> 0, 1));
|
package/kms_lib_bg.wasm
CHANGED
|
Binary file
|