node-tkms 0.9.1-rc3 → 0.11.0-rc3

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 CHANGED
@@ -1,24 +1,8 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- /**
4
- * @param {PublicSigKey} pk
5
- * @returns {Uint8Array}
6
- */
7
3
  export function public_sig_key_to_u8vec(pk: PublicSigKey): Uint8Array;
8
- /**
9
- * @param {Uint8Array} v
10
- * @returns {PublicSigKey}
11
- */
12
4
  export function u8vec_to_public_sig_key(v: Uint8Array): PublicSigKey;
13
- /**
14
- * @param {PrivateSigKey} sk
15
- * @returns {Uint8Array}
16
- */
17
5
  export function private_sig_key_to_u8vec(sk: PrivateSigKey): Uint8Array;
18
- /**
19
- * @param {Uint8Array} v
20
- * @returns {PrivateSigKey}
21
- */
22
6
  export function u8vec_to_private_sig_key(v: Uint8Array): PrivateSigKey;
23
7
  /**
24
8
  * Instantiate a new client.
@@ -29,71 +13,20 @@ export function u8vec_to_private_sig_key(v: Uint8Array): PrivateSigKey;
29
13
  * * `client_address_hex` - the client (wallet) address in hex,
30
14
  * must be prefixed with "0x".
31
15
  *
32
- * * `param_choice` - the parameter choice, which can be either `"test"` or `"default"`.
16
+ * * `fhe_parameter` - the parameter choice, which can be either `"test"` or `"default"`.
33
17
  * The "default" parameter choice is selected if no matching string is found.
34
- * @param {(string)[]} server_addrs
35
- * @param {string} client_address_hex
36
- * @param {string} param_choice
37
- * @returns {Client}
38
- */
39
- export function new_client(server_addrs: (string)[], client_address_hex: string, param_choice: string): Client;
40
- /**
41
- * @param {Client} client
42
- * @returns {(string)[]}
43
18
  */
19
+ export function new_client(server_addrs: (string)[], client_address_hex: string, fhe_parameter: string): Client;
44
20
  export function get_server_addrs(client: Client): (string)[];
45
- /**
46
- * @param {Client} client
47
- * @returns {PrivateSigKey | undefined}
48
- */
49
21
  export function get_client_secret_key(client: Client): PrivateSigKey | undefined;
50
- /**
51
- * @param {Client} client
52
- * @returns {string}
53
- */
54
22
  export function get_client_address(client: Client): string;
55
- /**
56
- * @returns {PrivateEncKey}
57
- */
58
23
  export function cryptobox_keygen(): PrivateEncKey;
59
- /**
60
- * @param {PrivateEncKey} sk
61
- * @returns {PublicEncKey}
62
- */
63
24
  export function cryptobox_get_pk(sk: PrivateEncKey): PublicEncKey;
64
- /**
65
- * @param {PublicEncKey} pk
66
- * @returns {Uint8Array}
67
- */
68
25
  export function cryptobox_pk_to_u8vec(pk: PublicEncKey): Uint8Array;
69
- /**
70
- * @param {PrivateEncKey} sk
71
- * @returns {Uint8Array}
72
- */
73
26
  export function cryptobox_sk_to_u8vec(sk: PrivateEncKey): Uint8Array;
74
- /**
75
- * @param {Uint8Array} v
76
- * @returns {PublicEncKey}
77
- */
78
27
  export function u8vec_to_cryptobox_pk(v: Uint8Array): PublicEncKey;
79
- /**
80
- * @param {Uint8Array} v
81
- * @returns {PrivateEncKey}
82
- */
83
28
  export function u8vec_to_cryptobox_sk(v: Uint8Array): PrivateEncKey;
84
- /**
85
- * @param {Uint8Array} msg
86
- * @param {PublicEncKey} their_pk
87
- * @param {PrivateEncKey} my_sk
88
- * @returns {CryptoBoxCt}
89
- */
90
29
  export function cryptobox_encrypt(msg: Uint8Array, their_pk: PublicEncKey, my_sk: PrivateEncKey): CryptoBoxCt;
