@inco/js 0.9.0-devnet-test-10 → 0.10.0-devnet-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 (226) hide show
  1. package/README.md +503 -47
  2. package/dist/cjs/advancedacl/session-key.d.ts +5 -5
  3. package/dist/cjs/advancedacl/session-key.js +33 -9
  4. package/dist/cjs/attestedcompute/attested-compute.d.ts +1 -2
  5. package/dist/cjs/attestedcompute/attested-compute.js +15 -7
  6. package/dist/cjs/attesteddecrypt/attested-decrypt.d.ts +5 -43
  7. package/dist/cjs/attesteddecrypt/attested-decrypt.js +33 -96
  8. package/dist/cjs/attestedreveal/attested-reveal.d.ts +21 -0
  9. package/dist/cjs/attestedreveal/attested-reveal.js +31 -0
  10. package/dist/cjs/attestedreveal/index.d.ts +2 -0
  11. package/dist/cjs/attestedreveal/index.js +21 -0
  12. package/dist/cjs/attestedreveal/types.d.ts +4 -0
  13. package/dist/cjs/attestedreveal/types.js +13 -0
  14. package/dist/cjs/binary.d.ts +82 -0
  15. package/dist/cjs/binary.js +87 -5
  16. package/dist/cjs/chain.d.ts +29 -4
  17. package/dist/cjs/chain.js +34 -6
  18. package/dist/cjs/eip712/eip712.d.ts +18 -0
  19. package/dist/cjs/eip712/eip712.js +51 -0
  20. package/dist/cjs/eip712/index.d.ts +1 -0
  21. package/dist/cjs/eip712/index.js +8 -0
  22. package/dist/cjs/elistattesteddecrypt/elist-attested-decrypt.d.ts +49 -0
  23. package/dist/cjs/elistattesteddecrypt/elist-attested-decrypt.js +94 -0
  24. package/dist/cjs/elistattesteddecrypt/index.d.ts +2 -0
  25. package/dist/cjs/elistattesteddecrypt/index.js +22 -0
  26. package/dist/cjs/elistattesteddecrypt/types.d.ts +31 -0
  27. package/dist/cjs/elistattesteddecrypt/types.js +16 -0
  28. package/dist/cjs/encryption/encryption.d.ts +115 -0
  29. package/dist/cjs/encryption/encryption.js +98 -7
  30. package/dist/cjs/encryption/index.d.ts +1 -1
  31. package/dist/cjs/encryption/index.js +17 -16
  32. package/dist/cjs/generated/abis/lightning.d.ts +1119 -107
  33. package/dist/cjs/generated/abis/lightning.js +762 -52
  34. package/dist/cjs/generated/abis/test-elist.d.ts +20 -2
  35. package/dist/cjs/generated/abis/test-elist.js +16 -3
  36. package/dist/cjs/generated/abis/verifier.d.ts +118 -15
  37. package/dist/cjs/generated/abis/verifier.js +71 -19
  38. package/dist/cjs/generated/es/inco/covalidator/compute/v1/server_pb.d.ts +23 -37
  39. package/dist/cjs/generated/es/inco/covalidator/compute/v1/server_pb.js +36 -41
  40. package/dist/cjs/generated/es/inco/covalidator/compute/v1/types_pb.js +1 -1
  41. package/dist/cjs/generated/es/inco/helioswrapper/v1/helioswrapper_pb.js +1 -1
  42. package/dist/cjs/generated/es/inco/kms/lite/v1/kms_service_pb.d.ts +16 -0
  43. package/dist/cjs/generated/es/inco/kms/lite/v1/kms_service_pb.js +3 -3
  44. package/dist/cjs/generated/es/inco/kms/lite/v1/types_pb.js +1 -1
  45. package/dist/cjs/generated/es/inco/sealingfetcher/v1/sealingfetcher_pb.d.ts +7 -0
  46. package/dist/cjs/generated/es/inco/sealingfetcher/v1/sealingfetcher_pb.js +3 -3
  47. package/dist/cjs/generated/lightning.d.ts +150 -0
  48. package/dist/cjs/generated/lightning.js +157 -1
  49. package/dist/cjs/generated/local-node.d.ts +9 -9
  50. package/dist/cjs/generated/local-node.js +37 -10
  51. package/dist/cjs/handle.d.ts +72 -0
  52. package/dist/cjs/handle.js +113 -9
  53. package/dist/cjs/index.d.ts +1 -1
  54. package/dist/cjs/index.js +11 -2
  55. package/dist/cjs/kms/client.d.ts +1 -1
  56. package/dist/cjs/kms/client.js +4 -3
  57. package/dist/cjs/kms/quorumClient.d.ts +18 -12
  58. package/dist/cjs/kms/quorumClient.js +212 -231
  59. package/dist/cjs/kms/quorumConsistency.d.ts +82 -0
  60. package/dist/cjs/kms/quorumConsistency.js +269 -0
  61. package/dist/cjs/kms/signatureVerification.d.ts +35 -0
  62. package/dist/cjs/kms/signatureVerification.js +88 -0
  63. package/dist/cjs/kms/thresholdPromises.d.ts +4 -3
  64. package/dist/cjs/kms/thresholdPromises.js +25 -15
  65. package/dist/cjs/lite/attested-compute.d.ts +2 -2
  66. package/dist/cjs/lite/attested-compute.js +2 -3
  67. package/dist/cjs/lite/attested-decrypt.d.ts +2 -2
  68. package/dist/cjs/lite/attested-decrypt.js +2 -3
  69. package/dist/cjs/lite/hadu.d.ts +1 -1
  70. package/dist/cjs/lite/hadu.js +3 -3
  71. package/dist/cjs/lite/index.d.ts +6 -2
  72. package/dist/cjs/lite/index.js +8 -14
  73. package/dist/cjs/lite/lightning.d.ts +96 -47
  74. package/dist/cjs/lite/lightning.js +221 -267
  75. package/dist/cjs/lite/types.d.ts +47 -0
  76. package/dist/cjs/lite/types.js +3 -0
  77. package/dist/cjs/lite/xwing.d.ts +33 -2
  78. package/dist/cjs/lite/xwing.js +62 -7
  79. package/dist/cjs/local/local-node.d.ts +18 -0
  80. package/dist/cjs/local/local-node.js +18 -3
  81. package/dist/cjs/reencryption/eip712.d.ts +27 -0
  82. package/dist/cjs/reencryption/eip712.js +20 -7
  83. package/dist/cjs/reencryption/types.d.ts +24 -0
  84. package/dist/cjs/retry.d.ts +14 -0
  85. package/dist/cjs/retry.js +58 -2
  86. package/dist/cjs/test/mocks.d.ts +6 -1
  87. package/dist/cjs/test/mocks.js +31 -6
  88. package/dist/cjs/viem.d.ts +361 -1
  89. package/dist/cjs/viem.js +14 -1
  90. package/dist/esm/advancedacl/session-key.d.ts +5 -5
  91. package/dist/esm/advancedacl/session-key.js +33 -9
  92. package/dist/esm/attestedcompute/attested-compute.d.ts +1 -2
  93. package/dist/esm/attestedcompute/attested-compute.js +13 -5
  94. package/dist/esm/attesteddecrypt/attested-decrypt.d.ts +5 -43
  95. package/dist/esm/attesteddecrypt/attested-decrypt.js +34 -96
  96. package/dist/esm/attestedreveal/attested-reveal.d.ts +21 -0
  97. package/dist/esm/attestedreveal/attested-reveal.js +28 -0
  98. package/dist/esm/attestedreveal/index.d.ts +2 -0
  99. package/dist/esm/attestedreveal/index.js +3 -0
  100. package/dist/esm/attestedreveal/types.d.ts +4 -0
  101. package/dist/esm/attestedreveal/types.js +9 -0
  102. package/dist/esm/binary.d.ts +82 -0
  103. package/dist/esm/binary.js +87 -5
  104. package/dist/esm/chain.d.ts +29 -4
  105. package/dist/esm/chain.js +33 -5
  106. package/dist/esm/eip712/eip712.d.ts +18 -0
  107. package/dist/esm/eip712/eip712.js +46 -0
  108. package/dist/esm/eip712/index.d.ts +1 -0
  109. package/dist/esm/eip712/index.js +2 -0
  110. package/dist/esm/elistattesteddecrypt/elist-attested-decrypt.d.ts +49 -0
  111. package/dist/esm/elistattesteddecrypt/elist-attested-decrypt.js +89 -0
  112. package/dist/esm/elistattesteddecrypt/index.d.ts +2 -0
  113. package/dist/esm/elistattesteddecrypt/index.js +3 -0
  114. package/dist/esm/elistattesteddecrypt/types.d.ts +31 -0
  115. package/dist/esm/elistattesteddecrypt/types.js +12 -0
  116. package/dist/esm/encryption/encryption.d.ts +115 -0
  117. package/dist/esm/encryption/encryption.js +98 -7
  118. package/dist/esm/encryption/index.d.ts +1 -1
  119. package/dist/esm/encryption/index.js +2 -2
  120. package/dist/esm/generated/abis/lightning.d.ts +1119 -107
  121. package/dist/esm/generated/abis/lightning.js +761 -51
  122. package/dist/esm/generated/abis/test-elist.d.ts +20 -2
  123. package/dist/esm/generated/abis/test-elist.js +16 -3
  124. package/dist/esm/generated/abis/verifier.d.ts +118 -15
  125. package/dist/esm/generated/abis/verifier.js +71 -19
  126. package/dist/esm/generated/es/inco/covalidator/compute/v1/server_pb.d.ts +23 -37
  127. package/dist/esm/generated/es/inco/covalidator/compute/v1/server_pb.js +35 -40
  128. package/dist/esm/generated/es/inco/covalidator/compute/v1/types_pb.js +1 -1
  129. package/dist/esm/generated/es/inco/helioswrapper/v1/helioswrapper_pb.js +1 -1
  130. package/dist/esm/generated/es/inco/kms/lite/v1/kms_service_pb.d.ts +16 -0
  131. package/dist/esm/generated/es/inco/kms/lite/v1/kms_service_pb.js +3 -3
  132. package/dist/esm/generated/es/inco/kms/lite/v1/types_pb.js +1 -1
  133. package/dist/esm/generated/es/inco/sealingfetcher/v1/sealingfetcher_pb.d.ts +7 -0
  134. package/dist/esm/generated/es/inco/sealingfetcher/v1/sealingfetcher_pb.js +3 -3
  135. package/dist/esm/generated/lightning.d.ts +150 -0
  136. package/dist/esm/generated/lightning.js +157 -1
  137. package/dist/esm/generated/local-node.d.ts +9 -9
  138. package/dist/esm/generated/local-node.js +37 -10
  139. package/dist/esm/handle.d.ts +72 -0
  140. package/dist/esm/handle.js +110 -8
  141. package/dist/esm/index.d.ts +1 -1
  142. package/dist/esm/index.js +2 -2
  143. package/dist/esm/kms/client.d.ts +1 -1
  144. package/dist/esm/kms/client.js +3 -2
  145. package/dist/esm/kms/quorumClient.d.ts +18 -12
  146. package/dist/esm/kms/quorumClient.js +213 -232
  147. package/dist/esm/kms/quorumConsistency.d.ts +82 -0
  148. package/dist/esm/kms/quorumConsistency.js +260 -0
  149. package/dist/esm/kms/signatureVerification.d.ts +35 -0
  150. package/dist/esm/kms/signatureVerification.js +84 -0
  151. package/dist/esm/kms/thresholdPromises.d.ts +4 -3
  152. package/dist/esm/kms/thresholdPromises.js +25 -15
  153. package/dist/esm/lite/attested-compute.d.ts +2 -2
  154. package/dist/esm/lite/attested-compute.js +3 -3
  155. package/dist/esm/lite/attested-decrypt.d.ts +2 -2
  156. package/dist/esm/lite/attested-decrypt.js +3 -3
  157. package/dist/esm/lite/hadu.d.ts +1 -1
  158. package/dist/esm/lite/hadu.js +2 -2
  159. package/dist/esm/lite/index.d.ts +6 -2
  160. package/dist/esm/lite/index.js +5 -3
  161. package/dist/esm/lite/lightning.d.ts +96 -47
  162. package/dist/esm/lite/lightning.js +217 -263
  163. package/dist/esm/lite/types.d.ts +47 -0
  164. package/dist/esm/lite/types.js +2 -0
  165. package/dist/esm/lite/xwing.d.ts +33 -2
  166. package/dist/esm/lite/xwing.js +59 -7
  167. package/dist/esm/local/local-node.d.ts +18 -0
  168. package/dist/esm/local/local-node.js +18 -3
  169. package/dist/esm/reencryption/eip712.d.ts +27 -0
  170. package/dist/esm/reencryption/eip712.js +20 -7
  171. package/dist/esm/reencryption/types.d.ts +24 -0
  172. package/dist/esm/retry.d.ts +14 -0
  173. package/dist/esm/retry.js +56 -2
  174. package/dist/esm/test/mocks.d.ts +6 -1
  175. package/dist/esm/test/mocks.js +31 -8
  176. package/dist/esm/viem.d.ts +361 -1
  177. package/dist/esm/viem.js +15 -2
  178. package/dist/types/advancedacl/session-key.d.ts +5 -5
  179. package/dist/types/attestedcompute/attested-compute.d.ts +1 -2
  180. package/dist/types/attesteddecrypt/attested-decrypt.d.ts +5 -43
  181. package/dist/types/attestedreveal/attested-reveal.d.ts +21 -0
  182. package/dist/types/attestedreveal/index.d.ts +2 -0
  183. package/dist/types/attestedreveal/types.d.ts +4 -0
  184. package/dist/types/binary.d.ts +82 -0
  185. package/dist/types/chain.d.ts +29 -4
  186. package/dist/types/eip712/eip712.d.ts +18 -0
  187. package/dist/types/eip712/index.d.ts +1 -0
  188. package/dist/types/elistattesteddecrypt/elist-attested-decrypt.d.ts +49 -0
  189. package/dist/types/elistattesteddecrypt/index.d.ts +2 -0
  190. package/dist/types/elistattesteddecrypt/types.d.ts +31 -0
  191. package/dist/types/encryption/encryption.d.ts +115 -0
  192. package/dist/types/encryption/index.d.ts +1 -1
  193. package/dist/types/generated/abis/lightning.d.ts +1119 -107
  194. package/dist/types/generated/abis/test-elist.d.ts +20 -2
  195. package/dist/types/generated/abis/verifier.d.ts +118 -15
  196. package/dist/types/generated/es/inco/covalidator/compute/v1/server_pb.d.ts +23 -37
  197. package/dist/types/generated/es/inco/kms/lite/v1/kms_service_pb.d.ts +16 -0
  198. package/dist/types/generated/es/inco/sealingfetcher/v1/sealingfetcher_pb.d.ts +7 -0
  199. package/dist/types/generated/lightning.d.ts +150 -0
  200. package/dist/types/generated/local-node.d.ts +9 -9
  201. package/dist/types/handle.d.ts +72 -0
  202. package/dist/types/index.d.ts +1 -1
  203. package/dist/types/kms/client.d.ts +1 -1
  204. package/dist/types/kms/quorumClient.d.ts +18 -12
  205. package/dist/types/kms/quorumConsistency.d.ts +82 -0
  206. package/dist/types/kms/signatureVerification.d.ts +35 -0
  207. package/dist/types/kms/thresholdPromises.d.ts +4 -3
  208. package/dist/types/lite/attested-compute.d.ts +2 -2
  209. package/dist/types/lite/attested-decrypt.d.ts +2 -2
  210. package/dist/types/lite/hadu.d.ts +1 -1
  211. package/dist/types/lite/index.d.ts +6 -2
  212. package/dist/types/lite/lightning.d.ts +96 -47
  213. package/dist/types/lite/types.d.ts +47 -0
  214. package/dist/types/lite/xwing.d.ts +33 -2
  215. package/dist/types/local/local-node.d.ts +18 -0
  216. package/dist/types/reencryption/eip712.d.ts +27 -0
  217. package/dist/types/reencryption/types.d.ts +24 -0
  218. package/dist/types/retry.d.ts +14 -0
  219. package/dist/types/test/mocks.d.ts +6 -1
  220. package/dist/types/viem.d.ts +361 -1
  221. package/package.json +19 -21
  222. package/dist/cjs/generated/abis/lightning-preview.d.ts +0 -1385
  223. package/dist/cjs/generated/abis/lightning-preview.js +0 -857
  224. package/dist/esm/generated/abis/lightning-preview.d.ts +0 -1385
  225. package/dist/esm/generated/abis/lightning-preview.js +0 -854
  226. package/dist/types/generated/abis/lightning-preview.d.ts +0 -1385
