@inco/lightning-js 0.0.0-bootstrap.0

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 (283) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +587 -0
  3. package/dist/cjs/advancedacl/index.d.ts +2 -0
  4. package/dist/cjs/advancedacl/index.js +19 -0
  5. package/dist/cjs/advancedacl/session-key.d.ts +95 -0
  6. package/dist/cjs/advancedacl/session-key.js +376 -0
  7. package/dist/cjs/advancedacl/types.d.ts +16 -0
  8. package/dist/cjs/advancedacl/types.js +3 -0
  9. package/dist/cjs/attestedcompute/attested-compute.d.ts +65 -0
  10. package/dist/cjs/attestedcompute/attested-compute.js +80 -0
  11. package/dist/cjs/attestedcompute/types.d.ts +35 -0
  12. package/dist/cjs/attestedcompute/types.js +46 -0
  13. package/dist/cjs/attesteddecrypt/attested-decrypt.d.ts +61 -0
  14. package/dist/cjs/attesteddecrypt/attested-decrypt.js +118 -0
  15. package/dist/cjs/attesteddecrypt/index.d.ts +1 -0
  16. package/dist/cjs/attesteddecrypt/index.js +18 -0
  17. package/dist/cjs/attesteddecrypt/types.d.ts +27 -0
  18. package/dist/cjs/attesteddecrypt/types.js +16 -0
  19. package/dist/cjs/attestedreveal/attested-reveal.d.ts +21 -0
  20. package/dist/cjs/attestedreveal/attested-reveal.js +31 -0
  21. package/dist/cjs/attestedreveal/index.d.ts +2 -0
  22. package/dist/cjs/attestedreveal/index.js +21 -0
  23. package/dist/cjs/attestedreveal/types.d.ts +4 -0
  24. package/dist/cjs/attestedreveal/types.js +13 -0
  25. package/dist/cjs/binary.d.ts +104 -0
  26. package/dist/cjs/binary.js +171 -0
  27. package/dist/cjs/chain.d.ts +50 -0
  28. package/dist/cjs/chain.js +62 -0
  29. package/dist/cjs/eip712/eip712.d.ts +18 -0
  30. package/dist/cjs/eip712/eip712.js +51 -0
  31. package/dist/cjs/eip712/index.d.ts +1 -0
  32. package/dist/cjs/eip712/index.js +8 -0
  33. package/dist/cjs/elistattesteddecrypt/elist-attested-decrypt.d.ts +51 -0
  34. package/dist/cjs/elistattesteddecrypt/elist-attested-decrypt.js +94 -0
  35. package/dist/cjs/elistattesteddecrypt/index.d.ts +2 -0
  36. package/dist/cjs/elistattesteddecrypt/index.js +22 -0
  37. package/dist/cjs/elistattesteddecrypt/types.d.ts +31 -0
  38. package/dist/cjs/elistattesteddecrypt/types.js +16 -0
  39. package/dist/cjs/encryption/encryption.d.ts +235 -0
  40. package/dist/cjs/encryption/encryption.js +226 -0
  41. package/dist/cjs/encryption/index.d.ts +1 -0
  42. package/dist/cjs/encryption/index.js +19 -0
  43. package/dist/cjs/generated/abis/add-two.d.ts +117 -0
  44. package/dist/cjs/generated/abis/add-two.js +80 -0
  45. package/dist/cjs/generated/abis/lightning.d.ts +3362 -0
  46. package/dist/cjs/generated/abis/lightning.js +2445 -0
  47. package/dist/cjs/generated/abis/test-elist.d.ts +276 -0
  48. package/dist/cjs/generated/abis/test-elist.js +168 -0
  49. package/dist/cjs/generated/abis/verifier.d.ts +1353 -0
  50. package/dist/cjs/generated/abis/verifier.js +954 -0
  51. package/dist/cjs/generated/es/inco/covalidator/compute/v1/server_pb.d.ts +1494 -0
  52. package/dist/cjs/generated/es/inco/covalidator/compute/v1/server_pb.js +395 -0
  53. package/dist/cjs/generated/es/inco/covalidator/compute/v1/types_pb.d.ts +247 -0
  54. package/dist/cjs/generated/es/inco/covalidator/compute/v1/types_pb.js +80 -0
  55. package/dist/cjs/generated/es/inco/helioswrapper/v1/helioswrapper_pb.d.ts +77 -0
  56. package/dist/cjs/generated/es/inco/helioswrapper/v1/helioswrapper_pb.js +28 -0
  57. package/dist/cjs/generated/es/inco/kms/lite/v1/kms_service_pb.d.ts +685 -0
  58. package/dist/cjs/generated/es/inco/kms/lite/v1/kms_service_pb.js +100 -0
  59. package/dist/cjs/generated/es/inco/kms/lite/v1/types_pb.d.ts +289 -0
  60. package/dist/cjs/generated/es/inco/kms/lite/v1/types_pb.js +136 -0
  61. package/dist/cjs/generated/es/inco/sealingfetcher/v1/sealingfetcher_pb.d.ts +371 -0
  62. package/dist/cjs/generated/es/inco/sealingfetcher/v1/sealingfetcher_pb.js +88 -0
  63. package/dist/cjs/generated/lightning.d.ts +830 -0
  64. package/dist/cjs/generated/lightning.js +872 -0
  65. package/dist/cjs/generated/local-node.d.ts +50 -0
  66. package/dist/cjs/generated/local-node.js +107 -0
  67. package/dist/cjs/handle.d.ts +123 -0
  68. package/dist/cjs/handle.js +221 -0
  69. package/dist/cjs/index.d.ts +5 -0
  70. package/dist/cjs/index.js +31 -0
  71. package/dist/cjs/kms/client.d.ts +12 -0
  72. package/dist/cjs/kms/client.js +47 -0
  73. package/dist/cjs/kms/quorumClient.d.ts +65 -0
  74. package/dist/cjs/kms/quorumClient.js +463 -0
  75. package/dist/cjs/kms/quorumConsistency.d.ts +82 -0
  76. package/dist/cjs/kms/quorumConsistency.js +269 -0
  77. package/dist/cjs/kms/signatureVerification.d.ts +35 -0
  78. package/dist/cjs/kms/signatureVerification.js +88 -0
  79. package/dist/cjs/kms/thresholdPromises.d.ts +8 -0
  80. package/dist/cjs/kms/thresholdPromises.js +62 -0
  81. package/dist/cjs/lite/attested-compute.d.ts +6 -0
  82. package/dist/cjs/lite/attested-compute.js +8 -0
  83. package/dist/cjs/lite/attested-decrypt.d.ts +4 -0
  84. package/dist/cjs/lite/attested-decrypt.js +6 -0
  85. package/dist/cjs/lite/deployments.d.ts +24 -0
  86. package/dist/cjs/lite/deployments.js +21 -0
  87. package/dist/cjs/lite/hadu.d.ts +4 -0
  88. package/dist/cjs/lite/hadu.js +28 -0
  89. package/dist/cjs/lite/index.d.ts +13 -0
  90. package/dist/cjs/lite/index.js +31 -0
  91. package/dist/cjs/lite/lightning.d.ts +459 -0
  92. package/dist/cjs/lite/lightning.js +696 -0
  93. package/dist/cjs/lite/types.d.ts +47 -0
  94. package/dist/cjs/lite/types.js +3 -0
  95. package/dist/cjs/lite/xwing.d.ts +154 -0
  96. package/dist/cjs/lite/xwing.js +326 -0
  97. package/dist/cjs/local/index.d.ts +1 -0
  98. package/dist/cjs/local/index.js +18 -0
  99. package/dist/cjs/local/local-node.d.ts +37 -0
  100. package/dist/cjs/local/local-node.js +80 -0
  101. package/dist/cjs/reencryption/eip712.d.ts +56 -0
  102. package/dist/cjs/reencryption/eip712.js +90 -0
  103. package/dist/cjs/reencryption/index.d.ts +2 -0
  104. package/dist/cjs/reencryption/index.js +19 -0
  105. package/dist/cjs/reencryption/types.d.ts +48 -0
  106. package/dist/cjs/reencryption/types.js +3 -0
  107. package/dist/cjs/retry.d.ts +30 -0
  108. package/dist/cjs/retry.js +87 -0
  109. package/dist/cjs/schema.d.ts +4 -0
  110. package/dist/cjs/schema.js +19 -0
  111. package/dist/cjs/test/mocks.d.ts +20 -0
  112. package/dist/cjs/test/mocks.js +72 -0
  113. package/dist/cjs/viem.d.ts +1141 -0
  114. package/dist/cjs/viem.js +36 -0
  115. package/dist/esm/advancedacl/index.d.ts +2 -0
  116. package/dist/esm/advancedacl/index.js +3 -0
  117. package/dist/esm/advancedacl/session-key.d.ts +95 -0
  118. package/dist/esm/advancedacl/session-key.js +367 -0
  119. package/dist/esm/advancedacl/types.d.ts +16 -0
  120. package/dist/esm/advancedacl/types.js +2 -0
  121. package/dist/esm/attestedcompute/attested-compute.d.ts +65 -0
  122. package/dist/esm/attestedcompute/attested-compute.js +76 -0
  123. package/dist/esm/attestedcompute/types.d.ts +35 -0
  124. package/dist/esm/attestedcompute/types.js +42 -0
  125. package/dist/esm/attesteddecrypt/attested-decrypt.d.ts +61 -0
  126. package/dist/esm/attesteddecrypt/attested-decrypt.js +112 -0
  127. package/dist/esm/attesteddecrypt/index.d.ts +1 -0
  128. package/dist/esm/attesteddecrypt/index.js +2 -0
  129. package/dist/esm/attesteddecrypt/types.d.ts +27 -0
  130. package/dist/esm/attesteddecrypt/types.js +12 -0
  131. package/dist/esm/attestedreveal/attested-reveal.d.ts +21 -0
  132. package/dist/esm/attestedreveal/attested-reveal.js +28 -0
  133. package/dist/esm/attestedreveal/index.d.ts +2 -0
  134. package/dist/esm/attestedreveal/index.js +3 -0
  135. package/dist/esm/attestedreveal/types.d.ts +4 -0
  136. package/dist/esm/attestedreveal/types.js +9 -0
  137. package/dist/esm/binary.d.ts +104 -0
  138. package/dist/esm/binary.js +155 -0
  139. package/dist/esm/chain.d.ts +50 -0
  140. package/dist/esm/chain.js +58 -0
  141. package/dist/esm/eip712/eip712.d.ts +18 -0
  142. package/dist/esm/eip712/eip712.js +46 -0
  143. package/dist/esm/eip712/index.d.ts +1 -0
  144. package/dist/esm/eip712/index.js +2 -0
  145. package/dist/esm/elistattesteddecrypt/elist-attested-decrypt.d.ts +51 -0
  146. package/dist/esm/elistattesteddecrypt/elist-attested-decrypt.js +89 -0
  147. package/dist/esm/elistattesteddecrypt/index.d.ts +2 -0
  148. package/dist/esm/elistattesteddecrypt/index.js +3 -0
  149. package/dist/esm/elistattesteddecrypt/types.d.ts +31 -0
  150. package/dist/esm/elistattesteddecrypt/types.js +12 -0
  151. package/dist/esm/encryption/encryption.d.ts +235 -0
  152. package/dist/esm/encryption/encryption.js +214 -0
  153. package/dist/esm/encryption/index.d.ts +1 -0
  154. package/dist/esm/encryption/index.js +2 -0
  155. package/dist/esm/generated/abis/add-two.d.ts +117 -0
  156. package/dist/esm/generated/abis/add-two.js +77 -0
  157. package/dist/esm/generated/abis/lightning.d.ts +3362 -0
  158. package/dist/esm/generated/abis/lightning.js +2442 -0
  159. package/dist/esm/generated/abis/test-elist.d.ts +276 -0
  160. package/dist/esm/generated/abis/test-elist.js +165 -0
  161. package/dist/esm/generated/abis/verifier.d.ts +1353 -0
  162. package/dist/esm/generated/abis/verifier.js +951 -0
  163. package/dist/esm/generated/es/inco/covalidator/compute/v1/server_pb.d.ts +1494 -0
  164. package/dist/esm/generated/es/inco/covalidator/compute/v1/server_pb.js +392 -0
  165. package/dist/esm/generated/es/inco/covalidator/compute/v1/types_pb.d.ts +247 -0
  166. package/dist/esm/generated/es/inco/covalidator/compute/v1/types_pb.js +77 -0
  167. package/dist/esm/generated/es/inco/helioswrapper/v1/helioswrapper_pb.d.ts +77 -0
  168. package/dist/esm/generated/es/inco/helioswrapper/v1/helioswrapper_pb.js +25 -0
  169. package/dist/esm/generated/es/inco/kms/lite/v1/kms_service_pb.d.ts +685 -0
  170. package/dist/esm/generated/es/inco/kms/lite/v1/kms_service_pb.js +97 -0
  171. package/dist/esm/generated/es/inco/kms/lite/v1/types_pb.d.ts +289 -0
  172. package/dist/esm/generated/es/inco/kms/lite/v1/types_pb.js +133 -0
  173. package/dist/esm/generated/es/inco/sealingfetcher/v1/sealingfetcher_pb.d.ts +371 -0
  174. package/dist/esm/generated/es/inco/sealingfetcher/v1/sealingfetcher_pb.js +85 -0
  175. package/dist/esm/generated/lightning.d.ts +830 -0
  176. package/dist/esm/generated/lightning.js +869 -0
  177. package/dist/esm/generated/local-node.d.ts +50 -0
  178. package/dist/esm/generated/local-node.js +104 -0
  179. package/dist/esm/handle.d.ts +123 -0
  180. package/dist/esm/handle.js +212 -0
  181. package/dist/esm/index.d.ts +5 -0
  182. package/dist/esm/index.js +6 -0
  183. package/dist/esm/kms/client.d.ts +12 -0
  184. package/dist/esm/kms/client.js +40 -0
  185. package/dist/esm/kms/quorumClient.d.ts +65 -0
  186. package/dist/esm/kms/quorumClient.js +459 -0
  187. package/dist/esm/kms/quorumConsistency.d.ts +82 -0
  188. package/dist/esm/kms/quorumConsistency.js +260 -0
  189. package/dist/esm/kms/signatureVerification.d.ts +35 -0
  190. package/dist/esm/kms/signatureVerification.js +84 -0
  191. package/dist/esm/kms/thresholdPromises.d.ts +8 -0
  192. package/dist/esm/kms/thresholdPromises.js +59 -0
  193. package/dist/esm/lite/attested-compute.d.ts +6 -0
  194. package/dist/esm/lite/attested-compute.js +4 -0
  195. package/dist/esm/lite/attested-decrypt.d.ts +4 -0
  196. package/dist/esm/lite/attested-decrypt.js +3 -0
  197. package/dist/esm/lite/deployments.d.ts +24 -0
  198. package/dist/esm/lite/deployments.js +17 -0
  199. package/dist/esm/lite/hadu.d.ts +4 -0
  200. package/dist/esm/lite/hadu.js +24 -0
  201. package/dist/esm/lite/index.d.ts +13 -0
  202. package/dist/esm/lite/index.js +10 -0
  203. package/dist/esm/lite/lightning.d.ts +459 -0
  204. package/dist/esm/lite/lightning.js +692 -0
  205. package/dist/esm/lite/types.d.ts +47 -0
  206. package/dist/esm/lite/types.js +2 -0
  207. package/dist/esm/lite/xwing.d.ts +154 -0
  208. package/dist/esm/lite/xwing.js +311 -0
  209. package/dist/esm/local/index.d.ts +1 -0
  210. package/dist/esm/local/index.js +2 -0
  211. package/dist/esm/local/local-node.d.ts +37 -0
  212. package/dist/esm/local/local-node.js +76 -0
  213. package/dist/esm/reencryption/eip712.d.ts +56 -0
  214. package/dist/esm/reencryption/eip712.js +87 -0
  215. package/dist/esm/reencryption/index.d.ts +2 -0
  216. package/dist/esm/reencryption/index.js +3 -0
  217. package/dist/esm/reencryption/types.d.ts +48 -0
  218. package/dist/esm/reencryption/types.js +2 -0
  219. package/dist/esm/retry.d.ts +30 -0
  220. package/dist/esm/retry.js +82 -0
  221. package/dist/esm/schema.d.ts +4 -0
  222. package/dist/esm/schema.js +15 -0
  223. package/dist/esm/test/mocks.d.ts +20 -0
  224. package/dist/esm/test/mocks.js +64 -0
  225. package/dist/esm/viem.d.ts +1141 -0
  226. package/dist/esm/viem.js +32 -0
  227. package/dist/types/advancedacl/index.d.ts +2 -0
  228. package/dist/types/advancedacl/session-key.d.ts +95 -0
  229. package/dist/types/advancedacl/types.d.ts +16 -0
  230. package/dist/types/attestedcompute/attested-compute.d.ts +65 -0
  231. package/dist/types/attestedcompute/types.d.ts +35 -0
  232. package/dist/types/attesteddecrypt/attested-decrypt.d.ts +61 -0
  233. package/dist/types/attesteddecrypt/index.d.ts +1 -0
  234. package/dist/types/attesteddecrypt/types.d.ts +27 -0
  235. package/dist/types/attestedreveal/attested-reveal.d.ts +21 -0
  236. package/dist/types/attestedreveal/index.d.ts +2 -0
  237. package/dist/types/attestedreveal/types.d.ts +4 -0
  238. package/dist/types/binary.d.ts +104 -0
  239. package/dist/types/chain.d.ts +50 -0
  240. package/dist/types/eip712/eip712.d.ts +18 -0
  241. package/dist/types/eip712/index.d.ts +1 -0
  242. package/dist/types/elistattesteddecrypt/elist-attested-decrypt.d.ts +51 -0
  243. package/dist/types/elistattesteddecrypt/index.d.ts +2 -0
  244. package/dist/types/elistattesteddecrypt/types.d.ts +31 -0
  245. package/dist/types/encryption/encryption.d.ts +235 -0
  246. package/dist/types/encryption/index.d.ts +1 -0
  247. package/dist/types/generated/abis/add-two.d.ts +117 -0
  248. package/dist/types/generated/abis/lightning.d.ts +3362 -0
  249. package/dist/types/generated/abis/test-elist.d.ts +276 -0
  250. package/dist/types/generated/abis/verifier.d.ts +1353 -0
  251. package/dist/types/generated/es/inco/covalidator/compute/v1/server_pb.d.ts +1494 -0
  252. package/dist/types/generated/es/inco/covalidator/compute/v1/types_pb.d.ts +247 -0
  253. package/dist/types/generated/es/inco/helioswrapper/v1/helioswrapper_pb.d.ts +77 -0
  254. package/dist/types/generated/es/inco/kms/lite/v1/kms_service_pb.d.ts +685 -0
  255. package/dist/types/generated/es/inco/kms/lite/v1/types_pb.d.ts +289 -0
  256. package/dist/types/generated/es/inco/sealingfetcher/v1/sealingfetcher_pb.d.ts +371 -0
  257. package/dist/types/generated/lightning.d.ts +830 -0
  258. package/dist/types/generated/local-node.d.ts +50 -0
  259. package/dist/types/handle.d.ts +123 -0
  260. package/dist/types/index.d.ts +5 -0
  261. package/dist/types/kms/client.d.ts +12 -0
  262. package/dist/types/kms/quorumClient.d.ts +65 -0
  263. package/dist/types/kms/quorumConsistency.d.ts +82 -0
  264. package/dist/types/kms/signatureVerification.d.ts +35 -0
  265. package/dist/types/kms/thresholdPromises.d.ts +8 -0
  266. package/dist/types/lite/attested-compute.d.ts +6 -0
  267. package/dist/types/lite/attested-decrypt.d.ts +4 -0
  268. package/dist/types/lite/deployments.d.ts +24 -0
  269. package/dist/types/lite/hadu.d.ts +4 -0
  270. package/dist/types/lite/index.d.ts +13 -0
  271. package/dist/types/lite/lightning.d.ts +459 -0
  272. package/dist/types/lite/types.d.ts +47 -0
  273. package/dist/types/lite/xwing.d.ts +154 -0
  274. package/dist/types/local/index.d.ts +1 -0
  275. package/dist/types/local/local-node.d.ts +37 -0
  276. package/dist/types/reencryption/eip712.d.ts +56 -0
  277. package/dist/types/reencryption/index.d.ts +2 -0
  278. package/dist/types/reencryption/types.d.ts +48 -0
  279. package/dist/types/retry.d.ts +30 -0
  280. package/dist/types/schema.d.ts +4 -0
  281. package/dist/types/test/mocks.d.ts +20 -0
  282. package/dist/types/viem.d.ts +1141 -0
  283. package/package.json +129 -0
