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