@@ -1,7 +1,8 @@
1
1
  /**
2
- * Executes promises and returns results as soon as threshold is reached
2
+ * Executes all promises and returns all successful results.
3
+ * Rejects early if it becomes mathematically impossible to reach the threshold.
3
4
  * @param promises Array of promises to execute
4
- * @param threshold Number of successful responses needed
5
- * @returns Promise that resolves with threshold number of results
5
+ * @param threshold Minimum number of successful responses required
6
+ * @returns Promise that resolves with all successful results (length >= threshold)
6
7
  */
7
8
  export declare function executeWithThreshold<T>(promises: Promise<T>[], threshold: number): Promise<T[]>;
@@ -1,6 +1,6 @@
1
- import { ATTESTED_COMPUTE_DOMAIN_NAME, DEFAULT_ATTESTED_COMPUTE_DOMAIN_VERSION, type IncoLiteAttestedComputeArgs } from '../attestedcompute/attested-compute.js';
1
+ import { ATTESTED_COMPUTE_DOMAIN_NAME, type IncoLiteAttestedComputeArgs } from '../attestedcompute/attested-compute.js';
2
2
  import type { AttestedCompute, AttestedComputeFnArgs } from '../attestedcompute/types.js';
3
3
  import { AttestedComputeSupportedOps } from '../attestedcompute/types.js';
