@inco/js 0.8.0-devnet-5 → 0.9.0-devnet-test-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.
Files changed (67) hide show
  1. package/dist/cjs/advancedacl/session-key.d.ts +11 -10
  2. package/dist/cjs/advancedacl/session-key.js +7 -11
  3. package/dist/cjs/attestedcompute/attested-compute.d.ts +6 -6
  4. package/dist/cjs/attestedcompute/attested-compute.js +2 -2
  5. package/dist/cjs/attesteddecrypt/attested-decrypt.d.ts +8 -8
  6. package/dist/cjs/attesteddecrypt/attested-decrypt.js +6 -6
  7. package/dist/cjs/encryption/encryption.d.ts +10 -10
  8. package/dist/cjs/encryption/encryption.js +5 -5
  9. package/dist/cjs/generated/es/inco/covalidator/compute/v1/server_pb.d.ts +270 -7
  10. package/dist/cjs/generated/es/inco/covalidator/compute/v1/server_pb.js +98 -12
  11. package/dist/cjs/generated/es/inco/covalidator/compute/v1/types_pb.d.ts +0 -6
  12. package/dist/cjs/generated/es/inco/covalidator/compute/v1/types_pb.js +2 -8
  13. package/dist/cjs/generated/es/inco/kms/lite/v1/kms_service_pb.d.ts +213 -0
  14. package/dist/cjs/generated/es/inco/kms/lite/v1/kms_service_pb.js +36 -11
  15. package/dist/cjs/generated/es/inco/sealingfetcher/v1/sealingfetcher_pb.d.ts +3 -3
  16. package/dist/cjs/kms/quorumClient.d.ts +5 -4
  17. package/dist/cjs/kms/quorumClient.js +33 -30
  18. package/dist/cjs/lite/index.d.ts +1 -1
  19. package/dist/cjs/lite/index.js +15 -2
  20. package/dist/cjs/lite/lightning.d.ts +33 -24
  21. package/dist/cjs/lite/lightning.js +67 -38
  22. package/dist/cjs/lite/xwing.d.ts +123 -0
  23. package/dist/cjs/lite/xwing.js +275 -0
  24. package/dist/cjs/reencryption/types.d.ts +2 -2
  25. package/dist/esm/advancedacl/session-key.d.ts +11 -10
  26. package/dist/esm/advancedacl/session-key.js +7 -11
  27. package/dist/esm/attestedcompute/attested-compute.d.ts +6 -6
  28. package/dist/esm/attestedcompute/attested-compute.js +2 -2
  29. package/dist/esm/attesteddecrypt/attested-decrypt.d.ts +8 -8
  30. package/dist/esm/attesteddecrypt/attested-decrypt.js +4 -4
  31. package/dist/esm/encryption/encryption.d.ts +10 -10
  32. package/dist/esm/encryption/encryption.js +5 -5
  33. package/dist/esm/generated/es/inco/covalidator/compute/v1/server_pb.d.ts +270 -7
  34. package/dist/esm/generated/es/inco/covalidator/compute/v1/server_pb.js +97 -11
  35. package/dist/esm/generated/es/inco/covalidator/compute/v1/types_pb.d.ts +0 -6
  36. package/dist/esm/generated/es/inco/covalidator/compute/v1/types_pb.js +2 -8
  37. package/dist/esm/generated/es/inco/kms/lite/v1/kms_service_pb.d.ts +213 -0
  38. package/dist/esm/generated/es/inco/kms/lite/v1/kms_service_pb.js +35 -10
  39. package/dist/esm/generated/es/inco/sealingfetcher/v1/sealingfetcher_pb.d.ts +3 -3
  40. package/dist/esm/kms/quorumClient.d.ts +5 -4
  41. package/dist/esm/kms/quorumClient.js +33 -30
  42. package/dist/esm/lite/index.d.ts +1 -1
  43. package/dist/esm/lite/index.js +2 -2
  44. package/dist/esm/lite/lightning.d.ts +33 -24
  45. package/dist/esm/lite/lightning.js +67 -38
  46. package/dist/esm/lite/xwing.d.ts +123 -0
  47. package/dist/esm/lite/xwing.js +263 -0
  48. package/dist/esm/reencryption/types.d.ts +2 -2
  49. package/dist/types/advancedacl/session-key.d.ts +11 -10
  50. package/dist/types/attestedcompute/attested-compute.d.ts +6 -6
  51. package/dist/types/attesteddecrypt/attested-decrypt.d.ts +8 -8
  52. package/dist/types/encryption/encryption.d.ts +10 -10
  53. package/dist/types/generated/es/inco/covalidator/compute/v1/server_pb.d.ts +270 -7
  54. package/dist/types/generated/es/inco/covalidator/compute/v1/types_pb.d.ts +0 -6
  55. package/dist/types/generated/es/inco/kms/lite/v1/kms_service_pb.d.ts +213 -0
  56. package/dist/types/generated/es/inco/sealingfetcher/v1/sealingfetcher_pb.d.ts +3 -3
  57. package/dist/types/kms/quorumClient.d.ts +5 -4
  58. package/dist/types/lite/index.d.ts +1 -1
  59. package/dist/types/lite/lightning.d.ts +33 -24
  60. package/dist/types/lite/xwing.d.ts +123 -0
  61. package/dist/types/reencryption/types.d.ts +2 -2
  62. package/package.json +6 -6
  63. package/dist/cjs/lite/ecies.d.ts +0 -26
  64. package/dist/cjs/lite/ecies.js +0 -146
  65. package/dist/esm/lite/ecies.d.ts +0 -26
  66. package/dist/esm/lite/ecies.js +0 -134
  67. package/dist/types/lite/ecies.d.ts +0 -26
@@ -1,16 +1,17 @@
1
1
  import { Account, Chain, GetContractReturnType, PublicClient, Transport, WalletClient } from 'viem';
2
+ import type { PrivateKeyAccount } from 'viem/accounts';
2
3
  import { AllowanceVoucherWithSig } from '../advancedacl/types.js';
3
4
  import { AttestedComputeOP } from '../attestedcompute/types.js';
4
5
  import { DecryptionAttestation, EncryptedDecryptionAttestation } from '../attesteddecrypt/index.js';
5
6
  import { Address, HexString } from '../binary.js';
