tkms 0.12.5 → 0.12.7
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 +56 -56
- package/kms_lib.js +204 -204
- package/kms_lib_bg.wasm +0 -0
- package/package.json +1 -1
package/kms_lib.d.ts
CHANGED
|
@@ -1,60 +1,5 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
export function get_server_addrs(client: Client): ServerIdAddr[];
|
|
4
|
-
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
|
-
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
|
-
export function u8vec_to_ml_kem_pke_pk(v: Uint8Array): PublicEncKeyMlKem512;
|
|
58
3
|
/**
|
|
59
4
|
* Process the user_decryption response from JavaScript objects.
|
|
60
5
|
* The returned result is a byte array representing a plaintext of any length,
|
|
@@ -117,6 +62,60 @@ export function u8vec_to_ml_kem_pke_pk(v: Uint8Array): PublicEncKeyMlKem512;
|
|
|
117
62
|
* It is insecure if `verify = false`!
|
|
118
63
|
*/
|
|
119
64
|
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[];
|
|
65
|
+
export function ml_kem_pke_keygen(): PrivateEncKeyMlKem512;
|
|
66
|
+
/**
|
|
67
|
+
* Create a new [ServerIdAddr] structure that holds an ID and an address
|
|
68
|
+
* which must be a valid EIP-55 address, notably prefixed with "0x".
|
|
69
|
+
*/
|
|
70
|
+
export function new_server_id_addr(id: number, addr: string): ServerIdAddr;
|
|
71
|
+
export function private_sig_key_to_u8vec(sk: PrivateSigKey): Uint8Array;
|
|
72
|
+
export function ml_kem_pke_get_pk(sk: PrivateEncKeyMlKem512): PublicEncKeyMlKem512;
|
|
73
|
+
export function u8vec_to_ml_kem_pke_pk(v: Uint8Array): PublicEncKeyMlKem512;
|
|
74
|
+
export function ml_kem_pke_sk_len(): number;
|
|
75
|
+
/**
|
|
76
|
+
* This function is *not* used by relayer-sdk because the decryption
|
|
77
|
+
* is handled by [process_user_decryption_resp].
|
|
78
|
+
* It's just here for completeness and tests.
|
|
79
|
+
*/
|
|
80
|
+
export function ml_kem_pke_decrypt(ct: Uint8Array, my_sk: PrivateEncKeyMlKem512): Uint8Array;
|
|
81
|
+
export function u8vec_to_public_sig_key(v: Uint8Array): PublicSigKey;
|
|
82
|
+
export function ml_kem_pke_sk_to_u8vec(sk: PrivateEncKeyMlKem512): Uint8Array;
|
|
83
|
+
export function ml_kem_pke_pk_to_u8vec(pk: PublicEncKeyMlKem512): Uint8Array;
|
|
84
|
+
export function u8vec_to_ml_kem_pke_sk(v: Uint8Array): PrivateEncKeyMlKem512;
|
|
85
|
+
export function ml_kem_pke_pk_len(): number;
|
|
86
|
+
/**
|
|
87
|
+
* This function is *not* used by relayer-sdk because the encryption
|
|
88
|
+
* happens on the KMS side. It's just here for completeness and tests.
|
|
89
|
+
*/
|
|
90
|
+
export function ml_kem_pke_encrypt(msg: Uint8Array, their_pk: PublicEncKeyMlKem512): Uint8Array;
|
|
91
|
+
/**
|
|
92
|
+
* Process the user_decryption response from Rust objects.
|
|
93
|
+
* Consider using [process_user_decryption_resp_from_js]
|
|
94
|
+
* when using the JS API.
|
|
95
|
+
* The result is a byte array representing a plaintext of any length.
|
|
96
|
+
*
|
|
97
|
+
* * `client` - client that wants to perform user_decryption.
|
|
98
|
+
*
|
|
99
|
+
* * `request` - the initial user_decryption request.
|
|
100
|
+
* Must be given if `verify` is true.
|
|
101
|
+
*
|
|
102
|
+
* * `eip712_domain` - the EIP-712 domain.
|
|
103
|
+
* Must be given if `verify` is true.
|
|
104
|
+
*
|
|
105
|
+
* * `agg_resp` - the vector of user_decryption responses.
|
|
106
|
+
*
|
|
107
|
+
* * `enc_pk` - The ephemeral public key.
|
|
108
|
+
*
|
|
109
|
+
* * `enc_sk` - The ephemeral secret key.
|
|
110
|
+
*
|
|
111
|
+
* * `verify` - Whether to perform signature verification for the response.
|
|
112
|
+
* It is insecure if `verify = false`!
|
|
113
|
+
*/
|
|
114
|
+
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[];
|
|
115
|
+
export function public_sig_key_to_u8vec(pk: PublicSigKey): Uint8Array;
|
|
116
|
+
export function get_server_addrs(client: Client): ServerIdAddr[];
|
|
117
|
+
export function u8vec_to_private_sig_key(v: Uint8Array): PrivateSigKey;
|
|
118
|
+
export function get_client_address(client: Client): string;
|
|
120
119
|
/**
|
|
121
120
|
* Instantiate a new client.
|
|
122
121
|
*
|
|
@@ -130,6 +129,7 @@ export function process_user_decryption_resp_from_js(client: Client, request: an
|
|
|
130
129
|
* The "default" parameter choice is selected if no matching string is found.
|
|
131
130
|
*/
|
|
132
131
|
export function new_client(server_addrs: ServerIdAddr[], client_address_hex: string, fhe_parameter: string): Client;
|
|
132
|
+
export function get_client_secret_key(client: Client): PrivateSigKey | undefined;
|
|
133
133
|
export class CiphertextHandle {
|
|
134
134
|
private constructor();
|
|
135
135
|
free(): 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,6 +173,12 @@ function _assertClass(instance, klass) {
|
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
+
function takeFromExternrefTable0(idx) {
|
|
177
|
+
const value = wasm.__wbindgen_export_4.get(idx);
|
|
178
|
+
wasm.__externref_table_dealloc(idx);
|
|
179
|
+
return value;
|
|
180
|
+
}
|
|
181
|
+
|
|
176
182
|
function getArrayJsValueFromWasm0(ptr, len) {
|
|
177
183
|
ptr = ptr >>> 0;
|
|
178
184
|
const mem = getDataViewMemory0();
|
|
@@ -184,21 +190,110 @@ function getArrayJsValueFromWasm0(ptr, len) {
|
|
|
184
190
|
return result;
|
|
185
191
|
}
|
|
186
192
|
/**
|
|
193
|
+
* Process the user_decryption response from JavaScript objects.
|
|
194
|
+
* The returned result is a byte array representing a plaintext of any length,
|
|
195
|
+
* postprocessing is returned to turn it into an integer.
|
|
196
|
+
*
|
|
197
|
+
* * `client` - client that wants to perform user_decryption.
|
|
198
|
+
*
|
|
199
|
+
* * `request` - the initial user_decryption request JS object.
|
|
200
|
+
* It can be set to null if `verify` is false.
|
|
201
|
+
* Otherwise the caller needs to give the following JS object.
|
|
202
|
+
* Note that `client_address` and `eip712_verifying_contract` follow EIP-55.
|
|
203
|
+
* The signature field is not needed.
|
|
204
|
+
* ```
|
|
205
|
+
* {
|
|
206
|
+
* signature: undefined,
|
|
207
|
+
* client_address: '0x17853A630aAe15AED549B2B874de08B73C0F59c5',
|
|
208
|
+
* enc_key: '2000000000000000df2fcacb774f03187f3802a27259f45c06d33cefa68d9c53426b15ad531aa822',
|
|
209
|
+
* ciphertext_handles: [ '0748b542afe2353c86cb707e3d21044b0be1fd18efc7cbaa6a415af055bfb358' ]
|
|
210
|
+
* eip712_verifying_contract: '0x66f9664f97F2b50F62D13eA064982f936dE76657'
|
|
211
|
+
* }
|
|
212
|
+
* ```
|
|
213
|
+
*
|
|
214
|
+
* * `eip712_domain` - the EIP-712 domain JS object.
|
|
215
|
+
* It can be set to null if `verify` is false.
|
|
216
|
+
* Otherwise the caller needs to give the following JS object.
|
|
217
|
+
* Note that `salt` is optional and `verifying_contract` follows EIP-55,
|
|
218
|
+
* additionally, `chain_id` is an array of u8.
|
|
219
|
+
* ```
|
|
220
|
+
* {
|
|
221
|
+
* name: 'Authorization token',
|
|
222
|
+
* version: '1',
|
|
223
|
+
* chain_id: [
|
|
224
|
+
* 70, 31, 0, 0, 0, 0, 0, 0, 0,
|
|
225
|
+
* 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
226
|
+
* 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
227
|
+
* 0, 0, 0, 0, 0
|
|
228
|
+
* ],
|
|
229
|
+
* verifying_contract: '0x66f9664f97F2b50F62D13eA064982f936dE76657',
|
|
230
|
+
* salt: []
|
|
231
|
+
* }
|
|
232
|
+
* ```
|
|
233
|
+
*
|
|
234
|
+
* * `agg_resp` - the response JS object from the gateway.
|
|
235
|
+
* It has two fields like so, both are hex encoded byte arrays.
|
|
236
|
+
* ```
|
|
237
|
+
* [
|
|
238
|
+
* {
|
|
239
|
+
* signature: '69e7e040cab157aa819015b321c012dccb1545ffefd325b359b492653f0347517e28e66c572cdc299e259024329859ff9fcb0096e1ce072af0b6e1ca1fe25ec6',
|
|
240
|
+
* payload: '0100000029...',
|
|
241
|
+
* extra_data: '01234...',
|
|
242
|
+
* }
|
|
243
|
+
* ]
|
|
244
|
+
* ```
|
|
245
|
+
*
|
|
246
|
+
* * `enc_pk` - The ephemeral public key.
|
|
247
|
+
*
|
|
248
|
+
* * `enc_sk` - The ephemeral secret key.
|
|
249
|
+
*
|
|
250
|
+
* * `verify` - Whether to perform signature verification for the response.
|
|
251
|
+
* It is insecure if `verify = false`!
|
|
187
252
|
* @param {Client} client
|
|
188
|
-
* @
|
|
253
|
+
* @param {any} request
|
|
254
|
+
* @param {any} eip712_domain
|
|
255
|
+
* @param {any} agg_resp
|
|
256
|
+
* @param {PublicEncKeyMlKem512} enc_pk
|
|
257
|
+
* @param {PrivateEncKeyMlKem512} enc_sk
|
|
258
|
+
* @param {boolean} verify
|
|
259
|
+
* @returns {TypedPlaintext[]}
|
|
189
260
|
*/
|
|
190
|
-
export function
|
|
261
|
+
export function process_user_decryption_resp_from_js(client, request, eip712_domain, agg_resp, enc_pk, enc_sk, verify) {
|
|
191
262
|
_assertClass(client, Client);
|
|
192
|
-
|
|
263
|
+
_assertClass(enc_pk, PublicEncKeyMlKem512);
|
|
264
|
+
_assertClass(enc_sk, PrivateEncKeyMlKem512);
|
|
265
|
+
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);
|
|
266
|
+
if (ret[3]) {
|
|
267
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
268
|
+
}
|
|
193
269
|
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
194
270
|
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
195
271
|
return v1;
|
|
196
272
|
}
|
|
197
273
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
274
|
+
/**
|
|
275
|
+
* @returns {PrivateEncKeyMlKem512}
|
|
276
|
+
*/
|
|
277
|
+
export function ml_kem_pke_keygen() {
|
|
278
|
+
const ret = wasm.ml_kem_pke_keygen();
|
|
279
|
+
return PrivateEncKeyMlKem512.__wrap(ret);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Create a new [ServerIdAddr] structure that holds an ID and an address
|
|
284
|
+
* which must be a valid EIP-55 address, notably prefixed with "0x".
|
|
285
|
+
* @param {number} id
|
|
286
|
+
* @param {string} addr
|
|
287
|
+
* @returns {ServerIdAddr}
|
|
288
|
+
*/
|
|
289
|
+
export function new_server_id_addr(id, addr) {
|
|
290
|
+
const ptr0 = passStringToWasm0(addr, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
291
|
+
const len0 = WASM_VECTOR_LEN;
|
|
292
|
+
const ret = wasm.new_server_id_addr(id, ptr0, len0);
|
|
293
|
+
if (ret[2]) {
|
|
294
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
295
|
+
}
|
|
296
|
+
return ServerIdAddr.__wrap(ret[0]);
|
|
202
297
|
}
|
|
203
298
|
|
|
204
299
|
function getArrayU8FromWasm0(ptr, len) {
|
|
@@ -206,12 +301,12 @@ function getArrayU8FromWasm0(ptr, len) {
|
|
|
206
301
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
207
302
|
}
|
|
208
303
|
/**
|
|
209
|
-
* @param {
|
|
304
|
+
* @param {PrivateSigKey} sk
|
|
210
305
|
* @returns {Uint8Array}
|
|
211
306
|
*/
|
|
212
|
-
export function
|
|
213
|
-
_assertClass(sk,
|
|
214
|
-
const ret = wasm.
|
|
307
|
+
export function private_sig_key_to_u8vec(sk) {
|
|
308
|
+
_assertClass(sk, PrivateSigKey);
|
|
309
|
+
const ret = wasm.private_sig_key_to_u8vec(sk.__wbg_ptr);
|
|
215
310
|
if (ret[3]) {
|
|
216
311
|
throw takeFromExternrefTable0(ret[2]);
|
|
217
312
|
}
|
|
@@ -221,21 +316,13 @@ export function ml_kem_pke_sk_to_u8vec(sk) {
|
|
|
221
316
|
}
|
|
222
317
|
|
|
223
318
|
/**
|
|
224
|
-
* @param {
|
|
225
|
-
* @returns {
|
|
319
|
+
* @param {PrivateEncKeyMlKem512} sk
|
|
320
|
+
* @returns {PublicEncKeyMlKem512}
|
|
226
321
|
*/
|
|
227
|
-
export function
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
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
|
-
}
|
|
322
|
+
export function ml_kem_pke_get_pk(sk) {
|
|
323
|
+
_assertClass(sk, PrivateEncKeyMlKem512);
|
|
324
|
+
const ret = wasm.ml_kem_pke_get_pk(sk.__wbg_ptr);
|
|
325
|
+
return PublicEncKeyMlKem512.__wrap(ret);
|
|
239
326
|
}
|
|
240
327
|
|
|
241
328
|
function passArray8ToWasm0(arg, malloc) {
|
|
@@ -246,43 +333,24 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
246
333
|
}
|
|
247
334
|
/**
|
|
248
335
|
* @param {Uint8Array} v
|
|
249
|
-
* @returns {
|
|
336
|
+
* @returns {PublicEncKeyMlKem512}
|
|
250
337
|
*/
|
|
251
|
-
export function
|
|
338
|
+
export function u8vec_to_ml_kem_pke_pk(v) {
|
|
252
339
|
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
253
340
|
const len0 = WASM_VECTOR_LEN;
|
|
254
|
-
const ret = wasm.
|
|
341
|
+
const ret = wasm.u8vec_to_ml_kem_pke_pk(ptr0, len0);
|
|
255
342
|
if (ret[2]) {
|
|
256
343
|
throw takeFromExternrefTable0(ret[1]);
|
|
257
344
|
}
|
|
258
|
-
return
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* @param {PrivateSigKey} sk
|
|
263
|
-
* @returns {Uint8Array}
|
|
264
|
-
*/
|
|
265
|
-
export function private_sig_key_to_u8vec(sk) {
|
|
266
|
-
_assertClass(sk, PrivateSigKey);
|
|
267
|
-
const ret = wasm.private_sig_key_to_u8vec(sk.__wbg_ptr);
|
|
268
|
-
if (ret[3]) {
|
|
269
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
270
|
-
}
|
|
271
|
-
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
272
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
273
|
-
return v1;
|
|
345
|
+
return PublicEncKeyMlKem512.__wrap(ret[0]);
|
|
274
346
|
}
|
|
275
347
|
|
|
276
348
|
/**
|
|
277
|
-
* @
|
|
278
|
-
* @returns {Uint8Array}
|
|
349
|
+
* @returns {number}
|
|
279
350
|
*/
|
|
280
|
-
export function
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
284
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
285
|
-
return v1;
|
|
351
|
+
export function ml_kem_pke_sk_len() {
|
|
352
|
+
const ret = wasm.ml_kem_pke_sk_len();
|
|
353
|
+
return ret >>> 0;
|
|
286
354
|
}
|
|
287
355
|
|
|
288
356
|
/**
|
|
@@ -303,78 +371,33 @@ export function ml_kem_pke_decrypt(ct, my_sk) {
|
|
|
303
371
|
return v2;
|
|
304
372
|
}
|
|
305
373
|
|
|
306
|
-
/**
|
|
307
|
-
* @returns {number}
|
|
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}
|
|
316
|
-
*/
|
|
317
|
-
export function ml_kem_pke_pk_len() {
|
|
318
|
-
const ret = wasm.ml_kem_pke_pk_len();
|
|
319
|
-
return ret >>> 0;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* This function is *not* used by relayer-sdk because the encryption
|
|
324
|
-
* happens on the KMS side. It's just here for completeness and tests.
|
|
325
|
-
* @param {Uint8Array} msg
|
|
326
|
-
* @param {PublicEncKeyMlKem512} their_pk
|
|
327
|
-
* @returns {Uint8Array}
|
|
328
|
-
*/
|
|
329
|
-
export function ml_kem_pke_encrypt(msg, their_pk) {
|
|
330
|
-
const ptr0 = passArray8ToWasm0(msg, wasm.__wbindgen_malloc);
|
|
331
|
-
const len0 = WASM_VECTOR_LEN;
|
|
332
|
-
_assertClass(their_pk, PublicEncKeyMlKem512);
|
|
333
|
-
const ret = wasm.ml_kem_pke_encrypt(ptr0, len0, their_pk.__wbg_ptr);
|
|
334
|
-
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
335
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
336
|
-
return v2;
|
|
337
|
-
}
|
|
338
|
-
|
|
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
374
|
/**
|
|
357
375
|
* @param {Uint8Array} v
|
|
358
|
-
* @returns {
|
|
376
|
+
* @returns {PublicSigKey}
|
|
359
377
|
*/
|
|
360
|
-
export function
|
|
378
|
+
export function u8vec_to_public_sig_key(v) {
|
|
361
379
|
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
362
380
|
const len0 = WASM_VECTOR_LEN;
|
|
363
|
-
const ret = wasm.
|
|
381
|
+
const ret = wasm.u8vec_to_public_sig_key(ptr0, len0);
|
|
364
382
|
if (ret[2]) {
|
|
365
383
|
throw takeFromExternrefTable0(ret[1]);
|
|
366
384
|
}
|
|
367
|
-
return
|
|
385
|
+
return PublicSigKey.__wrap(ret[0]);
|
|
368
386
|
}
|
|
369
387
|
|
|
370
388
|
/**
|
|
371
389
|
* @param {PrivateEncKeyMlKem512} sk
|
|
372
|
-
* @returns {
|
|
390
|
+
* @returns {Uint8Array}
|
|
373
391
|
*/
|
|
374
|
-
export function
|
|
392
|
+
export function ml_kem_pke_sk_to_u8vec(sk) {
|
|
375
393
|
_assertClass(sk, PrivateEncKeyMlKem512);
|
|
376
|
-
const ret = wasm.
|
|
377
|
-
|
|
394
|
+
const ret = wasm.ml_kem_pke_sk_to_u8vec(sk.__wbg_ptr);
|
|
395
|
+
if (ret[3]) {
|
|
396
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
397
|
+
}
|
|
398
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
399
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
400
|
+
return v1;
|
|
378
401
|
}
|
|
379
402
|
|
|
380
403
|
/**
|
|
@@ -394,16 +417,41 @@ export function ml_kem_pke_pk_to_u8vec(pk) {
|
|
|
394
417
|
|
|
395
418
|
/**
|
|
396
419
|
* @param {Uint8Array} v
|
|
397
|
-
* @returns {
|
|
420
|
+
* @returns {PrivateEncKeyMlKem512}
|
|
398
421
|
*/
|
|
399
|
-
export function
|
|
422
|
+
export function u8vec_to_ml_kem_pke_sk(v) {
|
|
400
423
|
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
401
424
|
const len0 = WASM_VECTOR_LEN;
|
|
402
|
-
const ret = wasm.
|
|
425
|
+
const ret = wasm.u8vec_to_ml_kem_pke_sk(ptr0, len0);
|
|
403
426
|
if (ret[2]) {
|
|
404
427
|
throw takeFromExternrefTable0(ret[1]);
|
|
405
428
|
}
|
|
406
|
-
return
|
|
429
|
+
return PrivateEncKeyMlKem512.__wrap(ret[0]);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* @returns {number}
|
|
434
|
+
*/
|
|
435
|
+
export function ml_kem_pke_pk_len() {
|
|
436
|
+
const ret = wasm.ml_kem_pke_pk_len();
|
|
437
|
+
return ret >>> 0;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* This function is *not* used by relayer-sdk because the encryption
|
|
442
|
+
* happens on the KMS side. It's just here for completeness and tests.
|
|
443
|
+
* @param {Uint8Array} msg
|
|
444
|
+
* @param {PublicEncKeyMlKem512} their_pk
|
|
445
|
+
* @returns {Uint8Array}
|
|
446
|
+
*/
|
|
447
|
+
export function ml_kem_pke_encrypt(msg, their_pk) {
|
|
448
|
+
const ptr0 = passArray8ToWasm0(msg, wasm.__wbindgen_malloc);
|
|
449
|
+
const len0 = WASM_VECTOR_LEN;
|
|
450
|
+
_assertClass(their_pk, PublicEncKeyMlKem512);
|
|
451
|
+
const ret = wasm.ml_kem_pke_encrypt(ptr0, len0, their_pk.__wbg_ptr);
|
|
452
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
453
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
454
|
+
return v2;
|
|
407
455
|
}
|
|
408
456
|
|
|
409
457
|
function passArrayJsValueToWasm0(array, malloc) {
|
|
@@ -472,117 +520,59 @@ export function process_user_decryption_resp(client, request, eip712_domain, agg
|
|
|
472
520
|
}
|
|
473
521
|
|
|
474
522
|
/**
|
|
475
|
-
* @param {
|
|
476
|
-
* @returns {
|
|
523
|
+
* @param {PublicSigKey} pk
|
|
524
|
+
* @returns {Uint8Array}
|
|
477
525
|
*/
|
|
478
|
-
export function
|
|
479
|
-
_assertClass(
|
|
480
|
-
const ret = wasm.
|
|
481
|
-
|
|
526
|
+
export function public_sig_key_to_u8vec(pk) {
|
|
527
|
+
_assertClass(pk, PublicSigKey);
|
|
528
|
+
const ret = wasm.public_sig_key_to_u8vec(pk.__wbg_ptr);
|
|
529
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
530
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
531
|
+
return v1;
|
|
482
532
|
}
|
|
483
533
|
|
|
484
534
|
/**
|
|
485
|
-
* @
|
|
535
|
+
* @param {Client} client
|
|
536
|
+
* @returns {ServerIdAddr[]}
|
|
486
537
|
*/
|
|
487
|
-
export function
|
|
488
|
-
|
|
489
|
-
|
|
538
|
+
export function get_server_addrs(client) {
|
|
539
|
+
_assertClass(client, Client);
|
|
540
|
+
const ret = wasm.get_server_addrs(client.__wbg_ptr);
|
|
541
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
542
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
543
|
+
return v1;
|
|
490
544
|
}
|
|
491
545
|
|
|
492
546
|
/**
|
|
493
547
|
* @param {Uint8Array} v
|
|
494
|
-
* @returns {
|
|
548
|
+
* @returns {PrivateSigKey}
|
|
495
549
|
*/
|
|
496
|
-
export function
|
|
550
|
+
export function u8vec_to_private_sig_key(v) {
|
|
497
551
|
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
498
552
|
const len0 = WASM_VECTOR_LEN;
|
|
499
|
-
const ret = wasm.
|
|
553
|
+
const ret = wasm.u8vec_to_private_sig_key(ptr0, len0);
|
|
500
554
|
if (ret[2]) {
|
|
501
555
|
throw takeFromExternrefTable0(ret[1]);
|
|
502
556
|
}
|
|
503
|
-
return
|
|
557
|
+
return PrivateSigKey.__wrap(ret[0]);
|
|
504
558
|
}
|
|
505
559
|
|
|
506
560
|
/**
|
|
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
561
|
* @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[]}
|
|
562
|
+
* @returns {string}
|
|
574
563
|
*/
|
|
575
|
-
export function
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
564
|
+
export function get_client_address(client) {
|
|
565
|
+
let deferred1_0;
|
|
566
|
+
let deferred1_1;
|
|
567
|
+
try {
|
|
568
|
+
_assertClass(client, Client);
|
|
569
|
+
const ret = wasm.get_client_address(client.__wbg_ptr);
|
|
570
|
+
deferred1_0 = ret[0];
|
|
571
|
+
deferred1_1 = ret[1];
|
|
572
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
573
|
+
} finally {
|
|
574
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
582
575
|
}
|
|
583
|
-
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
584
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
585
|
-
return v1;
|
|
586
576
|
}
|
|
587
577
|
|
|
588
578
|
/**
|
|
@@ -615,6 +605,16 @@ export function new_client(server_addrs, client_address_hex, fhe_parameter) {
|
|
|
615
605
|
return Client.__wrap(ret[0]);
|
|
616
606
|
}
|
|
617
607
|
|
|
608
|
+
/**
|
|
609
|
+
* @param {Client} client
|
|
610
|
+
* @returns {PrivateSigKey | undefined}
|
|
611
|
+
*/
|
|
612
|
+
export function get_client_secret_key(client) {
|
|
613
|
+
_assertClass(client, Client);
|
|
614
|
+
const ret = wasm.get_client_secret_key(client.__wbg_ptr);
|
|
615
|
+
return ret === 0 ? undefined : PrivateSigKey.__wrap(ret);
|
|
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
|