4
4
  import type { AttestedDecryptFnArgs } from '../attesteddecrypt/types.js';
5
- export { ATTESTED_COMPUTE_DOMAIN_NAME, AttestedComputeSupportedOps, DEFAULT_ATTESTED_COMPUTE_DOMAIN_VERSION, };
5
+ export { ATTESTED_COMPUTE_DOMAIN_NAME, AttestedComputeSupportedOps };
6
6
  export type { AttestedCompute, AttestedComputeFnArgs, AttestedDecryptFnArgs, IncoLiteAttestedComputeArgs, };
@@ -1,4 +1,4 @@
1
1
  import { type IncoLiteAttestedDecryptorArgs } from '../attesteddecrypt/attested-decrypt.js';
2
2
  export type { IncoLiteAttestedDecryptorArgs };
3
- import { ATTESTED_DECRYPT_DOMAIN_NAME, DEFAULT_ATTESTED_DECRYPT_DOMAIN_VERSION } from '../attesteddecrypt/attested-decrypt.js';
4
- export { ATTESTED_DECRYPT_DOMAIN_NAME, DEFAULT_ATTESTED_DECRYPT_DOMAIN_VERSION, };
3
+ import { ATTESTED_DECRYPT_DOMAIN_NAME } from '../attesteddecrypt/attested-decrypt.js';
4
+ export { ATTESTED_DECRYPT_DOMAIN_NAME };
@@ -1,4 +1,4 @@
1
- import { PlaintextWithContext } from '../encryption/index.js';
1
+ import { PlaintextWithContext } from '../encryption/encryption.js';
2
2
  import { InputPayload } from '../generated/es/inco/covalidator/compute/v1/types_pb.js';
3
3
  export declare function encodeInput({ plaintext, context, }: PlaintextWithContext): Uint8Array;
4
4
  export declare function decodeInput(input: Uint8Array): InputPayload;
@@ -1,9 +1,13 @@
1
+ export { AttestedComputeError } from '../attestedcompute/types.js';
2
+ export { AttestedDecryptError } from '../attesteddecrypt/types.js';
3
+ export { AttestedRevealError } from '../attestedreveal/types.js';
1
4
  export * from '../generated/abis/lightning.js';
2
5
  export type { AttestedComputeRequest, AttestedDecryptRequest, KmsService, } from '../generated/es/inco/kms/lite/v1/kms_service_pb.js';
3
6
  export type { HandleWithProof } from '../generated/es/inco/kms/lite/v1/types_pb.js';
4
7
  export * from './attested-compute.js';
5
8
  export * from './attested-decrypt.js';
6
9
  export * from './deployments.js';
7
- export * from './hadu.js';
8
10
  export * from './lightning.js';
9
- export { TEST_NETWORK_SEED_KEY, TEST_NETWORK_XWING_PUBKEY, XWING_PUBLIC_KEY_SIZE, decodeXwingPrivateKey, decodeXwingPublicKey, decrypt, deriveXwingKeypairFromSeed, encodeXwingPublicKey, encrypt, generateXwingKeypair, getXwingDecryptor, getXwingEncryptor, type XwingDecryptorArgs, type XwingEncryptorArgs, type XwingKeypair, } from './xwing.js';
11
+ export type { AttestedOpts, AttestedOptsDecrypted, AttestedOptsEncrypted, AttestedOptsEphemeral, AttestedRevealOpts, AttestedWithVoucherOpts, AttestedWithVoucherOptsDecrypted, AttestedWithVoucherOptsEncrypted, AttestedWithVoucherOptsEphemeral, } from './types.js';
12
+ export { generateXwingKeypair } from './xwing.js';
13
+ export type { XwingKeypair } from './xwing.js';
@@ -4,14 +4,14 @@ import { AllowanceVoucherWithSig } from '../advancedacl/types.js';
4
4
  import { AttestedComputeOP } from '../attestedcompute/types.js';
5
5
  import { DecryptionAttestation, EncryptedDecryptionAttestation } from '../attesteddecrypt/index.js';
6
6
  import { Address, HexString } from '../binary.js';