6
- import { EciesScheme, SupportedFheType } from '../encryption/index.js';
7
+ import { EncryptionScheme, SupportedFheType } from '../encryption/index.js';
7
8
  import { incoVerifierAbi } from '../generated/abis/verifier.js';
8
9
  import { lightningDeployments } from '../generated/lightning.js';
9
10
  import { localNodeLightningConfig } from '../generated/local-node.js';
10
11
  import { FheType } from '../handle.js';
11
12
  import { LocalNodeEnv } from '../local/index.js';
12
13
  import { BackoffConfig } from '../retry.js';
13
- import { Secp256k1Keypair } from './ecies.js';
14
+ import { XwingKeypair } from './xwing.js';
14
15
  type TupleToUnion<T> = T extends readonly unknown[] ? T[number] : never;
15
16
  type Deployment = TupleToUnion<typeof lightningDeployments>;
16
17
  type DistributedPick<T, K> = T extends any ? Pick<T, Extract<keyof T, K>> : never;
@@ -59,10 +60,17 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
59
60
  private readonly networkPubkey;
60
61
  readonly executorAddress: Address;
61
62
  readonly chainId: bigint;
62
- private readonly ephemeralKeypair;
63
63
  private readonly kmsQuorumClient;
64
- private readonly encryptor;
64
+ private encryptor;
65
+ private encryptionScheme;
65
66
  private constructor();
67
+ private getEncryptor;
68
+ /**
69
+ * Get the encryption scheme version used by this Lightning instance.
70
+ * Returns 1 for ECIES or 2 for X-Wing.
71
+ * This is a convenience method to get the encryption scheme used by this Lightning instance.
72
+ */
73
+ getEncryptionScheme(): Promise<EncryptionScheme>;
66
74
  /**
67
75
  * Get a Lightning instance bound to the latest Lightning deployment for the Base Sepolia testnet.
68
76
  */
@@ -121,7 +129,8 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
121
129
  static latest<P extends Pepper>(pepper: P, chainId: ChainId): Promise<Lightning<Deployment>>;
122
130
  get deployment(): T;
123
131
  /**
124
- * Encrypt a value using the public ECIES key of the Lightning deployment.
132
+ * Encrypt a value using the network's public key (ECIES or X-Wing).
133
+ * The encryption scheme is automatically detected based on the public key length.
125
134
  *
126
135
  * @param value a boolean or numeric value to encrypt
127
136
  * @param accountAddress the address of the account interacting with the dapp contract, normally an Externally Owned Account (EOA)
@@ -224,13 +233,13 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
224
233
  * console.log(decrypted[0].plaintext.value);
225
234
  * ```
226
235
  */
227
- attestedDecrypt(walletClient: WalletClient<Transport, Chain, Account>, handles: HexString[], backoffConfig?: Partial<BackoffConfig>): Promise<Array<DecryptionAttestation<EciesScheme, SupportedFheType>>>;
228
- attestedDecrypt(walletClient: WalletClient<Transport, Chain, Account>, handles: HexString[], reencryptPubKey: Uint8Array, backoffConfig?: Partial<BackoffConfig>): Promise<Array<EncryptedDecryptionAttestation<EciesScheme, SupportedFheType>>>;
229
- attestedDecrypt(walletClient: WalletClient<Transport, Chain, Account>, handles: HexString[], reencryptPubKey: Uint8Array, reencryptKeypair: Secp256k1Keypair, backoffConfig?: Partial<BackoffConfig>): Promise<Array<DecryptionAttestation<EciesScheme, SupportedFheType>>>;
236
+ attestedDecrypt(walletClient: WalletClient<Transport, Chain, Account>, handles: HexString[], backoffConfig?: Partial<BackoffConfig>): Promise<Array<DecryptionAttestation<EncryptionScheme, SupportedFheType>>>;
237
+ attestedDecrypt(walletClient: WalletClient<Transport, Chain, Account>, handles: HexString[], reencryptPubKey: Uint8Array, backoffConfig?: Partial<BackoffConfig>): Promise<Array<EncryptedDecryptionAttestation<EncryptionScheme, SupportedFheType>>>;
238
+ attestedDecrypt(walletClient: WalletClient<Transport, Chain, Account>, handles: HexString[], reencryptPubKey: Uint8Array, reencryptKeypair: XwingKeypair, backoffConfig?: Partial<BackoffConfig>): Promise<Array<DecryptionAttestation<EncryptionScheme, SupportedFheType>>>;
230
239
  /**
231
240
  * Requests attested decrypts using a voucher-backed session key.
232
241
  *
233
- * @param ephemeralKeypair Session keypair matching the voucher grantee.
242
+ * @param ephemeralAccount Session Account matching the voucher grantee.
234
243
  * @param allowanceVoucherWithSig Signed allowance voucher.
235
244
  * @param ethClient - A public eth client or eth wallet client used for signing the attested decrypt request
236
245
  * @param handles Handles to decrypt.
@@ -239,7 +248,7 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
239
248
  * @example Plaintext results
240
249
  * ```ts
241
250
  * const attestations = await lightning.attestedDecryptWithVoucher(
242
- * ephemeralKeypair,
251
+ * ephemeralAccount,
243
252
  * voucher,
244
253
  * ethClient,
245
254
  * [handle],
@@ -249,7 +258,7 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
249
258
  * @example Reencrypt for a delegate
250
259
  * ```ts
251
260
  * const encrypted = await lightning.attestedDecryptWithVoucher(
252
- * ephemeralKeypair,
261
+ * ephemeralAccount,
253
262
  * voucher,
254
263
  * ethClient,
255
264
  * [handle],
@@ -257,9 +266,9 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
257
266
  * );
258
267
  * ```
259
268
  */
