tkms 0.13.1 → 0.13.3
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 +51 -51
- package/kms_lib.js +210 -211
- package/kms_lib_bg.wasm +0 -0
- package/package.json +1 -1
package/kms_lib.d.ts
CHANGED
|
@@ -1,50 +1,10 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
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
3
|
/**
|
|
17
4
|
* Create a new [ServerIdAddr] structure that holds an ID and an address
|
|
18
5
|
* which must be a valid EIP-55 address, notably prefixed with "0x".
|
|
19
6
|
*/
|
|
20
7
|
export function new_server_id_addr(id: number, addr: string): ServerIdAddr;
|
|
21
|
-
/**
|
|
22
|
-
* Process the user_decryption response from Rust objects.
|
|
23
|
-
* Consider using [process_user_decryption_resp_from_js]
|
|
24
|
-
* when using the JS API.
|
|
25
|
-
* The result is a byte array representing a plaintext of any length.
|
|
26
|
-
*
|
|
27
|
-
* * `client` - client that wants to perform user_decryption.
|
|
28
|
-
*
|
|
29
|
-
* * `request` - the initial user_decryption request.
|
|
30
|
-
* Must be given if `verify` is true.
|
|
31
|
-
*
|
|
32
|
-
* * `eip712_domain` - the EIP-712 domain.
|
|
33
|
-
* Must be given if `verify` is true.
|
|
34
|
-
*
|
|
35
|
-
* * `agg_resp` - the vector of user_decryption responses.
|
|
36
|
-
*
|
|
37
|
-
* * `enc_pk` - The ephemeral public key.
|
|
38
|
-
*
|
|
39
|
-
* * `enc_sk` - The ephemeral secret key.
|
|
40
|
-
*
|
|
41
|
-
* * `verify` - Whether to perform signature verification for the response.
|
|
42
|
-
* It is insecure if `verify = false`!
|
|
43
|
-
*/
|
|
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[];
|
|
45
|
-
export function ml_kem_pke_keygen(): PrivateEncKeyMlKem512;
|
|
46
|
-
export function ml_kem_pke_sk_len(): number;
|
|
47
|
-
export function ml_kem_pke_pk_to_u8vec(pk: PublicEncKeyMlKem512): Uint8Array;
|
|
48
8
|
/**
|
|
49
9
|
* Process the user_decryption response from JavaScript objects.
|
|
50
10
|
* The returned result is a byte array representing a plaintext of any length,
|
|
@@ -107,29 +67,69 @@ export function ml_kem_pke_pk_to_u8vec(pk: PublicEncKeyMlKem512): Uint8Array;
|
|
|
107
67
|
* It is insecure if `verify = false`!
|
|
108
68
|
*/
|
|
109
69
|
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[];
|
|
70
|
+
export function u8vec_to_ml_kem_pke_pk(v: Uint8Array): PublicEncKeyMlKem512;
|
|
71
|
+
/**
|
|
72
|
+
* Instantiate a new client.
|
|
73
|
+
*
|
|
74
|
+
* * `server_addrs` - a list of KMS server ID with EIP-55 addresses,
|
|
75
|
+
* the elements in the list can be created using [new_server_id_addr].
|
|
76
|
+
*
|
|
77
|
+
* * `client_address_hex` - the client (wallet) address in hex,
|
|
78
|
+
* must be prefixed with "0x".
|
|
79
|
+
*
|
|
80
|
+
* * `fhe_parameter` - the parameter choice, which can be either `"test"` or `"default"`.
|
|
81
|
+
* The "default" parameter choice is selected if no matching string is found.
|
|
82
|
+
*/
|
|
83
|
+
export function new_client(server_addrs: ServerIdAddr[], client_address_hex: string, fhe_parameter: string): Client;
|
|
84
|
+
export function ml_kem_pke_get_pk(sk: PrivateEncKeyMlKem512): PublicEncKeyMlKem512;
|
|
85
|
+
export function u8vec_to_private_sig_key(v: Uint8Array): PrivateSigKey;
|
|
86
|
+
export function u8vec_to_ml_kem_pke_sk(v: Uint8Array): PrivateEncKeyMlKem512;
|
|
87
|
+
/**
|
|
88
|
+
* This function is *not* used by relayer-sdk because the encryption
|
|
89
|
+
* happens on the KMS side. It's just here for completeness and tests.
|
|
90
|
+
*/
|
|
91
|
+
export function ml_kem_pke_encrypt(msg: Uint8Array, their_pk: PublicEncKeyMlKem512): Uint8Array;
|
|
110
92
|
/**
|
|
111
93
|
* This function is *not* used by relayer-sdk because the decryption
|
|
112
94
|
* is handled by [process_user_decryption_resp].
|
|
113
95
|
* It's just here for completeness and tests.
|
|
114
96
|
*/
|
|
115
97
|
export function ml_kem_pke_decrypt(ct: Uint8Array, my_sk: PrivateEncKeyMlKem512): Uint8Array;
|
|
116
|
-
export function
|
|
98
|
+
export function ml_kem_pke_pk_len(): number;
|
|
117
99
|
/**
|
|
118
|
-
*
|
|
119
|
-
*
|
|
100
|
+
* Process the user_decryption response from Rust objects.
|
|
101
|
+
* Consider using [process_user_decryption_resp_from_js]
|
|
102
|
+
* when using the JS API.
|
|
103
|
+
* The result is a byte array representing a plaintext of any length.
|
|
104
|
+
*
|
|
105
|
+
* * `client` - client that wants to perform user_decryption.
|
|
106
|
+
*
|
|
107
|
+
* * `request` - the initial user_decryption request.
|
|
108
|
+
* Must be given if `verify` is true.
|
|
109
|
+
*
|
|
110
|
+
* * `eip712_domain` - the EIP-712 domain.
|
|
111
|
+
* Must be given if `verify` is true.
|
|
112
|
+
*
|
|
113
|
+
* * `agg_resp` - the vector of user_decryption responses.
|
|
114
|
+
*
|
|
115
|
+
* * `enc_pk` - The ephemeral public key.
|
|
116
|
+
*
|
|
117
|
+
* * `enc_sk` - The ephemeral secret key.
|
|
118
|
+
*
|
|
119
|
+
* * `verify` - Whether to perform signature verification for the response.
|
|
120
|
+
* It is insecure if `verify = false`!
|
|
120
121
|
*/
|
|
121
|
-
export function
|
|
122
|
-
export function
|
|
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;
|
|
122
|
+
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[];
|
|
123
|
+
export function ml_kem_pke_pk_to_u8vec(pk: PublicEncKeyMlKem512): Uint8Array;
|
|
126
124
|
export function ml_kem_pke_sk_to_u8vec(sk: PrivateEncKeyMlKem512): Uint8Array;
|
|
127
|
-
export function
|
|
125
|
+
export function ml_kem_pke_sk_len(): number;
|
|
128
126
|
export function get_client_address(client: Client): string;
|
|
127
|
+
export function private_sig_key_to_u8vec(sk: PrivateSigKey): Uint8Array;
|
|
128
|
+
export function get_client_secret_key(client: Client): PrivateSigKey | undefined;
|
|
129
|
+
export function public_sig_key_to_u8vec(pk: PublicSigKey): Uint8Array;
|
|
130
|
+
export function ml_kem_pke_keygen(): PrivateEncKeyMlKem512;
|
|
129
131
|
export function u8vec_to_public_sig_key(v: Uint8Array): PublicSigKey;
|
|
130
|
-
export function u8vec_to_ml_kem_pke_pk(v: Uint8Array): PublicEncKeyMlKem512;
|
|
131
132
|
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
|
@@ -167,51 +167,11 @@ function debugString(val) {
|
|
|
167
167
|
return className;
|
|
168
168
|
}
|
|
169
169
|
|
|
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);
|
|
175
|
-
}
|
|
176
|
-
WASM_VECTOR_LEN = array.length;
|
|
177
|
-
return ptr;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
170
|
function takeFromExternrefTable0(idx) {
|
|
181
171
|
const value = wasm.__wbindgen_export_4.get(idx);
|
|
182
172
|
wasm.__externref_table_dealloc(idx);
|
|
183
173
|
return value;
|
|
184
174
|
}
|
|
185
|
-
/**
|
|
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}
|
|
200
|
-
*/
|
|
201
|
-
export function new_client(server_addrs, client_address_hex, fhe_parameter) {
|
|
202
|
-
const ptr0 = passArrayJsValueToWasm0(server_addrs, wasm.__wbindgen_malloc);
|
|
203
|
-
const len0 = WASM_VECTOR_LEN;
|
|
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);
|
|
209
|
-
if (ret[2]) {
|
|
210
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
211
|
-
}
|
|
212
|
-
return Client.__wrap(ret[0]);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
175
|
/**
|
|
216
176
|
* Create a new [ServerIdAddr] structure that holds an ID and an address
|
|
217
177
|
* which must be a valid EIP-55 address, notably prefixed with "0x".
|
|
@@ -245,97 +205,6 @@ function getArrayJsValueFromWasm0(ptr, len) {
|
|
|
245
205
|
wasm.__externref_drop_slice(ptr, len);
|
|
246
206
|
return result;
|
|
247
207
|
}
|
|
248
|
-
/**
|
|
249
|
-
* Process the user_decryption response from Rust objects.
|
|
250
|
-
* Consider using [process_user_decryption_resp_from_js]
|
|
251
|
-
* when using the JS API.
|
|
252
|
-
* The result is a byte array representing a plaintext of any length.
|
|
253
|
-
*
|
|
254
|
-
* * `client` - client that wants to perform user_decryption.
|
|
255
|
-
*
|
|
256
|
-
* * `request` - the initial user_decryption request.
|
|
257
|
-
* Must be given if `verify` is true.
|
|
258
|
-
*
|
|
259
|
-
* * `eip712_domain` - the EIP-712 domain.
|
|
260
|
-
* Must be given if `verify` is true.
|
|
261
|
-
*
|
|
262
|
-
* * `agg_resp` - the vector of user_decryption responses.
|
|
263
|
-
*
|
|
264
|
-
* * `enc_pk` - The ephemeral public key.
|
|
265
|
-
*
|
|
266
|
-
* * `enc_sk` - The ephemeral secret key.
|
|
267
|
-
*
|
|
268
|
-
* * `verify` - Whether to perform signature verification for the response.
|
|
269
|
-
* It is insecure if `verify = false`!
|
|
270
|
-
* @param {Client} client
|
|
271
|
-
* @param {ParsedUserDecryptionRequest | null | undefined} request
|
|
272
|
-
* @param {Eip712DomainMsg | null | undefined} eip712_domain
|
|
273
|
-
* @param {UserDecryptionResponse[]} agg_resp
|
|
274
|
-
* @param {PublicEncKeyMlKem512} enc_pk
|
|
275
|
-
* @param {PrivateEncKeyMlKem512} enc_sk
|
|
276
|
-
* @param {boolean} verify
|
|
277
|
-
* @returns {TypedPlaintext[]}
|
|
278
|
-
*/
|
|
279
|
-
export function process_user_decryption_resp(client, request, eip712_domain, agg_resp, enc_pk, enc_sk, verify) {
|
|
280
|
-
_assertClass(client, Client);
|
|
281
|
-
let ptr0 = 0;
|
|
282
|
-
if (!isLikeNone(request)) {
|
|
283
|
-
_assertClass(request, ParsedUserDecryptionRequest);
|
|
284
|
-
ptr0 = request.__destroy_into_raw();
|
|
285
|
-
}
|
|
286
|
-
let ptr1 = 0;
|
|
287
|
-
if (!isLikeNone(eip712_domain)) {
|
|
288
|
-
_assertClass(eip712_domain, Eip712DomainMsg);
|
|
289
|
-
ptr1 = eip712_domain.__destroy_into_raw();
|
|
290
|
-
}
|
|
291
|
-
const ptr2 = passArrayJsValueToWasm0(agg_resp, wasm.__wbindgen_malloc);
|
|
292
|
-
const len2 = WASM_VECTOR_LEN;
|
|
293
|
-
_assertClass(enc_pk, PublicEncKeyMlKem512);
|
|
294
|
-
_assertClass(enc_sk, PrivateEncKeyMlKem512);
|
|
295
|
-
const ret = wasm.process_user_decryption_resp(client.__wbg_ptr, ptr0, ptr1, ptr2, len2, enc_pk.__wbg_ptr, enc_sk.__wbg_ptr, verify);
|
|
296
|
-
if (ret[3]) {
|
|
297
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
298
|
-
}
|
|
299
|
-
var v4 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
300
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
301
|
-
return v4;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* @returns {PrivateEncKeyMlKem512}
|
|
306
|
-
*/
|
|
307
|
-
export function ml_kem_pke_keygen() {
|
|
308
|
-
const ret = wasm.ml_kem_pke_keygen();
|
|
309
|
-
return PrivateEncKeyMlKem512.__wrap(ret);
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* @returns {number}
|
|
314
|
-
*/
|
|
315
|
-
export function ml_kem_pke_sk_len() {
|
|
316
|
-
const ret = wasm.ml_kem_pke_sk_len();
|
|
317
|
-
return ret >>> 0;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
321
|
-
ptr = ptr >>> 0;
|
|
322
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* @param {PublicEncKeyMlKem512} pk
|
|
326
|
-
* @returns {Uint8Array}
|
|
327
|
-
*/
|
|
328
|
-
export function ml_kem_pke_pk_to_u8vec(pk) {
|
|
329
|
-
_assertClass(pk, PublicEncKeyMlKem512);
|
|
330
|
-
const ret = wasm.ml_kem_pke_pk_to_u8vec(pk.__wbg_ptr);
|
|
331
|
-
if (ret[3]) {
|
|
332
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
333
|
-
}
|
|
334
|
-
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
335
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
336
|
-
return v1;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
208
|
/**
|
|
340
209
|
* Process the user_decryption response from JavaScript objects.
|
|
341
210
|
* The returned result is a byte array representing a plaintext of any length,
|
|
@@ -425,48 +294,66 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
425
294
|
return ptr;
|
|
426
295
|
}
|
|
427
296
|
/**
|
|
428
|
-
*
|
|
429
|
-
*
|
|
430
|
-
* It's just here for completeness and tests.
|
|
431
|
-
* @param {Uint8Array} ct
|
|
432
|
-
* @param {PrivateEncKeyMlKem512} my_sk
|
|
433
|
-
* @returns {Uint8Array}
|
|
297
|
+
* @param {Uint8Array} v
|
|
298
|
+
* @returns {PublicEncKeyMlKem512}
|
|
434
299
|
*/
|
|
435
|
-
export function
|
|
436
|
-
const ptr0 = passArray8ToWasm0(
|
|
300
|
+
export function u8vec_to_ml_kem_pke_pk(v) {
|
|
301
|
+
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
437
302
|
const len0 = WASM_VECTOR_LEN;
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
return
|
|
303
|
+
const ret = wasm.u8vec_to_ml_kem_pke_pk(ptr0, len0);
|
|
304
|
+
if (ret[2]) {
|
|
305
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
306
|
+
}
|
|
307
|
+
return PublicEncKeyMlKem512.__wrap(ret[0]);
|
|
443
308
|
}
|
|
444
309
|
|
|
310
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
311
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
312
|
+
for (let i = 0; i < array.length; i++) {
|
|
313
|
+
const add = addToExternrefTable0(array[i]);
|
|
314
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
315
|
+
}
|
|
316
|
+
WASM_VECTOR_LEN = array.length;
|
|
317
|
+
return ptr;
|
|
318
|
+
}
|
|
445
319
|
/**
|
|
446
|
-
*
|
|
447
|
-
*
|
|
320
|
+
* Instantiate a new client.
|
|
321
|
+
*
|
|
322
|
+
* * `server_addrs` - a list of KMS server ID with EIP-55 addresses,
|
|
323
|
+
* the elements in the list can be created using [new_server_id_addr].
|
|
324
|
+
*
|
|
325
|
+
* * `client_address_hex` - the client (wallet) address in hex,
|
|
326
|
+
* must be prefixed with "0x".
|
|
327
|
+
*
|
|
328
|
+
* * `fhe_parameter` - the parameter choice, which can be either `"test"` or `"default"`.
|
|
329
|
+
* The "default" parameter choice is selected if no matching string is found.
|
|
330
|
+
* @param {ServerIdAddr[]} server_addrs
|
|
331
|
+
* @param {string} client_address_hex
|
|
332
|
+
* @param {string} fhe_parameter
|
|
333
|
+
* @returns {Client}
|
|
448
334
|
*/
|
|
449
|
-
export function
|
|
450
|
-
|
|
451
|
-
const
|
|
452
|
-
|
|
335
|
+
export function new_client(server_addrs, client_address_hex, fhe_parameter) {
|
|
336
|
+
const ptr0 = passArrayJsValueToWasm0(server_addrs, wasm.__wbindgen_malloc);
|
|
337
|
+
const len0 = WASM_VECTOR_LEN;
|
|
338
|
+
const ptr1 = passStringToWasm0(client_address_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
339
|
+
const len1 = WASM_VECTOR_LEN;
|
|
340
|
+
const ptr2 = passStringToWasm0(fhe_parameter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
341
|
+
const len2 = WASM_VECTOR_LEN;
|
|
342
|
+
const ret = wasm.new_client(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
343
|
+
if (ret[2]) {
|
|
344
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
345
|
+
}
|
|
346
|
+
return Client.__wrap(ret[0]);
|
|
453
347
|
}
|
|
454
348
|
|
|
455
349
|
/**
|
|
456
|
-
*
|
|
457
|
-
*
|
|
458
|
-
* @param {Uint8Array} msg
|
|
459
|
-
* @param {PublicEncKeyMlKem512} their_pk
|
|
460
|
-
* @returns {Uint8Array}
|
|
350
|
+
* @param {PrivateEncKeyMlKem512} sk
|
|
351
|
+
* @returns {PublicEncKeyMlKem512}
|
|
461
352
|
*/
|
|
462
|
-
export function
|
|
463
|
-
|
|
464
|
-
const
|
|
465
|
-
|
|
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;
|
|
353
|
+
export function ml_kem_pke_get_pk(sk) {
|
|
354
|
+
_assertClass(sk, PrivateEncKeyMlKem512);
|
|
355
|
+
const ret = wasm.ml_kem_pke_get_pk(sk.__wbg_ptr);
|
|
356
|
+
return PublicEncKeyMlKem512.__wrap(ret);
|
|
470
357
|
}
|
|
471
358
|
|
|
472
359
|
/**
|
|
@@ -483,18 +370,6 @@ export function u8vec_to_private_sig_key(v) {
|
|
|
483
370
|
return PrivateSigKey.__wrap(ret[0]);
|
|
484
371
|
}
|
|
485
372
|
|
|
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
373
|
/**
|
|
499
374
|
* @param {Uint8Array} v
|
|
500
375
|
* @returns {PrivateEncKeyMlKem512}
|
|
@@ -509,14 +384,122 @@ export function u8vec_to_ml_kem_pke_sk(v) {
|
|
|
509
384
|
return PrivateEncKeyMlKem512.__wrap(ret[0]);
|
|
510
385
|
}
|
|
511
386
|
|
|
387
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
388
|
+
ptr = ptr >>> 0;
|
|
389
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
390
|
+
}
|
|
512
391
|
/**
|
|
513
|
-
*
|
|
514
|
-
*
|
|
392
|
+
* This function is *not* used by relayer-sdk because the encryption
|
|
393
|
+
* happens on the KMS side. It's just here for completeness and tests.
|
|
394
|
+
* @param {Uint8Array} msg
|
|
395
|
+
* @param {PublicEncKeyMlKem512} their_pk
|
|
396
|
+
* @returns {Uint8Array}
|
|
515
397
|
*/
|
|
516
|
-
export function
|
|
517
|
-
|
|
518
|
-
const
|
|
519
|
-
|
|
398
|
+
export function ml_kem_pke_encrypt(msg, their_pk) {
|
|
399
|
+
const ptr0 = passArray8ToWasm0(msg, wasm.__wbindgen_malloc);
|
|
400
|
+
const len0 = WASM_VECTOR_LEN;
|
|
401
|
+
_assertClass(their_pk, PublicEncKeyMlKem512);
|
|
402
|
+
const ret = wasm.ml_kem_pke_encrypt(ptr0, len0, their_pk.__wbg_ptr);
|
|
403
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
404
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
405
|
+
return v2;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* This function is *not* used by relayer-sdk because the decryption
|
|
410
|
+
* is handled by [process_user_decryption_resp].
|
|
411
|
+
* It's just here for completeness and tests.
|
|
412
|
+
* @param {Uint8Array} ct
|
|
413
|
+
* @param {PrivateEncKeyMlKem512} my_sk
|
|
414
|
+
* @returns {Uint8Array}
|
|
415
|
+
*/
|
|
416
|
+
export function ml_kem_pke_decrypt(ct, my_sk) {
|
|
417
|
+
const ptr0 = passArray8ToWasm0(ct, wasm.__wbindgen_malloc);
|
|
418
|
+
const len0 = WASM_VECTOR_LEN;
|
|
419
|
+
_assertClass(my_sk, PrivateEncKeyMlKem512);
|
|
420
|
+
const ret = wasm.ml_kem_pke_decrypt(ptr0, len0, my_sk.__wbg_ptr);
|
|
421
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
422
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
423
|
+
return v2;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* @returns {number}
|
|
428
|
+
*/
|
|
429
|
+
export function ml_kem_pke_pk_len() {
|
|
430
|
+
const ret = wasm.ml_kem_pke_pk_len();
|
|
431
|
+
return ret >>> 0;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Process the user_decryption response from Rust objects.
|
|
436
|
+
* Consider using [process_user_decryption_resp_from_js]
|
|
437
|
+
* when using the JS API.
|
|
438
|
+
* The result is a byte array representing a plaintext of any length.
|
|
439
|
+
*
|
|
440
|
+
* * `client` - client that wants to perform user_decryption.
|
|
441
|
+
*
|
|
442
|
+
* * `request` - the initial user_decryption request.
|
|
443
|
+
* Must be given if `verify` is true.
|
|
444
|
+
*
|
|
445
|
+
* * `eip712_domain` - the EIP-712 domain.
|
|
446
|
+
* Must be given if `verify` is true.
|
|
447
|
+
*
|
|
448
|
+
* * `agg_resp` - the vector of user_decryption responses.
|
|
449
|
+
*
|
|
450
|
+
* * `enc_pk` - The ephemeral public key.
|
|
451
|
+
*
|
|
452
|
+
* * `enc_sk` - The ephemeral secret key.
|
|
453
|
+
*
|
|
454
|
+
* * `verify` - Whether to perform signature verification for the response.
|
|
455
|
+
* It is insecure if `verify = false`!
|
|
456
|
+
* @param {Client} client
|
|
457
|
+
* @param {ParsedUserDecryptionRequest | null | undefined} request
|
|
458
|
+
* @param {Eip712DomainMsg | null | undefined} eip712_domain
|
|
459
|
+
* @param {UserDecryptionResponse[]} agg_resp
|
|
460
|
+
* @param {PublicEncKeyMlKem512} enc_pk
|
|
461
|
+
* @param {PrivateEncKeyMlKem512} enc_sk
|
|
462
|
+
* @param {boolean} verify
|
|
463
|
+
* @returns {TypedPlaintext[]}
|
|
464
|
+
*/
|
|
465
|
+
export function process_user_decryption_resp(client, request, eip712_domain, agg_resp, enc_pk, enc_sk, verify) {
|
|
466
|
+
_assertClass(client, Client);
|
|
467
|
+
let ptr0 = 0;
|
|
468
|
+
if (!isLikeNone(request)) {
|
|
469
|
+
_assertClass(request, ParsedUserDecryptionRequest);
|
|
470
|
+
ptr0 = request.__destroy_into_raw();
|
|
471
|
+
}
|
|
472
|
+
let ptr1 = 0;
|
|
473
|
+
if (!isLikeNone(eip712_domain)) {
|
|
474
|
+
_assertClass(eip712_domain, Eip712DomainMsg);
|
|
475
|
+
ptr1 = eip712_domain.__destroy_into_raw();
|
|
476
|
+
}
|
|
477
|
+
const ptr2 = passArrayJsValueToWasm0(agg_resp, wasm.__wbindgen_malloc);
|
|
478
|
+
const len2 = WASM_VECTOR_LEN;
|
|
479
|
+
_assertClass(enc_pk, PublicEncKeyMlKem512);
|
|
480
|
+
_assertClass(enc_sk, PrivateEncKeyMlKem512);
|
|
481
|
+
const ret = wasm.process_user_decryption_resp(client.__wbg_ptr, ptr0, ptr1, ptr2, len2, enc_pk.__wbg_ptr, enc_sk.__wbg_ptr, verify);
|
|
482
|
+
if (ret[3]) {
|
|
483
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
484
|
+
}
|
|
485
|
+
var v4 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
486
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
487
|
+
return v4;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* @param {PublicEncKeyMlKem512} pk
|
|
492
|
+
* @returns {Uint8Array}
|
|
493
|
+
*/
|
|
494
|
+
export function ml_kem_pke_pk_to_u8vec(pk) {
|
|
495
|
+
_assertClass(pk, PublicEncKeyMlKem512);
|
|
496
|
+
const ret = wasm.ml_kem_pke_pk_to_u8vec(pk.__wbg_ptr);
|
|
497
|
+
if (ret[3]) {
|
|
498
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
499
|
+
}
|
|
500
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
501
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
502
|
+
return v1;
|
|
520
503
|
}
|
|
521
504
|
|
|
522
505
|
/**
|
|
@@ -537,8 +520,8 @@ export function ml_kem_pke_sk_to_u8vec(sk) {
|
|
|
537
520
|
/**
|
|
538
521
|
* @returns {number}
|
|
539
522
|
*/
|
|
540
|
-
export function
|
|
541
|
-
const ret = wasm.
|
|
523
|
+
export function ml_kem_pke_sk_len() {
|
|
524
|
+
const ret = wasm.ml_kem_pke_sk_len();
|
|
542
525
|
return ret >>> 0;
|
|
543
526
|
}
|
|
544
527
|
|
|
@@ -561,31 +544,62 @@ export function get_client_address(client) {
|
|
|
561
544
|
}
|
|
562
545
|
|
|
563
546
|
/**
|
|
564
|
-
* @param {
|
|
565
|
-
* @returns {
|
|
547
|
+
* @param {PrivateSigKey} sk
|
|
548
|
+
* @returns {Uint8Array}
|
|
566
549
|
*/
|
|
567
|
-
export function
|
|
568
|
-
|
|
569
|
-
const
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
550
|
+
export function private_sig_key_to_u8vec(sk) {
|
|
551
|
+
_assertClass(sk, PrivateSigKey);
|
|
552
|
+
const ret = wasm.private_sig_key_to_u8vec(sk.__wbg_ptr);
|
|
553
|
+
if (ret[3]) {
|
|
554
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
573
555
|
}
|
|
574
|
-
|
|
556
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
557
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
558
|
+
return v1;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* @param {Client} client
|
|
563
|
+
* @returns {PrivateSigKey | undefined}
|
|
564
|
+
*/
|
|
565
|
+
export function get_client_secret_key(client) {
|
|
566
|
+
_assertClass(client, Client);
|
|
567
|
+
const ret = wasm.get_client_secret_key(client.__wbg_ptr);
|
|
568
|
+
return ret === 0 ? undefined : PrivateSigKey.__wrap(ret);
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* @param {PublicSigKey} pk
|
|
573
|
+
* @returns {Uint8Array}
|
|
574
|
+
*/
|
|
575
|
+
export function public_sig_key_to_u8vec(pk) {
|
|
576
|
+
_assertClass(pk, PublicSigKey);
|
|
577
|
+
const ret = wasm.public_sig_key_to_u8vec(pk.__wbg_ptr);
|
|
578
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
579
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
580
|
+
return v1;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* @returns {PrivateEncKeyMlKem512}
|
|
585
|
+
*/
|
|
586
|
+
export function ml_kem_pke_keygen() {
|
|
587
|
+
const ret = wasm.ml_kem_pke_keygen();
|
|
588
|
+
return PrivateEncKeyMlKem512.__wrap(ret);
|
|
575
589
|
}
|
|
576
590
|
|
|
577
591
|
/**
|
|
578
592
|
* @param {Uint8Array} v
|
|
579
|
-
* @returns {
|
|
593
|
+
* @returns {PublicSigKey}
|
|
580
594
|
*/
|
|
581
|
-
export function
|
|
595
|
+
export function u8vec_to_public_sig_key(v) {
|
|
582
596
|
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
583
597
|
const len0 = WASM_VECTOR_LEN;
|
|
584
|
-
const ret = wasm.
|
|
598
|
+
const ret = wasm.u8vec_to_public_sig_key(ptr0, len0);
|
|
585
599
|
if (ret[2]) {
|
|
586
600
|
throw takeFromExternrefTable0(ret[1]);
|
|
587
601
|
}
|
|
588
|
-
return
|
|
602
|
+
return PublicSigKey.__wrap(ret[0]);
|
|
589
603
|
}
|
|
590
604
|
|
|
591
605
|
/**
|
|
@@ -600,21 +614,6 @@ export function get_server_addrs(client) {
|
|
|
600
614
|
return v1;
|
|
601
615
|
}
|
|
602
616
|
|
|
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
617
|
const CiphertextHandleFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
619
618
|
? { register: () => {}, unregister: () => {} }
|
|
620
619
|
: new FinalizationRegistry(ptr => wasm.__wbg_ciphertexthandle_free(ptr >>> 0, 1));
|
package/kms_lib_bg.wasm
CHANGED
|
Binary file
|