7
- import { EncryptionScheme, SupportedFheType } from '../encryption/index.js';
7
+ import { EListDecryptionAttestation, EncryptedEListDecryptionAttestation } from '../elistattesteddecrypt/index.js';
8
+ import { EncryptionScheme, SupportedFheType } from '../encryption/encryption.js';
8
9
  import { incoVerifierAbi } from '../generated/abis/verifier.js';
9
10
  import { lightningDeployments } from '../generated/lightning.js';
10
11
  import { localNodeLightningConfig } from '../generated/local-node.js';
11
12
  import { FheType } from '../handle.js';
12
13
  import { LocalNodeEnv } from '../local/index.js';
13
- import { BackoffConfig } from '../retry.js';
14
- import { XwingKeypair } from './xwing.js';
14
+ import type { AttestedOptsDecrypted, AttestedOptsEncrypted, AttestedOptsEphemeral, AttestedRevealOpts, AttestedWithVoucherOptsDecrypted, AttestedWithVoucherOptsEncrypted, AttestedWithVoucherOptsEphemeral } from './types.js';
15
15
  type TupleToUnion<T> = T extends readonly unknown[] ? T[number] : never;
16
16
  type Deployment = TupleToUnion<typeof lightningDeployments>;
17
17
  type DistributedPick<T, K> = T extends any ? Pick<T, Extract<keyof T, K>> : never;
@@ -36,7 +36,7 @@ export type CustomConfig = {
36
36
  chainId: number;
37
37
  covalidatorUrls: string[];
38
38
  signers?: Address[];
39
- hostChainRpcUrl?: string;
39
+ hostChainRpcUrls?: readonly string[] | string[];
40
40
  senderPrivateKey?: HexString;
41
41
  };
42
42
  export type CustomDeployment = DeploymentSlice & CustomConfig;
@@ -58,6 +58,7 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
58
58
  private readonly signers;
59
59
  private readonly threshold;
60
60
  private readonly networkPubkey;
61
+ private readonly publicClient;
61
62
  readonly executorAddress: Address;
62
63
  readonly chainId: bigint;
63
64
  private readonly kmsQuorumClient;
@@ -67,14 +68,19 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
67
68
  private getEncryptor;
68
69
  /**
69
70
  * Get the encryption scheme version used by this Lightning instance.
70
- * Returns 1 for ECIES or 2 for X-Wing.
71
+ * Returns the X-Wing encryption scheme identifier.
71
72
  * This is a convenience method to get the encryption scheme used by this Lightning instance.
72
73
  */
73
74
  getEncryptionScheme(): Promise<EncryptionScheme>;
74
75
  /**
75
76
  * Get a Lightning instance bound to the latest Lightning deployment for the Base Sepolia testnet.
77
+ *
78
+ * @param options.hostChainRpcUrls optional list of RPC URLs for the host chain. When multiple URLs are
79
+ * provided, viem's fallback transport is used and providers are tried in order on failure.
76
80
  */
77
- static baseSepoliaTestnet(): Promise<Lightning<Deployment>>;
81
+ static baseSepoliaTestnet(options?: {
82
+ hostChainRpcUrls?: readonly string[];
83
+ }): Promise<Lightning<Deployment>>;
78
84
  /**
79
85
  * Get a Lightning instance bound to our canonical Anvil-based test node and test Covalidator node
80
86
  *
@@ -101,8 +107,12 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
101
107
  * Get a Lightning deployment by name or executor address on a particular chain.
102
108
  *
103
109
  * @param id this is an object containing either the pair of name and chainId or the executorAddress and chainId
110
+ * @param options.hostChainRpcUrls optional list of RPC URLs for the host chain. When multiple URLs are
111
+ * provided, viem's fallback transport is used and providers are tried in order on failure.
104
112
  */
105
- static at(id: DeploymentId): Promise<Lightning<Deployment>>;
113
+ static at(id: DeploymentId, options?: {
114
+ hostChainRpcUrls?: readonly string[];
115
+ }): Promise<Lightning<Deployment>>;
106
116
  /**
107
117
  * Get a Lightning deployment for a local or custom node
108
118
  *
@@ -124,12 +134,17 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
124
134
  * will not be compatible with the new version.
125
135
  *
126
136
  * @param pepper the pepper to use to filter the deployments
127
- * @param chain the chain to use to filter the deployments
137
+ * @param chainId the chainId to use to filter the deployments
138
+ * @param options.hostChainRpcUrls optional list of RPC URLs for the host chain. When multiple URLs are
139
+ * provided, viem's fallback transport is used and providers are tried in order on failure.
128
140
  */
129
- static latest<P extends Pepper>(pepper: P, chainId: ChainId): Promise<Lightning<Deployment>>;
141
+ static latest<P extends Pepper>(pepper: P, chainId: ChainId, options?: {
142
+ hostChainRpcUrls?: readonly string[];
143
+ }): Promise<Lightning<Deployment>>;
144
+ /** Returns a shallow copy of the deployment configuration this Lightning instance is bound to. */
130
145
  get deployment(): T;