91
- /**
92
- * @param {CryptoBoxCt} ct
93
- * @param {PrivateEncKey} my_sk
94
- * @param {PublicEncKey} their_pk
95
- * @returns {Uint8Array}
96
- */
97
30
  export function cryptobox_decrypt(ct: CryptoBoxCt, my_sk: PrivateEncKey, their_pk: PublicEncKey): Uint8Array;
98
31
  /**
99
32
  * Process the reencryption response from JavaScript objects.
@@ -153,16 +86,8 @@ export function cryptobox_decrypt(ct: CryptoBoxCt, my_sk: PrivateEncKey, their_p
153
86
  *
154
87
  * * `verify` - Whether to perform signature verification for the response.
155
88
  * It is insecure if `verify = false`!
156
- * @param {Client} client
157
- * @param {any} request
158
- * @param {any} eip712_domain
159
- * @param {any} agg_resp
160
- * @param {PublicEncKey} enc_pk
161
- * @param {PrivateEncKey} enc_sk
162
- * @param {boolean} verify
163
- * @returns {Uint8Array}
164
89
  */
165
- export function process_reencryption_resp_from_js(client: Client, request: any, eip712_domain: any, agg_resp: any, enc_pk: PublicEncKey, enc_sk: PrivateEncKey, verify: boolean): Uint8Array;
90
+ export function process_reencryption_resp_from_js(client: Client, request: any, eip712_domain: any, agg_resp: any, enc_pk: PublicEncKey, enc_sk: PrivateEncKey, verify: boolean): (TypedPlaintext)[];
166
91
  /**
167
92
  * Process the reencryption response from Rust objects.
168
93
  * Consider using [process_reencryption_resp_from_js]
@@ -185,16 +110,8 @@ export function process_reencryption_resp_from_js(client: Client, request: any,
185
110
  *
186
111
  * * `verify` - Whether to perform signature verification for the response.
187
112
  * It is insecure if `verify = false`!
188
- * @param {Client} client
189
- * @param {ParsedReencryptionRequest | undefined} request
190
- * @param {Eip712DomainMsg | undefined} eip712_domain
191
- * @param {(ReencryptionResponse)[]} agg_resp
192
- * @param {PublicEncKey} enc_pk
193
- * @param {PrivateEncKey} enc_sk
194
- * @param {boolean} verify
195
- * @returns {Uint8Array}
196
113
  */
197
- export function process_reencryption_resp(client: Client, request: ParsedReencryptionRequest | undefined, eip712_domain: Eip712DomainMsg | undefined, agg_resp: (ReencryptionResponse)[], enc_pk: PublicEncKey, enc_sk: PrivateEncKey, verify: boolean): Uint8Array;
114
+ export function process_reencryption_resp(client: Client, request: ParsedReencryptionRequest | undefined, eip712_domain: Eip712DomainMsg | undefined, agg_resp: (ReencryptionResponse)[], enc_pk: PublicEncKey, enc_sk: PrivateEncKey, verify: boolean): (TypedPlaintext)[];
198
115
  /**
199
116
  * The plaintext types that can be encrypted in a fhevm ciphertext.
200
117
  */
@@ -212,6 +129,10 @@ export enum FheType {
212
129
  Euint1024 = 10,
213
130
  Euint2048 = 11,
214
131
  }
132
+ export class CiphertextHandle {
133
+ private constructor();
134
+ free(): void;
135
+ }
215
136
  /**
216
137
  * Core Client
217
138
  *
@@ -220,9 +141,11 @@ export enum FheType {
220
141
  * distributed across the aggregator/proxy and smart contracts.
221
142
  */
222
143
  export class Client {
144
+ private constructor();
223
145
  free(): void;
224
146
  }
225
147
  export class CryptoBoxCt {
148
+ private constructor();
226
149
  free(): void;
227
150
  }
228
151
  /**
@@ -231,134 +154,172 @@ export class CryptoBoxCt {
231
154
  * solidity types
232
155
  */
