node-tkms 0.13.0-rc.1 → 0.13.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/kms_lib.d.ts +355 -302
- package/kms_lib.js +1707 -1800
- package/kms_lib_bg.wasm +0 -0
- package/package.json +1 -1
package/kms_lib.d.ts
CHANGED
|
@@ -1,10 +1,324 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export class CiphertextHandle {
|
|
5
|
+
private constructor();
|
|
6
|
+
free(): void;
|
|
7
|
+
[Symbol.dispose](): void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Core Client
|
|
12
|
+
*
|
|
13
|
+
* Simple client to interact with the KMS servers. This can be seen as a proof-of-concept
|
|
14
|
+
* and reference code for validating the KMS. The logic supplied by the client will be
|
|
15
|
+
* distributed across the aggregator/proxy and smart contracts.
|
|
16
|
+
*/
|
|
17
|
+
export class Client {
|
|
18
|
+
private constructor();
|
|
19
|
+
free(): void;
|
|
20
|
+
[Symbol.dispose](): void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Eip712 domain information.
|
|
25
|
+
* Any constraints specified in the [standard](<https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator>) _must_ be fulfilled.
|
|
26
|
+
* Furthermore, be aware that all parameters will eventually be parsed into Solidity types.
|
|
27
|
+
*/
|
|
28
|
+
export class Eip712DomainMsg {
|
|
29
|
+
private constructor();
|
|
30
|
+
free(): void;
|
|
31
|
+
[Symbol.dispose](): void;
|
|
32
|
+
chain_id: Uint8Array;
|
|
33
|
+
name: string;
|
|
34
|
+
get salt(): Uint8Array | undefined;
|
|
35
|
+
set salt(value: Uint8Array | null | undefined);
|
|
36
|
+
verifying_contract: string;
|
|
37
|
+
version: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Validity of this struct is not checked.
|
|
42
|
+
*/
|
|
43
|
+
export class ParsedUserDecryptionRequest {
|
|
44
|
+
private constructor();
|
|
45
|
+
free(): void;
|
|
46
|
+
[Symbol.dispose](): void;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export class PrivateEncKeyMlKem512 {
|
|
50
|
+
private constructor();
|
|
51
|
+
free(): void;
|
|
52
|
+
[Symbol.dispose](): void;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export class PrivateSigKey {
|
|
56
|
+
private constructor();
|
|
57
|
+
free(): void;
|
|
58
|
+
[Symbol.dispose](): void;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export class PublicEncKeyMlKem512 {
|
|
62
|
+
private constructor();
|
|
63
|
+
free(): void;
|
|
64
|
+
[Symbol.dispose](): void;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export class PublicSigKey {
|
|
68
|
+
private constructor();
|
|
69
|
+
free(): void;
|
|
70
|
+
[Symbol.dispose](): void;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* / A unique 32 Byte / 256 Bit ID, to be used to identify a request and
|
|
75
|
+
* / for retrieving the computed result later on.
|
|
76
|
+
* / Must be encoded in lower-case hex. The string must NOT contain a `0x` prefix.
|
|
77
|
+
*/
|
|
78
|
+
export class RequestId {
|
|
79
|
+
private constructor();
|
|
80
|
+
free(): void;
|
|
81
|
+
[Symbol.dispose](): void;
|
|
82
|
+
request_id: string;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export class ServerIdAddr {
|
|
86
|
+
private constructor();
|
|
87
|
+
free(): void;
|
|
88
|
+
[Symbol.dispose](): void;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export class TypedCiphertext {
|
|
92
|
+
private constructor();
|
|
93
|
+
free(): void;
|
|
94
|
+
[Symbol.dispose](): void;
|
|
95
|
+
/**
|
|
96
|
+
* The ciphertext format, see CiphertextFormat documentation for details.
|
|
97
|
+
* CiphertextFormat::default() is used if unspecified.
|
|
98
|
+
*/
|
|
99
|
+
ciphertext_format: number;
|
|
100
|
+
/**
|
|
101
|
+
* The actual ciphertext to decrypt, taken directly from fhevm.
|
|
102
|
+
*/
|
|
103
|
+
ciphertext: Uint8Array;
|
|
104
|
+
/**
|
|
105
|
+
* The external handle of the ciphertext (the handle used in the copro).
|
|
106
|
+
*/
|
|
107
|
+
external_handle: Uint8Array;
|
|
108
|
+
/**
|
|
109
|
+
* The type of plaintext encrypted. The type should match FheType from tfhe-rs:
|
|
110
|
+
* <https://github.com/zama-ai/tfhe-rs/blob/main/tfhe/src/high_level_api/mod.rs>
|
|
111
|
+
*/
|
|
112
|
+
fhe_type: number;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export class TypedPlaintext {
|
|
116
|
+
private constructor();
|
|
117
|
+
free(): void;
|
|
118
|
+
[Symbol.dispose](): void;
|
|
119
|
+
/**
|
|
120
|
+
* The actual plaintext in bytes.
|
|
121
|
+
*/
|
|
122
|
+
bytes: Uint8Array;
|
|
123
|
+
/**
|
|
124
|
+
* The type of plaintext encrypted. The type should match FheType from tfhe-rs:
|
|
125
|
+
* <https://github.com/zama-ai/tfhe-rs/blob/main/tfhe/src/high_level_api/mod.rs>
|
|
126
|
+
*/
|
|
127
|
+
fhe_type: number;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export class TypedSigncryptedCiphertext {
|
|
131
|
+
private constructor();
|
|
132
|
+
free(): void;
|
|
133
|
+
[Symbol.dispose](): void;
|
|
134
|
+
/**
|
|
135
|
+
* The external handles that were originally in the request.
|
|
136
|
+
*/
|
|
137
|
+
external_handle: Uint8Array;
|
|
138
|
+
/**
|
|
139
|
+
* The type of plaintext encrypted. The type should match FheType from tfhe-rs:
|
|
140
|
+
* <https://github.com/zama-ai/tfhe-rs/blob/main/tfhe/src/high_level_api/mod.rs>
|
|
141
|
+
*/
|
|
142
|
+
fhe_type: number;
|
|
143
|
+
/**
|
|
144
|
+
* The packing factor determines whether the decrypted plaintext
|
|
145
|
+
* has a different way of packing compared to what is specified in the plaintext modulus.
|
|
146
|
+
*/
|
|
147
|
+
packing_factor: number;
|
|
148
|
+
/**
|
|
149
|
+
* The signcrypted payload, using a hybrid encryption approach in
|
|
150
|
+
* sign-then-encrypt.
|
|
151
|
+
*/
|
|
152
|
+
signcrypted_ciphertext: Uint8Array;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export class UserDecryptionRequest {
|
|
156
|
+
private constructor();
|
|
157
|
+
free(): void;
|
|
158
|
+
[Symbol.dispose](): void;
|
|
159
|
+
/**
|
|
160
|
+
* The client's (blockchain wallet) address, encoded using EIP-55. I.e. including `0x`.
|
|
161
|
+
*/
|
|
162
|
+
client_address: string;
|
|
163
|
+
/**
|
|
164
|
+
* MPC context ID which is used to identify the context to use for this request.
|
|
165
|
+
*
|
|
166
|
+
* NOTE: at the moment this can be None since we do not fully support multiple contexts.
|
|
167
|
+
* See <https://github.com/zama-ai/kms-internal/issues/2530>
|
|
168
|
+
*/
|
|
169
|
+
get context_id(): RequestId | undefined;
|
|
170
|
+
/**
|
|
171
|
+
* MPC context ID which is used to identify the context to use for this request.
|
|
172
|
+
*
|
|
173
|
+
* NOTE: at the moment this can be None since we do not fully support multiple contexts.
|
|
174
|
+
* See <https://github.com/zama-ai/kms-internal/issues/2530>
|
|
175
|
+
*/
|
|
176
|
+
set context_id(value: RequestId | null | undefined);
|
|
177
|
+
/**
|
|
178
|
+
* The user's EIP712 domain. This MUST be present. Furthermore, the `verifying_contract` MUST be set and be distinct from `client_address`.
|
|
179
|
+
*/
|
|
180
|
+
get domain(): Eip712DomainMsg | undefined;
|
|
181
|
+
/**
|
|
182
|
+
* The user's EIP712 domain. This MUST be present. Furthermore, the `verifying_contract` MUST be set and be distinct from `client_address`.
|
|
183
|
+
*/
|
|
184
|
+
set domain(value: Eip712DomainMsg | null | undefined);
|
|
185
|
+
/**
|
|
186
|
+
* Encoding of the user's public encryption key for this request.
|
|
187
|
+
* This must be a bincode (v.1) encoded ML-KEM 512 key.
|
|
188
|
+
*/
|
|
189
|
+
enc_key: Uint8Array;
|
|
190
|
+
/**
|
|
191
|
+
* The epoch number placeholder (zama-ai/kms-internal#2743).
|
|
192
|
+
*/
|
|
193
|
+
get epoch_id(): RequestId | undefined;
|
|
194
|
+
/**
|
|
195
|
+
* The epoch number placeholder (zama-ai/kms-internal#2743).
|
|
196
|
+
*/
|
|
197
|
+
set epoch_id(value: RequestId | null | undefined);
|
|
198
|
+
/**
|
|
199
|
+
* Extra data from the gateway.
|
|
200
|
+
*/
|
|
201
|
+
extra_data: Uint8Array;
|
|
202
|
+
/**
|
|
203
|
+
* The 32 Byte / 256 Bit key id to use for decryption. This is the request_id
|
|
204
|
+
* used for key generation
|
|
205
|
+
*/
|
|
206
|
+
get key_id(): RequestId | undefined;
|
|
207
|
+
/**
|
|
208
|
+
* The 32 Byte / 256 Bit key id to use for decryption. This is the request_id
|
|
209
|
+
* used for key generation
|
|
210
|
+
*/
|
|
211
|
+
set key_id(value: RequestId | null | undefined);
|
|
212
|
+
/**
|
|
213
|
+
* The 32 Byte / 256 Bit ID of the user decryption request, without `0x`
|
|
214
|
+
* prefix. Future queries for the result must use this request ID.
|
|
215
|
+
*/
|
|
216
|
+
get request_id(): RequestId | undefined;
|
|
217
|
+
/**
|
|
218
|
+
* The 32 Byte / 256 Bit ID of the user decryption request, without `0x`
|
|
219
|
+
* prefix. Future queries for the result must use this request ID.
|
|
220
|
+
*/
|
|
221
|
+
set request_id(value: RequestId | null | undefined);
|
|
222
|
+
/**
|
|
223
|
+
* The list of ciphertexts to decrypt for the user.
|
|
224
|
+
*/
|
|
225
|
+
typed_ciphertexts: TypedCiphertext[];
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export class UserDecryptionResponse {
|
|
229
|
+
private constructor();
|
|
230
|
+
free(): void;
|
|
231
|
+
[Symbol.dispose](): void;
|
|
232
|
+
/**
|
|
233
|
+
* This is the external signature created from the Eip712 domain
|
|
234
|
+
* on the structure, where userDecryptedShare is bc2wrap::serialize(&payload)
|
|
235
|
+
* struct UserDecryptResponseVerification {
|
|
236
|
+
* bytes publicKey;
|
|
237
|
+
* uint256\[\] ctHandles;
|
|
238
|
+
* bytes userDecryptedShare; // serialization of payload
|
|
239
|
+
* bytes extraData;
|
|
240
|
+
* }
|
|
241
|
+
*/
|
|
242
|
+
external_signature: Uint8Array;
|
|
243
|
+
/**
|
|
244
|
+
* Extra data used in the EIP712 signature - external_signature.
|
|
245
|
+
*/
|
|
246
|
+
extra_data: Uint8Array;
|
|
247
|
+
/**
|
|
248
|
+
* The actual \[UserDecryptionResponsePayload\].
|
|
249
|
+
*/
|
|
250
|
+
get payload(): UserDecryptionResponsePayload | undefined;
|
|
251
|
+
/**
|
|
252
|
+
* The actual \[UserDecryptionResponsePayload\].
|
|
253
|
+
*/
|
|
254
|
+
set payload(value: UserDecryptionResponsePayload | null | undefined);
|
|
255
|
+
signature: Uint8Array;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export class UserDecryptionResponsePayload {
|
|
259
|
+
private constructor();
|
|
260
|
+
free(): void;
|
|
261
|
+
[Symbol.dispose](): void;
|
|
262
|
+
/**
|
|
263
|
+
* The degree of the sharing scheme used.
|
|
264
|
+
*/
|
|
265
|
+
degree: number;
|
|
266
|
+
/**
|
|
267
|
+
* This is needed to ensure the response corresponds to the request.
|
|
268
|
+
* It is the digest of UserDecryptionLinker hashed using EIP712
|
|
269
|
+
* under the given domain in the request.
|
|
270
|
+
*/
|
|
271
|
+
digest: Uint8Array;
|
|
272
|
+
/**
|
|
273
|
+
* The ID of the MPC party doing the user decryption. Used for polynomial
|
|
274
|
+
* reconstruction.
|
|
275
|
+
*/
|
|
276
|
+
party_id: number;
|
|
277
|
+
/**
|
|
278
|
+
* The resulting signcrypted ciphertexts, each ciphertext
|
|
279
|
+
* must be decrypted and then reconstructed with the other shares
|
|
280
|
+
* to produce the final plaintext.
|
|
281
|
+
*/
|
|
282
|
+
signcrypted_ciphertexts: TypedSigncryptedCiphertext[];
|
|
283
|
+
/**
|
|
284
|
+
* The server's signature verification key, Encoded using SEC1.
|
|
285
|
+
* Needed to validate the response, but MUST also be linked to a list of
|
|
286
|
+
* trusted keys.
|
|
287
|
+
*/
|
|
288
|
+
verification_key: Uint8Array;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export function get_client_address(client: Client): string;
|
|
292
|
+
|
|
293
|
+
export function get_client_secret_key(client: Client): PrivateSigKey | undefined;
|
|
294
|
+
|
|
295
|
+
export function get_server_addrs(client: Client): ServerIdAddr[];
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* This function is *not* used by relayer-sdk because the decryption
|
|
299
|
+
* is handled by [process_user_decryption_resp].
|
|
300
|
+
* It's just here for completeness and tests.
|
|
301
|
+
*/
|
|
302
|
+
export function ml_kem_pke_decrypt(ct: Uint8Array, my_sk: PrivateEncKeyMlKem512): Uint8Array;
|
|
303
|
+
|
|
3
304
|
/**
|
|
4
305
|
* This function is *not* used by relayer-sdk because the encryption
|
|
5
306
|
* happens on the KMS side. It's just here for completeness and tests.
|
|
6
307
|
*/
|
|
7
308
|
export function ml_kem_pke_encrypt(msg: Uint8Array, their_pk: PublicEncKeyMlKem512): Uint8Array;
|
|
309
|
+
|
|
310
|
+
export function ml_kem_pke_get_pk(sk: PrivateEncKeyMlKem512): PublicEncKeyMlKem512;
|
|
311
|
+
|
|
312
|
+
export function ml_kem_pke_keygen(): PrivateEncKeyMlKem512;
|
|
313
|
+
|
|
314
|
+
export function ml_kem_pke_pk_len(): number;
|
|
315
|
+
|
|
316
|
+
export function ml_kem_pke_pk_to_u8vec(pk: PublicEncKeyMlKem512): Uint8Array;
|
|
317
|
+
|
|
318
|
+
export function ml_kem_pke_sk_len(): number;
|
|
319
|
+
|
|
320
|
+
export function ml_kem_pke_sk_to_u8vec(sk: PrivateEncKeyMlKem512): Uint8Array;
|
|
321
|
+
|
|
8
322
|
/**
|
|
9
323
|
* Instantiate a new client.
|
|
10
324
|
*
|
|
@@ -18,20 +332,40 @@ export function ml_kem_pke_encrypt(msg: Uint8Array, their_pk: PublicEncKeyMlKem5
|
|
|
18
332
|
* The "default" parameter choice is selected if no matching string is found.
|
|
19
333
|
*/
|
|
20
334
|
export function new_client(server_addrs: ServerIdAddr[], client_address_hex: string, fhe_parameter: string): Client;
|
|
21
|
-
|
|
22
|
-
export function ml_kem_pke_get_pk(sk: PrivateEncKeyMlKem512): PublicEncKeyMlKem512;
|
|
23
|
-
export function u8vec_to_private_sig_key(v: Uint8Array): PrivateSigKey;
|
|
24
|
-
export function public_sig_key_to_u8vec(pk: PublicSigKey): Uint8Array;
|
|
335
|
+
|
|
25
336
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* It's just here for completeness and tests.
|
|
337
|
+
* Create a new [ServerIdAddr] structure that holds an ID and an address
|
|
338
|
+
* which must be a valid EIP-55 address, notably prefixed with "0x".
|
|
29
339
|
*/
|
|
30
|
-
export function
|
|
31
|
-
|
|
32
|
-
export function
|
|
33
|
-
|
|
34
|
-
|
|
340
|
+
export function new_server_id_addr(id: number, addr: string): ServerIdAddr;
|
|
341
|
+
|
|
342
|
+
export function private_sig_key_to_u8vec(sk: PrivateSigKey): Uint8Array;
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Process the user_decryption response from Rust objects.
|
|
346
|
+
* Consider using [process_user_decryption_resp_from_js]
|
|
347
|
+
* when using the JS API.
|
|
348
|
+
* The result is a byte array representing a plaintext of any length.
|
|
349
|
+
*
|
|
350
|
+
* * `client` - client that wants to perform user_decryption.
|
|
351
|
+
*
|
|
352
|
+
* * `request` - the initial user_decryption request.
|
|
353
|
+
* Must be given if `verify` is true.
|
|
354
|
+
*
|
|
355
|
+
* * `eip712_domain` - the EIP-712 domain.
|
|
356
|
+
* Must be given if `verify` is true.
|
|
357
|
+
*
|
|
358
|
+
* * `agg_resp` - the vector of user_decryption responses.
|
|
359
|
+
*
|
|
360
|
+
* * `enc_pk` - The ephemeral public key.
|
|
361
|
+
*
|
|
362
|
+
* * `enc_sk` - The ephemeral secret key.
|
|
363
|
+
*
|
|
364
|
+
* * `verify` - Whether to perform signature verification for the response.
|
|
365
|
+
* It is insecure if `verify = false`!
|
|
366
|
+
*/
|
|
367
|
+
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[];
|
|
368
|
+
|
|
35
369
|
/**
|
|
36
370
|
* Process the user_decryption response from JavaScript objects.
|
|
37
371
|
* The returned result is a byte array representing a plaintext of any length,
|
|
@@ -94,294 +428,13 @@ export function get_server_addrs(client: Client): ServerIdAddr[];
|
|
|
94
428
|
* It is insecure if `verify = false`!
|
|
95
429
|
*/
|
|
96
430
|
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[];
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
export function ml_kem_pke_sk_len(): number;
|
|
103
|
-
export function private_sig_key_to_u8vec(sk: PrivateSigKey): Uint8Array;
|
|
431
|
+
|
|
432
|
+
export function public_sig_key_to_u8vec(pk: PublicSigKey): Uint8Array;
|
|
433
|
+
|
|
434
|
+
export function u8vec_to_ml_kem_pke_pk(v: Uint8Array): PublicEncKeyMlKem512;
|
|
435
|
+
|
|
104
436
|
export function u8vec_to_ml_kem_pke_sk(v: Uint8Array): PrivateEncKeyMlKem512;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
* when using the JS API.
|
|
110
|
-
* The result is a byte array representing a plaintext of any length.
|
|
111
|
-
*
|
|
112
|
-
* * `client` - client that wants to perform user_decryption.
|
|
113
|
-
*
|
|
114
|
-
* * `request` - the initial user_decryption request.
|
|
115
|
-
* Must be given if `verify` is true.
|
|
116
|
-
*
|
|
117
|
-
* * `eip712_domain` - the EIP-712 domain.
|
|
118
|
-
* Must be given if `verify` is true.
|
|
119
|
-
*
|
|
120
|
-
* * `agg_resp` - the vector of user_decryption responses.
|
|
121
|
-
*
|
|
122
|
-
* * `enc_pk` - The ephemeral public key.
|
|
123
|
-
*
|
|
124
|
-
* * `enc_sk` - The ephemeral secret key.
|
|
125
|
-
*
|
|
126
|
-
* * `verify` - Whether to perform signature verification for the response.
|
|
127
|
-
* It is insecure if `verify = false`!
|
|
128
|
-
*/
|
|
129
|
-
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[];
|
|
130
|
-
export function get_client_secret_key(client: Client): PrivateSigKey | undefined;
|
|
131
|
-
export function ml_kem_pke_pk_to_u8vec(pk: PublicEncKeyMlKem512): Uint8Array;
|
|
132
|
-
export function ml_kem_pke_sk_to_u8vec(sk: PrivateEncKeyMlKem512): Uint8Array;
|
|
133
|
-
export class CiphertextHandle {
|
|
134
|
-
private constructor();
|
|
135
|
-
free(): void;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Core Client
|
|
139
|
-
*
|
|
140
|
-
* Simple client to interact with the KMS servers. This can be seen as a proof-of-concept
|
|
141
|
-
* and reference code for validating the KMS. The logic supplied by the client will be
|
|
142
|
-
* distributed across the aggregator/proxy and smart contracts.
|
|
143
|
-
*/
|
|
144
|
-
export class Client {
|
|
145
|
-
private constructor();
|
|
146
|
-
free(): void;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Eip712 domain information.
|
|
150
|
-
* Any constraints specified in the [standard](<https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator>) _must_ be fulfilled.
|
|
151
|
-
* Furthermore, be aware that all parameters will eventually be parsed into Solidity types.
|
|
152
|
-
*/
|
|
153
|
-
export class Eip712DomainMsg {
|
|
154
|
-
private constructor();
|
|
155
|
-
free(): void;
|
|
156
|
-
name: string;
|
|
157
|
-
version: string;
|
|
158
|
-
chain_id: Uint8Array;
|
|
159
|
-
verifying_contract: string;
|
|
160
|
-
get salt(): Uint8Array | undefined;
|
|
161
|
-
set salt(value: Uint8Array | null | undefined);
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Validity of this struct is not checked.
|
|
165
|
-
*/
|
|
166
|
-
export class ParsedUserDecryptionRequest {
|
|
167
|
-
private constructor();
|
|
168
|
-
free(): void;
|
|
169
|
-
}
|
|
170
|
-
export class PrivateEncKeyMlKem512 {
|
|
171
|
-
private constructor();
|
|
172
|
-
free(): void;
|
|
173
|
-
}
|
|
174
|
-
export class PrivateSigKey {
|
|
175
|
-
private constructor();
|
|
176
|
-
free(): void;
|
|
177
|
-
}
|
|
178
|
-
export class PublicEncKeyMlKem512 {
|
|
179
|
-
private constructor();
|
|
180
|
-
free(): void;
|
|
181
|
-
}
|
|
182
|
-
export class PublicSigKey {
|
|
183
|
-
private constructor();
|
|
184
|
-
free(): void;
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* / A unique 32 Byte / 256 Bit ID, to be used to identify a request and
|
|
188
|
-
* / for retrieving the computed result later on.
|
|
189
|
-
* / Must be encoded in lower-case hex. The string must NOT contain a `0x` prefix.
|
|
190
|
-
*/
|
|
191
|
-
export class RequestId {
|
|
192
|
-
private constructor();
|
|
193
|
-
free(): void;
|
|
194
|
-
request_id: string;
|
|
195
|
-
}
|
|
196
|
-
export class ServerIdAddr {
|
|
197
|
-
private constructor();
|
|
198
|
-
free(): void;
|
|
199
|
-
}
|
|
200
|
-
export class TypedCiphertext {
|
|
201
|
-
private constructor();
|
|
202
|
-
free(): void;
|
|
203
|
-
/**
|
|
204
|
-
* The actual ciphertext to decrypt, taken directly from fhevm.
|
|
205
|
-
*/
|
|
206
|
-
ciphertext: Uint8Array;
|
|
207
|
-
/**
|
|
208
|
-
* The type of plaintext encrypted. The type should match FheType from tfhe-rs:
|
|
209
|
-
* <https://github.com/zama-ai/tfhe-rs/blob/main/tfhe/src/high_level_api/mod.rs>
|
|
210
|
-
*/
|
|
211
|
-
fhe_type: number;
|
|
212
|
-
/**
|
|
213
|
-
* The external handle of the ciphertext (the handle used in the copro).
|
|
214
|
-
*/
|
|
215
|
-
external_handle: Uint8Array;
|
|
216
|
-
/**
|
|
217
|
-
* The ciphertext format, see CiphertextFormat documentation for details.
|
|
218
|
-
* CiphertextFormat::default() is used if unspecified.
|
|
219
|
-
*/
|
|
220
|
-
ciphertext_format: number;
|
|
221
|
-
}
|
|
222
|
-
export class TypedPlaintext {
|
|
223
|
-
private constructor();
|
|
224
|
-
free(): void;
|
|
225
|
-
/**
|
|
226
|
-
* The actual plaintext in bytes.
|
|
227
|
-
*/
|
|
228
|
-
bytes: Uint8Array;
|
|
229
|
-
/**
|
|
230
|
-
* The type of plaintext encrypted. The type should match FheType from tfhe-rs:
|
|
231
|
-
* <https://github.com/zama-ai/tfhe-rs/blob/main/tfhe/src/high_level_api/mod.rs>
|
|
232
|
-
*/
|
|
233
|
-
fhe_type: number;
|
|
234
|
-
}
|
|
235
|
-
export class TypedSigncryptedCiphertext {
|
|
236
|
-
private constructor();
|
|
237
|
-
free(): void;
|
|
238
|
-
/**
|
|
239
|
-
* The type of plaintext encrypted. The type should match FheType from tfhe-rs:
|
|
240
|
-
* <https://github.com/zama-ai/tfhe-rs/blob/main/tfhe/src/high_level_api/mod.rs>
|
|
241
|
-
*/
|
|
242
|
-
fhe_type: number;
|
|
243
|
-
/**
|
|
244
|
-
* The signcrypted payload, using a hybrid encryption approach in
|
|
245
|
-
* sign-then-encrypt.
|
|
246
|
-
*/
|
|
247
|
-
signcrypted_ciphertext: Uint8Array;
|
|
248
|
-
/**
|
|
249
|
-
* The external handles that were originally in the request.
|
|
250
|
-
*/
|
|
251
|
-
external_handle: Uint8Array;
|
|
252
|
-
/**
|
|
253
|
-
* The packing factor determines whether the decrypted plaintext
|
|
254
|
-
* has a different way of packing compared to what is specified in the plaintext modulus.
|
|
255
|
-
*/
|
|
256
|
-
packing_factor: number;
|
|
257
|
-
}
|
|
258
|
-
export class UserDecryptionRequest {
|
|
259
|
-
private constructor();
|
|
260
|
-
free(): void;
|
|
261
|
-
/**
|
|
262
|
-
* The 32 Byte / 256 Bit ID of the user decryption request, without `0x`
|
|
263
|
-
* prefix. Future queries for the result must use this request ID.
|
|
264
|
-
*/
|
|
265
|
-
get request_id(): RequestId | undefined;
|
|
266
|
-
/**
|
|
267
|
-
* The 32 Byte / 256 Bit ID of the user decryption request, without `0x`
|
|
268
|
-
* prefix. Future queries for the result must use this request ID.
|
|
269
|
-
*/
|
|
270
|
-
set request_id(value: RequestId | null | undefined);
|
|
271
|
-
/**
|
|
272
|
-
* The list of ciphertexts to decrypt for the user.
|
|
273
|
-
*/
|
|
274
|
-
typed_ciphertexts: TypedCiphertext[];
|
|
275
|
-
/**
|
|
276
|
-
* The 32 Byte / 256 Bit key id to use for decryption. This is the request_id
|
|
277
|
-
* used for key generation
|
|
278
|
-
*/
|
|
279
|
-
get key_id(): RequestId | undefined;
|
|
280
|
-
/**
|
|
281
|
-
* The 32 Byte / 256 Bit key id to use for decryption. This is the request_id
|
|
282
|
-
* used for key generation
|
|
283
|
-
*/
|
|
284
|
-
set key_id(value: RequestId | null | undefined);
|
|
285
|
-
/**
|
|
286
|
-
* The client's (blockchain wallet) address, encoded using EIP-55. I.e. including `0x`.
|
|
287
|
-
*/
|
|
288
|
-
client_address: string;
|
|
289
|
-
/**
|
|
290
|
-
* Encoding of the user's public encryption key for this request.
|
|
291
|
-
* This must be a bincode (v.1) encoded ML-KEM 512 key.
|
|
292
|
-
*/
|
|
293
|
-
enc_key: Uint8Array;
|
|
294
|
-
/**
|
|
295
|
-
* The user's EIP712 domain. This MUST be present. Furthermore, the `verifying_contract` MUST be set and be distinct from `client_address`.
|
|
296
|
-
*/
|
|
297
|
-
get domain(): Eip712DomainMsg | undefined;
|
|
298
|
-
/**
|
|
299
|
-
* The user's EIP712 domain. This MUST be present. Furthermore, the `verifying_contract` MUST be set and be distinct from `client_address`.
|
|
300
|
-
*/
|
|
301
|
-
set domain(value: Eip712DomainMsg | null | undefined);
|
|
302
|
-
/**
|
|
303
|
-
* Extra data from the gateway.
|
|
304
|
-
*/
|
|
305
|
-
extra_data: Uint8Array;
|
|
306
|
-
/**
|
|
307
|
-
* MPC context ID which is used to identify the context to use for this request.
|
|
308
|
-
*
|
|
309
|
-
* NOTE: at the moment this can be None since we do not fully support multiple contexts.
|
|
310
|
-
* See <https://github.com/zama-ai/kms-internal/issues/2530>
|
|
311
|
-
*/
|
|
312
|
-
get context_id(): RequestId | undefined;
|
|
313
|
-
/**
|
|
314
|
-
* MPC context ID which is used to identify the context to use for this request.
|
|
315
|
-
*
|
|
316
|
-
* NOTE: at the moment this can be None since we do not fully support multiple contexts.
|
|
317
|
-
* See <https://github.com/zama-ai/kms-internal/issues/2530>
|
|
318
|
-
*/
|
|
319
|
-
set context_id(value: RequestId | null | undefined);
|
|
320
|
-
/**
|
|
321
|
-
* The epoch number placeholder (zama-ai/kms-internal#2743).
|
|
322
|
-
*/
|
|
323
|
-
get epoch_id(): RequestId | undefined;
|
|
324
|
-
/**
|
|
325
|
-
* The epoch number placeholder (zama-ai/kms-internal#2743).
|
|
326
|
-
*/
|
|
327
|
-
set epoch_id(value: RequestId | null | undefined);
|
|
328
|
-
}
|
|
329
|
-
export class UserDecryptionResponse {
|
|
330
|
-
private constructor();
|
|
331
|
-
free(): void;
|
|
332
|
-
signature: Uint8Array;
|
|
333
|
-
/**
|
|
334
|
-
* This is the external signature created from the Eip712 domain
|
|
335
|
-
* on the structure, where userDecryptedShare is bc2wrap::serialize(&payload)
|
|
336
|
-
* struct UserDecryptResponseVerification {
|
|
337
|
-
* bytes publicKey;
|
|
338
|
-
* uint256\[\] ctHandles;
|
|
339
|
-
* bytes userDecryptedShare; // serialization of payload
|
|
340
|
-
* bytes extraData;
|
|
341
|
-
* }
|
|
342
|
-
*/
|
|
343
|
-
external_signature: Uint8Array;
|
|
344
|
-
/**
|
|
345
|
-
* The actual \[UserDecryptionResponsePayload\].
|
|
346
|
-
*/
|
|
347
|
-
get payload(): UserDecryptionResponsePayload | undefined;
|
|
348
|
-
/**
|
|
349
|
-
* The actual \[UserDecryptionResponsePayload\].
|
|
350
|
-
*/
|
|
351
|
-
set payload(value: UserDecryptionResponsePayload | null | undefined);
|
|
352
|
-
/**
|
|
353
|
-
* Extra data used in the EIP712 signature - external_signature.
|
|
354
|
-
*/
|
|
355
|
-
extra_data: Uint8Array;
|
|
356
|
-
}
|
|
357
|
-
export class UserDecryptionResponsePayload {
|
|
358
|
-
private constructor();
|
|
359
|
-
free(): void;
|
|
360
|
-
/**
|
|
361
|
-
* The server's signature verification key, Encoded using SEC1.
|
|
362
|
-
* Needed to validate the response, but MUST also be linked to a list of
|
|
363
|
-
* trusted keys.
|
|
364
|
-
*/
|
|
365
|
-
verification_key: Uint8Array;
|
|
366
|
-
/**
|
|
367
|
-
* This is needed to ensure the response corresponds to the request.
|
|
368
|
-
* It is the digest of UserDecryptionLinker hashed using EIP712
|
|
369
|
-
* under the given domain in the request.
|
|
370
|
-
*/
|
|
371
|
-
digest: Uint8Array;
|
|
372
|
-
/**
|
|
373
|
-
* The resulting signcrypted ciphertexts, each ciphertext
|
|
374
|
-
* must be decrypted and then reconstructed with the other shares
|
|
375
|
-
* to produce the final plaintext.
|
|
376
|
-
*/
|
|
377
|
-
signcrypted_ciphertexts: TypedSigncryptedCiphertext[];
|
|
378
|
-
/**
|
|
379
|
-
* The ID of the MPC party doing the user decryption. Used for polynomial
|
|
380
|
-
* reconstruction.
|
|
381
|
-
*/
|
|
382
|
-
party_id: number;
|
|
383
|
-
/**
|
|
384
|
-
* The degree of the sharing scheme used.
|
|
385
|
-
*/
|
|
386
|
-
degree: number;
|
|
387
|
-
}
|
|
437
|
+
|
|
438
|
+
export function u8vec_to_private_sig_key(v: Uint8Array): PrivateSigKey;
|
|
439
|
+
|
|
440
|
+
export function u8vec_to_public_sig_key(v: Uint8Array): PublicSigKey;
|