260
- attestedDecryptWithVoucher(ephemeralKeypair: Secp256k1Keypair, allowanceVoucherWithSig: AllowanceVoucherWithSig, ethClient: PublicClient<Transport, Chain> | WalletClient<Transport, Chain, Account>, handles: HexString[], requesterArgData?: HexString, backoffConfig?: Partial<BackoffConfig>): Promise<Array<DecryptionAttestation<EciesScheme, SupportedFheType>>>;
261
- attestedDecryptWithVoucher(ephemeralKeypair: Secp256k1Keypair, allowanceVoucherWithSig: AllowanceVoucherWithSig, ethClient: PublicClient<Transport, Chain> | WalletClient<Transport, Chain, Account>, handles: HexString[], reencryptPubKey: Uint8Array, requesterArgData?: HexString, backoffConfig?: Partial<BackoffConfig>): Promise<Array<EncryptedDecryptionAttestation<EciesScheme, SupportedFheType>>>;
262
- attestedDecryptWithVoucher(ephemeralKeypair: Secp256k1Keypair, allowanceVoucherWithSig: AllowanceVoucherWithSig, ethClient: PublicClient<Transport, Chain> | WalletClient<Transport, Chain, Account>, handles: HexString[], reencryptPubKey: Uint8Array, reencryptKeypair: Secp256k1Keypair, requesterArgData?: HexString, backoffConfig?: Partial<BackoffConfig>): Promise<Array<DecryptionAttestation<EciesScheme, SupportedFheType>>>;
269
+ attestedDecryptWithVoucher(ephemeralAccount: PrivateKeyAccount, allowanceVoucherWithSig: AllowanceVoucherWithSig, ethClient: PublicClient<Transport, Chain> | WalletClient<Transport, Chain, Account>, handles: HexString[], requesterArgData?: HexString, backoffConfig?: Partial<BackoffConfig>): Promise<Array<DecryptionAttestation<EncryptionScheme, SupportedFheType>>>;
270
+ attestedDecryptWithVoucher(ephemeralAccount: PrivateKeyAccount, allowanceVoucherWithSig: AllowanceVoucherWithSig, ethClient: PublicClient<Transport, Chain> | WalletClient<Transport, Chain, Account>, handles: HexString[], reencryptPubKey: Uint8Array, requesterArgData?: HexString, backoffConfig?: Partial<BackoffConfig>): Promise<Array<EncryptedDecryptionAttestation<EncryptionScheme, SupportedFheType>>>;
271
+ attestedDecryptWithVoucher(ephemeralAccount: PrivateKeyAccount, allowanceVoucherWithSig: AllowanceVoucherWithSig, ethClient: PublicClient<Transport, Chain> | WalletClient<Transport, Chain, Account>, handles: HexString[], reencryptPubKey: Uint8Array, reencryptKeypair: XwingKeypair, requesterArgData?: HexString, backoffConfig?: Partial<BackoffConfig>): Promise<Array<DecryptionAttestation<EncryptionScheme, SupportedFheType>>>;
263
272
  /**
264
273
  * Get an attested compute for the given wallet client.
265
274
  *
@@ -305,16 +314,16 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
305
314
  * console.log(decrypted.plaintext.value);
306
315
  * ```
307
316
  */
308
- attestedCompute(walletClient: WalletClient<Transport, Chain, Account>, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, backoffConfig?: Partial<BackoffConfig>): Promise<DecryptionAttestation<EciesScheme, SupportedFheType>>;
309
- attestedCompute(walletClient: WalletClient<Transport, Chain, Account>, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, reencryptPubKey: Uint8Array, backoffConfig?: Partial<BackoffConfig>): Promise<EncryptedDecryptionAttestation<EciesScheme, SupportedFheType>>;
310
- attestedCompute(walletClient: WalletClient<Transport, Chain, Account>, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, reencryptPubKey: Uint8Array, reencryptKeypair: Secp256k1Keypair, backoffConfig?: Partial<BackoffConfig>): Promise<DecryptionAttestation<EciesScheme, SupportedFheType>>;
317
+ attestedCompute(walletClient: WalletClient<Transport, Chain, Account>, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, backoffConfig?: Partial<BackoffConfig>): Promise<DecryptionAttestation<EncryptionScheme, SupportedFheType>>;
318
+ attestedCompute(walletClient: WalletClient<Transport, Chain, Account>, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, reencryptPubKey: Uint8Array, backoffConfig?: Partial<BackoffConfig>): Promise<EncryptedDecryptionAttestation<EncryptionScheme, SupportedFheType>>;
319
+ attestedCompute(walletClient: WalletClient<Transport, Chain, Account>, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, reencryptPubKey: Uint8Array, reencryptKeypair: XwingKeypair, backoffConfig?: Partial<BackoffConfig>): Promise<DecryptionAttestation<EncryptionScheme, SupportedFheType>>;
311
320
  /**
312
321
  * Performs attested compute via a voucher-backed session key.
313
322
  *
314
323
  * @example Plaintext result
315
324
  * ```ts
316
325
  * const attestation = await lightning.attestedComputeWithVoucher(
317
- * ephemeralKeypair,
326
+ * ephemeralAccount,
318
327
  * voucher,
319
328
  * ethClient,
320
329
  * lhsHandle,
@@ -326,7 +335,7 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
326
335
  * @example Reencrypt for a delegate
327
336
  * ```ts
328
337
  * const encrypted = await lightning.attestedComputeWithVoucher(
329
- * ephemeralKeypair,
338
+ * ephemeralAccount,
330
339
  * voucher,
331
340
  * lhsHandle,
332
341
  * AttestedComputeSupportedOps.Eq,
@@ -339,7 +348,7 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
339
348
  * @example Reencrypt and decrypt locally
340
349
  * ```ts
341
350
  * const decrypted = await lightning.attestedComputeWithVoucher(
342
- * ephemeralKeypair,
351
+ * ephemeralAccount,
343
352
  * voucher,
344
353
  * lhsHandle,
345
354
  * AttestedComputeSupportedOps.Eq,
@@ -350,9 +359,9 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
350
359
  * console.log(decrypted.plaintext.value);
351
360
  * ```
352
361
  */