131
146
  /**
132
- * Encrypt a value using the network's public key (ECIES or X-Wing).
147
+ * Encrypt a value using the network's public key (X-Wing).
133
148
  * The encryption scheme is automatically detected based on the public key length.
134
149
  *
135
150
  * @param value a boolean or numeric value to encrypt
@@ -218,39 +233,37 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
218
233
  *
219
234
  * @example Reencrypt for a delegate
220
235
  * ```ts
221
- * const encrypted = await lightning.attestedDecrypt(walletClient, [handle], delegatePubKey);
236
+ * const encrypted = await lightning.attestedDecrypt(walletClient, [handle], {
237
+ * reencryptPubKey: delegatePubKey,
238
+ * });
222
239
  * console.log(encrypted[0].encryptedPlaintext.ciphertext.value);
223
240
  * ```
224
241
  *
225
242
  * @example Reencrypt and decrypt locally
226
243
  * ```ts
227
- * const decrypted = await lightning.attestedDecrypt(
228
- * walletClient,
229
- * [handle],
230
- * keypair.encodePublicKey(),
231
- * keypair,
232
- * );
244
+ * const decrypted = await lightning.attestedDecrypt(walletClient, [handle], {
245
+ * reencryptPubKey: keypair.encodePublicKey(),
246
+ * reencryptKeypair: keypair,
247
+ * });
233
248
  * console.log(decrypted[0].plaintext.value);
234
249
  * ```
235
250
  */
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>>>;
251
+ attestedDecrypt(walletClient: WalletClient<Transport, Chain, Account>, handles: HexString[], opts?: AttestedOptsEphemeral): Promise<Array<DecryptionAttestation<EncryptionScheme, SupportedFheType>>>;
252
+ attestedDecrypt(walletClient: WalletClient<Transport, Chain, Account>, handles: HexString[], opts: AttestedOptsEncrypted): Promise<Array<EncryptedDecryptionAttestation<EncryptionScheme, SupportedFheType>>>;
253
+ attestedDecrypt(walletClient: WalletClient<Transport, Chain, Account>, handles: HexString[], opts: AttestedOptsDecrypted): Promise<Array<DecryptionAttestation<EncryptionScheme, SupportedFheType>>>;
239
254
  /**
240
255
  * Requests attested decrypts using a voucher-backed session key.
241
256
  *
242
257
  * @param ephemeralAccount Session Account matching the voucher grantee.
243
258
  * @param allowanceVoucherWithSig Signed allowance voucher.
244
- * @param ethClient - A public eth client or eth wallet client used for signing the attested decrypt request
245
259
  * @param handles Handles to decrypt.
246
- * @param options Optional reencryption/backoff configuration.
260
+ * @param opts Optional reencryption/backoff configuration.
247
261
  *
248
262
  * @example Plaintext results
249
263
  * ```ts
250
264
  * const attestations = await lightning.attestedDecryptWithVoucher(
251
265
  * ephemeralAccount,
252
266
  * voucher,
253
- * ethClient,
254
267
  * [handle],
255
268
  * );
256
269
  * ```
@@ -260,15 +273,36 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
260
273
  * const encrypted = await lightning.attestedDecryptWithVoucher(
261
274
  * ephemeralAccount,
262
275
  * voucher,
263
- * ethClient,
264
276
  * [handle],
265
277
  * { reencryptPubKey: delegateKeypair.encodePublicKey() },
266
278
  * );
267
279
  * ```
280
+ *
281
+ * @example Reencrypt and decrypt locally
282
+ * ```ts
283
+ * const decrypted = await lightning.attestedDecryptWithVoucher(
284
+ * ephemeralAccount,
285
+ * voucher,
286
+ * [handle],
287
+ * { reencryptPubKey: keypair.encodePublicKey(), reencryptKeypair: keypair },
288
+ * );
289
+ * ```
290
+ */
291
+ attestedDecryptWithVoucher(ephemeralAccount: PrivateKeyAccount, allowanceVoucherWithSig: AllowanceVoucherWithSig, handles: HexString[], opts?: AttestedWithVoucherOptsEphemeral): Promise<Array<DecryptionAttestation<EncryptionScheme, SupportedFheType>>>;
292
+ attestedDecryptWithVoucher(ephemeralAccount: PrivateKeyAccount, allowanceVoucherWithSig: AllowanceVoucherWithSig, handles: HexString[], opts: AttestedWithVoucherOptsEncrypted): Promise<Array<EncryptedDecryptionAttestation<EncryptionScheme, SupportedFheType>>>;
293
+ attestedDecryptWithVoucher(ephemeralAccount: PrivateKeyAccount, allowanceVoucherWithSig: AllowanceVoucherWithSig, handles: HexString[], opts: AttestedWithVoucherOptsDecrypted): Promise<Array<DecryptionAttestation<EncryptionScheme, SupportedFheType>>>;
294
+ eListAttestedDecrypt(walletClient: WalletClient<Transport, Chain, Account>, handle: HexString, opts?: AttestedOptsEphemeral): Promise<EListDecryptionAttestation<EncryptionScheme, SupportedFheType>>;
295
+ eListAttestedDecrypt(walletClient: WalletClient<Transport, Chain, Account>, handle: HexString, opts: AttestedOptsEncrypted): Promise<EncryptedEListDecryptionAttestation<EncryptionScheme, SupportedFheType>>;
296
+ eListAttestedDecrypt(walletClient: WalletClient<Transport, Chain, Account>, handle: HexString, opts: AttestedOptsDecrypted): Promise<EListDecryptionAttestation<EncryptionScheme, SupportedFheType>>;
297
+ /**
298
+ * Reveal a single elist handle without wallet authentication.
299
+ * Returns plaintext values along with an attestation of the checksum.
300
+ *
301
+ * @param handle - The elist handle to reveal
302
+ * @param opts - Optional backoff configuration
303
+ * @returns The elist decryption attestation with plaintext values
268
304
  */
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>>>;
305
+ eListAttestedReveal(handle: HexString, opts?: AttestedRevealOpts): Promise<EListDecryptionAttestation<EncryptionScheme, SupportedFheType>>;
272
306
  /**
273
307
  * Get an attested compute for the given wallet client.
274
308
  *
@@ -276,7 +310,7 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
276
310
  * @param lhsHandle - The handle to compute
277
311
  * @param op - The operation to perform
278
312
  * @param rhsPlaintext - The plaintext to compute with
279
- * @param backoffConfig - The backoff configuration for the attested compute request
313
+ * @param opts - Optional configuration (reencryption keys and/or backoff config)
280
314
  * @returns The decryption attestation
281
315
  *
282
316
  * @example Plaintext result
@@ -296,7 +330,7 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
296
330
  * lhsHandle,
297
331
  * op,
298
332
  * rhsPlaintext,
299
- * delegatePubKey,
333
+ * { reencryptPubKey: delegatePubKey },
300
334
  * );
301
335
  * console.log(encrypted.encryptedPlaintext.ciphertext.value);
302
336
  * ```
@@ -308,15 +342,14 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
308
342
  * lhsHandle,
309
343
  * op,
310
344
  * rhsPlaintext,
311
- * keypair.encodePublicKey(),
312
- * keypair,
345
+ * { reencryptPubKey: keypair.encodePublicKey(), reencryptKeypair: keypair },
313
346
  * );
314
347
  * console.log(decrypted.plaintext.value);
315
348
  * ```
316
349
  */
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>>;
350
+ attestedCompute(walletClient: WalletClient<Transport, Chain, Account>, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, opts?: AttestedOptsEphemeral): Promise<DecryptionAttestation<EncryptionScheme, SupportedFheType>>;
351
+ attestedCompute(walletClient: WalletClient<Transport, Chain, Account>, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, opts: AttestedOptsEncrypted): Promise<EncryptedDecryptionAttestation<EncryptionScheme, SupportedFheType>>;
352
+ attestedCompute(walletClient: WalletClient<Transport, Chain, Account>, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, opts: AttestedOptsDecrypted): Promise<DecryptionAttestation<EncryptionScheme, SupportedFheType>>;
320
353
  /**
321
354
  * Performs attested compute via a voucher-backed session key.
322
355
  *
@@ -325,7 +358,6 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
325
358
  * const attestation = await lightning.attestedComputeWithVoucher(
326
359
  * ephemeralAccount,
327
360
  * voucher,
328
- * ethClient,
329
361
  * lhsHandle,
330
362
  * AttestedComputeSupportedOps.Eq,
331
363
  * true,
@@ -340,7 +372,7 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
340
372
  * lhsHandle,
341
373
  * AttestedComputeSupportedOps.Eq,
342
374
  * true,
343
- * delegatePubKey,
375
+ * { reencryptPubKey: delegatePubKey },
344
376
  * );
345
377
  * console.log(encrypted.encryptedPlaintext.ciphertext.value);
346
378
  * ```
@@ -353,15 +385,14 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
353
385
  * lhsHandle,
354
386
  * AttestedComputeSupportedOps.Eq,
355
387
  * true,
356
- * keypair.encodePublicKey(),
357
- * keypair,
388
+ * { reencryptPubKey: keypair.encodePublicKey(), reencryptKeypair: keypair },
358
389
  * );
359
390
  * console.log(decrypted.plaintext.value);
360
391
  * ```
361
392
  */
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>>;
393
+ attestedComputeWithVoucher(ephemeralAccount: PrivateKeyAccount, allowanceVoucherWithSig: AllowanceVoucherWithSig, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, opts?: AttestedWithVoucherOptsEphemeral): Promise<DecryptionAttestation<EncryptionScheme, SupportedFheType>>;
394
+ attestedComputeWithVoucher(ephemeralAccount: PrivateKeyAccount, allowanceVoucherWithSig: AllowanceVoucherWithSig, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, opts: AttestedWithVoucherOptsEncrypted): Promise<EncryptedDecryptionAttestation<EncryptionScheme, SupportedFheType>>;
395
+ attestedComputeWithVoucher(ephemeralAccount: PrivateKeyAccount, allowanceVoucherWithSig: AllowanceVoucherWithSig, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, opts: AttestedWithVoucherOptsDecrypted): Promise<DecryptionAttestation<EncryptionScheme, SupportedFheType>>;
365
396
  /**
366
397
  * Get an decryption of publicly revealed handles.
367
398
  *
@@ -371,31 +402,49 @@ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
371
402
  *
372
403
  * @example
373
404
  * ```typescript
374
- * const response = await lightning.attestedReveal([handle1, handle2], ethClient);
405
+ * const response = await lightning.attestedReveal([handle1, handle2]);
375
406
  * const { plaintext, covalidatorSignature } = response[0];
376
407
  * ```
377
408
  */