233
156
  export class Eip712DomainMsg {
157
+ private constructor();
234
158
  free(): void;
235
- chain_id: Uint8Array;
236
159
  name: string;
237
- salt?: Uint8Array;
238
- verifying_contract: string;
239
160
  version: string;
161
+ chain_id: Uint8Array;
162
+ verifying_contract: string;
163
+ salt?: Uint8Array;
240
164
  }
241
165
  /**
242
166
  * Validity of this struct is not checked.
243
167
  */
244
168
  export class ParsedReencryptionRequest {
169
+ private constructor();
245
170
  free(): void;
246
171
  }
247
172
  export class PrivateEncKey {
173
+ private constructor();
248
174
  free(): void;
249
175
  }
250
176
  export class PrivateSigKey {
177
+ private constructor();
251
178
  free(): void;
252
179
  }
253
180
  export class PublicEncKey {
181
+ private constructor();
254
182
  free(): void;
255
183
  }
256
184
  export class PublicSigKey {
185
+ private constructor();
257
186
  free(): void;
258
187
  }
259
188
  export class ReencryptionRequest {
189
+ private constructor();
260
190
  free(): void;
261
- domain?: Eip712DomainMsg;
262
191
  payload?: ReencryptionRequestPayload;
263
- /**
264
- * The ID that identifies this request.
265
- * Future queries for the result must use this request ID.
266
- */
192
+ domain?: Eip712DomainMsg;
193
+ /**
194
+ * The ID that identifies this request.
195
+ * Future queries for the result must use this request ID.
196
+ */
267
197
  request_id?: RequestId;
268
- /**
269
- * Signature of the serialization of \[ReencryptionRequestPayload\].
270
- */
271
- signature: Uint8Array;
272
198
  }
273
199
  export class ReencryptionRequestPayload {
200
+ private constructor();
274
201
  free(): void;
275
- /**
276
- * The actual ciphertext to decrypt, taken directly from the fhevm.
277
- * When creating the payload, this field may be empty,
278
- * it is the responsibility of the gateway to fetch the
279
- * ciphertext for the given digest below.
280
- */
281
- ciphertext?: Uint8Array;
282
- /**
283
- * The SHA3 digest of the ciphertext above.
284
- */
285
- ciphertext_digest: Uint8Array;
286
- /**
287
- * The client's (blockchain wallet) address,
288
- * encoded using EIP-55.
289
- */
202
+ /**
203
+ * The client's (blockchain wallet) address,
204
+ * encoded using EIP-55.
205
+ */
290
206
  client_address: string;
291
- /**
292
- * Encoding of the user's public encryption key for this request.
293
- * Encoding using the default encoding of libsodium, i.e. the 32 bytes of a
294
- * Montgomery point.
295
- */
207
+ /**
208
+ * Encoding of the user's public encryption key for this request.
209
+ * Encoding using the default encoding of libsodium, i.e. the 32 bytes of a
210
+ * Montgomery point.
211
+ */
296
212
  enc_key: Uint8Array;
297
- /**
298
- * The type of plaintext encrypted.
299
- */
300
- fhe_type: number;
301
- /**
302
- * The key id to use for decryption. Will be the request_id used during key
303
- * generation
304
- */
213
+ /**
214
+ * The key id to use for decryption. Will be the request_id used during key
215
+ * generation
216
+ */
305
217
  key_id?: RequestId;
306
- /**
307
- * Version of the request format.
308
- */
309
- version: number;
218
+ /**
219
+ * The list of ciphertexts to reencrypt.
220
+ */
221
+ typed_ciphertexts: (TypedCiphertext)[];
310
222
  }
311
223
  export class ReencryptionResponse {
224
+ private constructor();
312
225
  free(): void;
313
- /**
314
- * Signature of the serialization of \[ReencryptionResponsePayload\].
315
- */
316
- payload?: ReencryptionResponsePayload;
317
226
  signature: Uint8Array;
227
+ /**
228
+ * Signature of the serialization of \[ReencryptionResponsePayload\].
229
+ */
230
+ payload?: ReencryptionResponsePayload;
318
231
  }
