node-tkms 0.9.0-rc11 → 0.9.0-rc21

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,202 +1,203 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
- * @param {PublicSigKey} pk
5
- * @returns {Uint8Array}
6
- */
4
+ * @param {PublicSigKey} pk
5
+ * @returns {Uint8Array}
6
+ */
7
7
  export function public_sig_key_to_u8vec(pk: PublicSigKey): Uint8Array;
8
8
  /**
9
- * @param {Uint8Array} v
10
- * @returns {PublicSigKey}
11
- */
9
+ * @param {Uint8Array} v
10
+ * @returns {PublicSigKey}
11
+ */
12
12
  export function u8vec_to_public_sig_key(v: Uint8Array): PublicSigKey;
13
13
  /**
14
- * @param {PrivateSigKey} sk
15
- * @returns {Uint8Array}
16
- */
14
+ * @param {PrivateSigKey} sk
15
+ * @returns {Uint8Array}
16
+ */
17
17
  export function private_sig_key_to_u8vec(sk: PrivateSigKey): Uint8Array;
18
18
  /**
19
- * @param {Uint8Array} v
20
- * @returns {PrivateSigKey}
21
- */
19
+ * @param {Uint8Array} v
20
+ * @returns {PrivateSigKey}
21
+ */
22
22
  export function u8vec_to_private_sig_key(v: Uint8Array): PrivateSigKey;
23
23
  /**
24
- * Instantiate a new client.
25
- *
26
- * * `server_pks` - a list of KMS server signature public keys,
27
- * which can parsed using [u8vec_to_public_sig_key].
28
- *
29
- * * `client_address_hex` - the client (wallet) address in hex,
30
- * must be prefixed with "0x".
31
- *
32
- * * `param_choice` - the parameter choice, which can be either `"test"` or `"default"`.
33
- * 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
- */
24
+ * Instantiate a new client.
25
+ *
26
+ * * `server_addrs` - a list of KMS server EIP-55 addresses,
27
+ * must be prefixed with "0x".
28
+ *
29
+ * * `client_address_hex` - the client (wallet) address in hex,
30
+ * must be prefixed with "0x".
31
+ *
32
+ * * `param_choice` - the parameter choice, which can be either `"test"` or `"default"`.
33
+ * 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
39
  export function new_client(server_addrs: (string)[], client_address_hex: string, param_choice: string): Client;
40
40
  /**
41
- * @param {Client} client
42
- * @returns {(string)[]}
43
- */
41
+ * @param {Client} client
42
+ * @returns {(string)[]}
43
+ */
44
44
  export function get_server_addrs(client: Client): (string)[];
45
45
  /**
46
- * @param {Client} client
47
- * @returns {PrivateSigKey | undefined}
48
- */
46
+ * @param {Client} client
47
+ * @returns {PrivateSigKey | undefined}
48
+ */
49
49
  export function get_client_secret_key(client: Client): PrivateSigKey | undefined;
50
50
  /**
51
- * @param {Client} client
52
- * @returns {string}
53
- */
51
+ * @param {Client} client
52
+ * @returns {string}
53
+ */
54
54
  export function get_client_address(client: Client): string;
55
55
  /**
56
- * @returns {PrivateEncKey}
57
- */
56
+ * @returns {PrivateEncKey}
57
+ */
58
58
  export function cryptobox_keygen(): PrivateEncKey;
59
59
  /**
60
- * @param {PrivateEncKey} sk
61
- * @returns {PublicEncKey}
62
- */
60
+ * @param {PrivateEncKey} sk
61
+ * @returns {PublicEncKey}
62
+ */
63
63
  export function cryptobox_get_pk(sk: PrivateEncKey): PublicEncKey;
64
64
  /**
65
- * @param {PublicEncKey} pk
66
- * @returns {Uint8Array}
67
- */
65
+ * @param {PublicEncKey} pk
66
+ * @returns {Uint8Array}
67
+ */
68
68
  export function cryptobox_pk_to_u8vec(pk: PublicEncKey): Uint8Array;