378
- attestedReveal(handles: HexString[], backoffConfig?: Partial<BackoffConfig>): Promise<Array<DecryptionAttestation<EncryptionScheme, SupportedFheType>>>;
409
+ attestedReveal(handles: HexString[], opts?: AttestedRevealOpts): Promise<Array<DecryptionAttestation<EncryptionScheme, SupportedFheType>>>;
379
410
  /**
380
411
  * Get the GRPC endpoint for the covalidator that services this deployment.
381
412
  */
382
413
  static getCovalidatorUrls(deployment: DeploymentSlice & {
383
414
  pepper: string;
384
- }, threshold: number): string[];
415
+ majorVersion: number;
416
+ }, signers: Address[]): string[];
385
417
  private static isIdByName;
386
418
  private static plaintextFromValue;
419
+ /**
420
+ * Reads the network public key from the on-chain Inco Verifier contract.
421
+ *
422
+ * Falls back to the legacy `eciesPubkey()` getter for older contract versions.
423
+ *
424
+ * @param client - A viem public client connected to the host chain.
425
+ * @param executorAddress - The address of the Inco Lightning executor contract.
426
+ * @returns The network public key as a hex string.
427
+ */
387
428
  static getNetworkPubkey(client: PublicClient, executorAddress: Address): Promise<HexString>;
429
+ /**
430
+ * Resolves the Inco Verifier contract instance associated with a Lightning executor.
431
+ *
432
+ * Reads the `incoVerifier` address from the executor contract and returns a typed contract handle.
433
+ *
434
+ * @param client - A viem public client connected to the host chain.
435
+ * @param executorAddress - The address of the Inco Lightning executor contract.
436
+ * @returns A viem contract instance bound to the Inco Verifier ABI.
437
+ */
388
438
  static getIncoVerifierContract(client: PublicClient, executorAddress: Address): Promise<GetContractReturnType<typeof incoVerifierAbi, PublicClient, Address>>;
389
439
  /**
390
- * Retrieves the verifier contract details including threshold, signers, and ECIES public key from the Inco Verifier contract.
440
+ * Retrieves the verifier contract details including threshold, signers, and XWING public key from the Inco Verifier contract.
391
441
  *
392
442
  * @param executorAddress The address of the Inco Lightning executor contract.
393
443
  * @param client The public client to interact with the blockchain.
394
- * @returns An object containing the threshold, signers, and ECIES public key.
444
+ * @returns An object containing the threshold, signers, and XWING public key.
395
445
  */
396
446
  private static getVerifierContractDetails;
397
447
  private static getChainConfig;
398
448
  private static supportsThresholdRetrieval;
399
- private static getDefaultThresholdAndSigners;
400
449
  }
401
450
  export {};
@@ -0,0 +1,47 @@
1
+ import type { HexString } from '../binary.js';
2
+ import type { BackoffConfig } from '../retry.js';
3
+ import type { XwingKeypair } from './xwing.js';
4
+ /**
5
+ * Options for attested methods when no reencrypt keys are provided.
6
+ * The KMS generates an ephemeral keypair and returns plaintext.
7
+ */
8
+ export type AttestedOptsEphemeral = {
9
+ reencryptPubKey?: never;
10
+ reencryptKeypair?: never;
11
+ backoffConfig?: Partial<BackoffConfig>;
12
+ };
13
+ /**
14
+ * Options for attested methods when only a reencrypt public key is provided.
15
+ * The KMS encrypts the result under the provided key; caller receives ciphertext.
16
+ */
17
+ export type AttestedOptsEncrypted = {
18
+ reencryptPubKey: Uint8Array;
19
+ reencryptKeypair?: never;
20
+ backoffConfig?: Partial<BackoffConfig>;
21
+ };
22
+ /**
23
+ * Options for attested methods when both a reencrypt key and keypair are provided.
24
+ * The KMS reencrypts under the public key; the SDK decrypts locally using the keypair.
25
+ */
26
+ export type AttestedOptsDecrypted = {
27
+ reencryptPubKey: Uint8Array;
28
+ reencryptKeypair: XwingKeypair;
29
+ backoffConfig?: Partial<BackoffConfig>;
30
+ };
31
+ /** Union of all valid opts for attestedDecrypt / attestedCompute. */
32
+ export type AttestedOpts = AttestedOptsEphemeral | AttestedOptsEncrypted | AttestedOptsDecrypted;
33
+ /** Extends the base opts with voucher-specific fields for WithVoucher methods. */
34
+ export type AttestedWithVoucherOptsEphemeral = AttestedOptsEphemeral & {
35
+ requesterArgData?: HexString;
36
+ };
37
+ export type AttestedWithVoucherOptsEncrypted = AttestedOptsEncrypted & {
38
+ requesterArgData?: HexString;
39
+ };
40
+ export type AttestedWithVoucherOptsDecrypted = AttestedOptsDecrypted & {
41
+ requesterArgData?: HexString;
42
+ };
43
+ export type AttestedWithVoucherOpts = AttestedWithVoucherOptsEphemeral | AttestedWithVoucherOptsEncrypted | AttestedWithVoucherOptsDecrypted;
44
+ /** Options for attestedReveal. */
45
+ export type AttestedRevealOpts = {
46
+ backoffConfig?: Partial<BackoffConfig>;
47
+ };
@@ -5,8 +5,33 @@ import { PubKeyEncodable } from '../reencryption/index.js';
5
5
  * Combining ML-KEM-768 (1184 bytes) and X25519 (32 bytes).
6
6
  */
7
7
  export declare const XWING_PUBLIC_KEY_SIZE: number;
8
+ /**
9
+ * WARNING: TEST KEY - DO NOT USE IN PRODUCTION
10
+ * This is a well-known test seed (all zeros) that provides NO security.
11
+ * Anyone can derive the private key from this seed and decrypt all data.
12
+ * Only use for local development and testing.
13
+ */
8
14
  export declare const TEST_NETWORK_SEED_KEY = "0x0000000000000000000000000000000000000000000000000000000000000000";