319
232
  export class ReencryptionResponsePayload {
233
+ private constructor();
320
234
  free(): void;
321
- /**
322
- * The degree of the sharing scheme used.
323
- */
324
- degree: number;
325
- /**
326
- * The concatenation of two digests:
327
- * (eip712_signing_hash(pk, domain) || ciphertext digest).
328
- * This is needed to ensure the response corresponds to the request.
329
- */
235
+ /**
236
+ * The server's signature verification key.
237
+ * Encoded using SEC1.
238
+ * Needed to validate the response, but MUST also be linked to a list of
239
+ * trusted keys.
240
+ */
241
+ verification_key: Uint8Array;
242
+ /**
243
+ * The concatenation of two digests:
244
+ * (eip712_signing_hash(pk, domain) || ciphertext digest).
245
+ * This is needed to ensure the response corresponds to the request.
246
+ */
330
247
  digest: Uint8Array;
331
- /**
332
- * The type of plaintext encrypted.
333
- */
334
- fhe_type: number;
335
- /**
336
- * The ID of the MPC party doing the reencryption. Used for polynomial
337
- * reconstruction.
338
- */
248
+ signcrypted_ciphertexts: (TypedSigncryptedCiphertext)[];
249
+ /**
250
+ * The ID of the MPC party doing the reencryption. Used for polynomial
251
+ * reconstruction.
252
+ */
339
253
  party_id: number;
340
- /**
341
- * The signcrypted payload, using a hybrid encryption approach in
342
- * sign-then-encrypt.
343
- */
344
- signcrypted_ciphertext: Uint8Array;
345
- /**
346
- * The server's signature verification key.
347
- * Encoded using SEC1.
348
- * Needed to validate the response, but MUST also be linked to a list of
349
- * trusted keys.
350
- */
351
- verification_key: Uint8Array;
352
- /**
353
- * Version of the response format.
354
- */
355
- version: number;
254
+ /**
255
+ * The degree of the sharing scheme used.
256
+ */
257
+ degree: number;
258
+ /**
259
+ * This is the external signature created from the Eip712 domain
260
+ * on the structure, where reencryptedShare is bincode::serialize(&signcrypted_ciphertexts)
261
+ * struct UserDecryptionResult {
262
+ * bytes publicKey;
263
+ * uint256\[\] handles;
264
+ * bytes reencryptedShare;
265
+ * }
266
+ */
267
+ external_signature: Uint8Array;
356
268
  }
357
269
  /**
358
270
  * Simple response to return an ID, to be used to retrieve the computed result
359
271
  * later on.
360
272
  */
361
273
  export class RequestId {
274
+ private constructor();
362
275
  free(): void;
363
276
  request_id: string;
364
277
  }
278
+ export class TypedCiphertext {
279
+ private constructor();
280
+ free(): void;
281
+ /**
282
+ * The actual ciphertext to decrypt, taken directly from the fhevm.
283
+ */
284
+ ciphertext: Uint8Array;
285
+ /**
286
+ * The type of plaintext encrypted.
287
+ */
288
+ fhe_type: number;
289
+ /**
290
+ * The external handle of the ciphertext (the handle used in the copro).
291
+ */
292
+ external_handle: Uint8Array;
293
+ }
294
+ /**
295
+ * The typed plaintext type, which is the result of decryption.
296
+ */
297
+ export class TypedPlaintext {
298
+ private constructor();
299
+ free(): void;
300
+ /**
301
+ * The actual plaintext in bytes.
302
+ */
303
+ bytes: Uint8Array;
304
+ /**
305
+ * The type of plaintext encrypted.
306
+ */
307
+ fhe_type: number;
308
+ }
309
+ export class TypedSigncryptedCiphertext {
310
+ private constructor();
311
+ free(): void;
312
+ /**
313
+ * The type of plaintext encrypted.
314
+ */
315
+ fhe_type: number;
316
+ /**
317
+ * The signcrypted payload, using a hybrid encryption approach in
318
+ * sign-then-encrypt.
319
+ */
320
+ signcrypted_ciphertext: Uint8Array;
321
+ /**
322
+ * The external handles that were originally in the request.
323
+ */
324
+ external_handle: Uint8Array;
325
+ }