69
69
  /**
70
- * @param {PrivateEncKey} sk
71
- * @returns {Uint8Array}
72
- */
70
+ * @param {PrivateEncKey} sk
71
+ * @returns {Uint8Array}
72
+ */
73
73
  export function cryptobox_sk_to_u8vec(sk: PrivateEncKey): Uint8Array;
74
74
  /**
75
- * @param {Uint8Array} v
76
- * @returns {PublicEncKey}
77
- */
75
+ * @param {Uint8Array} v
76
+ * @returns {PublicEncKey}
77
+ */
78
78
  export function u8vec_to_cryptobox_pk(v: Uint8Array): PublicEncKey;
79
79
  /**
80
- * @param {Uint8Array} v
81
- * @returns {PrivateEncKey}
82
- */
80
+ * @param {Uint8Array} v
81
+ * @returns {PrivateEncKey}
82
+ */
83
83
  export function u8vec_to_cryptobox_sk(v: Uint8Array): PrivateEncKey;
84
84
  /**
85
- * @param {Uint8Array} msg
86
- * @param {PublicEncKey} their_pk
87
- * @param {PrivateEncKey} my_sk
88
- * @returns {CryptoBoxCt}
89
- */
85
+ * @param {Uint8Array} msg
86
+ * @param {PublicEncKey} their_pk
87
+ * @param {PrivateEncKey} my_sk
88
+ * @returns {CryptoBoxCt}
89
+ */
90
90
  export function cryptobox_encrypt(msg: Uint8Array, their_pk: PublicEncKey, my_sk: PrivateEncKey): CryptoBoxCt;
91
91
  /**
92
- * @param {CryptoBoxCt} ct
93
- * @param {PrivateEncKey} my_sk
94
- * @param {PublicEncKey} their_pk
95
- * @returns {Uint8Array}
96
- */
92
+ * @param {CryptoBoxCt} ct
93
+ * @param {PrivateEncKey} my_sk
94
+ * @param {PublicEncKey} their_pk
95
+ * @returns {Uint8Array}
96
+ */
97
97
  export function cryptobox_decrypt(ct: CryptoBoxCt, my_sk: PrivateEncKey, their_pk: PublicEncKey): Uint8Array;
