tkms 0.13.0 → 0.13.2
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 +43 -43
- package/kms_lib.js +239 -239
- package/kms_lib_bg.wasm +0 -0
- package/package.json +1 -1
package/kms_lib.d.ts
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
export function
|
|
3
|
+
export function public_sig_key_to_u8vec(pk: PublicSigKey): Uint8Array;
|
|
4
|
+
/**
|
|
5
|
+
* Instantiate a new client.
|
|
6
|
+
*
|
|
7
|
+
* * `server_addrs` - a list of KMS server ID with EIP-55 addresses,
|
|
8
|
+
* the elements in the list can be created using [new_server_id_addr].
|
|
9
|
+
*
|
|
10
|
+
* * `client_address_hex` - the client (wallet) address in hex,
|
|
11
|
+
* must be prefixed with "0x".
|
|
12
|
+
*
|
|
13
|
+
* * `fhe_parameter` - the parameter choice, which can be either `"test"` or `"default"`.
|
|
14
|
+
* The "default" parameter choice is selected if no matching string is found.
|
|
15
|
+
*/
|
|
16
|
+
export function new_client(server_addrs: ServerIdAddr[], client_address_hex: string, fhe_parameter: string): Client;
|
|
17
|
+
export function ml_kem_pke_get_pk(sk: PrivateEncKeyMlKem512): PublicEncKeyMlKem512;
|
|
18
|
+
export function ml_kem_pke_pk_to_u8vec(pk: PublicEncKeyMlKem512): Uint8Array;
|
|
4
19
|
export function u8vec_to_ml_kem_pke_pk(v: Uint8Array): PublicEncKeyMlKem512;
|
|
5
|
-
export function ml_kem_pke_sk_to_u8vec(sk: PrivateEncKeyMlKem512): Uint8Array;
|
|
6
|
-
export function u8vec_to_private_sig_key(v: Uint8Array): PrivateSigKey;
|
|
7
|
-
export function get_client_secret_key(client: Client): PrivateSigKey | undefined;
|
|
8
|
-
export function u8vec_to_ml_kem_pke_sk(v: Uint8Array): PrivateEncKeyMlKem512;
|
|
9
20
|
/**
|
|
10
21
|
* Process the user_decryption response from Rust objects.
|
|
11
22
|
* Consider using [process_user_decryption_resp_from_js]
|
|
@@ -30,44 +41,8 @@ export function u8vec_to_ml_kem_pke_sk(v: Uint8Array): PrivateEncKeyMlKem512;
|
|
|
30
41
|
* It is insecure if `verify = false`!
|
|
31
42
|
*/
|
|
32
43
|
export function process_user_decryption_resp(client: Client, request: ParsedUserDecryptionRequest | null | undefined, eip712_domain: Eip712DomainMsg | null | undefined, agg_resp: UserDecryptionResponse[], enc_pk: PublicEncKeyMlKem512, enc_sk: PrivateEncKeyMlKem512, verify: boolean): TypedPlaintext[];
|
|
33
|
-
export function private_sig_key_to_u8vec(sk: PrivateSigKey): Uint8Array;
|
|
34
|
-
/**
|
|
35
|
-
* This function is *not* used by relayer-sdk because the encryption
|
|
36
|
-
* happens on the KMS side. It's just here for completeness and tests.
|
|
37
|
-
*/
|
|
38
|
-
export function ml_kem_pke_encrypt(msg: Uint8Array, their_pk: PublicEncKeyMlKem512): Uint8Array;
|
|
39
|
-
export function u8vec_to_public_sig_key(v: Uint8Array): PublicSigKey;
|
|
40
|
-
/**
|
|
41
|
-
* Instantiate a new client.
|
|
42
|
-
*
|
|
43
|
-
* * `server_addrs` - a list of KMS server ID with EIP-55 addresses,
|
|
44
|
-
* the elements in the list can be created using [new_server_id_addr].
|
|
45
|
-
*
|
|
46
|
-
* * `client_address_hex` - the client (wallet) address in hex,
|
|
47
|
-
* must be prefixed with "0x".
|
|
48
|
-
*
|
|
49
|
-
* * `fhe_parameter` - the parameter choice, which can be either `"test"` or `"default"`.
|
|
50
|
-
* The "default" parameter choice is selected if no matching string is found.
|
|
51
|
-
*/
|
|
52
|
-
export function new_client(server_addrs: ServerIdAddr[], client_address_hex: string, fhe_parameter: string): Client;
|
|
53
|
-
export function get_client_address(client: Client): string;
|
|
54
|
-
export function ml_kem_pke_get_pk(sk: PrivateEncKeyMlKem512): PublicEncKeyMlKem512;
|
|
55
|
-
/**
|
|
56
|
-
* Create a new [ServerIdAddr] structure that holds an ID and an address
|
|
57
|
-
* which must be a valid EIP-55 address, notably prefixed with "0x".
|
|
58
|
-
*/
|
|
59
|
-
export function new_server_id_addr(id: number, addr: string): ServerIdAddr;
|
|
60
44
|
export function ml_kem_pke_sk_len(): number;
|
|
61
|
-
export function
|
|
62
|
-
export function public_sig_key_to_u8vec(pk: PublicSigKey): Uint8Array;
|
|
63
|
-
export function ml_kem_pke_pk_len(): number;
|
|
64
|
-
/**
|
|
65
|
-
* This function is *not* used by relayer-sdk because the decryption
|
|
66
|
-
* is handled by [process_user_decryption_resp].
|
|
67
|
-
* It's just here for completeness and tests.
|
|
68
|
-
*/
|
|
69
|
-
export function ml_kem_pke_decrypt(ct: Uint8Array, my_sk: PrivateEncKeyMlKem512): Uint8Array;
|
|
70
|
-
export function ml_kem_pke_pk_to_u8vec(pk: PublicEncKeyMlKem512): Uint8Array;
|
|
45
|
+
export function u8vec_to_private_sig_key(v: Uint8Array): PrivateSigKey;
|
|
71
46
|
/**
|
|
72
47
|
* Process the user_decryption response from JavaScript objects.
|
|
73
48
|
* The returned result is a byte array representing a plaintext of any length,
|
|
@@ -130,6 +105,31 @@ export function ml_kem_pke_pk_to_u8vec(pk: PublicEncKeyMlKem512): Uint8Array;
|
|
|
130
105
|
* It is insecure if `verify = false`!
|
|
131
106
|
*/
|
|
132
107
|
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[];
|
|
108
|
+
export function get_client_address(client: Client): string;
|
|
109
|
+
export function get_client_secret_key(client: Client): PrivateSigKey | undefined;
|
|
110
|
+
export function get_server_addrs(client: Client): ServerIdAddr[];
|
|
111
|
+
export function private_sig_key_to_u8vec(sk: PrivateSigKey): Uint8Array;
|
|
112
|
+
/**
|
|
113
|
+
* This function is *not* used by relayer-sdk because the decryption
|
|
114
|
+
* is handled by [process_user_decryption_resp].
|
|
115
|
+
* It's just here for completeness and tests.
|
|
116
|
+
*/
|
|
117
|
+
export function ml_kem_pke_decrypt(ct: Uint8Array, my_sk: PrivateEncKeyMlKem512): Uint8Array;
|
|
118
|
+
/**
|
|
119
|
+
* Create a new [ServerIdAddr] structure that holds an ID and an address
|
|
120
|
+
* which must be a valid EIP-55 address, notably prefixed with "0x".
|
|
121
|
+
*/
|
|
122
|
+
export function new_server_id_addr(id: number, addr: string): ServerIdAddr;
|
|
123
|
+
export function u8vec_to_ml_kem_pke_sk(v: Uint8Array): PrivateEncKeyMlKem512;
|
|
124
|
+
export function ml_kem_pke_keygen(): PrivateEncKeyMlKem512;
|
|
125
|
+
export function ml_kem_pke_sk_to_u8vec(sk: PrivateEncKeyMlKem512): Uint8Array;
|
|
126
|
+
/**
|
|
127
|
+
* This function is *not* used by relayer-sdk because the encryption
|
|
128
|
+
* happens on the KMS side. It's just here for completeness and tests.
|
|
129
|
+
*/
|
|
130
|
+
export function ml_kem_pke_encrypt(msg: Uint8Array, their_pk: PublicEncKeyMlKem512): Uint8Array;
|
|
131
|
+
export function ml_kem_pke_pk_len(): number;
|
|
132
|
+
export function u8vec_to_public_sig_key(v: Uint8Array): PublicSigKey;
|
|
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,32 +173,29 @@ function _assertClass(instance, klass) {
|
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
function
|
|
176
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
177
177
|
ptr = ptr >>> 0;
|
|
178
|
-
|
|
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;
|
|
178
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
185
179
|
}
|
|
186
180
|
/**
|
|
187
|
-
* @param {
|
|
188
|
-
* @returns {
|
|
181
|
+
* @param {PublicSigKey} pk
|
|
182
|
+
* @returns {Uint8Array}
|
|
189
183
|
*/
|
|
190
|
-
export function
|
|
191
|
-
_assertClass(
|
|
192
|
-
const ret = wasm.
|
|
193
|
-
var v1 =
|
|
194
|
-
wasm.__wbindgen_free(ret[0], ret[1] *
|
|
184
|
+
export function public_sig_key_to_u8vec(pk) {
|
|
185
|
+
_assertClass(pk, PublicSigKey);
|
|
186
|
+
const ret = wasm.public_sig_key_to_u8vec(pk.__wbg_ptr);
|
|
187
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
188
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
195
189
|
return v1;
|
|
196
190
|
}
|
|
197
191
|
|
|
198
|
-
function
|
|
199
|
-
const ptr = malloc(
|
|
200
|
-
|
|
201
|
-
|
|
192
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
193
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
194
|
+
for (let i = 0; i < array.length; i++) {
|
|
195
|
+
const add = addToExternrefTable0(array[i]);
|
|
196
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
197
|
+
}
|
|
198
|
+
WASM_VECTOR_LEN = array.length;
|
|
202
199
|
return ptr;
|
|
203
200
|
}
|
|
204
201
|
|
|
@@ -208,30 +205,52 @@ function takeFromExternrefTable0(idx) {
|
|
|
208
205
|
return value;
|
|
209
206
|
}
|
|
210
207
|
/**
|
|
211
|
-
*
|
|
212
|
-
*
|
|
208
|
+
* Instantiate a new client.
|
|
209
|
+
*
|
|
210
|
+
* * `server_addrs` - a list of KMS server ID with EIP-55 addresses,
|
|
211
|
+
* the elements in the list can be created using [new_server_id_addr].
|
|
212
|
+
*
|
|
213
|
+
* * `client_address_hex` - the client (wallet) address in hex,
|
|
214
|
+
* must be prefixed with "0x".
|
|
215
|
+
*
|
|
216
|
+
* * `fhe_parameter` - the parameter choice, which can be either `"test"` or `"default"`.
|
|
217
|
+
* The "default" parameter choice is selected if no matching string is found.
|
|
218
|
+
* @param {ServerIdAddr[]} server_addrs
|
|
219
|
+
* @param {string} client_address_hex
|
|
220
|
+
* @param {string} fhe_parameter
|
|
221
|
+
* @returns {Client}
|
|
213
222
|
*/
|
|
214
|
-
export function
|
|
215
|
-
const ptr0 =
|
|
223
|
+
export function new_client(server_addrs, client_address_hex, fhe_parameter) {
|
|
224
|
+
const ptr0 = passArrayJsValueToWasm0(server_addrs, wasm.__wbindgen_malloc);
|
|
216
225
|
const len0 = WASM_VECTOR_LEN;
|
|
217
|
-
const
|
|
226
|
+
const ptr1 = passStringToWasm0(client_address_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
227
|
+
const len1 = WASM_VECTOR_LEN;
|
|
228
|
+
const ptr2 = passStringToWasm0(fhe_parameter, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
229
|
+
const len2 = WASM_VECTOR_LEN;
|
|
230
|
+
const ret = wasm.new_client(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
218
231
|
if (ret[2]) {
|
|
219
232
|
throw takeFromExternrefTable0(ret[1]);
|
|
220
233
|
}
|
|
221
|
-
return
|
|
234
|
+
return Client.__wrap(ret[0]);
|
|
222
235
|
}
|
|
223
236
|
|
|
224
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
225
|
-
ptr = ptr >>> 0;
|
|
226
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
227
|
-
}
|
|
228
237
|
/**
|
|
229
238
|
* @param {PrivateEncKeyMlKem512} sk
|
|
230
|
-
* @returns {
|
|
239
|
+
* @returns {PublicEncKeyMlKem512}
|
|
231
240
|
*/
|
|
232
|
-
export function
|
|
241
|
+
export function ml_kem_pke_get_pk(sk) {
|
|
233
242
|
_assertClass(sk, PrivateEncKeyMlKem512);
|
|
234
|
-
const ret = wasm.
|
|
243
|
+
const ret = wasm.ml_kem_pke_get_pk(sk.__wbg_ptr);
|
|
244
|
+
return PublicEncKeyMlKem512.__wrap(ret);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* @param {PublicEncKeyMlKem512} pk
|
|
249
|
+
* @returns {Uint8Array}
|
|
250
|
+
*/
|
|
251
|
+
export function ml_kem_pke_pk_to_u8vec(pk) {
|
|
252
|
+
_assertClass(pk, PublicEncKeyMlKem512);
|
|
253
|
+
const ret = wasm.ml_kem_pke_pk_to_u8vec(pk.__wbg_ptr);
|
|
235
254
|
if (ret[3]) {
|
|
236
255
|
throw takeFromExternrefTable0(ret[2]);
|
|
237
256
|
}
|
|
@@ -240,52 +259,35 @@ export function ml_kem_pke_sk_to_u8vec(sk) {
|
|
|
240
259
|
return v1;
|
|
241
260
|
}
|
|
242
261
|
|
|
243
|
-
|
|
244
|
-
*
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
249
|
-
const len0 = WASM_VECTOR_LEN;
|
|
250
|
-
const ret = wasm.u8vec_to_private_sig_key(ptr0, len0);
|
|
251
|
-
if (ret[2]) {
|
|
252
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
253
|
-
}
|
|
254
|
-
return PrivateSigKey.__wrap(ret[0]);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* @param {Client} client
|
|
259
|
-
* @returns {PrivateSigKey | undefined}
|
|
260
|
-
*/
|
|
261
|
-
export function get_client_secret_key(client) {
|
|
262
|
-
_assertClass(client, Client);
|
|
263
|
-
const ret = wasm.get_client_secret_key(client.__wbg_ptr);
|
|
264
|
-
return ret === 0 ? undefined : PrivateSigKey.__wrap(ret);
|
|
262
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
263
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
264
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
265
|
+
WASM_VECTOR_LEN = arg.length;
|
|
266
|
+
return ptr;
|
|
265
267
|
}
|
|
266
|
-
|
|
267
268
|
/**
|
|
268
269
|
* @param {Uint8Array} v
|
|
269
|
-
* @returns {
|
|
270
|
+
* @returns {PublicEncKeyMlKem512}
|
|
270
271
|
*/
|
|
271
|
-
export function
|
|
272
|
+
export function u8vec_to_ml_kem_pke_pk(v) {
|
|
272
273
|
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
273
274
|
const len0 = WASM_VECTOR_LEN;
|
|
274
|
-
const ret = wasm.
|
|
275
|
+
const ret = wasm.u8vec_to_ml_kem_pke_pk(ptr0, len0);
|
|
275
276
|
if (ret[2]) {
|
|
276
277
|
throw takeFromExternrefTable0(ret[1]);
|
|
277
278
|
}
|
|
278
|
-
return
|
|
279
|
+
return PublicEncKeyMlKem512.__wrap(ret[0]);
|
|
279
280
|
}
|
|
280
281
|
|
|
281
|
-
function
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
282
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
283
|
+
ptr = ptr >>> 0;
|
|
284
|
+
const mem = getDataViewMemory0();
|
|
285
|
+
const result = [];
|
|
286
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
287
|
+
result.push(wasm.__wbindgen_export_4.get(mem.getUint32(i, true)));
|
|
286
288
|
}
|
|
287
|
-
|
|
288
|
-
return
|
|
289
|
+
wasm.__externref_drop_slice(ptr, len);
|
|
290
|
+
return result;
|
|
289
291
|
}
|
|
290
292
|
/**
|
|
291
293
|
* Process the user_decryption response from Rust objects.
|
|
@@ -344,79 +346,107 @@ export function process_user_decryption_resp(client, request, eip712_domain, agg
|
|
|
344
346
|
}
|
|
345
347
|
|
|
346
348
|
/**
|
|
347
|
-
* @
|
|
348
|
-
* @returns {Uint8Array}
|
|
349
|
-
*/
|
|
350
|
-
export function private_sig_key_to_u8vec(sk) {
|
|
351
|
-
_assertClass(sk, PrivateSigKey);
|
|
352
|
-
const ret = wasm.private_sig_key_to_u8vec(sk.__wbg_ptr);
|
|
353
|
-
if (ret[3]) {
|
|
354
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
355
|
-
}
|
|
356
|
-
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
357
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
358
|
-
return v1;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* This function is *not* used by relayer-sdk because the encryption
|
|
363
|
-
* happens on the KMS side. It's just here for completeness and tests.
|
|
364
|
-
* @param {Uint8Array} msg
|
|
365
|
-
* @param {PublicEncKeyMlKem512} their_pk
|
|
366
|
-
* @returns {Uint8Array}
|
|
349
|
+
* @returns {number}
|
|
367
350
|
*/
|
|
368
|
-
export function
|
|
369
|
-
const
|
|
370
|
-
|
|
371
|
-
_assertClass(their_pk, PublicEncKeyMlKem512);
|
|
372
|
-
const ret = wasm.ml_kem_pke_encrypt(ptr0, len0, their_pk.__wbg_ptr);
|
|
373
|
-
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
374
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
375
|
-
return v2;
|
|
351
|
+
export function ml_kem_pke_sk_len() {
|
|
352
|
+
const ret = wasm.ml_kem_pke_sk_len();
|
|
353
|
+
return ret >>> 0;
|
|
376
354
|
}
|
|
377
355
|
|
|
378
356
|
/**
|
|
379
357
|
* @param {Uint8Array} v
|
|
380
|
-
* @returns {
|
|
358
|
+
* @returns {PrivateSigKey}
|
|
381
359
|
*/
|
|
382
|
-
export function
|
|
360
|
+
export function u8vec_to_private_sig_key(v) {
|
|
383
361
|
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
384
362
|
const len0 = WASM_VECTOR_LEN;
|
|
385
|
-
const ret = wasm.
|
|
363
|
+
const ret = wasm.u8vec_to_private_sig_key(ptr0, len0);
|
|
386
364
|
if (ret[2]) {
|
|
387
365
|
throw takeFromExternrefTable0(ret[1]);
|
|
388
366
|
}
|
|
389
|
-
return
|
|
367
|
+
return PrivateSigKey.__wrap(ret[0]);
|
|
390
368
|
}
|
|
391
369
|
|
|
392
370
|
/**
|
|
393
|
-
*
|
|
371
|
+
* Process the user_decryption response from JavaScript objects.
|
|
372
|
+
* The returned result is a byte array representing a plaintext of any length,
|
|
373
|
+
* postprocessing is returned to turn it into an integer.
|
|
394
374
|
*
|
|
395
|
-
* * `
|
|
396
|
-
* the elements in the list can be created using [new_server_id_addr].
|
|
375
|
+
* * `client` - client that wants to perform user_decryption.
|
|
397
376
|
*
|
|
398
|
-
* * `
|
|
399
|
-
*
|
|
377
|
+
* * `request` - the initial user_decryption request JS object.
|
|
378
|
+
* It can be set to null if `verify` is false.
|
|
379
|
+
* Otherwise the caller needs to give the following JS object.
|
|
380
|
+
* Note that `client_address` and `eip712_verifying_contract` follow EIP-55.
|
|
381
|
+
* The signature field is not needed.
|
|
382
|
+
* ```
|
|
383
|
+
* {
|
|
384
|
+
* signature: undefined,
|
|
385
|
+
* client_address: '0x17853A630aAe15AED549B2B874de08B73C0F59c5',
|
|
386
|
+
* enc_key: '2000000000000000df2fcacb774f03187f3802a27259f45c06d33cefa68d9c53426b15ad531aa822',
|
|
387
|
+
* ciphertext_handles: [ '0748b542afe2353c86cb707e3d21044b0be1fd18efc7cbaa6a415af055bfb358' ]
|
|
388
|
+
* eip712_verifying_contract: '0x66f9664f97F2b50F62D13eA064982f936dE76657'
|
|
389
|
+
* }
|
|
390
|
+
* ```
|
|
400
391
|
*
|
|
401
|
-
* * `
|
|
402
|
-
*
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
406
|
-
*
|
|
392
|
+
* * `eip712_domain` - the EIP-712 domain JS object.
|
|
393
|
+
* It can be set to null if `verify` is false.
|
|
394
|
+
* Otherwise the caller needs to give the following JS object.
|
|
395
|
+
* Note that `salt` is optional and `verifying_contract` follows EIP-55,
|
|
396
|
+
* additionally, `chain_id` is an array of u8.
|
|
397
|
+
* ```
|
|
398
|
+
* {
|
|
399
|
+
* name: 'Authorization token',
|
|
400
|
+
* version: '1',
|
|
401
|
+
* chain_id: [
|
|
402
|
+
* 70, 31, 0, 0, 0, 0, 0, 0, 0,
|
|
403
|
+
* 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
404
|
+
* 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
405
|
+
* 0, 0, 0, 0, 0
|
|
406
|
+
* ],
|
|
407
|
+
* verifying_contract: '0x66f9664f97F2b50F62D13eA064982f936dE76657',
|
|
408
|
+
* salt: []
|
|
409
|
+
* }
|
|
410
|
+
* ```
|
|
411
|
+
*
|
|
412
|
+
* * `agg_resp` - the response JS object from the gateway.
|
|
413
|
+
* It has two fields like so, both are hex encoded byte arrays.
|
|
414
|
+
* ```
|
|
415
|
+
* [
|
|
416
|
+
* {
|
|
417
|
+
* signature: '69e7e040cab157aa819015b321c012dccb1545ffefd325b359b492653f0347517e28e66c572cdc299e259024329859ff9fcb0096e1ce072af0b6e1ca1fe25ec6',
|
|
418
|
+
* payload: '0100000029...',
|
|
419
|
+
* extra_data: '01234...',
|
|
420
|
+
* }
|
|
421
|
+
* ]
|
|
422
|
+
* ```
|
|
423
|
+
*
|
|
424
|
+
* * `enc_pk` - The ephemeral public key.
|
|
425
|
+
*
|
|
426
|
+
* * `enc_sk` - The ephemeral secret key.
|
|
427
|
+
*
|
|
428
|
+
* * `verify` - Whether to perform signature verification for the response.
|
|
429
|
+
* It is insecure if `verify = false`!
|
|
430
|
+
* @param {Client} client
|
|
431
|
+
* @param {any} request
|
|
432
|
+
* @param {any} eip712_domain
|
|
433
|
+
* @param {any} agg_resp
|
|
434
|
+
* @param {PublicEncKeyMlKem512} enc_pk
|
|
435
|
+
* @param {PrivateEncKeyMlKem512} enc_sk
|
|
436
|
+
* @param {boolean} verify
|
|
437
|
+
* @returns {TypedPlaintext[]}
|
|
407
438
|
*/
|
|
408
|
-
export function
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
const
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
const ret = wasm.new_client(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
416
|
-
if (ret[2]) {
|
|
417
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
439
|
+
export function process_user_decryption_resp_from_js(client, request, eip712_domain, agg_resp, enc_pk, enc_sk, verify) {
|
|
440
|
+
_assertClass(client, Client);
|
|
441
|
+
_assertClass(enc_pk, PublicEncKeyMlKem512);
|
|
442
|
+
_assertClass(enc_sk, PrivateEncKeyMlKem512);
|
|
443
|
+
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);
|
|
444
|
+
if (ret[3]) {
|
|
445
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
418
446
|
}
|
|
419
|
-
|
|
447
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
448
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
449
|
+
return v1;
|
|
420
450
|
}
|
|
421
451
|
|
|
422
452
|
/**
|
|
@@ -438,13 +468,58 @@ export function get_client_address(client) {
|
|
|
438
468
|
}
|
|
439
469
|
|
|
440
470
|
/**
|
|
441
|
-
* @param {
|
|
442
|
-
* @returns {
|
|
471
|
+
* @param {Client} client
|
|
472
|
+
* @returns {PrivateSigKey | undefined}
|
|
443
473
|
*/
|
|
444
|
-
export function
|
|
445
|
-
_assertClass(
|
|
446
|
-
const ret = wasm.
|
|
447
|
-
return
|
|
474
|
+
export function get_client_secret_key(client) {
|
|
475
|
+
_assertClass(client, Client);
|
|
476
|
+
const ret = wasm.get_client_secret_key(client.__wbg_ptr);
|
|
477
|
+
return ret === 0 ? undefined : PrivateSigKey.__wrap(ret);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* @param {Client} client
|
|
482
|
+
* @returns {ServerIdAddr[]}
|
|
483
|
+
*/
|
|
484
|
+
export function get_server_addrs(client) {
|
|
485
|
+
_assertClass(client, Client);
|
|
486
|
+
const ret = wasm.get_server_addrs(client.__wbg_ptr);
|
|
487
|
+
var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
|
|
488
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
489
|
+
return v1;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* @param {PrivateSigKey} sk
|
|
494
|
+
* @returns {Uint8Array}
|
|
495
|
+
*/
|
|
496
|
+
export function private_sig_key_to_u8vec(sk) {
|
|
497
|
+
_assertClass(sk, PrivateSigKey);
|
|
498
|
+
const ret = wasm.private_sig_key_to_u8vec(sk.__wbg_ptr);
|
|
499
|
+
if (ret[3]) {
|
|
500
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
501
|
+
}
|
|
502
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
503
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
504
|
+
return v1;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* This function is *not* used by relayer-sdk because the decryption
|
|
509
|
+
* is handled by [process_user_decryption_resp].
|
|
510
|
+
* It's just here for completeness and tests.
|
|
511
|
+
* @param {Uint8Array} ct
|
|
512
|
+
* @param {PrivateEncKeyMlKem512} my_sk
|
|
513
|
+
* @returns {Uint8Array}
|
|
514
|
+
*/
|
|
515
|
+
export function ml_kem_pke_decrypt(ct, my_sk) {
|
|
516
|
+
const ptr0 = passArray8ToWasm0(ct, wasm.__wbindgen_malloc);
|
|
517
|
+
const len0 = WASM_VECTOR_LEN;
|
|
518
|
+
_assertClass(my_sk, PrivateEncKeyMlKem512);
|
|
519
|
+
const ret = wasm.ml_kem_pke_decrypt(ptr0, len0, my_sk.__wbg_ptr);
|
|
520
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
521
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
522
|
+
return v2;
|
|
448
523
|
}
|
|
449
524
|
|
|
450
525
|
/**
|
|
@@ -465,11 +540,17 @@ export function new_server_id_addr(id, addr) {
|
|
|
465
540
|
}
|
|
466
541
|
|
|
467
542
|
/**
|
|
468
|
-
* @
|
|
543
|
+
* @param {Uint8Array} v
|
|
544
|
+
* @returns {PrivateEncKeyMlKem512}
|
|
469
545
|
*/
|
|
470
|
-
export function
|
|
471
|
-
const
|
|
472
|
-
|
|
546
|
+
export function u8vec_to_ml_kem_pke_sk(v) {
|
|
547
|
+
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
548
|
+
const len0 = WASM_VECTOR_LEN;
|
|
549
|
+
const ret = wasm.u8vec_to_ml_kem_pke_sk(ptr0, len0);
|
|
550
|
+
if (ret[2]) {
|
|
551
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
552
|
+
}
|
|
553
|
+
return PrivateEncKeyMlKem512.__wrap(ret[0]);
|
|
473
554
|
}
|
|
474
555
|
|
|
475
556
|
/**
|
|
@@ -481,138 +562,57 @@ export function ml_kem_pke_keygen() {
|
|
|
481
562
|
}
|
|
482
563
|
|
|
483
564
|
/**
|
|
484
|
-
* @param {
|
|
565
|
+
* @param {PrivateEncKeyMlKem512} sk
|
|
485
566
|
* @returns {Uint8Array}
|
|
486
567
|
*/
|
|
487
|
-
export function
|
|
488
|
-
_assertClass(
|
|
489
|
-
const ret = wasm.
|
|
568
|
+
export function ml_kem_pke_sk_to_u8vec(sk) {
|
|
569
|
+
_assertClass(sk, PrivateEncKeyMlKem512);
|
|
570
|
+
const ret = wasm.ml_kem_pke_sk_to_u8vec(sk.__wbg_ptr);
|
|
571
|
+
if (ret[3]) {
|
|
572
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
573
|
+
}
|
|
490
574
|
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
491
575
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
492
576
|
return v1;
|
|
493
577
|
}
|
|
494
578
|
|
|
495
579
|
/**
|
|
496
|
-
*
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
return ret >>> 0;
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
/**
|
|
504
|
-
* This function is *not* used by relayer-sdk because the decryption
|
|
505
|
-
* is handled by [process_user_decryption_resp].
|
|
506
|
-
* It's just here for completeness and tests.
|
|
507
|
-
* @param {Uint8Array} ct
|
|
508
|
-
* @param {PrivateEncKeyMlKem512} my_sk
|
|
580
|
+
* This function is *not* used by relayer-sdk because the encryption
|
|
581
|
+
* happens on the KMS side. It's just here for completeness and tests.
|
|
582
|
+
* @param {Uint8Array} msg
|
|
583
|
+
* @param {PublicEncKeyMlKem512} their_pk
|
|
509
584
|
* @returns {Uint8Array}
|
|
510
585
|
*/
|
|
511
|
-
export function
|
|
512
|
-
const ptr0 = passArray8ToWasm0(
|
|
586
|
+
export function ml_kem_pke_encrypt(msg, their_pk) {
|
|
587
|
+
const ptr0 = passArray8ToWasm0(msg, wasm.__wbindgen_malloc);
|
|
513
588
|
const len0 = WASM_VECTOR_LEN;
|
|
514
|
-
_assertClass(
|
|
515
|
-
const ret = wasm.
|
|
589
|
+
_assertClass(their_pk, PublicEncKeyMlKem512);
|
|
590
|
+
const ret = wasm.ml_kem_pke_encrypt(ptr0, len0, their_pk.__wbg_ptr);
|
|
516
591
|
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
517
592
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
518
593
|
return v2;
|
|
519
594
|
}
|
|
520
595
|
|
|
521
596
|
/**
|
|
522
|
-
* @
|
|
523
|
-
* @returns {Uint8Array}
|
|
597
|
+
* @returns {number}
|
|
524
598
|
*/
|
|
525
|
-
export function
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
if (ret[3]) {
|
|
529
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
530
|
-
}
|
|
531
|
-
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
532
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
533
|
-
return v1;
|
|
599
|
+
export function ml_kem_pke_pk_len() {
|
|
600
|
+
const ret = wasm.ml_kem_pke_pk_len();
|
|
601
|
+
return ret >>> 0;
|
|
534
602
|
}
|
|
535
603
|
|
|
536
604
|
/**
|
|
537
|
-
*
|
|
538
|
-
*
|
|
539
|
-
* postprocessing is returned to turn it into an integer.
|
|
540
|
-
*
|
|
541
|
-
* * `client` - client that wants to perform user_decryption.
|
|
542
|
-
*
|
|
543
|
-
* * `request` - the initial user_decryption request JS object.
|
|
544
|
-
* It can be set to null if `verify` is false.
|
|
545
|
-
* Otherwise the caller needs to give the following JS object.
|
|
546
|
-
* Note that `client_address` and `eip712_verifying_contract` follow EIP-55.
|
|
547
|
-
* The signature field is not needed.
|
|
548
|
-
* ```
|
|
549
|
-
* {
|
|
550
|
-
* signature: undefined,
|
|
551
|
-
* client_address: '0x17853A630aAe15AED549B2B874de08B73C0F59c5',
|
|
552
|
-
* enc_key: '2000000000000000df2fcacb774f03187f3802a27259f45c06d33cefa68d9c53426b15ad531aa822',
|
|
553
|
-
* ciphertext_handles: [ '0748b542afe2353c86cb707e3d21044b0be1fd18efc7cbaa6a415af055bfb358' ]
|
|
554
|
-
* eip712_verifying_contract: '0x66f9664f97F2b50F62D13eA064982f936dE76657'
|
|
555
|
-
* }
|
|
556
|
-
* ```
|
|
557
|
-
*
|
|
558
|
-
* * `eip712_domain` - the EIP-712 domain JS object.
|
|
559
|
-
* It can be set to null if `verify` is false.
|
|
560
|
-
* Otherwise the caller needs to give the following JS object.
|
|
561
|
-
* Note that `salt` is optional and `verifying_contract` follows EIP-55,
|
|
562
|
-
* additionally, `chain_id` is an array of u8.
|
|
563
|
-
* ```
|
|
564
|
-
* {
|
|
565
|
-
* name: 'Authorization token',
|
|
566
|
-
* version: '1',
|
|
567
|
-
* chain_id: [
|
|
568
|
-
* 70, 31, 0, 0, 0, 0, 0, 0, 0,
|
|
569
|
-
* 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
570
|
-
* 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
571
|
-
* 0, 0, 0, 0, 0
|
|
572
|
-
* ],
|
|
573
|
-
* verifying_contract: '0x66f9664f97F2b50F62D13eA064982f936dE76657',
|
|
574
|
-
* salt: []
|
|
575
|
-
* }
|
|
576
|
-
* ```
|
|
577
|
-
*
|
|
578
|
-
* * `agg_resp` - the response JS object from the gateway.
|
|
579
|
-
* It has two fields like so, both are hex encoded byte arrays.
|
|
580
|
-
* ```
|
|
581
|
-
* [
|
|
582
|
-
* {
|
|
583
|
-
* signature: '69e7e040cab157aa819015b321c012dccb1545ffefd325b359b492653f0347517e28e66c572cdc299e259024329859ff9fcb0096e1ce072af0b6e1ca1fe25ec6',
|
|
584
|
-
* payload: '0100000029...',
|
|
585
|
-
* extra_data: '01234...',
|
|
586
|
-
* }
|
|
587
|
-
* ]
|
|
588
|
-
* ```
|
|
589
|
-
*
|
|
590
|
-
* * `enc_pk` - The ephemeral public key.
|
|
591
|
-
*
|
|
592
|
-
* * `enc_sk` - The ephemeral secret key.
|
|
593
|
-
*
|
|
594
|
-
* * `verify` - Whether to perform signature verification for the response.
|
|
595
|
-
* It is insecure if `verify = false`!
|
|
596
|
-
* @param {Client} client
|
|
597
|
-
* @param {any} request
|
|
598
|
-
* @param {any} eip712_domain
|
|
599
|
-
* @param {any} agg_resp
|
|
600
|
-
* @param {PublicEncKeyMlKem512} enc_pk
|
|
601
|
-
* @param {PrivateEncKeyMlKem512} enc_sk
|
|
602
|
-
* @param {boolean} verify
|
|
603
|
-
* @returns {TypedPlaintext[]}
|
|
605
|
+
* @param {Uint8Array} v
|
|
606
|
+
* @returns {PublicSigKey}
|
|
604
607
|
*/
|
|
605
|
-
export function
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
608
|
+
export function u8vec_to_public_sig_key(v) {
|
|
609
|
+
const ptr0 = passArray8ToWasm0(v, wasm.__wbindgen_malloc);
|
|
610
|
+
const len0 = WASM_VECTOR_LEN;
|
|
611
|
+
const ret = wasm.u8vec_to_public_sig_key(ptr0, len0);
|
|
612
|
+
if (ret[2]) {
|
|
613
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
612
614
|
}
|
|
613
|
-
|
|
614
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
615
|
-
return v1;
|
|
615
|
+
return PublicSigKey.__wrap(ret[0]);
|
|
616
616
|
}
|
|
617
617
|
|
|
618
618
|
const CiphertextHandleFinalization = (typeof FinalizationRegistry === 'undefined')
|
package/kms_lib_bg.wasm
CHANGED
|
Binary file
|