353
- attestedComputeWithVoucher(ephemeralKeypair: Secp256k1Keypair, allowanceVoucherWithSig: AllowanceVoucherWithSig, ethClient: PublicClient<Transport, Chain> | WalletClient<Transport, Chain, Account>, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, requesterArgData?: HexString, backoffConfig?: Partial<BackoffConfig>): Promise<DecryptionAttestation<EciesScheme, SupportedFheType>>;
354
- attestedComputeWithVoucher(ephemeralKeypair: Secp256k1Keypair, allowanceVoucherWithSig: AllowanceVoucherWithSig, ethClient: PublicClient<Transport, Chain> | WalletClient<Transport, Chain, Account>, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, reencryptPubKey: Uint8Array, requesterArgData?: HexString, backoffConfig?: Partial<BackoffConfig>): Promise<EncryptedDecryptionAttestation<EciesScheme, SupportedFheType>>;
355
- attestedComputeWithVoucher(ephemeralKeypair: Secp256k1Keypair, allowanceVoucherWithSig: AllowanceVoucherWithSig, ethClient: PublicClient<Transport, Chain> | WalletClient<Transport, Chain, Account>, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, reencryptPubKey: Uint8Array, reencryptKeypair: Secp256k1Keypair, requesterArgData?: HexString, backoffConfig?: Partial<BackoffConfig>): Promise<DecryptionAttestation<EciesScheme, SupportedFheType>>;
362
+ attestedComputeWithVoucher(ephemeralAccount: PrivateKeyAccount, allowanceVoucherWithSig: AllowanceVoucherWithSig, ethClient: PublicClient<Transport, Chain> | WalletClient<Transport, Chain, Account>, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, requesterArgData?: HexString, backoffConfig?: Partial<BackoffConfig>): Promise<DecryptionAttestation<EncryptionScheme, SupportedFheType>>;
363
+ attestedComputeWithVoucher(ephemeralAccount: PrivateKeyAccount, allowanceVoucherWithSig: AllowanceVoucherWithSig, ethClient: PublicClient<Transport, Chain> | WalletClient<Transport, Chain, Account>, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, reencryptPubKey: Uint8Array, requesterArgData?: HexString, backoffConfig?: Partial<BackoffConfig>): Promise<EncryptedDecryptionAttestation<EncryptionScheme, SupportedFheType>>;
364
+ attestedComputeWithVoucher(ephemeralAccount: PrivateKeyAccount, allowanceVoucherWithSig: AllowanceVoucherWithSig, ethClient: PublicClient<Transport, Chain> | WalletClient<Transport, Chain, Account>, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, reencryptPubKey: Uint8Array, reencryptKeypair: XwingKeypair, requesterArgData?: HexString, backoffConfig?: Partial<BackoffConfig>): Promise<DecryptionAttestation<EncryptionScheme, SupportedFheType>>;
356
365
  /**
357
366
  * Get an decryption of publicly revealed handles.
358
367
  *
@@ -366,7 +375,7 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
366
375
  * const { plaintext, covalidatorSignature } = response[0];
367
376
  * ```
368
377
  */
369
- attestedReveal(handles: HexString[], backoffConfig?: Partial<BackoffConfig>): Promise<Array<DecryptionAttestation<EciesScheme, SupportedFheType>>>;
378
+ attestedReveal(handles: HexString[], backoffConfig?: Partial<BackoffConfig>): Promise<Array<DecryptionAttestation<EncryptionScheme, SupportedFheType>>>;
370
379
  /**
371
380
  * Get the GRPC endpoint for the covalidator that services this deployment.
372
381
  */