15
+ /**
16
+ * WARNING: TEST KEY - DO NOT USE IN PRODUCTION
17
+ * This is the public key derived from TEST_NETWORK_SEED_KEY (all zeros).
18
+ * Data encrypted with this key can be decrypted by anyone who knows the seed.
19
+ * Only use for local development and testing.
20
+ *
21
+ * Generated from Go with seed of all zeros using HPKE layer: hpke.KEM_XWING.Scheme().DeriveKeyPair(seed)
22
+ * This matches the key used in covalidator's GetXwingPrivateKeyForTesting() via DeriveXwingPrivateKey
23
+ */
9
24
  export declare const TEST_NETWORK_XWING_PUBKEY = "0xca882388911c7c762aafc20debd63e845b3bed28c9d5262cdea7771fb31bd660a1ae7b395a9a7df3d12c7b118e8eda5057572c1ba05cd9b635edf33dabca4cac7291e0848f19c20e5beb850c3818f3543d49b3a5c729cb86a28fda539775d04feda112fe0c81d138aaf623aea7d507a4e826e890105db6065a44aba76a10d771c00d1b33f4ac51869806aae18eada68f19047024542d64a7aa1c91a5e1aa49d93613b5224b415bcc7aa166e4b55033438d20c641f9664fdb1689b53208181463e3d1325d46b30f07c5945b7e3fa1418bf833d975258461b294664eaf60795964924a280729c10a37fc6e967440bdd55d4ca53596286383481291152365303d44517cef369c00933b0b30368a230353e729c031075e8388673678a56b3ba84a165b28096ee9bd684483e1844258b451c365c41fa534152a3b64120041450128e960c7d6437d717ee266bdde7aaeec225ed93b958d188e97407349f1382976ca47d761ecc59a6f394487eb015c083abb490584677240eb47f838c838568a496119378b8bb81484610a50792b5d9c9939db188e7d0249d3cb918c436f111a2898849b286b0743a22c57464c709c5eaceac1ba493adca3328c0b14b5e38d3aea74e328b622b17e7181c35ad11c2103bdb7f2b209d93dcbc4ab61a06bc37139e6d2b7a06c5b7e9267bef3a8918a706f793271a5acc2574532da79e5a10cf074b998147a3c43586a411a513bba0d11cc19a36c83b19277f28022c88b120abfdba7076a8263e05336e3245aef7033eb3c762b5bbfa5791ac960398b649d5cbb652ddc6b2398143a0861ab3b410b696328879c099098adf819fbf7ac170030e86675e7f45c22ac9e1cf52c3102487bb0b91ab592afdc69c6e3a9b71876b86260b6c736b8291098f1130d3b763525cbad540ce2d042eacb6ed43b7bcba898f712c412f26066e09945f44ec7026c8ef959831abc10719d2017a12a41728b41c02371a5f5756ebc79406be708ea41bbd21563c874a0b791a3b4e4224a609967004f065c5ab4f3b4c61cb35df70573269da53179c3701fc5205f61974426f9b794c1b5826494b70842b6920c17752029369264dc8590b898b85c9d89a258e1f46c1b0490efd17c485cb51687cea272041e90b8e629521d3c5e3fa7518161bad7a159295b63cc6c0077897b53d47db8bc0ecb820f550705b65715a1a1094d04854f56acd26aa0baa10cb8447fad6211f53105796a42882328e6852e8de821c283b51eaab9bc95c4dc53615626049d63b1f9a457193805276b1905b0ab39353b5cf91fdd6023d4d816aef9cce4a3cfb3d12190172df221ae61d427563a098cc60e3dc9997ef54959180be5dc64a911157db6be3a01be2ee343caab33b8729abf0c50c674758c511291941fceac646232920907c2e88b9ec10211161729c797643a553a6ae5c4b7483c04e3263bd291e311c609071348b7c3310aa97d6b8318e0a4afe8399fa22f951049a9bb8860f7c69a333d3cc1aaf0129ab560713bf29eb3a01f9a276c78e54e3a3648b2447c80242b271b11406866389426d8b59796540d6b5702092ab21ee217c075cfc0c17ef826ce9ea29b9e61617457a5b1aaa23a58615dc53c59183beb36ea19498c21820b70ab47adeb678f1c52bf8768b3597b608ea1a8a15cd62e8a29bec4a1ac248ef9f02de0144bca06025f95a42bd6c8eaaaaaa2366328561d";
25
+ /**
26
+ * Check if a byte array matches the test seed key.
27
+ * Logs a warning if it does.
28
+ */
29
+ export declare function warnIfTestSeed(seed: Uint8Array): boolean;
30
+ /**
31
+ * Check if a byte array matches the test public key.
32
+ * Logs a warning if it does.
33
+ */
34
+ export declare function warnIfTestPubKey(pubKeyBytes: Uint8Array): boolean;
10
35
  /**
11
36
  * X-Wing keypair interface.
12
37
  * X-Wing is a post-quantum hybrid KEM combining ML-KEM-768 and X25519.
@@ -72,7 +97,7 @@ export type XwingDecryptorArgs = {
72
97
  /**
73
98
  * Encrypt using X-Wing HPKE (RFC 9180) with ChaCha20-Poly1305 AEAD.
74
99
  *
75
- * Output format: encappedKey (1184 bytes) || ciphertext (variable length)
100
+ * Output format: encappedKey (1120 bytes) || ciphertext (variable length)
76
101
  *
77
102
  * @param pubKeyA - Recipient's public key
78
103
  * @param msg - Message to encrypt
@@ -84,7 +109,7 @@ export declare function encrypt(pubKeyA: CryptoKey, msg: Uint8Array, aad?: Uint8
84
109
  /**
85
110
  * Decrypt using X-Wing HPKE (RFC 9180) with ChaCha20-Poly1305 AEAD.
86
111
  *
87
- * Input format: encappedKey (1184 bytes) || ciphertext (variable length)
112
+ * Input format: encappedKey (1120 bytes) || ciphertext (variable length)
88
113
  *
89
114
  * @param privKeyA - Recipient's private key
90
115
  * @param encryptedData - Encrypted data (encappedKey || ciphertext)
@@ -121,3 +146,9 @@ export declare function getXwingEncryptor({ pubKeyA, }: XwingEncryptorArgs): Enc
121
146
  * @returns Decryptor function
122
147
  */
123
148
  export declare function getXwingDecryptor({ privKeyA, }: XwingDecryptorArgs): Decryptor<XwingScheme>;
149
+ /**
150
+ * Returns true if the raw public key bytes match the public key encoded by the keypair.
151
+ * Used to catch caller mistakes before sending the keypair to the covalidator, where a
152
+ * mismatch would produce a cryptic signature error instead of a clear failure.
153
+ */
154
+ export declare function reencryptPublicKeysMatch(reencryptPubKey: Uint8Array, reencryptKeypair: XwingKeypair): boolean;
@@ -1,4 +1,10 @@
1
1
  import { Schema } from 'effect';
2
+ /**
3
+ * Schema for the environment variables required to connect to a local Inco node.
4
+ *
5
+ * Includes executor/sender addresses, keys, covalidator settings, and optional
6
+ * remote compute-server overrides. Typically populated from a `.env` file.
7
+ */
2
8
  export declare const LocalNodeEnv: Schema.Struct<{
3
9
  DEPLOYER_ADDRESS: Schema.brand<Schema.filter<Schema.TemplateLiteral<`0x${string}`>>, "Address">;
4
10
  STATE_DUMP: typeof Schema.String;
@@ -14,6 +20,18 @@ export declare const LocalNodeEnv: Schema.Struct<{
14
20
  COVALIDATOR_HOST_CHAIN_ID: Schema.optional<typeof Schema.String>;
15
21
  COVALIDATOR_URL: Schema.optional<typeof Schema.String>;
16
22
  COVALIDATOR_HOST_CHAIN_RPC_URL: Schema.optional<typeof Schema.String>;
23
+ COVALIDATOR_COMPUTE_TYPE: Schema.optional<typeof Schema.String>;
24
+ COVALIDATOR_STORAGE_KEY: Schema.optional<Schema.TemplateLiteral<`0x${string}`>>;
17
25
  }>;
26
+ /** Parsed local node environment configuration. */
18
27
  export type LocalNodeEnv = typeof LocalNodeEnv.Type;
28
+ /**
29
+ * Parses a dotenv-formatted string or `Buffer` into a validated {@link LocalNodeEnv}.
30
+ *
31
+ * Falls back to `process.env` when no argument is provided.
32
+ *
33
+ * @param envFileOrObj - A dotenv-formatted string, `Buffer`, or `undefined` to use `process.env`.
34
+ * @returns A validated `LocalNodeEnv` object.
35
+ * @throws If required environment variables are missing or invalid.
36
+ */
19
37
  export declare function parseLocalEnv(envFileOrObj?: string | Buffer): LocalNodeEnv;
@@ -14,9 +14,36 @@ declare const baseEIP712: Schema.Struct<{
14
14
  }>>>;
15
15
  }>;
