tkms 0.12.5 → 0.13.0-rc.0
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 +57 -57
- package/kms_lib.js +228 -228
- package/kms_lib_bg.wasm +0 -0
- package/package.json +1 -1
package/kms_lib.d.ts
CHANGED
|
@@ -1,60 +1,9 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
export function get_server_addrs(client: Client): ServerIdAddr[];
|
|
4
3
|
export function ml_kem_pke_sk_to_u8vec(sk: PrivateEncKeyMlKem512): Uint8Array;
|
|
5
|
-
export function get_client_address(client: Client): string;
|
|
6
|
-
export function u8vec_to_public_sig_key(v: Uint8Array): PublicSigKey;
|
|
7
|
-
export function private_sig_key_to_u8vec(sk: PrivateSigKey): Uint8Array;
|
|
8
|
-
export function public_sig_key_to_u8vec(pk: PublicSigKey): Uint8Array;
|
|
9
|
-
/**
|
|
10
|
-
* This function is *not* used by relayer-sdk because the decryption
|
|
11
|
-
* is handled by [process_user_decryption_resp].
|
|
12
|
-
* It's just here for completeness and tests.
|
|
13
|
-
*/
|
|
14
|
-
export function ml_kem_pke_decrypt(ct: Uint8Array, my_sk: PrivateEncKeyMlKem512): Uint8Array;
|
|
15
4
|
export function ml_kem_pke_sk_len(): number;
|
|
16
|
-
export function ml_kem_pke_pk_len(): number;
|
|
17
|
-
/**
|
|
18
|
-
* This function is *not* used by relayer-sdk because the encryption
|
|
19
|
-
* happens on the KMS side. It's just here for completeness and tests.
|
|
20
|
-
*/
|
|
21
|
-
export function ml_kem_pke_encrypt(msg: Uint8Array, their_pk: PublicEncKeyMlKem512): Uint8Array;
|
|
22
|
-
/**
|
|
23
|
-
* Create a new [ServerIdAddr] structure that holds an ID and an address
|
|
24
|
-
* which must be a valid EIP-55 address, notably prefixed with "0x".
|
|
25
|
-
*/
|
|
26
|
-
export function new_server_id_addr(id: number, addr: string): ServerIdAddr;
|
|
27
|
-
export function u8vec_to_ml_kem_pke_sk(v: Uint8Array): PrivateEncKeyMlKem512;
|
|
28
|
-
export function ml_kem_pke_get_pk(sk: PrivateEncKeyMlKem512): PublicEncKeyMlKem512;
|
|
29
|
-
export function ml_kem_pke_pk_to_u8vec(pk: PublicEncKeyMlKem512): Uint8Array;
|
|
30
|
-
export function u8vec_to_private_sig_key(v: Uint8Array): PrivateSigKey;
|
|
31
|
-
/**
|
|
32
|
-
* Process the user_decryption response from Rust objects.
|
|
33
|
-
* Consider using [process_user_decryption_resp_from_js]
|
|
34
|
-
* when using the JS API.
|
|
35
|
-
* The result is a byte array representing a plaintext of any length.
|
|
36
|
-
*
|
|
37
|
-
* * `client` - client that wants to perform user_decryption.
|
|
38
|
-
*
|
|
39
|
-
* * `request` - the initial user_decryption request.
|
|
40
|
-
* Must be given if `verify` is true.
|
|
41
|
-
*
|
|
42
|
-
* * `eip712_domain` - the EIP-712 domain.
|
|
43
|
-
* Must be given if `verify` is true.
|
|
44
|
-
*
|
|
45
|
-
* * `agg_resp` - the vector of user_decryption responses.
|
|
46
|
-
*
|
|
47
|
-
* * `enc_pk` - The ephemeral public key.
|
|
48
|
-
*
|
|
49
|
-
* * `enc_sk` - The ephemeral secret key.
|
|
50
|
-
*
|
|
51
|
-
* * `verify` - Whether to perform signature verification for the response.
|
|
52
|
-
* It is insecure if `verify = false`!
|
|
53
|
-
*/
|
|
54
|
-
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[];
|
|
55
|
-
export function get_client_secret_key(client: Client): PrivateSigKey | undefined;
|
|
56
|
-
export function ml_kem_pke_keygen(): PrivateEncKeyMlKem512;
|
|
57
5
|
export function u8vec_to_ml_kem_pke_pk(v: Uint8Array): PublicEncKeyMlKem512;
|
|
6
|
+
export function ml_kem_pke_pk_to_u8vec(pk: PublicEncKeyMlKem512): Uint8Array;
|
|
58
7
|
/**
|
|
59
8
|
* Process the user_decryption response from JavaScript objects.
|
|
60
9
|
* The returned result is a byte array representing a plaintext of any length,
|
|
@@ -117,6 +66,46 @@ export function u8vec_to_ml_kem_pke_pk(v: Uint8Array): PublicEncKeyMlKem512;
|
|
|
117
66
|
* It is insecure if `verify = false`!
|
|
118
67
|
*/
|
|
119
68
|
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
|
+
/**
|
|
78
|
+
* This function is *not* used by relayer-sdk because the encryption
|
|
79
|
+
* happens on the KMS side. It's just here for completeness and tests.
|
|
80
|
+
*/
|
|
81
|
+
export function ml_kem_pke_encrypt(msg: Uint8Array, their_pk: PublicEncKeyMlKem512): Uint8Array;
|
|
82
|
+
/**
|
|
83
|
+
* Process the user_decryption response from Rust objects.
|
|
84
|
+
* Consider using [process_user_decryption_resp_from_js]
|
|
85
|
+
* when using the JS API.
|
|
86
|
+
* The result is a byte array representing a plaintext of any length.
|
|
87
|
+
*
|
|
88
|
+
* * `client` - client that wants to perform user_decryption.
|
|
89
|
+
*
|
|
90
|
+
* * `request` - the initial user_decryption request.
|
|
91
|
+
* Must be given if `verify` is true.
|
|
92
|
+
*
|
|
93
|
+
* * `eip712_domain` - the EIP-712 domain.
|
|
94
|
+
* Must be given if `verify` is true.
|
|
95
|
+
*
|
|
96
|
+
* * `agg_resp` - the vector of user_decryption responses.
|
|
97
|
+
*
|
|
98
|
+
* * `enc_pk` - The ephemeral public key.
|
|
99
|
+
*
|
|
100
|
+
* * `enc_sk` - The ephemeral secret key.
|
|
101
|
+
*
|
|
102
|
+
* * `verify` - Whether to perform signature verification for the response.
|
|
103
|
+
* It is insecure if `verify = false`!
|
|
104
|
+
*/
|
|
105
|
+
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
|
+
export function get_client_secret_key(client: Client): PrivateSigKey | undefined;
|
|
107
|
+
export function get_server_addrs(client: Client): ServerIdAddr[];
|
|
108
|
+
export function ml_kem_pke_keygen(): PrivateEncKeyMlKem512;
|
|
120
109
|
/**
|
|
121
110
|
* Instantiate a new client.
|
|
122
111
|
*
|
|
@@ -130,6 +119,17 @@ export function process_user_decryption_resp_from_js(client: Client, request: an
|
|
|
130
119
|
* The "default" parameter choice is selected if no matching string is found.
|
|
131
120
|
*/
|
|
132
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;
|
|
133
133
|
export class CiphertextHandle {
|
|
134
134
|
private constructor();
|
|
135
135
|
free(): void;
|
|
@@ -391,6 +391,8 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
391
391
|
export interface InitOutput {
|
|
392
392
|
readonly memory: WebAssembly.Memory;
|
|
393
393
|
readonly __wbg_client_free: (a: number, b: number) => void;
|
|
394
|
+
readonly __wbg_ciphertexthandle_free: (a: number, b: number) => void;
|
|
395
|
+
readonly __wbg_parseduserdecryptionrequest_free: (a: number, b: number) => void;
|
|
394
396
|
readonly __wbg_privateenckeymlkem512_free: (a: number, b: number) => void;
|
|
395
397
|
readonly __wbg_publicenckeymlkem512_free: (a: number, b: number) => void;
|
|
396
398
|
readonly __wbg_serveridaddr_free: (a: number, b: number) => void;
|
|
@@ -415,8 +417,6 @@ export interface InitOutput {
|
|
|
415
417
|
readonly u8vec_to_ml_kem_pke_sk: (a: number, b: number) => [number, number, number];
|
|
416
418
|
readonly u8vec_to_private_sig_key: (a: number, b: number) => [number, number, number];
|
|
417
419
|
readonly u8vec_to_public_sig_key: (a: number, b: number) => [number, number, number];
|
|
418
|
-
readonly __wbg_ciphertexthandle_free: (a: number, b: number) => void;
|
|
419
|
-
readonly __wbg_parseduserdecryptionrequest_free: (a: number, b: number) => void;
|
|
420
420
|
readonly __wbg_privatesigkey_free: (a: number, b: number) => void;
|
|
421
421
|
readonly __wbg_publicsigkey_free: (a: number, b: number) => void;
|
|
422
422
|
readonly __wbg_eip712domainmsg_free: (a: number, b: number) => void;
|
|
@@ -425,13 +425,11 @@ export interface InitOutput {
|
|
|
425
425
|
readonly __wbg_get_eip712domainmsg_salt: (a: number) => [number, number];
|
|
426
426
|
readonly __wbg_get_eip712domainmsg_verifying_contract: (a: number) => [number, number];
|
|
427
427
|
readonly __wbg_get_eip712domainmsg_version: (a: number) => [number, number];
|
|
428
|
-
readonly __wbg_get_requestid_request_id: (a: number) => [number, number];
|
|
429
428
|
readonly __wbg_get_typedciphertext_ciphertext: (a: number) => [number, number];
|
|
430
429
|
readonly __wbg_get_typedciphertext_ciphertext_format: (a: number) => number;
|
|
431
430
|
readonly __wbg_get_typedciphertext_external_handle: (a: number) => [number, number];
|
|
432
431
|
readonly __wbg_get_typedciphertext_fhe_type: (a: number) => number;
|
|
433
432
|
readonly __wbg_get_typedplaintext_fhe_type: (a: number) => number;
|
|
434
|
-
readonly __wbg_get_userdecryptionrequest_client_address: (a: number) => [number, number];
|
|
435
433
|
readonly __wbg_get_userdecryptionrequest_context_id: (a: number) => number;
|
|
436
434
|
readonly __wbg_get_userdecryptionrequest_domain: (a: number) => number;
|
|
437
435
|
readonly __wbg_get_userdecryptionrequest_epoch_id: (a: number) => number;
|
|
@@ -468,6 +466,8 @@ export interface InitOutput {
|
|
|
468
466
|
readonly __wbg_userdecryptionrequest_free: (a: number, b: number) => void;
|
|
469
467
|
readonly __wbg_userdecryptionresponse_free: (a: number, b: number) => void;
|
|
470
468
|
readonly __wbg_userdecryptionresponsepayload_free: (a: number, b: number) => void;
|
|
469
|
+
readonly __wbg_get_requestid_request_id: (a: number) => [number, number];
|
|
470
|
+
readonly __wbg_get_userdecryptionrequest_client_address: (a: number) => [number, number];
|
|
471
471
|
readonly __wbg_set_typedsigncryptedciphertext_fhe_type: (a: number, b: number) => void;
|
|
472
472
|
readonly __wbg_set_typedsigncryptedciphertext_packing_factor: (a: number, b: number) => void;
|
|
473
473
|
readonly __wbg_set_requestid_request_id: (a: number, b: number, c: number) => void;
|
|
@@ -501,8 +501,8 @@ export interface InitOutput {
|
|
|
501
501
|
readonly __externref_table_alloc: () => number;
|
|
502
502
|
readonly __wbindgen_export_4: WebAssembly.Table;
|
|
503
503
|
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
504
|
-
readonly __externref_drop_slice: (a: number, b: number) => void;
|
|
505
504
|
readonly __externref_table_dealloc: (a: number) => void;
|
|
505
|
+
readonly __externref_drop_slice: (a: number, b: number) => void;
|
|
506
506
|
readonly __wbindgen_start: () => void;
|
|
507
507
|
}
|
|
508
508
|
|
package/kms_lib.js
CHANGED
|
@@ -173,28 +173,6 @@ function _assertClass(instance, klass) {
|
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
function getArrayJsValueFromWasm0(ptr, len) {
|
|
177
|
-
ptr = ptr >>> 0;
|
|
178
|
-
const mem = getDataViewMemory0();
|
|
179
|
-
const result = [];
|
|
180
|
-
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
181
|
-
result.push(wasm.__wbindgen_export_4.get(mem.getUint32(i, true)));
|
|
182
|
-
}
|
|
183
|
-
wasm.__externref_drop_slice(ptr, len);
|
|
184
|
-
return result;
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* @param {Client} client
|
|
188
|
-
* @returns {ServerIdAddr[]}
|
|
189
|
-
*/
|
|
190
|
-
export function get_server_addrs(client) {
|
|
191
|
-
_assertClass(client, Client);
|
|
192
|
-
const ret = wasm.get_server_addrs(client.__wbg_ptr);
|
|
193
|
-
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
194
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
195
|
-
return v1;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
176
|
function takeFromExternrefTable0(idx) {
|
|
199
177
|
const value = wasm.__wbindgen_export_4.get(idx);
|
|
200
178
|
wasm.__externref_table_dealloc(idx);
|
|
@@ -221,21 +199,11 @@ export function ml_kem_pke_sk_to_u8vec(sk) {
|
|
|
221
199
|
}
|
|
222
200
|
|
|
223
201
|
/**
|
|
224
|
-
* @
|
|
225
|
-
* @returns {string}
|
|
202
|
+
* @returns {number}
|
|
226
203
|
*/
|
|
227
|
-
export function
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
try {
|
|
231
|
-
_assertClass(client, Client);
|
|
232
|
-
const ret = wasm.get_client_address(client.__wbg_ptr);
|
|
233
|
-
deferred1_0 = ret[0];
|
|
234
|
-
deferred1_1 = ret[1];
|
|
235
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
236
|
-
} finally {
|
|
237
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
238
|
-
}
|
|
204
|
+
export function ml_kem_pke_sk_len() {
|
|
205
|
+
const ret = wasm.ml_kem_pke_sk_len();
|
|
206
|
+
return ret >>> 0;
|
|
239
207
|
}
|
|
240
208
|
|
|
241
209
|
function passArray8ToWasm0(arg, malloc) {
|
|
@@ -246,25 +214,25 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
246
214
|
}
|
|
247
215
|
/**
|
|
248
216
|
* @param {Uint8Array} v
|
|
249
|
-
* @returns {
|
|
217
|
+
* @returns {PublicEncKeyMlKem512}
|
|
250
218
|
*/
|
|
251
|
-
export function
|
|
219
|
+
export function u8vec_to_ml_kem_pke_pk(v) {
|
|
252
220
|
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
253
221
|
const len0 = WASM_VECTOR_LEN;
|
|
254
|
-
const ret = wasm.
|
|
222
|
+
const ret = wasm.u8vec_to_ml_kem_pke_pk(ptr0, len0);
|
|
255
223
|
if (ret[2]) {
|
|
256
224
|
throw takeFromExternrefTable0(ret[1]);
|
|
257
225
|
}
|
|
258
|
-
return
|
|
226
|
+
return PublicEncKeyMlKem512.__wrap(ret[0]);
|
|
259
227
|
}
|
|
260
228
|
|
|
261
229
|
/**
|
|
262
|
-
* @param {
|
|
230
|
+
* @param {PublicEncKeyMlKem512} pk
|
|
263
231
|
* @returns {Uint8Array}
|
|
264
232
|
*/
|
|
265
|
-
export function
|
|
266
|
-
_assertClass(
|
|
267
|
-
const ret = wasm.
|
|
233
|
+
export function ml_kem_pke_pk_to_u8vec(pk) {
|
|
234
|
+
_assertClass(pk, PublicEncKeyMlKem512);
|
|
235
|
+
const ret = wasm.ml_kem_pke_pk_to_u8vec(pk.__wbg_ptr);
|
|
268
236
|
if (ret[3]) {
|
|
269
237
|
throw takeFromExternrefTable0(ret[2]);
|
|
270
238
|
}
|
|
@@ -273,18 +241,106 @@ export function private_sig_key_to_u8vec(sk) {
|
|
|
273
241
|
return v1;
|
|
274
242
|
}
|
|
275
243
|
|
|
244
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
245
|
+
ptr = ptr >>> 0;
|
|
246
|
+
const mem = getDataViewMemory0();
|
|
247
|
+
const result = [];
|
|
248
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
249
|
+
result.push(wasm.__wbindgen_export_4.get(mem.getUint32(i, true)));
|
|
250
|
+
}
|
|
251
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
252
|
+
return result;
|
|
253
|
+
}
|
|
276
254
|
/**
|
|
277
|
-
*
|
|
278
|
-
*
|
|
255
|
+
* Process the user_decryption response from JavaScript objects.
|
|
256
|
+
* The returned result is a byte array representing a plaintext of any length,
|
|
257
|
+
* postprocessing is returned to turn it into an integer.
|
|
258
|
+
*
|
|
259
|
+
* * `client` - client that wants to perform user_decryption.
|
|
260
|
+
*
|
|
261
|
+
* * `request` - the initial user_decryption request JS object.
|
|
262
|
+
* It can be set to null if `verify` is false.
|
|
263
|
+
* Otherwise the caller needs to give the following JS object.
|
|
264
|
+
* Note that `client_address` and `eip712_verifying_contract` follow EIP-55.
|
|
265
|
+
* The signature field is not needed.
|
|
266
|
+
* ```
|
|
267
|
+
* {
|
|
268
|
+
* signature: undefined,
|
|
269
|
+
* client_address: '0x17853A630aAe15AED549B2B874de08B73C0F59c5',
|
|
270
|
+
* enc_key: '2000000000000000df2fcacb774f03187f3802a27259f45c06d33cefa68d9c53426b15ad531aa822',
|
|
271
|
+
* ciphertext_handles: [ '0748b542afe2353c86cb707e3d21044b0be1fd18efc7cbaa6a415af055bfb358' ]
|
|
272
|
+
* eip712_verifying_contract: '0x66f9664f97F2b50F62D13eA064982f936dE76657'
|
|
273
|
+
* }
|
|
274
|
+
* ```
|
|
275
|
+
*
|
|
276
|
+
* * `eip712_domain` - the EIP-712 domain JS object.
|
|
277
|
+
* It can be set to null if `verify` is false.
|
|
278
|
+
* Otherwise the caller needs to give the following JS object.
|
|
279
|
+
* Note that `salt` is optional and `verifying_contract` follows EIP-55,
|
|
280
|
+
* additionally, `chain_id` is an array of u8.
|
|
281
|
+
* ```
|
|
282
|
+
* {
|
|
283
|
+
* name: 'Authorization token',
|
|
284
|
+
* version: '1',
|
|
285
|
+
* chain_id: [
|
|
286
|
+
* 70, 31, 0, 0, 0, 0, 0, 0, 0,
|
|
287
|
+
* 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
288
|
+
* 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
289
|
+
* 0, 0, 0, 0, 0
|
|
290
|
+
* ],
|
|
291
|
+
* verifying_contract: '0x66f9664f97F2b50F62D13eA064982f936dE76657',
|
|
292
|
+
* salt: []
|
|
293
|
+
* }
|
|
294
|
+
* ```
|
|
295
|
+
*
|
|
296
|
+
* * `agg_resp` - the response JS object from the gateway.
|
|
297
|
+
* It has two fields like so, both are hex encoded byte arrays.
|
|
298
|
+
* ```
|
|
299
|
+
* [
|
|
300
|
+
* {
|
|
301
|
+
* signature: '69e7e040cab157aa819015b321c012dccb1545ffefd325b359b492653f0347517e28e66c572cdc299e259024329859ff9fcb0096e1ce072af0b6e1ca1fe25ec6',
|
|
302
|
+
* payload: '0100000029...',
|
|
303
|
+
* extra_data: '01234...',
|
|
304
|
+
* }
|
|
305
|
+
* ]
|
|
306
|
+
* ```
|
|
307
|
+
*
|
|
308
|
+
* * `enc_pk` - The ephemeral public key.
|
|
309
|
+
*
|
|
310
|
+
* * `enc_sk` - The ephemeral secret key.
|
|
311
|
+
*
|
|
312
|
+
* * `verify` - Whether to perform signature verification for the response.
|
|
313
|
+
* It is insecure if `verify = false`!
|
|
314
|
+
* @param {Client} client
|
|
315
|
+
* @param {any} request
|
|
316
|
+
* @param {any} eip712_domain
|
|
317
|
+
* @param {any} agg_resp
|
|
318
|
+
* @param {PublicEncKeyMlKem512} enc_pk
|
|
319
|
+
* @param {PrivateEncKeyMlKem512} enc_sk
|
|
320
|
+
* @param {boolean} verify
|
|
321
|
+
* @returns {TypedPlaintext[]}
|
|
279
322
|
*/
|
|
280
|
-
export function
|
|
281
|
-
_assertClass(
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
wasm.
|
|
323
|
+
export function process_user_decryption_resp_from_js(client, request, eip712_domain, agg_resp, enc_pk, enc_sk, verify) {
|
|
324
|
+
_assertClass(client, Client);
|
|
325
|
+
_assertClass(enc_pk, PublicEncKeyMlKem512);
|
|
326
|
+
_assertClass(enc_sk, PrivateEncKeyMlKem512);
|
|
327
|
+
const ret = wasm.process_user_decryption_resp_from_js(client.__wbg_ptr, request, eip712_domain, agg_resp, enc_pk.__wbg_ptr, enc_sk.__wbg_ptr, verify);
|
|
328
|
+
if (ret[3]) {
|
|
329
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
330
|
+
}
|
|
331
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
332
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
285
333
|
return v1;
|
|
286
334
|
}
|
|
287
335
|
|
|
336
|
+
/**
|
|
337
|
+
* @returns {number}
|
|
338
|
+
*/
|
|
339
|
+
export function ml_kem_pke_pk_len() {
|
|
340
|
+
const ret = wasm.ml_kem_pke_pk_len();
|
|
341
|
+
return ret >>> 0;
|
|
342
|
+
}
|
|
343
|
+
|
|
288
344
|
/**
|
|
289
345
|
* This function is *not* used by relayer-sdk because the decryption
|
|
290
346
|
* is handled by [process_user_decryption_resp].
|
|
@@ -304,19 +360,13 @@ export function ml_kem_pke_decrypt(ct, my_sk) {
|
|
|
304
360
|
}
|
|
305
361
|
|
|
306
362
|
/**
|
|
307
|
-
* @
|
|
308
|
-
|
|
309
|
-
export function ml_kem_pke_sk_len() {
|
|
310
|
-
const ret = wasm.ml_kem_pke_sk_len();
|
|
311
|
-
return ret >>> 0;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* @returns {number}
|
|
363
|
+
* @param {PrivateEncKeyMlKem512} sk
|
|
364
|
+
* @returns {PublicEncKeyMlKem512}
|
|
316
365
|
*/
|
|
317
|
-
export function
|
|
318
|
-
|
|
319
|
-
|
|
366
|
+
export function ml_kem_pke_get_pk(sk) {
|
|
367
|
+
_assertClass(sk, PrivateEncKeyMlKem512);
|
|
368
|
+
const ret = wasm.ml_kem_pke_get_pk(sk.__wbg_ptr);
|
|
369
|
+
return PublicEncKeyMlKem512.__wrap(ret);
|
|
320
370
|
}
|
|
321
371
|
|
|
322
372
|
/**
|
|
@@ -336,76 +386,6 @@ export function ml_kem_pke_encrypt(msg, their_pk) {
|
|
|
336
386
|
return v2;
|
|
337
387
|
}
|
|
338
388
|
|
|
339
|
-
/**
|
|
340
|
-
* Create a new [ServerIdAddr] structure that holds an ID and an address
|
|
341
|
-
* which must be a valid EIP-55 address, notably prefixed with "0x".
|
|
342
|
-
* @param {number} id
|
|
343
|
-
* @param {string} addr
|
|
344
|
-
* @returns {ServerIdAddr}
|
|
345
|
-
*/
|
|
346
|
-
export function new_server_id_addr(id, addr) {
|
|
347
|
-
const ptr0 = passStringToWasm0(addr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
348
|
-
const len0 = WASM_VECTOR_LEN;
|
|
349
|
-
const ret = wasm.new_server_id_addr(id, ptr0, len0);
|
|
350
|
-
if (ret[2]) {
|
|
351
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
352
|
-
}
|
|
353
|
-
return ServerIdAddr.__wrap(ret[0]);
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
/**
|
|
357
|
-
* @param {Uint8Array} v
|
|
358
|
-
* @returns {PrivateEncKeyMlKem512}
|
|
359
|
-
*/
|
|
360
|
-
export function u8vec_to_ml_kem_pke_sk(v) {
|
|
361
|
-
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
362
|
-
const len0 = WASM_VECTOR_LEN;
|
|
363
|
-
const ret = wasm.u8vec_to_ml_kem_pke_sk(ptr0, len0);
|
|
364
|
-
if (ret[2]) {
|
|
365
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
366
|
-
}
|
|
367
|
-
return PrivateEncKeyMlKem512.__wrap(ret[0]);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* @param {PrivateEncKeyMlKem512} sk
|
|
372
|
-
* @returns {PublicEncKeyMlKem512}
|
|
373
|
-
*/
|
|
374
|
-
export function ml_kem_pke_get_pk(sk) {
|
|
375
|
-
_assertClass(sk, PrivateEncKeyMlKem512);
|
|
376
|
-
const ret = wasm.ml_kem_pke_get_pk(sk.__wbg_ptr);
|
|
377
|
-
return PublicEncKeyMlKem512.__wrap(ret);
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* @param {PublicEncKeyMlKem512} pk
|
|
382
|
-
* @returns {Uint8Array}
|
|
383
|
-
*/
|
|
384
|
-
export function ml_kem_pke_pk_to_u8vec(pk) {
|
|
385
|
-
_assertClass(pk, PublicEncKeyMlKem512);
|
|
386
|
-
const ret = wasm.ml_kem_pke_pk_to_u8vec(pk.__wbg_ptr);
|
|
387
|
-
if (ret[3]) {
|
|
388
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
389
|
-
}
|
|
390
|
-
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
391
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
392
|
-
return v1;
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* @param {Uint8Array} v
|
|
397
|
-
* @returns {PrivateSigKey}
|
|
398
|
-
*/
|
|
399
|
-
export function u8vec_to_private_sig_key(v) {
|
|
400
|
-
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
401
|
-
const len0 = WASM_VECTOR_LEN;
|
|
402
|
-
const ret = wasm.u8vec_to_private_sig_key(ptr0, len0);
|
|
403
|
-
if (ret[2]) {
|
|
404
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
405
|
-
}
|
|
406
|
-
return PrivateSigKey.__wrap(ret[0]);
|
|
407
|
-
}
|
|
408
|
-
|
|
409
389
|
function passArrayJsValueToWasm0(array, malloc) {
|
|
410
390
|
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
411
391
|
for (let i = 0; i < array.length; i++) {
|
|
@@ -482,109 +462,25 @@ export function get_client_secret_key(client) {
|
|
|
482
462
|
}
|
|
483
463
|
|
|
484
464
|
/**
|
|
485
|
-
* @returns {PrivateEncKeyMlKem512}
|
|
486
|
-
*/
|
|
487
|
-
export function ml_kem_pke_keygen() {
|
|
488
|
-
const ret = wasm.ml_kem_pke_keygen();
|
|
489
|
-
return PrivateEncKeyMlKem512.__wrap(ret);
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
/**
|
|
493
|
-
* @param {Uint8Array} v
|
|
494
|
-
* @returns {PublicEncKeyMlKem512}
|
|
495
|
-
*/
|
|
496
|
-
export function u8vec_to_ml_kem_pke_pk(v) {
|
|
497
|
-
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
498
|
-
const len0 = WASM_VECTOR_LEN;
|
|
499
|
-
const ret = wasm.u8vec_to_ml_kem_pke_pk(ptr0, len0);
|
|
500
|
-
if (ret[2]) {
|
|
501
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
502
|
-
}
|
|
503
|
-
return PublicEncKeyMlKem512.__wrap(ret[0]);
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
/**
|
|
507
|
-
* Process the user_decryption response from JavaScript objects.
|
|
508
|
-
* The returned result is a byte array representing a plaintext of any length,
|
|
509
|
-
* postprocessing is returned to turn it into an integer.
|
|
510
|
-
*
|
|
511
|
-
* * `client` - client that wants to perform user_decryption.
|
|
512
|
-
*
|
|
513
|
-
* * `request` - the initial user_decryption request JS object.
|
|
514
|
-
* It can be set to null if `verify` is false.
|
|
515
|
-
* Otherwise the caller needs to give the following JS object.
|
|
516
|
-
* Note that `client_address` and `eip712_verifying_contract` follow EIP-55.
|
|
517
|
-
* The signature field is not needed.
|
|
518
|
-
* ```
|
|
519
|
-
* {
|
|
520
|
-
* signature: undefined,
|
|
521
|
-
* client_address: '0x17853A630aAe15AED549B2B874de08B73C0F59c5',
|
|
522
|
-
* enc_key: '2000000000000000df2fcacb774f03187f3802a27259f45c06d33cefa68d9c53426b15ad531aa822',
|
|
523
|
-
* ciphertext_handles: [ '0748b542afe2353c86cb707e3d21044b0be1fd18efc7cbaa6a415af055bfb358' ]
|
|
524
|
-
* eip712_verifying_contract: '0x66f9664f97F2b50F62D13eA064982f936dE76657'
|
|
525
|
-
* }
|
|
526
|
-
* ```
|
|
527
|
-
*
|
|
528
|
-
* * `eip712_domain` - the EIP-712 domain JS object.
|
|
529
|
-
* It can be set to null if `verify` is false.
|
|
530
|
-
* Otherwise the caller needs to give the following JS object.
|
|
531
|
-
* Note that `salt` is optional and `verifying_contract` follows EIP-55,
|
|
532
|
-
* additionally, `chain_id` is an array of u8.
|
|
533
|
-
* ```
|
|
534
|
-
* {
|
|
535
|
-
* name: 'Authorization token',
|
|
536
|
-
* version: '1',
|
|
537
|
-
* chain_id: [
|
|
538
|
-
* 70, 31, 0, 0, 0, 0, 0, 0, 0,
|
|
539
|
-
* 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
540
|
-
* 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
541
|
-
* 0, 0, 0, 0, 0
|
|
542
|
-
* ],
|
|
543
|
-
* verifying_contract: '0x66f9664f97F2b50F62D13eA064982f936dE76657',
|
|
544
|
-
* salt: []
|
|
545
|
-
* }
|
|
546
|
-
* ```
|
|
547
|
-
*
|
|
548
|
-
* * `agg_resp` - the response JS object from the gateway.
|
|
549
|
-
* It has two fields like so, both are hex encoded byte arrays.
|
|
550
|
-
* ```
|
|
551
|
-
* [
|
|
552
|
-
* {
|
|
553
|
-
* signature: '69e7e040cab157aa819015b321c012dccb1545ffefd325b359b492653f0347517e28e66c572cdc299e259024329859ff9fcb0096e1ce072af0b6e1ca1fe25ec6',
|
|
554
|
-
* payload: '0100000029...',
|
|
555
|
-
* extra_data: '01234...',
|
|
556
|
-
* }
|
|
557
|
-
* ]
|
|
558
|
-
* ```
|
|
559
|
-
*
|
|
560
|
-
* * `enc_pk` - The ephemeral public key.
|
|
561
|
-
*
|
|
562
|
-
* * `enc_sk` - The ephemeral secret key.
|
|
563
|
-
*
|
|
564
|
-
* * `verify` - Whether to perform signature verification for the response.
|
|
565
|
-
* It is insecure if `verify = false`!
|
|
566
465
|
* @param {Client} client
|
|
567
|
-
* @
|
|
568
|
-
* @param {any} eip712_domain
|
|
569
|
-
* @param {any} agg_resp
|
|
570
|
-
* @param {PublicEncKeyMlKem512} enc_pk
|
|
571
|
-
* @param {PrivateEncKeyMlKem512} enc_sk
|
|
572
|
-
* @param {boolean} verify
|
|
573
|
-
* @returns {TypedPlaintext[]}
|
|
466
|
+
* @returns {ServerIdAddr[]}
|
|
574
467
|
*/
|
|
575
|
-
export function
|
|
468
|
+
export function get_server_addrs(client) {
|
|
576
469
|
_assertClass(client, Client);
|
|
577
|
-
|
|
578
|
-
_assertClass(enc_sk, PrivateEncKeyMlKem512);
|
|
579
|
-
const ret = wasm.process_user_decryption_resp_from_js(client.__wbg_ptr, request, eip712_domain, agg_resp, enc_pk.__wbg_ptr, enc_sk.__wbg_ptr, verify);
|
|
580
|
-
if (ret[3]) {
|
|
581
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
582
|
-
}
|
|
470
|
+
const ret = wasm.get_server_addrs(client.__wbg_ptr);
|
|
583
471
|
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
584
472
|
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
585
473
|
return v1;
|
|
586
474
|
}
|
|
587
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
|
+
|
|
588
484
|
/**
|
|
589
485
|
* Instantiate a new client.
|
|
590
486
|
*
|
|
@@ -615,6 +511,110 @@ export function new_client(server_addrs, client_address_hex, fhe_parameter) {
|
|
|
615
511
|
return Client.__wrap(ret[0]);
|
|
616
512
|
}
|
|
617
513
|
|
|
514
|
+
/**
|
|
515
|
+
* @param {PublicSigKey} pk
|
|
516
|
+
* @returns {Uint8Array}
|
|
517
|
+
*/
|
|
518
|
+
export function public_sig_key_to_u8vec(pk) {
|
|
519
|
+
_assertClass(pk, PublicSigKey);
|
|
520
|
+
const ret = wasm.public_sig_key_to_u8vec(pk.__wbg_ptr);
|
|
521
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
522
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
523
|
+
return v1;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* @param {PrivateSigKey} sk
|
|
528
|
+
* @returns {Uint8Array}
|
|
529
|
+
*/
|
|
530
|
+
export function private_sig_key_to_u8vec(sk) {
|
|
531
|
+
_assertClass(sk, PrivateSigKey);
|
|
532
|
+
const ret = wasm.private_sig_key_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
|
+
* @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
618
|
const CiphertextHandleFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
619
619
|
? { register: () => {}, unregister: () => {} }
|
|
620
620
|
: new FinalizationRegistry(ptr => wasm.__wbg_ciphertexthandle_free(ptr >>> 0, 1));
|
package/kms_lib_bg.wasm
CHANGED
|
Binary file
|