@@ -0,0 +1,123 @@
1
+ import { Decryptor, Encryptor, XwingScheme } from '../encryption/encryption.js';
2
+ import { PubKeyEncodable } from '../reencryption/index.js';
3
+ /**
4
+ * X-Wing public key size in bytes.
5
+ * Combining ML-KEM-768 (1184 bytes) and X25519 (32 bytes).
6
+ */
7
+ export declare const XWING_PUBLIC_KEY_SIZE: number;
8
+ export declare const TEST_NETWORK_SEED_KEY = "0x0000000000000000000000000000000000000000000000000000000000000000";
9
+ export declare const TEST_NETWORK_XWING_PUBKEY = "0xca882388911c7c762aafc20debd63e845b3bed28c9d5262cdea7771fb31bd660a1ae7b395a9a7df3d12c7b118e8eda5057572c1ba05cd9b635edf33dabca4cac7291e0848f19c20e5beb850c3818f3543d49b3a5c729cb86a28fda539775d04feda112fe0c81d138aaf623aea7d507a4e826e890105db6065a44aba76a10d771c00d1b33f4ac51869806aae18eada68f19047024542d64a7aa1c91a5e1aa49d93613b5224b415bcc7aa166e4b55033438d20c641f9664fdb1689b53208181463e3d1325d46b30f07c5945b7e3fa1418bf833d975258461b294664eaf60795964924a280729c10a37fc6e967440bdd55d4ca53596286383481291152365303d44517cef369c00933b0b30368a230353e729c031075e8388673678a56b3ba84a165b28096ee9bd684483e1844258b451c365c41fa534152a3b64120041450128e960c7d6437d717ee266bdde7aaeec225ed93b958d188e97407349f1382976ca47d761ecc59a6f394487eb015c083abb490584677240eb47f838c838568a496119378b8bb81484610a50792b5d9c9939db188e7d0249d3cb918c436f111a2898849b286b0743a22c57464c709c5eaceac1ba493adca3328c0b14b5e38d3aea74e328b622b17e7181c35ad11c2103bdb7f2b209d93dcbc4ab61a06bc37139e6d2b7a06c5b7e9267bef3a8918a706f793271a5acc2574532da79e5a10cf074b998147a3c43586a411a513bba0d11cc19a36c83b19277f28022c88b120abfdba7076a8263e05336e3245aef7033eb3c762b5bbfa5791ac960398b649d5cbb652ddc6b2398143a0861ab3b410b696328879c099098adf819fbf7ac170030e86675e7f45c22ac9e1cf52c3102487bb0b91ab592afdc69c6e3a9b71876b86260b6c736b8291098f1130d3b763525cbad540ce2d042eacb6ed43b7bcba898f712c412f26066e09945f44ec7026c8ef959831abc10719d2017a12a41728b41c02371a5f5756ebc79406be708ea41bbd21563c874a0b791a3b4e4224a609967004f065c5ab4f3b4c61cb35df70573269da53179c3701fc5205f61974426f9b794c1b5826494b70842b6920c17752029369264dc8590b898b85c9d89a258e1f46c1b0490efd17c485cb51687cea272041e90b8e629521d3c5e3fa7518161bad7a159295b63cc6c0077897b53d47db8bc0ecb820f550705b65715a1a1094d04854f56acd26aa0baa10cb8447fad6211f53105796a42882328e6852e8de821c283b51eaab9bc95c4dc53615626049d63b1f9a457193805276b1905b0ab39353b5cf91fdd6023d4d816aef9cce4a3cfb3d12190172df221ae61d427563a098cc60e3dc9997ef54959180be5dc64a911157db6be3a01be2ee343caab33b8729abf0c50c674758c511291941fceac646232920907c2e88b9ec10211161729c797643a553a6ae5c4b7483c04e3263bd291e311c609071348b7c3310aa97d6b8318e0a4afe8399fa22f951049a9bb8860f7c69a333d3cc1aaf0129ab560713bf29eb3a01f9a276c78e54e3a3648b2447c80242b271b11406866389426d8b59796540d6b5702092ab21ee217c075cfc0c17ef826ce9ea29b9e61617457a5b1aaa23a58615dc53c59183beb36ea19498c21820b70ab47adeb678f1c52bf8768b3597b608ea1a8a15cd62e8a29bec4a1ac248ef9f02de0144bca06025f95a42bd6c8eaaaaaa2366328561d";
10
+ /**
11
+ * X-Wing keypair interface.
12
+ * X-Wing is a post-quantum hybrid KEM combining ML-KEM-768 and X25519.
13
+ * - Private key: 32-byte seed
14
+ * - Public key: 1216 bytes
15
+ * - Encapsulated key: 1120 bytes
16
+ */
17
+ export interface XwingKeypair extends PubKeyEncodable {
18
+ scheme: XwingScheme;
19
+ publicKey: CryptoKey;
20
+ privateKey: CryptoKey;
21
+ }
22
+ /**
23
+ * Derive X-Wing keypair from a 32-byte seed (deterministic).
24
+ * This matches the Go implementation in covalidator/encoding/xwing.go
25
+ *
26
+ * @param seed - 32-byte seed for deterministic key derivation
27
+ * @returns X-Wing keypair with cached public key bytes
28
+ */
29
+ export declare function deriveXwingKeypairFromSeed(seed: Uint8Array): Promise<XwingKeypair>;
30
+ /**
31
+ * Generate a random X-Wing keypair.
32
+ *
33
+ * @returns X-Wing keypair with cached public key bytes
34
+ */
35
+ export declare function generateXwingKeypair(): Promise<XwingKeypair>;
36
+ /**
37
+ * Decode X-Wing public key from bytes.
38
+ *
39
+ * @param pubKeyBytes - 1216-byte X-Wing public key
40
+ * @returns CryptoKey for encryption operations
41
+ */
42
+ export declare function decodeXwingPublicKey(pubKeyBytes: Uint8Array): Promise<CryptoKey>;
43
+ /**
44
+ * Decode X-Wing private key from 32-byte seed.
45
+ * Alias for deriveXwingKeypairFromSeed for consistency with Go API.
46
+ *
47
+ * @param seed - 32-byte seed
48
+ * @returns X-Wing keypair
49
+ */
50
+ export declare function decodeXwingPrivateKey(seed: Uint8Array): Promise<XwingKeypair>;
51
+ /**
52
+ * Encode X-Wing public key to bytes.
53
+ *
54
+ * @param publicKey - CryptoKey containing X-Wing public key
55
+ * @returns 1216-byte serialized public key
56
+ */
57
+ export declare function encodeXwingPublicKey(publicKey: CryptoKey): Promise<Uint8Array>;
58
+ /**
59
+ * X-Wing encryptor arguments.
60
+ * pubKeyA is the recipient's public key (usually the covalidator's public key).
61
+ */
62
+ export type XwingEncryptorArgs = {
63
+ pubKeyA: CryptoKey;
64
+ };
65
+ /**
66
+ * X-Wing decryptor arguments.
67
+ * privKeyA is the recipient's private key (usually the covalidator's private key).
68
+ */
69
+ export type XwingDecryptorArgs = {
70
+ privKeyA: XwingKeypair;
71
+ };
72
+ /**
73
+ * Encrypt using X-Wing HPKE (RFC 9180) with ChaCha20-Poly1305 AEAD.
74
+ *
75
+ * Output format: encappedKey (1184 bytes) || ciphertext (variable length)
76
+ *
77
+ * @param pubKeyA - Recipient's public key
78
+ * @param msg - Message to encrypt
79
+ * @param aad - Additional authenticated data (default: empty)
80
+ * @param info - Context info for key derivation (default: empty)
81
+ * @returns Encrypted data (encappedKey || ciphertext)
82
+ */
83
+ export declare function encrypt(pubKeyA: CryptoKey, msg: Uint8Array, aad?: Uint8Array, info?: Uint8Array): Promise<Uint8Array>;
84
+ /**
85
+ * Decrypt using X-Wing HPKE (RFC 9180) with ChaCha20-Poly1305 AEAD.
86
+ *
87
+ * Input format: encappedKey (1184 bytes) || ciphertext (variable length)
88
+ *
89
+ * @param privKeyA - Recipient's private key
90
+ * @param encryptedData - Encrypted data (encappedKey || ciphertext)
91
+ * @param aad - Additional authenticated data (default: empty)
92
+ * @param info - Context info for key derivation (default: empty)
93
+ * @returns Decrypted plaintext
94
+ */
95
+ export declare function decrypt(privKeyA: XwingKeypair, encryptedData: Uint8Array, aad?: Uint8Array, info?: Uint8Array): Promise<Uint8Array>;
96
+ /**
97
+ * Create an X-Wing encryptor for encrypting inputs.
98
+ * Follows the same pattern as ECIES encryptor in ecies.ts.
99
+ *
100
+ * The encryptor:
101
+ * 1. Encodes the plaintext with its context (HADU encoding)
102
+ * 2. Encrypts using X-Wing HPKE
103
+ * 3. Computes prehandle and handle for tracking
104
+ * 4. Returns the encrypted ciphertext with metadata
105
+ *
106
+ * @param args - X-Wing encryptor arguments (recipient's public key)
107
+ * @returns Encryptor function
108
+ */
109
+ export declare function getXwingEncryptor({ pubKeyA, }: XwingEncryptorArgs): Encryptor<XwingScheme>;
110
+ /**
111
+ * Create an X-Wing decryptor for decrypting inputs.
112
+ * Follows the same pattern as ECIES decryptor in ecies.ts.
113
+ *
114
+ * The decryptor:
115
+ * 1. Removes the prepended handle from the ciphertext
116
+ * 2. Decrypts using X-Wing HPKE
117
+ * 3. Decodes the HADU-encoded payload
118
+ * 4. Extracts and returns the plaintext
119
+ *
120
+ * @param args - X-Wing decryptor arguments (recipient's private key)
121
+ * @returns Decryptor function
122
+ */
123
+ export declare function getXwingDecryptor({ privKeyA, }: XwingDecryptorArgs): Decryptor<XwingScheme>;
@@ -2,7 +2,7 @@ import { Address } from 'viem';
2
2
  import { HexString } from '../binary.js';