@@ -0,0 +1,459 @@
1
+ import { Account, Chain, GetContractReturnType, PublicClient, Transport, WalletClient } from 'viem';
2
+ import type { PrivateKeyAccount } from 'viem/accounts';
3
+ import { AllowanceVoucherWithSig } from '../advancedacl/types.js';
4
+ import { AttestedComputeOP } from '../attestedcompute/types.js';
5
+ import { DecryptionAttestation, EncryptedDecryptionAttestation } from '../attesteddecrypt/index.js';
6
+ import { Address, HexString } from '../binary.js';
7
+ import { EListDecryptionAttestation, EncryptedEListDecryptionAttestation } from '../elistattesteddecrypt/index.js';
8
+ import { EncryptionScheme, SupportedTeeType } from '../encryption/encryption.js';
9
+ import { incoVerifierAbi } from '../generated/abis/verifier.js';
10
+ import { lightningDeployments } from '../generated/lightning.js';
11
+ import { localNodeLightningConfig } from '../generated/local-node.js';
12
+ import { TeeType } from '../handle.js';
13
+ import { LocalNodeEnv } from '../local/index.js';
14
+ import type { AttestedOptsDecrypted, AttestedOptsEncrypted, AttestedOptsEphemeral, AttestedRevealOpts, AttestedWithVoucherOptsDecrypted, AttestedWithVoucherOptsEncrypted, AttestedWithVoucherOptsEphemeral } from './types.js';
15
+ type TupleToUnion<T> = T extends readonly unknown[] ? T[number] : never;
16
+ type Deployment = TupleToUnion<typeof lightningDeployments>;
17
+ type DistributedPick<T, K> = T extends any ? Pick<T, Extract<keyof T, K>> : never;
18
+ export type DeploymentByName = DistributedPick<Deployment, 'name' | 'chainId'>;
19
+ export type DeploymentByExecutor = DistributedPick<Deployment, 'executorAddress' | 'chainId'>;
20
+ export type DeploymentId = DeploymentByName | DeploymentByExecutor;
21
+ export type Pepper = Deployment['pepper'];
22
+ export type LocalNodePepper = keyof typeof localNodeLightningConfig;
23
+ export type ChainId = Deployment['chainId'];
24
+ export type SupportedNativeType = boolean | bigint | number;
25
+ export type EncryptionContext = {
26
+ accountAddress: string;
27
+ dappAddress: string;
28
+ handleType: TeeType;
29
+ };
30
+ export type DeploymentSlice = {
31
+ executorAddress: string;
32
+ chainId: number;
33
+ };
34
+ export type CustomConfig = {
35
+ executorAddress: string;
36
+ chainId: number;
37
+ covalidatorUrls: string[];
38
+ signers?: Address[];
39
+ hostChainRpcUrls?: readonly string[] | string[];
40
+ senderPrivateKey?: HexString;
41
+ };
42
+ export type CustomDeployment = DeploymentSlice & CustomConfig;
43
+ export type IncoVerifierConfig = {
44
+ threshold: number;
45
+ signers: Address[];
46
+ networkPubkey: HexString;
47
+ };
48
+ type LocalNodeEnvFileSource = {
49
+ filePath: string;
50
+ };
51
+ /**
52
+ * The Lightning class provides a convenient way to interact with the Inco Lightning contract by binding to a specific
53
+ * deployment.
54
+ */
55
+ export declare class Lightning<T extends DeploymentSlice = DeploymentSlice> {
56
+ private readonly _deployment;
57
+ private readonly covalidatorUrls;
58
+ private readonly signers;
59
+ private readonly threshold;
60
+ private readonly networkPubkey;
61
+ private readonly publicClient;
62
+ readonly executorAddress: Address;
63
+ readonly chainId: bigint;
64
+ private readonly kmsQuorumClient;
65
+ private encryptor;
66
+ private encryptionScheme;
67
+ private constructor();
68
+ private getEncryptor;
69
+ /**
70
+ * Get the encryption scheme version used by this Lightning instance.
71
+ * Returns the X-Wing encryption scheme identifier.
72
+ * This is a convenience method to get the encryption scheme used by this Lightning instance.
73
+ */
74
+ getEncryptionScheme(): Promise<EncryptionScheme>;
75
+ /**
76
+ * Get a Lightning instance bound to the latest Lightning deployment for Base mainnet.
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.
80
+ */
81
+ static baseMainnet(options?: {
82
+ hostChainRpcUrls?: readonly string[];
83
+ }): Promise<Lightning<Deployment>>;
84
+ /**
85
+ * Get a Lightning instance bound to the latest Lightning deployment for the Base Sepolia testnet.
86
+ *
87
+ * @param options.hostChainRpcUrls optional list of RPC URLs for the host chain. When multiple URLs are
88
+ * provided, viem's fallback transport is used and providers are tried in order on failure.
89
+ */
90
+ static baseSepoliaTestnet(options?: {
91
+ hostChainRpcUrls?: readonly string[];
92
+ }): Promise<Lightning<Deployment>>;
93
+ /**
94
+ * Get a Lightning instance bound to our canonical Anvil-based test node and test Covalidator node
95
+ *
96
+ * These can be run in docker-compose using images pushed to dockerhub as:
97
+ * - inconetwork/local-node-anvil
98
+ * - inconetwork/local-node-covalidator
99
+ *
100
+ * See the sample docker-compose file here: https://github.com/Inco-fhevm/lightning-rod/blob/main/docker-compose.yaml
101
+ *
102
+ * @param env either a Pepper such as 'testnet', 'devnet', 'alphanet' or a LocalNodeEnv object containing the
103
+ * executorAddress, networkPubkey, chainId, covalidatorUrl and senderPrivateKey. If none is provided, it defaults to
104
+ * the 'testnet' Pepper. This produces allows connection to a local node running against a state dump of the
105
+ * corresponding Pepper.
106
+ *
107
+ */
108
+ static localNode(env?: LocalNodeEnv | LocalNodePepper): Promise<Lightning<CustomDeployment>>;
109
+ /**
110
+ * Get a Lightning instance bound to a local node from a file containing a LocalNodeEnv environment .
111
+ *
112
+ * @param filePath the path to the file containing the environment variables in dotenv format
113
+ */
114
+ static localNodeFromEnv(source?: string | Buffer | LocalNodeEnvFileSource): Promise<Lightning<CustomDeployment>>;
115
+ /**
116
+ * Get a Lightning deployment by name or executor address on a particular chain.
117
+ *
118
+ * @param id this is an object containing either the pair of name and chainId or the executorAddress and chainId
119
+ * @param options.hostChainRpcUrls optional list of RPC URLs for the host chain. When multiple URLs are
120
+ * provided, viem's fallback transport is used and providers are tried in order on failure.
121
+ */
122
+ static at(id: DeploymentId, options?: {
123
+ hostChainRpcUrls?: readonly string[];
124
+ }): Promise<Lightning<Deployment>>;
125
+ /**
126
+ * Get a Lightning deployment for a local or custom node
127
+ *
128
+ * @param config this is an object containing the executorAddress, networkPubkey, chainId and covalidatorUrl.
129
+ * additional fields past will be made available as part of the `deployment` property.
130
+ */
131
+ static custom<T extends CustomConfig>(config: T): Promise<Lightning<DeploymentSlice & T>>;
132
+ /**
133
+ * Get the latest deployment for a given pepper, which usually denotes a family of deployments distinct from their
134
+ * version such as 'devnet', 'testnet', 'mainnet', etc.
135
+ *
136
+ * @param pepper the pepper to use to filter the deployments
137
+ * @param chainId the chainId to use to filter the deployments
138
+ */
139
+ static latestDeployment<P extends Pepper>(pepper: P, chainId: ChainId): Deployment;
140
+ /**
141
+ * Get the latest Lightning deployment for a given pepper amd chainId unconditionally.
142
+ * Note that if you upgrade the library the latest deployment may change and contracts deployed to a previous version
143
+ * will not be compatible with the new version.
144
+ *
145
+ * @param pepper the pepper to use to filter the deployments
146
+ * @param chainId the chainId to use to filter the deployments
147
+ * @param options.hostChainRpcUrls optional list of RPC URLs for the host chain. When multiple URLs are
148
+ * provided, viem's fallback transport is used and providers are tried in order on failure.
149
+ */
150
+ static latest<P extends Pepper>(pepper: P, chainId: ChainId, options?: {
151
+ hostChainRpcUrls?: readonly string[];
152
+ }): Promise<Lightning<Deployment>>;
153
+ /** Returns a shallow copy of the deployment configuration this Lightning instance is bound to. */
154
+ get deployment(): T;
155
+ /**
156
+ * Encrypt a value using the network's public key (X-Wing).
157
+ * The encryption scheme is automatically detected based on the public key length.
158
+ *
159
+ * @param value a boolean or numeric value to encrypt
160
+ * @param accountAddress the address of the account interacting with the dapp contract, normally an Externally Owned Account (EOA)
161
+ * @param dappAddress the address of the dapp contract that interacts with the Inco Lightning contract or library
162
+ * @param handleType (optional) the handle type to be used for encrypting the value - this is required in case of non-default handle types
163
+ * default handle types:
164
+ * - boolean -> handleTypes.ebool
165
+ * - number | bigint -> handleTypes.euint256
166
+ * @returns a promise that resolves to the encrypted value as a HexString
167
+ */
168
+ encrypt<T extends SupportedNativeType>(value: T, { accountAddress, dappAddress, handleType }: EncryptionContext): Promise<HexString>;
169
+ /**
170
+ * Grants a session key allowance voucher for secure reencryption operations.
171
+ *
172
+ * This method creates a signed allowance voucher that authorizes a specific requester address
173
+ * to perform reencryption operations using session keys. The voucher includes an expiration time
174
+ * and can optionally specify a custom session verifier contract address.
175
+ *
176
+ * @param walletClient - The wallet client used for signing the allowance voucher
177
+ * @param granteeAddress - The address of the entity requesting the session key allowance
178
+ * @param expiresAt - The timestamp when the allowance voucher expires (as a bigint)
179
+ * @param sessionVerifierAddress - Optional custom session verifier contract address. If not provided, uses the executor address
180
+ * @returns A promise that resolves to an AllowanceVoucherWithSig containing the signed allowance voucher
181
+ *
182
+ * @example
183
+ * ```typescript
184
+ * const voucher = await lightning.grantSessionKeyAllowanceVoucher(
185
+ * walletClient,
186
+ * "0x1234...",
187
+ * BigInt(Date.now() + 3600000), // 1 hour from now
188
+ * "0x5678..." // optional custom verifier
189
+ * );
190
+ * ```
191
+ */
192
+ grantSessionKeyAllowanceVoucher(walletClient: WalletClient<Transport, Chain, Account>, granteeAddress: string, expiresAt: Date, sessionVerifierAddress: string): Promise<AllowanceVoucherWithSig>;
193
+ /**
194
+ * Grants a session key allowance voucher using a custom session verifier contract.
195
+ *
196
+ * This method creates a signed allowance voucher that authorizes reencryption operations
197
+ * using a custom session verifier. Unlike `grantSessionKeyAllowanceVoucher`, this method
198
+ * allows specifying custom `sharerArgData` for use with custom verifier contracts that
199
+ * require additional authorization parameters.
200
+ *
201
+ * @param walletClient - The wallet client used for signing the allowance voucher
202
+ * @param sessionVerifierAddress - The address of the custom session verifier contract
203
+ * @param sharerArgData - Custom encoded arguments for the session verifier's `canUseSession` function
204
+ * @returns A promise that resolves to an AllowanceVoucherWithSig containing the signed allowance voucher
205
+ *
206
+ * @example
207
+ * ```typescript
208
+ * const sharerArgData = encodeAbiParameters(
209
+ * [{ type: 'address' }, { type: 'uint256' }],
210
+ * [granteeAddress, expiresAt]
211
+ * );
212
+ * const voucher = await lightning.grantCustomSessionKeyAllowanceVoucher(
213
+ * walletClient,
214
+ * "0x5678...", // custom verifier address
215
+ * sharerArgData
216
+ * );
217
+ * ```
218
+ */
219
+ grantCustomSessionKeyAllowanceVoucher(walletClient: WalletClient<Transport, Chain, Account>, sessionVerifierAddress: string, sharerArgData: HexString): Promise<AllowanceVoucherWithSig>;
220
+ /**
221
+ * Updates the active session nonce for the given wallet client.
222
+ *
223
+ * This method updates the active session nonce for the given wallet client.
224
+ * It nullifies all the previous shared addresses accessing the voucher.
225
+ *
226
+ * @param walletClient - The wallet client used for updating the session nonce
227
+ * @returns The transaction hash of the updateActiveVouchersSessionNonce transaction
228
+ */
229
+ updateActiveVouchersSessionNonce(walletClient: WalletClient<Transport, Chain, Account>): Promise<HexString>;
230
+ /**
231
+ * Requests attested decrypts signed by the covalidator using a wallet client.
232
+ *
233
+ * @param walletClient Wallet used to sign the EIP-712 request.
234
+ * @param handles 32-byte handles to decrypt.
235
+ * @param backoffConfig Optional retry configuration.
236
+ *
237
+ * @example Plaintext results
238
+ * ```ts
239
+ * const attestations = await lightning.attestedDecrypt(walletClient, [handle]);
240
+ * console.log(attestations[0].plaintext.value);
241
+ * ```
242
+ *
243
+ * @example Reencrypt for a delegate
244
+ * ```ts
245
+ * const encrypted = await lightning.attestedDecrypt(walletClient, [handle], {
246
+ * reencryptPubKey: delegatePubKey,
247
+ * });
248
+ * console.log(encrypted[0].encryptedPlaintext.ciphertext.value);
249
+ * ```
250
+ *
251
+ * @example Reencrypt and decrypt locally
252
+ * ```ts
253
+ * const decrypted = await lightning.attestedDecrypt(walletClient, [handle], {
254
+ * reencryptPubKey: keypair.encodePublicKey(),
255
+ * reencryptKeypair: keypair,
256
+ * });
257
+ * console.log(decrypted[0].plaintext.value);
258
+ * ```
259
+ */
260
+ attestedDecrypt(walletClient: WalletClient<Transport, Chain, Account>, handles: HexString[], opts?: AttestedOptsEphemeral): Promise<Array<DecryptionAttestation<EncryptionScheme, SupportedTeeType>>>;
261
+ attestedDecrypt(walletClient: WalletClient<Transport, Chain, Account>, handles: HexString[], opts: AttestedOptsEncrypted): Promise<Array<EncryptedDecryptionAttestation<EncryptionScheme, SupportedTeeType>>>;
262
+ attestedDecrypt(walletClient: WalletClient<Transport, Chain, Account>, handles: HexString[], opts: AttestedOptsDecrypted): Promise<Array<DecryptionAttestation<EncryptionScheme, SupportedTeeType>>>;
263
+ /**
264
+ * Requests attested decrypts using a voucher-backed session key.
265
+ *
266
+ * @param ephemeralAccount Session Account matching the voucher grantee.
267
+ * @param allowanceVoucherWithSig Signed allowance voucher.
268
+ * @param handles Handles to decrypt.
269
+ * @param opts Optional reencryption/backoff configuration.
270
+ *
271
+ * @example Plaintext results
272
+ * ```ts
273
+ * const attestations = await lightning.attestedDecryptWithVoucher(
274
+ * ephemeralAccount,
275
+ * voucher,
276
+ * [handle],
277
+ * );
278
+ * ```
279
+ *
280
+ * @example Reencrypt for a delegate
281
+ * ```ts
282
+ * const encrypted = await lightning.attestedDecryptWithVoucher(
283
+ * ephemeralAccount,
284
+ * voucher,
285
+ * [handle],
286
+ * { reencryptPubKey: delegateKeypair.encodePublicKey() },
287
+ * );
288
+ * ```
289
+ *
290
+ * @example Reencrypt and decrypt locally
291
+ * ```ts
292
+ * const decrypted = await lightning.attestedDecryptWithVoucher(
293
+ * ephemeralAccount,
294
+ * voucher,
295
+ * [handle],
296
+ * { reencryptPubKey: keypair.encodePublicKey(), reencryptKeypair: keypair },
297
+ * );
298
+ * ```
299
+ */
300
+ attestedDecryptWithVoucher(ephemeralAccount: PrivateKeyAccount, allowanceVoucherWithSig: AllowanceVoucherWithSig, handles: HexString[], opts?: AttestedWithVoucherOptsEphemeral): Promise<Array<DecryptionAttestation<EncryptionScheme, SupportedTeeType>>>;
301
+ attestedDecryptWithVoucher(ephemeralAccount: PrivateKeyAccount, allowanceVoucherWithSig: AllowanceVoucherWithSig, handles: HexString[], opts: AttestedWithVoucherOptsEncrypted): Promise<Array<EncryptedDecryptionAttestation<EncryptionScheme, SupportedTeeType>>>;
302
+ attestedDecryptWithVoucher(ephemeralAccount: PrivateKeyAccount, allowanceVoucherWithSig: AllowanceVoucherWithSig, handles: HexString[], opts: AttestedWithVoucherOptsDecrypted): Promise<Array<DecryptionAttestation<EncryptionScheme, SupportedTeeType>>>;
303
+ eListAttestedDecrypt(walletClient: WalletClient<Transport, Chain, Account>, handle: HexString, opts?: AttestedOptsEphemeral): Promise<EListDecryptionAttestation<EncryptionScheme, SupportedTeeType>>;
304
+ eListAttestedDecrypt(walletClient: WalletClient<Transport, Chain, Account>, handle: HexString, opts: AttestedOptsEncrypted): Promise<EncryptedEListDecryptionAttestation<EncryptionScheme, SupportedTeeType>>;
305
+ eListAttestedDecrypt(walletClient: WalletClient<Transport, Chain, Account>, handle: HexString, opts: AttestedOptsDecrypted): Promise<EListDecryptionAttestation<EncryptionScheme, SupportedTeeType>>;
306
+ /**
307
+ * Reveal a single elist handle without wallet authentication.
308
+ * Returns plaintext values along with an attestation of the checksum.
309
+ *
310
+ * @param handle - The elist handle to reveal
311
+ * @param opts - Optional backoff configuration
312
+ * @returns The elist decryption attestation with plaintext values
313
+ */
314
+ eListAttestedReveal(handle: HexString, opts?: AttestedRevealOpts): Promise<EListDecryptionAttestation<EncryptionScheme, SupportedTeeType>>;
315
+ /**
316
+ * Get an attested compute for the given wallet client.
317
+ *
318
+ * @param walletClient - The wallet client used for signing the attested compute request
319
+ * @param lhsHandle - The handle to compute
320
+ * @param op - The operation to perform
321
+ * @param rhsPlaintext - The plaintext to compute with
322
+ * @param opts - Optional configuration (reencryption keys and/or backoff config)
323
+ * @returns The decryption attestation
324
+ *
325
+ * @example Plaintext result
326
+ * ```typescript
327
+ * import { AttestedComputeSupportedOps } from '../lite/attested-compute.js';
328
+ * const lhsHandle = '0x...';
329
+ * const rhsPlaintext = 1337n;
330
+ * const op = AttestedComputeSupportedOps.Eq;
331
+ * const response = await lightning.attestedCompute(walletClient, lhsHandle, op, rhsPlaintext);
332
+ * const { plaintext, covalidatorSignature, handle } = response;
333
+ * ```
334
+ *
335
+ * @example Reencrypt for a delegate
336
+ * ```ts
337
+ * const encrypted = await lightning.attestedCompute(
338
+ * walletClient,
339
+ * lhsHandle,
340
+ * op,
341
+ * rhsPlaintext,
342
+ * { reencryptPubKey: delegatePubKey },
343
+ * );
344
+ * console.log(encrypted.encryptedPlaintext.ciphertext.value);
345
+ * ```
346
+ *
347
+ * @example Reencrypt and decrypt locally
348
+ * ```ts
349
+ * const decrypted = await lightning.attestedCompute(
350
+ * walletClient,
351
+ * lhsHandle,
352
+ * op,
353
+ * rhsPlaintext,
354
+ * { reencryptPubKey: keypair.encodePublicKey(), reencryptKeypair: keypair },
355
+ * );
356
+ * console.log(decrypted.plaintext.value);
357
+ * ```
358
+ */
359
+ attestedCompute(walletClient: WalletClient<Transport, Chain, Account>, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, opts?: AttestedOptsEphemeral): Promise<DecryptionAttestation<EncryptionScheme, SupportedTeeType>>;
360
+ attestedCompute(walletClient: WalletClient<Transport, Chain, Account>, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, opts: AttestedOptsEncrypted): Promise<EncryptedDecryptionAttestation<EncryptionScheme, SupportedTeeType>>;
361
+ attestedCompute(walletClient: WalletClient<Transport, Chain, Account>, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, opts: AttestedOptsDecrypted): Promise<DecryptionAttestation<EncryptionScheme, SupportedTeeType>>;
362
+ /**
363
+ * Performs attested compute via a voucher-backed session key.
364
+ *
365
+ * @example Plaintext result
366
+ * ```ts
367
+ * const attestation = await lightning.attestedComputeWithVoucher(
368
+ * ephemeralAccount,
369
+ * voucher,
370
+ * lhsHandle,
371
+ * AttestedComputeSupportedOps.Eq,
372
+ * true,
373
+ * );
374
+ * ```
375
+ *
376
+ * @example Reencrypt for a delegate
377
+ * ```ts
378
+ * const encrypted = await lightning.attestedComputeWithVoucher(
379
+ * ephemeralAccount,
380
+ * voucher,
381
+ * lhsHandle,
382
+ * AttestedComputeSupportedOps.Eq,
383
+ * true,
384
+ * { reencryptPubKey: delegatePubKey },
385
+ * );
386
+ * console.log(encrypted.encryptedPlaintext.ciphertext.value);
387
+ * ```
388
+ *
389
+ * @example Reencrypt and decrypt locally
390
+ * ```ts
391
+ * const decrypted = await lightning.attestedComputeWithVoucher(
392
+ * ephemeralAccount,
393
+ * voucher,
394
+ * lhsHandle,
395
+ * AttestedComputeSupportedOps.Eq,
396
+ * true,
397
+ * { reencryptPubKey: keypair.encodePublicKey(), reencryptKeypair: keypair },
398
+ * );
399
+ * console.log(decrypted.plaintext.value);
400
+ * ```
401
+ */
402
+ attestedComputeWithVoucher(ephemeralAccount: PrivateKeyAccount, allowanceVoucherWithSig: AllowanceVoucherWithSig, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, opts?: AttestedWithVoucherOptsEphemeral): Promise<DecryptionAttestation<EncryptionScheme, SupportedTeeType>>;
403
+ attestedComputeWithVoucher(ephemeralAccount: PrivateKeyAccount, allowanceVoucherWithSig: AllowanceVoucherWithSig, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, opts: AttestedWithVoucherOptsEncrypted): Promise<EncryptedDecryptionAttestation<EncryptionScheme, SupportedTeeType>>;
404
+ attestedComputeWithVoucher(ephemeralAccount: PrivateKeyAccount, allowanceVoucherWithSig: AllowanceVoucherWithSig, lhsHandle: HexString, op: AttestedComputeOP, rhsPlaintext: bigint | boolean, opts: AttestedWithVoucherOptsDecrypted): Promise<DecryptionAttestation<EncryptionScheme, SupportedTeeType>>;
405
+ /**
406
+ * Get an decryption of publicly revealed handles.
407
+ *
408
+ * @param handles - The handles to decrypt
409
+ * @param backoffConfig - The backoff configuration for the attested decrypt request
410
+ * @returns The decryption attestations
411
+ *
412
+ * @example
413
+ * ```typescript
414
+ * const response = await lightning.attestedReveal([handle1, handle2]);
415
+ * const { plaintext, covalidatorSignature } = response[0];
416
+ * ```
417
+ */
418
+ attestedReveal(handles: HexString[], opts?: AttestedRevealOpts): Promise<Array<DecryptionAttestation<EncryptionScheme, SupportedTeeType>>>;
419
+ /**
420
+ * Get the GRPC endpoint for the covalidator that services this deployment.
421
+ */
422
+ static getCovalidatorUrls(deployment: DeploymentSlice & {
423
+ pepper: string;
424
+ majorVersion: number;
425
+ }, signers: Address[]): string[];
426
+ private static isIdByName;
427
+ private static plaintextFromValue;
428
+ /**
429
+ * Reads the network public key from the on-chain Inco Verifier contract.
430
+ *
431
+ * Falls back to the legacy `eciesPubkey()` getter for older contract versions.
432
+ *
433
+ * @param client - A viem public client connected to the host chain.
434
+ * @param executorAddress - The address of the Inco Lightning executor contract.
435
+ * @returns The network public key as a hex string.
436
+ */
437
+ static getNetworkPubkey(client: PublicClient, executorAddress: Address): Promise<HexString>;
438
+ /**
439
+ * Resolves the Inco Verifier contract instance associated with a Lightning executor.
440
+ *
441
+ * Reads the `incoVerifier` address from the executor contract and returns a typed contract handle.
442
+ *
443
+ * @param client - A viem public client connected to the host chain.
444
+ * @param executorAddress - The address of the Inco Lightning executor contract.
445
+ * @returns A viem contract instance bound to the Inco Verifier ABI.
446
+ */
447
+ static getIncoVerifierContract(client: PublicClient, executorAddress: Address): Promise<GetContractReturnType<typeof incoVerifierAbi, PublicClient, Address>>;
448
+ /**
449
+ * Retrieves the verifier contract details including threshold, signers, and XWING public key from the Inco Verifier contract.
450
+ *
451
+ * @param executorAddress The address of the Inco Lightning executor contract.
452
+ * @param client The public client to interact with the blockchain.
453
+ * @returns An object containing the threshold, signers, and XWING public key.
454
+ */
455
+ private static getVerifierContractDetails;
456
+ private static getChainConfig;
457
+ private static supportsThresholdRetrieval;
458
+ }
459
+ export {};