node-tkms 0.9.0-rc11 → 0.9.0-rc19

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,202 @@
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_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
+ */
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 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
+ */
164
164
  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
165
  /**
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
- */
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
+ */
196
196
  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
197
  /**
198
- * The plaintext types that can be encrypted in a fhevm ciphertext.
199
- */
198
+ * The plaintext types that can be encrypted in a fhevm ciphertext.
199
+ */
200
200
  export enum FheType {
201
201
  Ebool = 0,
202
202
  Euint4 = 1,
@@ -212,194 +212,154 @@ export enum FheType {
212
212
  Euint2048 = 11,
213
213
  }
214
214
  /**
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
- */
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
+ */
219
219
  export class Client {
220
220
  free(): void;
221
221
  }
222
- /**
223
- */
224
222
  export class CryptoBoxCt {
225
223
  free(): void;
226
224
  }
227
225
  /**
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
- */
226
+ * <https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator>
227
+ * eventually chain_id, verifying_contract and salt will be parsed in to
228
+ * solidity types
229
+ */
232
230
  export class Eip712DomainMsg {
233
231
  free(): void;
234
- /**
235
- */
236
232
  chain_id: Uint8Array;
237
- /**
238
- */
239
233
  name: string;
240
- /**
241
- */
242
- salt: Uint8Array;
243
- /**
244
- */
234
+ salt?: Uint8Array;
245
235
  verifying_contract: string;
246
- /**
247
- */
248
236
  version: string;
249
237
  }
250
238
  /**
251
- * Validity of this struct is not checked.
252
- */
239
+ * Validity of this struct is not checked.
240
+ */
253
241
  export class ParsedReencryptionRequest {
254
242
  free(): void;
255
243
  }
256
- /**
257
- */
258
244
  export class Plaintext {
259
245
  free(): void;
260
- /**
261
- */
262
246
  bytes: Uint8Array;
263
247
  }
264
- /**
265
- */
266
248
  export class PrivateEncKey {
267
249
  free(): void;
268
250
  }
269
- /**
270
- */
271
251
  export class PrivateSigKey {
272
252
  free(): void;
273
253
  }
274
- /**
275
- */
276
254
  export class PublicEncKey {
277
255
  free(): void;
278
256
  }
279
- /**
280
- */
281
257
  export class PublicSigKey {
282
258
  free(): void;
283
259
  }
284
- /**
285
- */
286
260
  export class ReencryptionRequest {
287
261
  free(): void;
288
- /**
289
- */
290
262
  domain?: Eip712DomainMsg;
291
- /**
292
- */
293
263
  payload?: ReencryptionRequestPayload;
294
264
  /**
295
- * The ID that identifies this request.
296
- * Future queries for the result must use this request ID.
297
- */
265
+ * The ID that identifies this request.
266
+ * Future queries for the result must use this request ID.
267
+ */
298
268
  request_id?: RequestId;
299
269
  /**
300
- * Signature of the serialization of \[ReencryptionRequestPayload\].
301
- */
270
+ * Signature of the serialization of \[ReencryptionRequestPayload\].
271
+ */
302
272
  signature: Uint8Array;
303
273
  }
304
- /**
305
- */
306
274
  export class ReencryptionRequestPayload {
307
275
  free(): void;
308
276
  /**
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
- */
277
+ * The actual ciphertext to decrypt, taken directly from the fhevm.
278
+ * When creating the payload, this field may be empty,
279
+ * it is the responsibility of the gateway to fetch the
280
+ * ciphertext for the given digest below.
281
+ */
314
282
  ciphertext?: Uint8Array;
315
283
  /**
316
- * The SHA3 digest of the ciphertext above.
317
- */
284
+ * The SHA3 digest of the ciphertext above.
285
+ */
318
286
  ciphertext_digest: Uint8Array;
319
287
  /**
320
- * The client's (blockchain wallet) address,
321
- * encoded using EIP-55.
322
- */
288
+ * The client's (blockchain wallet) address,
289
+ * encoded using EIP-55.
290
+ */
323
291
  client_address: string;
324
292
  /**
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
- */
293
+ * Encoding of the user's public encryption key for this request.
294
+ * Encoding using the default encoding of libsodium, i.e. the 32 bytes of a
295
+ * Montgomery point.
296
+ */
329
297
  enc_key: Uint8Array;
330
298
  /**
331
- * The type of plaintext encrypted.
332
- */
299
+ * The type of plaintext encrypted.
300
+ */
333
301
  fhe_type: number;
334
302
  /**
335
- * The key id to use for decryption. Will be the request_id used during key
336
- * generation
337
- */
303
+ * The key id to use for decryption. Will be the request_id used during key
304
+ * generation
305
+ */
338
306
  key_id?: RequestId;
339
307
  /**
340
- * Version of the request format.
341
- */
308
+ * Version of the request format.
309
+ */
342
310
  version: number;
343
311
  }
344
- /**
345
- */
346
312
  export class ReencryptionResponse {
347
313
  free(): void;
348
314
  /**
349
- * Signature of the serialization of \[ReencryptionResponsePayload\].
350
- */
315
+ * Signature of the serialization of \[ReencryptionResponsePayload\].
316
+ */
351
317
  payload?: ReencryptionResponsePayload;
352
- /**
353
- */
354
318
  signature: Uint8Array;
355
319
  }
356
- /**
357
- */
358
320
  export class ReencryptionResponsePayload {
359
321
  free(): void;
360
322
  /**
361
- * The degree of the sharing scheme used.
362
- */
323
+ * The degree of the sharing scheme used.
324
+ */
363
325
  degree: number;
364
326
  /**
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
- */
327
+ * The concatenation of two digests:
328
+ * (eip712_signing_hash(pk, domain) || ciphertext digest).
329
+ * This is needed to ensure the response corresponds to the request.
330
+ */
369
331
  digest: Uint8Array;
370
332
  /**
371
- * The type of plaintext encrypted.
372
- */
333
+ * The type of plaintext encrypted.
334
+ */
373
335
  fhe_type: number;
374
336
  /**
375
- * The ID of the MPC party doing the reencryption. Used for polynomial
376
- * reconstruction.
377
- */
337
+ * The ID of the MPC party doing the reencryption. Used for polynomial
338
+ * reconstruction.
339
+ */
378
340
  party_id: number;
379
341
  /**
380
- * The signcrypted payload, using a hybrid encryption approach in
381
- * sign-then-encrypt.
382
- */
342
+ * The signcrypted payload, using a hybrid encryption approach in
343
+ * sign-then-encrypt.
344
+ */
383
345
  signcrypted_ciphertext: Uint8Array;
384
346
  /**
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
- */
347
+ * The server's signature verification key.
348
+ * Encoded using SEC1.
349
+ * Needed to validate the response, but MUST also be linked to a list of
350
+ * trusted keys.
351
+ */
390
352
  verification_key: Uint8Array;
391
353
  /**
392
- * Version of the response format.
393
- */
354
+ * Version of the response format.
355
+ */
394
356
  version: number;
395
357
  }
396
358
  /**
397
- * Simple response to return an ID, to be used to retrieve the computed result
398
- * later on.
399
- */
359
+ * Simple response to return an ID, to be used to retrieve the computed result
360
+ * later on.
361
+ */
400
362
  export class RequestId {
401
363
  free(): void;
402
- /**
403
- */
404
364
  request_id: string;
405
365
  }