3
3
  import { CiphertextOf, EncryptionScheme, PlaintextOf, SupportedFheType } from '../encryption/encryption.js';
4
4
  import { Handle } from '../handle.js';
5
- import type { Secp256k1Keypair } from '../lite/ecies.js';
5
+ import type { XwingKeypair } from '../lite/xwing.js';
6
6
  import type { BackoffConfig } from '../retry.js';
7
7
  export type Reencryptor<S extends EncryptionScheme> = <T extends SupportedFheType>(args: ReencryptFnArgs<S, T>, backoffConfig?: Partial<BackoffConfig>) => Promise<PlaintextOf<S, T>>;
8
8
  export interface ReencryptorArgs {
@@ -12,7 +12,7 @@ export type ReencryptFnArgs<S extends EncryptionScheme, T extends SupportedFheTy
12
12
  handle: Handle;
13
13
  ciphertext?: CiphertextOf<S, T>;
14
14
  };
15
- export type SupportedEphemeralKeypairs = Secp256k1Keypair;
15
+ export type SupportedEphemeralKeypairs = XwingKeypair;
16
16
  export interface PubKeyEncodable {
17
17
  encodePublicKey(): Uint8Array;
18
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inco/js",
3
- "version": "0.8.0-devnet-5",
3
+ "version": "0.9.0-devnet-test-2",
4
4
  "repository": "https://github.com/Inco-fhevm/inco-monorepo",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -77,7 +77,7 @@
77
77
  "generate:protos": "buf generate",
78
78
  "lint": "bun prettier --check . && eslint .",
79
79
  "lint:fix": "bun prettier --write . && eslint . --fix",
80
- "publish:npm": "bun publish",
80
+ "publish:npm": "npm publish --tag ${NPM_DIST_TAG:-alpha}",
81
81
  "test": "bun run lint && bun run test:tsc && bun run test:unit",
82
82
  "test:coverage": "bun vitest run --project unit --coverage",
83
83
  "test:e2e": "bun vitest run --bail=1 --project e2e",
@@ -91,15 +91,15 @@
91
91
  "@connectrpc/connect-node": "^2.0.0",
92
92
  "@connectrpc/connect-web": "^2.0.1",
93
93
  "@grpc/grpc-js": "^1.13.4",
94
- "@types/elliptic": "^6.4.18",
95
- "ecies-geth": "^1.7.5",
94
+ "@hpke/hybridkem-x-wing": "^0.6.1",
95
+ "@hpke/core": "^1.7.5",
96
+ "@hpke/chacha20poly1305": "^1.7.1",
96
97
  "effect": "^3.17.13",
97
- "elliptic": "^6.6.1",
98
98
  "sha3": "^2.1.4",
99
99
  "viem": "^2.39.3"
100
100
  },