16
16
  type BaseEIP712 = typeof baseEIP712.Type;
17
+ /**
18
+ * An EIP-712 typed data payload with a generic `message` field.
19
+ *
20
+ * Extends the base EIP-712 structure (domain, primaryType, types) with
21
+ * a strongly-typed `message` object for signing.
22
+ *
23
+ * @typeParam Message - The shape of the application-specific message to sign.
24
+ */
17
25
  export interface EIP712<Message extends object> extends BaseEIP712 {
18
26
  message: Message;
19
27
  }
28
+ /**
29
+ * Creates an EIP-712 typed data payload for user signing.
30
+ *
31
+ * Used to verify the user controls the private key corresponding to the ephemeral
32
+ * public key embedded in the payload. The `message` keys must exactly match the
33
+ * `name` values in `primaryTypeFields`.
34
+ *
35
+ * @typeParam PrimaryType - The EIP-712 primary type name.
36
+ * @typeParam Message - The shape of the message to sign.
37
+ * @param params.chainId - The chain ID for the EIP-712 domain.
38
+ * @param params.primaryType - The primary type name (e.g. `"Reencrypt"`).
39
+ * @param params.primaryTypeFields - The field definitions for the primary type.
40
+ * @param params.message - The message object to sign (must match `primaryTypeFields`).
41
+ * @param params.verifyingContract - Optional verifying contract address for the domain.
42
+ * @param params.domainName - Human-readable name for the EIP-712 domain.
43
+ * @param params.domainVersion - Version string for the EIP-712 domain.
44
+ * @returns A complete {@link EIP712} payload ready for signing.
45
+ * @throws If message keys do not match `primaryTypeFields` names.
46
+ */
20
47
  export declare function createEIP712Payload<PrimaryType extends string, Message extends object>({ chainId, primaryType, primaryTypeFields, message, verifyingContract, domainName, domainVersion, }: {
21
48
  chainId: bigint;
22
49
  primaryType: PrimaryType;
@@ -4,18 +4,42 @@ import { CiphertextOf, EncryptionScheme, PlaintextOf, SupportedFheType } from '.
4
4
  import { Handle } from '../handle.js';
5
5
  import type { XwingKeypair } from '../lite/xwing.js';
6
6
  import type { BackoffConfig } from '../retry.js';
7
+ /**
8
+ * The core reencryption function type. Takes a handle (and optional ciphertext) and returns
9
+ * the decrypted plaintext. Supports retry configuration for handles that are not yet available.
10
+ *
11
+ * @typeParam S - The encryption scheme (e.g. X-Wing).
12
+ */
7
13
  export type Reencryptor<S extends EncryptionScheme> = <T extends SupportedFheType>(args: ReencryptFnArgs<S, T>, backoffConfig?: Partial<BackoffConfig>) => Promise<PlaintextOf<S, T>>;
14
+ /** Arguments required to construct a {@link Reencryptor}. */
8
15
  export interface ReencryptorArgs {
9
16
  chainId: bigint;
10
17
  }
18
+ /**
19
+ * Arguments for a single reencryption call.
20
+ *
21
+ * @typeParam S - The encryption scheme.
22
+ * @typeParam T - The ENCRYPTION type of the ciphertext.
23
+ */
11
24
  export type ReencryptFnArgs<S extends EncryptionScheme, T extends SupportedFheType> = {
12
25
  handle: Handle;
26
+ /**
27
+ * Optional ciphertext hint. If provided, the reencrypt endpoint may use it directly
28
+ * instead of fetching from the covalidators.
29
+ */
13
30
  ciphertext?: CiphertextOf<S, T>;
14
31
  };
32
+ /** Union of supported ephemeral keypair types for reencryption (currently X-Wing only). */
15
33
  export type SupportedEphemeralKeypairs = XwingKeypair;
34
+ /** An object whose public key can be serialized to a `Uint8Array`. */
16
35
  export interface PubKeyEncodable {
17
36
  encodePublicKey(): Uint8Array;
18
37
  }
38
+ /**
39
+ * A reencryption request to be sent to a reencrypt endpoint.
40
+ *
41
+ * @typeParam EKP - The type of ephemeral keypair used for the reencryption session.
42
+ */
19
43
  export interface ReencryptEndpointRequest<EKP extends SupportedEphemeralKeypairs> {
20
44
  userAddress: Address;
21
45
  handle: Handle;
@@ -7,6 +7,20 @@ export type BackoffConfig = {
7
7
  backoffFactor: number;
8
8
  errHandler?: (error: Error, attempt: number) => 'stop' | 'continue';
9
9
  };
10
+ /**
11
+ * Checks if an error is safe to retry.
12
+ * Only transient errors matching the allowlist should return true.
13
+ * All other errors fail fast to avoid masking security-critical failures.
14
+ *
15
+ * @param error - The error to check
16
+ * @returns true if the error is transient and safe to retry, false otherwise
17
+ */
18
+ export declare function isRetryableError(error: Error): boolean;
19
+ /**
20
+ * Default error handler that only retries known transient errors.
21
+ * Security-critical errors will fail fast.
22
+ */
23
+ export declare function defaultRetryErrorHandler(error: Error): 'stop' | 'continue';
10
24
  /**
11
25
  * Helper function to implement exponential backoff retry logic.
12
26
  * @param fn - The function to retry
@@ -1,15 +1,20 @@
1
- import { Account, Chain, Transport, WalletClient } from 'viem';
1
+ import { Account, Chain, PublicClient, Transport, WalletClient } from 'viem';
2
2
  import { vi } from 'vitest';
3
3
  import { KmsClient } from '../kms/client.js';
4
4
  import { KmsQuorumClient } from '../kms/quorumClient.js';
5
5
  interface MinimalKmsClient {
6
6
  attestedCompute: ReturnType<typeof vi.fn>;
7
7
  attestedDecrypt: ReturnType<typeof vi.fn>;
8
+ attestedReveal: ReturnType<typeof vi.fn>;
9
+ eListAttestedDecrypt: ReturnType<typeof vi.fn>;
10
+ eListAttestedReveal: ReturnType<typeof vi.fn>;
8
11
  key: ReturnType<typeof vi.fn>;
9
12
  reencrypt: ReturnType<typeof vi.fn>;
10
13
  }
11
14
  export declare function createMockKmsClient(): MinimalKmsClient & KmsClient;
12
15
  export declare function createMockQuorumClient(): KmsQuorumClient;
13
16
  export declare function setupMockInQuorumClient(quorumClient: KmsQuorumClient, mockKmsClient: MinimalKmsClient & KmsClient): void;
17
+ export declare function createMockPublicClient(): PublicClient<Transport, Chain>;
14
18
  export declare function createTestWalletClient(): WalletClient<Transport, Chain, Account>;
19
+ export declare function createFallbackWalletClient(): WalletClient<Transport, Chain, Account>;
15
20
  export {};