98
98
  /**
99
- * Process the reencryption response from JavaScript objects.
100
- * The result is a byte array representing a plaintext of any length.
101
- *
102
- * * `client` - client that wants to perform reencryption.
103
- *
104
- * * `request` - the initial reencryption request JS object.
105
- * It can be set to null if `verify` is false.
106
- * Otherwise the caller needs to give the following JS object.
107
- * Note that `client_address` and `eip712_verifying_contract` follow EIP-55.
108
- * ```
109
- * {
110
- * signature: '15a4f9a8eb61459cfba7d103d8f911fb04ce91ecf841b34c49c0d56a70b896d20cbc31986188f91efc3842b7df215cee8acb40178daedb8b63d0ba5d199bce121c',
111
- * client_address: '0x17853A630aAe15AED549B2B874de08B73C0F59c5',
112
- * enc_key: '2000000000000000df2fcacb774f03187f3802a27259f45c06d33cefa68d9c53426b15ad531aa822',
113
- * ciphertext_digest: '0748b542afe2353c86cb707e3d21044b0be1fd18efc7cbaa6a415af055bfb358',
114
- * eip712_verifying_contract: '0x66f9664f97F2b50F62D13eA064982f936dE76657'
115
- * }
116
- * ```
117
- *
118
- * * `eip712_domain` - the EIP-712 domain JS object.
119
- * It can be set to null if `verify` is false.
120
- * Otherwise the caller needs to give the following JS object.
121
- * Note that `salt` is optional and `verifying_contract` follows EIP-55,
122
- * additionally, `chain_id` is an array of u8.
123
- * ```
124
- * {
125
- * name: 'Authorization token',
126
- * version: '1',
127
- * chain_id: [
128
- * 70, 31, 0, 0, 0, 0, 0, 0, 0,
129
- * 0, 0, 0, 0, 0, 0, 0, 0, 0,
130
- * 0, 0, 0, 0, 0, 0, 0, 0, 0,
131
- * 0, 0, 0, 0, 0
132
- * ],
133
- * verifying_contract: '0x66f9664f97F2b50F62D13eA064982f936dE76657',
134
- * salt: []
135
- * }
136
- * ```
137
- *
138
- * * `agg_resp` - the response JS object from the gateway.
139
- * It has two fields like so, both are hex encoded byte arrays.
140
- * ```
141
- * [
142
- * {
143
- * signature: '69e7e040cab157aa819015b321c012dccb1545ffefd325b359b492653f0347517e28e66c572cdc299e259024329859ff9fcb0096e1ce072af0b6e1ca1fe25ec6',
144
- * payload: '0100000029...'
145
- * }
146
- * ]
147
- * ```
148
- *
149
- * * `enc_pk` - The ephemeral public key.
150
- *
151
- * * `enc_sk` - The ephemeral secret key.
152
- *
153
- * * `verify` - Whether to perform signature verification for the response.
154
- * It is insecure if `verify = false`!
155
- * @param {Client} client
156
- * @param {any} request
157
- * @param {any} eip712_domain
158
- * @param {any} agg_resp
159
- * @param {PublicEncKey} enc_pk
160
- * @param {PrivateEncKey} enc_sk
161
- * @param {boolean} verify
162
- * @returns {Uint8Array}
163
- */
99
+ * Process the reencryption response from JavaScript objects.
100
+ * The returned result is a byte array representing a plaintext of any length,
101
+ * postprocessing is returned to turn it into an integer.
102
+ *
103
+ * * `client` - client that wants to perform reencryption.
104
+ *
105
+ * * `request` - the initial reencryption request JS object.
106
+ * It can be set to null if `verify` is false.
107
+ * Otherwise the caller needs to give the following JS object.
108
+ * Note that `client_address` and `eip712_verifying_contract` follow EIP-55.
109
+ * ```
110
+ * {
111
+ * signature: '15a4f9a8eb61459cfba7d103d8f911fb04ce91ecf841b34c49c0d56a70b896d20cbc31986188f91efc3842b7df215cee8acb40178daedb8b63d0ba5d199bce121c',
112
+ * client_address: '0x17853A630aAe15AED549B2B874de08B73C0F59c5',
113
+ * enc_key: '2000000000000000df2fcacb774f03187f3802a27259f45c06d33cefa68d9c53426b15ad531aa822',
114
+ * ciphertext_handle: '0748b542afe2353c86cb707e3d21044b0be1fd18efc7cbaa6a415af055bfb358',
115
+ * eip712_verifying_contract: '0x66f9664f97F2b50F62D13eA064982f936dE76657'
116
+ * }
117
+ * ```
118
+ *
119
+ * * `eip712_domain` - the EIP-712 domain JS object.
120
+ * It can be set to null if `verify` is false.
121
+ * Otherwise the caller needs to give the following JS object.
122
+ * Note that `salt` is optional and `verifying_contract` follows EIP-55,
123
+ * additionally, `chain_id` is an array of u8.
124
+ * ```
125
+ * {
126
+ * name: 'Authorization token',
127
+ * version: '1',
128
+ * chain_id: [
129
+ * 70, 31, 0, 0, 0, 0, 0, 0, 0,
130
+ * 0, 0, 0, 0, 0, 0, 0, 0, 0,
131
+ * 0, 0, 0, 0, 0, 0, 0, 0, 0,
132
+ * 0, 0, 0, 0, 0
133
+ * ],
134
+ * verifying_contract: '0x66f9664f97F2b50F62D13eA064982f936dE76657',
135
+ * salt: []
136
+ * }
137
+ * ```
138
+ *
139
+ * * `agg_resp` - the response JS object from the gateway.
140
+ * It has two fields like so, both are hex encoded byte arrays.
141
+ * ```
142
+ * [
143
+ * {
144
+ * signature: '69e7e040cab157aa819015b321c012dccb1545ffefd325b359b492653f0347517e28e66c572cdc299e259024329859ff9fcb0096e1ce072af0b6e1ca1fe25ec6',
145
+ * payload: '0100000029...'
146
+ * }
147
+ * ]
148
+ * ```
149
+ *
150
+ * * `enc_pk` - The ephemeral public key.
151
+ *
152
+ * * `enc_sk` - The ephemeral secret key.
153
+ *
154
+ * * `verify` - Whether to perform signature verification for the response.
155
+ * 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
+ */
164
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;
165
166
  /**
166
- * Process the reencryption response from Rust objects.
167
- * Consider using [process_reencryption_resp_from_js]
168
- * when using the JS API.
169
- * The result is a byte array representing a plaintext of any length.
170
- *
171
- * * `client` - client that wants to perform reencryption.
172
- *
173
- * * `request` - the initial reencryption request.
174
- * Must be given if `verify` is true.
175
- *
176
- * * `eip712_domain` - the EIP-712 domain.
177
- * Must be given if `verify` is true.
178
- *
179
- * * `agg_resp` - the vector of reencryption responses.
180
- *
181
- * * `enc_pk` - The ephemeral public key.
182
- *
183
- * * `enc_sk` - The ephemeral secret key.
184
- *
185
- * * `verify` - Whether to perform signature verification for the response.
186
- * It is insecure if `verify = false`!
187
- * @param {Client} client
188
- * @param {ParsedReencryptionRequest | undefined} request
189
- * @param {Eip712DomainMsg | undefined} eip712_domain
190
- * @param {(ReencryptionResponse)[]} agg_resp
191
- * @param {PublicEncKey} enc_pk
192
- * @param {PrivateEncKey} enc_sk
193
- * @param {boolean} verify
194
- * @returns {Uint8Array}
195
- */
167
+ * Process the reencryption response from Rust objects.
168
+ * Consider using [process_reencryption_resp_from_js]
169
+ * when using the JS API.
170
+ * The result is a byte array representing a plaintext of any length.
171
+ *
172
+ * * `client` - client that wants to perform reencryption.
173
+ *
174
+ * * `request` - the initial reencryption request.
175
+ * Must be given if `verify` is true.
176
+ *
177
+ * * `eip712_domain` - the EIP-712 domain.
178
+ * Must be given if `verify` is true.
179
+ *
180
+ * * `agg_resp` - the vector of reencryption responses.
181
+ *
182
+ * * `enc_pk` - The ephemeral public key.
183
+ *
184
+ * * `enc_sk` - The ephemeral secret key.
185
+ *
186
+ * * `verify` - Whether to perform signature verification for the response.
187
+ * 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
+ */
196
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;
197
198
  /**
198
- * The plaintext types that can be encrypted in a fhevm ciphertext.
199
- */
199
+ * The plaintext types that can be encrypted in a fhevm ciphertext.
200
+ */
200
201
  export enum FheType {
201
202
  Ebool = 0,
202
203
  Euint4 = 1,
@@ -212,194 +213,154 @@ export enum FheType {
212
213
  Euint2048 = 11,
213
214
  }
214
215
  /**
215
- * Simple client to interact with the KMS servers. This can be seen as a proof-of-concept
216
- * and reference code for validating the KMS. The logic supplied by the client will be
217
- * distributed across the aggregator/proxy and smart contracts.
218
- */
216
+ * Simple client to interact with the KMS servers. This can be seen as a proof-of-concept
217
+ * and reference code for validating the KMS. The logic supplied by the client will be
218
+ * distributed across the aggregator/proxy and smart contracts.
219
+ */
219
220
  export class Client {
220
221
  free(): void;
221
222
  }
222
- /**
223
- */
224
223
  export class CryptoBoxCt {
225
224
  free(): void;
226
225
  }
227
226
  /**
228
- * <https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator>
229
- * eventually chain_id, verifying_contract and salt will be parsed in to
230
- * solidity types
231
- */
227
+ * <https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator>
228
+ * eventually chain_id, verifying_contract and salt will be parsed in to
229
+ * solidity types
230
+ */
232
231
  export class Eip712DomainMsg {
233
232
  free(): void;
234
- /**
235
- */
236
233
  chain_id: Uint8Array;
237
- /**
238
- */
239
234
  name: string;
240
- /**
241
- */
242
- salt: Uint8Array;
243
- /**
244
- */
235
+ salt?: Uint8Array;
245
236
  verifying_contract: string;
246
- /**
247
- */
248
237
  version: string;
249
238
  }
250
239
  /**
251
- * Validity of this struct is not checked.
252
- */
240
+ * Validity of this struct is not checked.
241
+ */
253
242
  export class ParsedReencryptionRequest {
254
243
  free(): void;
255
244
  }
256
- /**
257
- */
258
245
  export class Plaintext {
259
246
  free(): void;
260
- /**
261
- */
262
247
  bytes: Uint8Array;
263
248
  }
264
- /**
265
- */
266
249
  export class PrivateEncKey {
267
250
  free(): void;
268
251
  }
269
- /**
270
- */
271
252
  export class PrivateSigKey {
272
253
  free(): void;
273
254
  }
274
- /**
275
- */
276
255
  export class PublicEncKey {
277
256
  free(): void;
278
257
  }
279
- /**
280
- */
281
258
  export class PublicSigKey {
282
259
  free(): void;
283
260
  }
284
- /**
285
- */
286
261
  export class ReencryptionRequest {
287
262
  free(): void;
288
- /**
289
- */
290
263
  domain?: Eip712DomainMsg;
291
- /**
292
- */
293
264
  payload?: ReencryptionRequestPayload;
294
265
  /**
295
- * The ID that identifies this request.
296
- * Future queries for the result must use this request ID.
297
- */
266
+ * The ID that identifies this request.
267
+ * Future queries for the result must use this request ID.
268
+ */
298
269
  request_id?: RequestId;
299
270
  /**
300
- * Signature of the serialization of \[ReencryptionRequestPayload\].
301
- */
271
+ * Signature of the serialization of \[ReencryptionRequestPayload\].
272
+ */
302
273
  signature: Uint8Array;
303
274
  }
304
- /**
305
- */
306
275
  export class ReencryptionRequestPayload {
307
276
  free(): void;
308
277
  /**
309
- * The actual ciphertext to decrypt, taken directly from the fhevm.
310
- * When creating the payload, this field may be empty,
311
- * it is the responsibility of the gateway to fetch the
312
- * ciphertext for the given digest below.
313
- */
278
+ * The actual ciphertext to decrypt, taken directly from the fhevm.
279
+ * When creating the payload, this field may be empty,
280
+ * it is the responsibility of the gateway to fetch the
281
+ * ciphertext for the given digest below.
282
+ */
314
283
  ciphertext?: Uint8Array;
315
284
  /**
316
- * The SHA3 digest of the ciphertext above.
317
- */
285
+ * The SHA3 digest of the ciphertext above.
286
+ */
318
287
  ciphertext_digest: Uint8Array;
319
288
  /**
320
- * The client's (blockchain wallet) address,
321
- * encoded using EIP-55.
322
- */
289
+ * The client's (blockchain wallet) address,
290
+ * encoded using EIP-55.
291
+ */
323
292
  client_address: string;
324
293
  /**
325
- * Encoding of the user's public encryption key for this request.
326
- * Encoding using the default encoding of libsodium, i.e. the 32 bytes of a
327
- * Montgomery point.
328
- */
294
+ * Encoding of the user's public encryption key for this request.
295
+ * Encoding using the default encoding of libsodium, i.e. the 32 bytes of a
296
+ * Montgomery point.
297
+ */
329
298
  enc_key: Uint8Array;
330
299
  /**
331
- * The type of plaintext encrypted.
332
- */
300
+ * The type of plaintext encrypted.
301
+ */
333
302
  fhe_type: number;
334
303
  /**
335
- * The key id to use for decryption. Will be the request_id used during key
336
- * generation
337
- */
304
+ * The key id to use for decryption. Will be the request_id used during key
305
+ * generation
306
+ */
338
307
  key_id?: RequestId;
339
308
  /**
340
- * Version of the request format.
341
- */
309
+ * Version of the request format.
310
+ */
342
311
  version: number;
343
312
  }
344
- /**
345
- */
346
313
  export class ReencryptionResponse {
347
314
  free(): void;
348
315
  /**
349
- * Signature of the serialization of \[ReencryptionResponsePayload\].
350
- */
316
+ * Signature of the serialization of \[ReencryptionResponsePayload\].
317
+ */
351
318
  payload?: ReencryptionResponsePayload;
352
- /**
353
- */
354
319
  signature: Uint8Array;
355
320
  }
356
- /**
357
- */
358
321
  export class ReencryptionResponsePayload {
359
322
  free(): void;
360
323
  /**
361
- * The degree of the sharing scheme used.
362
- */
324
+ * The degree of the sharing scheme used.
325
+ */
363
326
  degree: number;
364
327
  /**
365
- * The concatenation of two digests:
366
- * (eip712_signing_hash(pk, domain) || ciphertext digest).
367
- * This is needed to ensure the response corresponds to the request.
368
- */
328
+ * The concatenation of two digests:
329
+ * (eip712_signing_hash(pk, domain) || ciphertext digest).
330
+ * This is needed to ensure the response corresponds to the request.
331
+ */
369
332
  digest: Uint8Array;
370
333
  /**
371
- * The type of plaintext encrypted.
372
- */
334
+ * The type of plaintext encrypted.
335
+ */
373
336
  fhe_type: number;
374
337
  /**
375
- * The ID of the MPC party doing the reencryption. Used for polynomial
376
- * reconstruction.
377
- */
338
+ * The ID of the MPC party doing the reencryption. Used for polynomial
339
+ * reconstruction.
340
+ */
378
341
  party_id: number;
379
342
  /**
380
- * The signcrypted payload, using a hybrid encryption approach in
381
- * sign-then-encrypt.
382
- */
343
+ * The signcrypted payload, using a hybrid encryption approach in
344
+ * sign-then-encrypt.
345
+ */
383
346
  signcrypted_ciphertext: Uint8Array;
384
347
  /**
385
- * The server's signature verification key.
386
- * Encoded using SEC1.
387
- * Needed to validate the response, but MUST also be linked to a list of
388
- * trusted keys.
389
- */
348
+ * The server's signature verification key.
349
+ * Encoded using SEC1.
350
+ * Needed to validate the response, but MUST also be linked to a list of
351
+ * trusted keys.
352
+ */
390
353
  verification_key: Uint8Array;
391
354
  /**
392
- * Version of the response format.
393
- */
355
+ * Version of the response format.
356
+ */
394
357
  version: number;
395
358
  }
396
359
  /**
397
- * Simple response to return an ID, to be used to retrieve the computed result
398
- * later on.
399
- */
360
+ * Simple response to return an ID, to be used to retrieve the computed result
361
+ * later on.
362
+ */
400
363
  export class RequestId {
401
364
  free(): void;
402
- /**
403
- */
404
365
  request_id: string;
405
366
  }