101
101
  "devDependencies": {
102
- "@inco/pega": "0.0.0",
102
+ "@inco/pega": "workspace:*",
103
103
  "@bufbuild/protoc-gen-es": "^2.2.2",
104
104
  "@typescript-eslint/parser": "^8.35.1",
105
105
  "@vitest/coverage-istanbul": "3.1.1",
@@ -1,26 +0,0 @@
1
- import * as ellipticPkg from 'elliptic';
2
- import { Decryptor, EciesScheme, Encryptor } from '../encryption/encryption.js';
3
- import { PubKeyEncodable } from '../reencryption/index.js';
4
- export declare const TEST_NETWORK_PUBKEY = "0x02516bda9e68a1c3dce74dc1b6ed7d91a91d51c1e1933947f06331cef59631e9eb";
5
- export declare const TEST_NETWORK_PRIVATE_KEY = "0x384a707568ab63ad2ad9f10135faa0699801db3174f33f7846badc11affb8f57";
6
- export interface Secp256k1Keypair extends PubKeyEncodable {
7
- scheme: EciesScheme;
8
- kp: ellipticPkg.ec.KeyPair;
9
- }
10
- export type Secp256k1PubKey = ellipticPkg.curve.base.BasePoint;
11
- export declare function toSecp256k1Keypair(kp: ellipticPkg.ec.KeyPair): Secp256k1Keypair;
12
- export declare function generateSecp256k1Keypair(): Secp256k1Keypair;
13
- export declare function encodeSecp256k1PublicKey(pub: Secp256k1PubKey): Uint8Array;
14
- export declare function decodeSecp256k1PublicKey(pubKeyCompressed: Uint8Array): Secp256k1PubKey;
15
- export declare function decodeSecp256k1PrivateKey(privKey: Uint8Array): Secp256k1Keypair;
16
- export declare function encrypt(pubKeyA: Secp256k1PubKey, plaintext: Uint8Array, privKeyB: Secp256k1Keypair): Promise<Uint8Array>;
17
- export type EciesEncryptorArgs = {
18
- pubKeyA: Secp256k1PubKey;
19
- privKeyB: Secp256k1Keypair;
20
- };
21
- export declare function getEciesEncryptor({ pubKeyA, privKeyB, }: EciesEncryptorArgs): Encryptor<EciesScheme>;
22
- export declare function decrypt(privKeyA: Secp256k1Keypair, ciphertext: Uint8Array): Promise<Uint8Array>;
23
- export type EciesDecryptorArgs = {
24
- privKeyA: Secp256k1Keypair;
25
- };
26
- export declare function getEciesDecryptor({ privKeyA, }: EciesDecryptorArgs): Decryptor<EciesScheme>;
@@ -1,146 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TEST_NETWORK_PRIVATE_KEY = exports.TEST_NETWORK_PUBKEY = void 0;
4
- exports.toSecp256k1Keypair = toSecp256k1Keypair;
5
- exports.generateSecp256k1Keypair = generateSecp256k1Keypair;
6
- exports.encodeSecp256k1PublicKey = encodeSecp256k1PublicKey;
7
- exports.decodeSecp256k1PublicKey = decodeSecp256k1PublicKey;
8
- exports.decodeSecp256k1PrivateKey = decodeSecp256k1PrivateKey;
9
- exports.encrypt = encrypt;
10
- exports.getEciesEncryptor = getEciesEncryptor;
11
- exports.decrypt = decrypt;
12
- exports.getEciesDecryptor = getEciesDecryptor;
13
- const ecies_geth_1 = require("ecies-geth");
14
- const ellipticPkg = require("elliptic");
15
- const binary_js_1 = require("../binary.js");
16
- const encryption_js_1 = require("../encryption/encryption.js");
17
- const handle_js_1 = require("../handle.js");
18
- const schema_js_1 = require("../schema.js");
19
- const hadu_js_1 = require("./hadu.js");
20
- const secp256k1 = new ellipticPkg.ec('secp256k1');
21
- // These are ECIES keys for testing purposes
22
- exports.TEST_NETWORK_PUBKEY = '0x02516bda9e68a1c3dce74dc1b6ed7d91a91d51c1e1933947f06331cef59631e9eb';
23
- exports.TEST_NETWORK_PRIVATE_KEY = '0x384a707568ab63ad2ad9f10135faa0699801db3174f33f7846badc11affb8f57';
24
- // Convert an ec.KeyPair from the 'elliptic' package (assumed to have geen generated
25
- // with the secp256k1 curve) to our Secp256k1Keypair type.
26
- function toSecp256k1Keypair(kp) {
27
- return {
28
- scheme: encryption_js_1.encryptionSchemes.ecies,
29
- kp,
30
- encodePublicKey() {
31
- return new Uint8Array(kp.getPublic().encode('array', true));
32
- },
33
- };
34
- }
35
- // Generate a new ephemeral keypair for reencryption.
36
- function generateSecp256k1Keypair() {
37
- return toSecp256k1Keypair(secp256k1.genKeyPair());
38
- }
39
- // EncodePublicKey encodes an ECIES public key it's 33-byte compressed form.
40
- function encodeSecp256k1PublicKey(pub) {
41
- return new Uint8Array(pub.encodeCompressed('array'));
42
- }
43
- // DecodeSecp256k1PublicKey decodes a 33-byte compressed ECIES public key.
44
- function decodeSecp256k1PublicKey(pubKeyCompressed) {
45
- return secp256k1.keyFromPublic(pubKeyCompressed, 'array').getPublic();
46
- }
47
- // DecodeSecp256k1PrivateKey returns a ECIES secp256k1 private key based on the provided byte slice which is
48
- // interpreted as an unsigned 256-bit big-endian integer in the range [0, N-1],
49
- // where N is the order of the curve.
50
- // where N is the order of the curve.
51
- //
52
- // WARNING: This means passing a slice with more than 32 bytes is truncated and
53
- // that truncated value is reduced modulo N. Further, 0 is not a valid private
54
- // key. It is up to the caller to provide a value in the appropriate range of
55
- // [1, N-1]. Failure to do so will either result in an invalid private key or
56
- // potentially weak private keys that have bias that could be exploited.
57
- //
58
- // This function primarily exists to provide a mechanism for converting
59
- // serialized private keys that are already known to be good.
60
- //
61
- // For more info, refer to the decred/dcrd documentation:
62
- // ref: https://pkg.go.dev/github.com/decred/dcrd/dcrec/secp256k1/v4@v4.2.0#PrivKeyFromBytes
63
- //
64
- // We don't include any curve parameters or ECIES params, as they are assumed to
65
- // be the ones in ecies.ECIES_AES128_SHA256 from go-ethereum.
66
- // ref: https://github.com/ethereum/go-ethereum/blob/v1.15.0/crypto/ecies/params.go#L76-L82
67
- function decodeSecp256k1PrivateKey(privKey) {
68
- return toSecp256k1Keypair(secp256k1.keyFromPrivate(privKey, 'array'));
69
- }
70
- // Given a (usually 3rd-party known) public key, called `pubKeyA`, and an ephemeral
71
- // private key (usually generated locally), called `privKeyB`, encrypt the `msg`
72
- // using ECIES, with geth's parameters:
73
- // ref: https://github.com/ethereum/go-ethereum/blob/v1.15.2/crypto/ecies/ecies.go
74
- async function encrypt(pubKeyA, plaintext, privKeyB) {
75
- const pubKeyABuffer = Buffer.from(pubKeyA.encode('array', false));
76
- const privKeyBBuffer = privKeyB.kp.getPrivate().toArrayLike(Buffer, 'be', 32);
77
- const ct = await (0, ecies_geth_1.encrypt)(pubKeyABuffer, Buffer.from(plaintext), {
78
- ephemPrivateKey: privKeyBBuffer,
79
- });
80
- return new Uint8Array(ct);
81
- }
82
- function getEciesEncryptor({ pubKeyA, privKeyB, }) {
83
- const pubKeyABuffer = Buffer.from(pubKeyA.encode('array', false));
84
- const privKeyBBuffer = privKeyB.kp.getPrivate().toArrayLike(Buffer, 'be', 32);
85
- return async ({ plaintext, context, }) => {
86
- if (plaintext.scheme !== encryption_js_1.encryptionSchemes.ecies) {
87
- throw new Error(`Plaintext with scheme ${(0, encryption_js_1.getEncryptionSchemeName)(plaintext.scheme)} cannot be encrypted with ECIES`);
88
- }
89
- const inputCiphertextPayloadBytes = Buffer.from((0, hadu_js_1.encodeInput)({ plaintext, context }));
90
- const ct = await (0, ecies_geth_1.encrypt)(pubKeyABuffer, inputCiphertextPayloadBytes, {
91
- ephemPrivateKey: privKeyBBuffer,
92
- });
93
- const prehandle = (0, handle_js_1.computePrehandle)({
94
- ciphertext: ct,
95
- handleType: plaintext.type,
96
- indexHandle: 0,
97
- handleVersion: 0,
98
- });
99
- const handle = (0, handle_js_1.computeHandle)({
100
- prehandle,
101
- context: context,
102
- });
103
- // const inputBytes = Buffer.concat([handle, ct]);
104
- return {
105
- prehandle: (0, binary_js_1.asBytes32)(prehandle),
106
- handle: (0, binary_js_1.asBytes32)(handle),
107
- context,
108
- ciphertext: {
109
- scheme: encryption_js_1.encryptionSchemes.ecies,
110
- type: plaintext.type,
111
- // The prepended version keeps the bundle self-describing, avoiding a loose parameter.
112
- // The prepended handle serves as a checksum on the encrypted payload, so we can fail early on an accidental mismatch
113
- value: (0, encryption_js_1.encodeCiphertextInput)(context.version, (0, binary_js_1.bytesToHex)(handle), (0, binary_js_1.bytesToHex)(ct)),
114
- },
115
- };
116
- };
117
- }
118
- // Given an ephemeral private key, called `privKeyA`, and a ciphertext `ct`,
119
- // decrypt the ciphertext using ECIES, with geth's parameters:
120
- // ref: https://github.com/ethereum/go-ethereum/blob/v1.15.2/crypto/ecies/ecies.go
121
- async function decrypt(privKeyA, ciphertext) {
122
- const privKeyABuffer = privKeyA.kp.getPrivate().toArrayLike(Buffer, 'be', 32);
123
- const pt = await (0, ecies_geth_1.decrypt)(privKeyABuffer, Buffer.from(ciphertext));
124
- return new Uint8Array(pt);
125
- }
126
- function getEciesDecryptor({ privKeyA, }) {
127
- const privKeyABuffer = privKeyA.kp.getPrivate().toArrayLike(Buffer, 'be', 32);
128
- return async ({ scheme, value, }) => {
129
- if (scheme !== encryption_js_1.encryptionSchemes.ecies) {
130
- throw new Error(`Ciphertext with scheme ${(0, encryption_js_1.getEncryptionSchemeName)(scheme)} cannot be decrypted with ECIES`);
131
- }
132
- // remove the prepended version and handle
133
- // We could verify or dispatch on the version here,
134
- // but the intention is for the SDK to only support one input version at a time.
135
- const { ciphertext } = (0, encryption_js_1.decodeCiphertextInput)(value);
136
- const ptBuf = await (0, ecies_geth_1.decrypt)(privKeyABuffer, (0, binary_js_1.bytesFromHexString)(ciphertext));
137
- const payload = (0, hadu_js_1.decodeInput)(ptBuf);
138
- const computable = payload.value;
139
- if (computable.case !== 'scalar') {
140
- throw new Error(`decrypted plaintext is not a scalar, cannot currently be decrypted, this feature may be implemented on request`);
141
- }
142
- const typ = (0, schema_js_1.parse)(encryption_js_1.SupportedFheType, computable.value.type);
143
- return (0, encryption_js_1.bytesToPlaintext)(computable.value.value, encryption_js_1.encryptionSchemes.ecies, typ);
144
- };
145
- }
146
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZWNpZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvbGl0ZS9lY2llcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUF5Q0EsZ0RBVUM7QUFHRCw0REFFQztBQUdELDREQUVDO0FBR0QsNERBSUM7QUFzQkQsOERBSUM7QUFNRCwwQkFhQztBQU9ELDhDQW9EQztBQUtELDBCQU9DO0FBTUQsOENBb0NDO0FBbE9ELDJDQUE4RTtBQUM5RSx3Q0FBd0M7QUFDeEMsNENBQXlFO0FBQ3pFLCtEQWNxQztBQUNyQyw0Q0FBK0Q7QUFFL0QsNENBQXFDO0FBQ3JDLHVDQUFxRDtBQUVyRCxNQUFNLFNBQVMsR0FBRyxJQUFJLFdBQVcsQ0FBQyxFQUFFLENBQUMsV0FBVyxDQUFDLENBQUM7QUFFbEQsNENBQTRDO0FBQy9CLFFBQUEsbUJBQW1CLEdBQzlCLHNFQUFzRSxDQUFDO0FBQzVELFFBQUEsd0JBQXdCLEdBQ25DLG9FQUFvRSxDQUFDO0FBVXZFLG9GQUFvRjtBQUNwRiwwREFBMEQ7QUFDMUQsU0FBZ0Isa0JBQWtCLENBQ2hDLEVBQTBCO0lBRTFCLE9BQU87UUFDTCxNQUFN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@
1
- import * as ellipticPkg from 'elliptic';
2
- import { Decryptor, EciesScheme, Encryptor } from '../encryption/encryption.js';
3
- import { PubKeyEncodable } from '../reencryption/index.js';
4
- export declare const TEST_NETWORK_PUBKEY = "0x02516bda9e68a1c3dce74dc1b6ed7d91a91d51c1e1933947f06331cef59631e9eb";
5
- export declare const TEST_NETWORK_PRIVATE_KEY = "0x384a707568ab63ad2ad9f10135faa0699801db3174f33f7846badc11affb8f57";
6
- export interface Secp256k1Keypair extends PubKeyEncodable {
7
- scheme: EciesScheme;
8
- kp: ellipticPkg.ec.KeyPair;
9
- }
10
- export type Secp256k1PubKey = ellipticPkg.curve.base.BasePoint;
11
- export declare function toSecp256k1Keypair(kp: ellipticPkg.ec.KeyPair): Secp256k1Keypair;
12
- export declare function generateSecp256k1Keypair(): Secp256k1Keypair;
13
- export declare function encodeSecp256k1PublicKey(pub: Secp256k1PubKey): Uint8Array;
14
- export declare function decodeSecp256k1PublicKey(pubKeyCompressed: Uint8Array): Secp256k1PubKey;
15
- export declare function decodeSecp256k1PrivateKey(privKey: Uint8Array): Secp256k1Keypair;
16
- export declare function encrypt(pubKeyA: Secp256k1PubKey, plaintext: Uint8Array, privKeyB: Secp256k1Keypair): Promise<Uint8Array>;
17
- export type EciesEncryptorArgs = {
18
- pubKeyA: Secp256k1PubKey;
19
- privKeyB: Secp256k1Keypair;
20
- };
21
- export declare function getEciesEncryptor({ pubKeyA, privKeyB, }: EciesEncryptorArgs): Encryptor<EciesScheme>;
22
- export declare function decrypt(privKeyA: Secp256k1Keypair, ciphertext: Uint8Array): Promise<Uint8Array>;
23
- export type EciesDecryptorArgs = {
24
- privKeyA: Secp256k1Keypair;
25
- };
26
- export declare function getEciesDecryptor({ privKeyA, }: EciesDecryptorArgs): Decryptor<EciesScheme>;