@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
package/README.md ADDED
@@ -0,0 +1,587 @@
1
+ # @inco/lightning-js
2
+
3
+ TypeScript SDK for building privacy-preserving dapps on [Inco Lightning](https://docs.inco.org). Encrypt values client-side, post ciphertexts to smart contracts for confidential computation, and retrieve attested decryptions — all with post-quantum hybrid encryption (X-Wing KEM).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @inco/lightning-js
9
+ # or
10
+ yarn add @inco/lightning-js
11
+ # or
12
+ bun add @inco/lightning-js
13
+ ```
14
+
15
+ **Peer dependency:** [viem](https://viem.sh) `^2.39.3` is used for Ethereum interactions.
16
+
17
+ > **Note:** The library has currently only been tested with Webpack and Next.js. If you encounter issues with Rollup or Vite, please open an issue.
18
+
19
+ ## Quick Start
20
+
21
+ A typical workflow has three steps:
22
+
23
+ 1. **Encrypt** a value client-side
24
+ 2. **Submit** the ciphertext to a smart contract for confidential computation
25
+ 3. **Decrypt** the result via attested decryption
26
+
27
+ ```ts
28
+ import { getViemChain, supportedChains, handleTypes } from '@inco/lightning-js';
29
+ import { Lightning } from '@inco/lightning-js/lite';
30
+ import { createWalletClient } from 'viem';
31
+
32
+ // 1. Setup
33
+ const chainId = supportedChains.baseSepolia;
34
+ const zap = await Lightning.baseSepoliaTestnet();
35
+ const walletClient = createWalletClient({
36
+ chain: getViemChain(chainId),
37
+ account: /* your account */,
38
+ transport: /* your transport */,
39
+ });
40
+ const dappAddress = '0x...'; // Your contract address
41
+
42
+ // 2. Encrypt
43
+ const ciphertext = await zap.encrypt(42n, {
44
+ accountAddress: walletClient.account.address,
45
+ dappAddress,
46
+ handleType: handleTypes.euint256,
47
+ });
48
+
49
+ // 3. Submit ciphertext to contract via viem writeContract (not SDK-specific)
50
+
51
+ // 4. Decrypt the result
52
+ const resultHandle = '0x...'; // Retrieved from the contract
53
+ const [attestation] = await zap.attestedDecrypt(walletClient, [resultHandle]);
54
+ console.log(attestation.plaintext.value);
55
+ ```
56
+
57
+ ---
58
+
59
+ ## Package Exports
60
+
61
+ | Import Path | Description |
62
+ | --------------------------------- | --------------------------------------------------------------------------------- |
63
+ | `@inco/lightning-js` | Core utilities: binary helpers, chain definitions, handle types, viem integration |
64
+ | `@inco/lightning-js/lite` | Main SDK: `Lightning` class, encryption, attested decrypt/compute, session keys |
65
+ | `@inco/lightning-js/encryption` | Encryption types, plaintext/ciphertext conversions, scheme constants |
66
+ | `@inco/lightning-js/reencryption` | Reencryption types, EIP-712 payload creation |
67
+ | `@inco/lightning-js/abis` | Generated smart contract ABIs (Lightning, Verifier) |
68
+
69
+ ---
70
+
71
+ ## API Reference
72
+
73
+ ### `Lightning` Class
74
+
75
+ **Import:** `import { Lightning } from '@inco/lightning-js/lite'`
76
+
77
+ The primary entry point for all SDK operations. Binds to a specific Inco Lightning deployment and provides encryption, attested decryption, attested compute, and session key management.
78
+
79
+ #### Factory Methods
80
+
81
+ The constructor is private. Use one of the static factory methods. Prefer the network-specific factories — they bind to the latest deployment for that network:
82
+
83
+ ```ts
84
+ // Connect to the latest deployment on a known network
85
+ const zap = await Lightning.baseSepoliaTestnet(); // Base Sepolia testnet
86
+ const zap = await Lightning.baseMainnet(); // Base mainnet
87
+
88
+ // Provide your own RPC endpoint(s) (recommended for production).
89
+ // When more than one URL is given, they are wrapped in viem's `fallback()`
90
+ // transport for automatic failover.
91
+ const zap = await Lightning.baseSepoliaTestnet({
92
+ hostChainRpcUrls: ["https://your-rpc-url"],
93
+ });
94
+ ```
95
+
96
+ Both network factories (`baseSepoliaTestnet`, `baseMainnet`) accept an optional `{ hostChainRpcUrls?: readonly string[] }` argument.
97
+
98
+ | Method | Returns | Description |
99
+ | ---------------------------------------- | -------------------- | ----------------------------------------- |
100
+ | `Lightning.baseSepoliaTestnet(options?)` | `Promise<Lightning>` | Latest deployment on Base Sepolia (84532) |
101
+ | `Lightning.baseMainnet(options?)` | `Promise<Lightning>` | Latest deployment on Base mainnet (8453) |
102
+
103
+ > **Local development:** to run against a local Anvil + covalidator node, see the [quick start guide and tutorials](https://docs.inco.org) in the Inco docs.
104
+
105
+ #### Properties
106
+
107
+ | Property | Type | Description |
108
+ | ----------------- | --------- | -------------------------------------------- |
109
+ | `executorAddress` | `Address` | The executor contract address |
110
+ | `chainId` | `bigint` | The host chain ID |
111
+ | `deployment` | `T` | Shallow copy of the deployment configuration |
112
+
113
+ #### `encrypt(value, context)`
114
+
115
+ Encrypts a plaintext value using the network's public key.
116
+
117
+ ```ts
118
+ async encrypt<T extends boolean | bigint | number>(
119
+ value: T,
120
+ context: {
121
+ accountAddress: string; // EOA interacting with the dapp
122
+ dappAddress: string; // Contract address
123
+ handleType: TeeType; // Required — the TEE handle type to encrypt as
124
+ }
125
+ ): Promise<HexString>
126
+ ```
127
+
128
+ **Recommended handle type per value type:**
129
+
130
+ | Value Type | Handle Type | Example |
131
+ | ------------------- | ---------------------- | ------------------------------------------------------------------------- |
132
+ | `boolean` | `handleTypes.ebool` | `zap.encrypt(true, { ...ctx, handleType: handleTypes.ebool })` |
133
+ | `bigint` / `number` | `handleTypes.euint256` | `zap.encrypt(42n, { ...ctx, handleType: handleTypes.euint256 })` |
134
+ | `bigint` (address) | `handleTypes.euint160` | `zap.encrypt(BigInt(addr), { ...ctx, handleType: handleTypes.euint160 })` |
135
+
136
+ Returns a hex string ciphertext to pass to your contract as `bytes`.
137
+
138
+ #### `attestedDecrypt(walletClient, handles, ...)`
139
+
140
+ Requests attested decryption of one or more handles. Only handles approved via `e.allow()` can be decrypted.
141
+
142
+ **Three calling modes:**
143
+
144
+ ```ts
145
+ import { generateXwingKeypair } from "@inco/lightning-js/lite";
146
+
147
+ // Mode 1: Plaintext result (auto-generates ephemeral keypair internally)
148
+ const attestations = await zap.attestedDecrypt(walletClient, [handle]);
149
+ attestations[0].plaintext.value; // The decrypted value
150
+
151
+ // Mode 2: Reencrypt for a delegate (returns encrypted result)
152
+ const encrypted = await zap.attestedDecrypt(walletClient, [handle], {
153
+ reencryptPubKey: delegatePubKey,
154
+ });
155
+ encrypted[0].encryptedPlaintext.ciphertext.value;
156
+
157
+ // Mode 3: Reencrypt and decrypt locally
158
+ const keypair = await generateXwingKeypair();
159
+ const decrypted = await zap.attestedDecrypt(walletClient, [handle], {
160
+ reencryptPubKey: keypair.encodePublicKey(),
161
+ reencryptKeypair: keypair,
162
+ });
163
+ decrypted[0].plaintext.value;
164
+ ```
165
+
166
+ All modes accept an optional `backoffConfig` on the trailing `opts` object for retry tuning:
167
+
168
+ ```ts
169
+ const attestations = await zap.attestedDecrypt(walletClient, [handle], {
170
+ backoffConfig: {
171
+ maxRetries: 10,
172
+ baseDelayInMs: 1000,
173
+ backoffFactor: 1.5,
174
+ },
175
+ });
176
+ ```
177
+
178
+ **Return types:**
179
+
180
+ | Mode | Return Type |
181
+ | ------------------------- | ----------------------------------------------------------------------------------------------------------------- |
182
+ | Plaintext | `DecryptionAttestation[]` — `{ handle, plaintext, covalidatorSignatures }` |
183
+ | Reencrypt | `EncryptedDecryptionAttestation[]` — `{ handle, encryptedPlaintext, encryptedSignatures, covalidatorSignatures }` |
184
+ | Reencrypt + local decrypt | `DecryptionAttestation[]` |
185
+
186
+ #### `attestedReveal(handles, opts?)`
187
+
188
+ Decrypts publicly revealed handles (those marked with `e.reveal()`). Does not require a wallet — anyone can call this.
189
+
190
+ ```ts
191
+ const attestations = await zap.attestedReveal([handle]);
192
+ attestations[0].plaintext.value;
193
+ ```
194
+
195
+ > **Warning:** Once `e.reveal()` is called on-chain, the ciphertext is considered public and can be accessed by anyone. This cannot be undone.
196
+
197
+ #### `attestedCompute(walletClient, lhsHandle, op, rhsPlaintext, ...)`
198
+
199
+ Performs an off-chain comparison operation on an encrypted handle against a plaintext scalar, returning an attested result.
200
+
201
+ ```ts
202
+ import { AttestedComputeSupportedOps } from "@inco/lightning-js/lite";
203
+
204
+ // Plaintext result
205
+ const result = await zap.attestedCompute(
206
+ walletClient,
207
+ handle,
208
+ AttestedComputeSupportedOps.Ge,
209
+ 700n,
210
+ );
211
+ console.log(result.plaintext.value); // true or false
212
+ ```
213
+
214
+ **Supported operations:**
215
+
216
+ | Operation | Description |
217
+ | -------------------------------- | --------------------- |
218
+ | `AttestedComputeSupportedOps.Eq` | Equal |
219
+ | `AttestedComputeSupportedOps.Ne` | Not equal |
220
+ | `AttestedComputeSupportedOps.Ge` | Greater than or equal |
221
+ | `AttestedComputeSupportedOps.Gt` | Greater than |
222
+ | `AttestedComputeSupportedOps.Le` | Less than or equal |
223
+ | `AttestedComputeSupportedOps.Lt` | Less than |
224
+
225
+ Supports the same three calling modes as `attestedDecrypt` (plaintext, reencrypt, reencrypt + local decrypt).
226
+
227
+ #### Session Key Methods
228
+
229
+ Session keys (allowance vouchers) enable delegated decryption without requiring the data owner's wallet signature for each request.
230
+
231
+ ```ts
232
+ // Owner grants a session key to a delegate
233
+ const voucher = await zap.grantSessionKeyAllowanceVoucher(
234
+ walletClient, // Owner's wallet
235
+ granteeAddress, // Delegate's address
236
+ expiresAt, // Expiration Date
237
+ sessionVerifierAddr, // Session verifier contract
238
+ );
239
+
240
+ // Delegate decrypts using the voucher
241
+ const attestations = await zap.attestedDecryptWithVoucher(
242
+ ephemeralAccount,
243
+ voucher,
244
+ [handle],
245
+ );
246
+
247
+ // Delegate computes using the voucher
248
+ const result = await zap.attestedComputeWithVoucher(
249
+ ephemeralAccount,
250
+ voucher,
251
+ handle,
252
+ AttestedComputeSupportedOps.Eq,
253
+ 42n,
254
+ );
255
+
256
+ // Owner revokes all active vouchers
257
+ const txHash = await zap.updateActiveVouchersSessionNonce(walletClient);
258
+ ```
259
+
260
+ | Method | Description |
261
+ | ------------------------------------------------------------------------------ | ------------------------------------ |
262
+ | `grantSessionKeyAllowanceVoucher(walletClient, grantee, expiresAt, verifier)` | Grant a time-limited session key |
263
+ | `grantCustomSessionKeyAllowanceVoucher(walletClient, verifier, sharerArgData)` | Grant with custom verifier arguments |
264
+ | `attestedDecryptWithVoucher(account, voucher, handles, opts?)` | Decrypt using a session key |
265
+ | `attestedComputeWithVoucher(account, voucher, handle, op, rhs, opts?)` | Compute using a session key |
266
+ | `updateActiveVouchersSessionNonce(walletClient)` | Revoke all active vouchers |
267
+
268
+ #### Static Helpers
269
+
270
+ ```ts
271
+ // Read network public key from on-chain verifier
272
+ const pubkey = await Lightning.getNetworkPubkey(publicClient, executorAddress);
273
+
274
+ // Get the IncoVerifier contract instance
275
+ const verifier = await Lightning.getIncoVerifierContract(
276
+ publicClient,
277
+ executorAddress,
278
+ );
279
+
280
+ // Get covalidator URLs for a deployment
281
+ const urls = Lightning.getCovalidatorUrls(deployment, signers);
282
+ ```
283
+
284
+ ---
285
+
286
+ ### Core Utilities (`@inco/lightning-js`)
287
+
288
+ #### Chain Support
289
+
290
+ ```ts
291
+ import {
292
+ supportedChains,
293
+ getSupportedChain,
294
+ getViemChain,
295
+ } from "@inco/lightning-js";
296
+
297
+ // Supported chains
298
+ supportedChains.base; // 8453
299
+ supportedChains.baseSepolia; // 84532
300
+ supportedChains.anvil; // 31337
301
+
302
+ // Resolve chain from ID, name, or object
303
+ const chain = getSupportedChain(84532);
304
+ const chain = getSupportedChain("baseSepolia");
305
+ const chain = getSupportedChain({ id: 84532 });
306
+
307
+ // Get viem Chain object
308
+ const viemChain = getViemChain(84532);
309
+ ```
310
+
311
+ #### Handle Types
312
+
313
+ ```ts
314
+ import {
315
+ handleTypes,
316
+ isTeeType,
317
+ validateHandle,
318
+ getHandleType,
319
+ } from "@inco/lightning-js";
320
+
321
+ // FHE type identifiers
322
+ handleTypes.ebool; // 0
323
+ handleTypes.euint4; // 1
324
+ handleTypes.euint8; // 2
325
+ handleTypes.euint16; // 3
326
+ handleTypes.euint32; // 4
327
+ handleTypes.euint64; // 5
328
+ handleTypes.euint128; // 6
329
+ handleTypes.euint160; // 7
330
+ handleTypes.euint256; // 8
331
+ handleTypes.ebytes64; // 9
332
+ handleTypes.ebytes128; // 10
333
+ handleTypes.ebytes256; // 11
334
+
335
+ // Validate and inspect handles
336
+ validateHandle("0x..."); // throws if malformed
337
+ const handleType = getHandleType("0x..."); // extracts the handle type
338
+ isTeeType(5); // true (euint64)
339
+ ```
340
+
341
+ #### Binary Utilities
342
+
343
+ ```ts
344
+ import {
345
+ bytesToBigInt,
346
+ bigintToBytes,
347
+ bigintToBytes32,
348
+ bytes32ToBigint,
349
+ bytesFromHexString,
350
+ bytesToHex,
351
+ mustBeHex,
352
+ normaliseToHex,
353
+ padLeft,
354
+ asBytes32,
355
+ parseAddress,
356
+ parseHex,
357
+ } from "@inco/lightning-js";
358
+
359
+ // Conversions
360
+ bytesToBigInt(new Uint8Array([1, 0])); // 256n
361
+ bigintToBytes(42n); // 32-byte Buffer
362
+ bigintToBytes32(42n); // '0x000...002a' (Bytes32)
363
+
364
+ // Hex helpers
365
+ mustBeHex("0xdead"); // returns typed Hex, throws if invalid
366
+ normaliseToHex("dead"); // '0xdead'
367
+ bytesToHex(new Uint8Array()); // '0x'
368
+
369
+ // Parsing with validation
370
+ parseAddress("0x1234...5678"); // validated Address (20 bytes)
371
+ parseHex("0xabcd"); // validated HexString
372
+ asBytes32("0x00...00"); // validated Bytes32 (32 bytes)
373
+ ```
374
+
375
+ ---
376
+
377
+ ### Encryption Module (`@inco/lightning-js/encryption`)
378
+
379
+ Types and conversion utilities for plaintexts and ciphertexts.
380
+
381
+ ```ts
382
+ import {
383
+ // Constants
384
+ encryptionSchemes, // { xwing: 2 }
385
+ supportedTeeTypes, // { euint64: 5, euint160: 7, euint256: 8, ebool: 0 }
386
+
387
+ // Conversions
388
+ bigintToPlaintext, // (scheme, type, bigint) => Plaintext
389
+ plaintextToBigint, // (plaintext) => bigint
390
+ plaintextToBytes32, // (plaintext) => Bytes32
391
+ plaintextToBytes, // (plaintext) => Buffer
392
+ bytes32ToPlaintext, // (bytes32, scheme, type) => Plaintext
393
+ bytesToPlaintext, // (bytes, scheme, type) => Plaintext
394
+
395
+ // Helpers
396
+ getEncryptionSchemeName, // (scheme) => 'X-Wing'
397
+ } from "@inco/lightning-js/encryption";
398
+ ```
399
+
400
+ **Key types:**
401
+
402
+ | Type | Description |
403
+ | ------------------ | -------------------------------------------------------------------------------------- |
404
+ | `Plaintext` | `{ scheme, type, value }` — value is `bigint` for integer types, `boolean` for `ebool` |
405
+ | `Ciphertext` | `{ scheme, type, value }` — value is a hex string |
406
+ | `EncryptionScheme` | Currently only `2` (X-Wing) |
407
+ | `SupportedTeeType` | `0`, `5`, `7`, `8` (ebool, euint64, euint160, euint256) |
408
+
409
+ ---
410
+
411
+ ### Deployment Utilities (`@inco/lightning-js/lite`)
412
+
413
+ ```ts
414
+ import {
415
+ getActiveLightningDeployment,
416
+ getLightningDeployments,
417
+ } from "@inco/lightning-js/lite";
418
+
419
+ // Get the latest active deployment for a chain
420
+ const deployment = getActiveLightningDeployment("baseSepolia");
421
+
422
+ // Get all deployments for a chain
423
+ const deployments = getLightningDeployments(84532);
424
+ ```
425
+
426
+ #### X-Wing Keypair (`@inco/lightning-js/lite`)
427
+
428
+ Generate an ephemeral X-Wing keypair for local reencryption (Mode 3 of `attestedDecrypt` and `attestedCompute`):
429
+
430
+ ```ts
431
+ import {
432
+ generateXwingKeypair,
433
+ type XwingKeypair,
434
+ } from "@inco/lightning-js/lite";
435
+
436
+ const keypair: XwingKeypair = await generateXwingKeypair();
437
+
438
+ // Pass the public key to the attested call and the keypair for local decryption
439
+ const decrypted = await zap.attestedDecrypt(walletClient, [handle], {
440
+ reencryptPubKey: keypair.encodePublicKey(),
441
+ reencryptKeypair: keypair,
442
+ });
443
+ decrypted[0].plaintext.value;
444
+ ```
445
+
446
+ X-Wing is a post-quantum hybrid KEM combining ML-KEM-768 and X25519. The generated keypair is ephemeral — generate a fresh one per request.
447
+
448
+ ---
449
+
450
+ ### Reencryption Module (`@inco/lightning-js/reencryption`)
451
+
452
+ EIP-712 typed data utilities for signing reencryption requests.
453
+
454
+ ```ts
455
+ import { createEIP712Payload } from "@inco/lightning-js/reencryption";
456
+
457
+ const payload = createEIP712Payload({
458
+ chainId: 84532n,
459
+ primaryType: "Reencrypt",
460
+ primaryTypeFields: [{ name: "publicKey", type: "bytes" }],
461
+ message: { publicKey: "0x..." },
462
+ domainName: "IncoLite",
463
+ domainVersion: "1",
464
+ verifyingContract: "0x...",
465
+ });
466
+ ```
467
+
468
+ **Key types:**
469
+
470
+ | Type | Description |
471
+ | ----------------- | ---------------------------------------------- |
472
+ | `Reencryptor<S>` | `(args, backoffConfig?) => Promise<Plaintext>` |
473
+ | `PubKeyEncodable` | `{ encodePublicKey(): Uint8Array }` |
474
+ | `EIP712<Message>` | Full EIP-712 typed data payload |
475
+
476
+ ---
477
+
478
+ ### ABIs (`@inco/lightning-js/abis`)
479
+
480
+ Generated contract ABIs for direct contract interaction with viem.
481
+
482
+ ```ts
483
+ import { incoLightningAbi } from "@inco/lightning-js/abis/lightning";
484
+ import { incoVerifierAbi } from "@inco/lightning-js/abis/verifier";
485
+ ```
486
+
487
+ ---
488
+
489
+ ## Supported Chains
490
+
491
+ | Chain | Chain ID | Name |
492
+ | ------------- | -------- | ------------- |
493
+ | Base | `8453` | `base` |
494
+ | Base Sepolia | `84532` | `baseSepolia` |
495
+ | Anvil (local) | `31337` | `anvil` |
496
+
497
+ ---
498
+
499
+ ## BackoffConfig
500
+
501
+ All attested decrypt/compute methods support optional retry configuration:
502
+
503
+ ```ts
504
+ type BackoffConfig = {
505
+ maxRetries: number; // Default: 5
506
+ baseDelayInMs: number; // Default: 1000
507
+ backoffFactor: number; // Default: 1.5
508
+ errHandler?: (error: Error, attempt: number) => "stop" | "continue";
509
+ };
510
+ ```
511
+
512
+ Only transient errors (timeouts, connection issues, 503s) are retried. Security-critical errors (auth failures, invalid signatures) fail immediately.
513
+
514
+ ---
515
+
516
+ ## Migrating from `@inco/js` (v0.7.x → v1.0.0)
517
+
518
+ The package was renamed from **`@inco/js`** to **`@inco/lightning-js`** (the old package is deprecated on npm), and v1.0.0 ships **breaking API changes** on top of the rename. The headline change: encryption moved from ECIES to a **post-quantum X-Wing** scheme, so ciphertexts and reencryption keys produced by v0.7.x are **not interoperable** with v1.
519
+
520
+ ### Step 1 — Update the package
521
+
522
+ ```bash
523
+ npm uninstall @inco/js && npm install @inco/lightning-js
524
+ ```
525
+
526
+ Update every import specifier, including subpaths:
527
+
528
+ ```diff
529
+ -import { supportedChains } from '@inco/js';
530
+ -import { Lightning } from '@inco/js/lite';
531
+ +import { supportedChains } from '@inco/lightning-js';
532
+ +import { Lightning } from '@inco/lightning-js/lite';
533
+ ```
534
+
535
+ `@inco/js/encryption`, `@inco/js/reencryption`, and `@inco/js/abis` rename the same way. Note also that the **`@inco/js/fhevm`** subpath was removed.
536
+
537
+ ### Step 2 — Breaking API changes
538
+
539
+ | Area | Before (`@inco/js` v0.7.x) | After (`@inco/lightning-js` v1.0.0) |
540
+ | ---------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
541
+ | Encryption scheme | ECIES (`encryptionSchemes.ecies`, `1`) | post-quantum X-Wing (`encryptionSchemes.xwing`, `2`) — not interoperable |
542
+ | Reencryption keypair | `generateSecp256k1Keypair()` (sync), `Secp256k1Keypair` | `await generateXwingKeypair()` (async), `XwingKeypair` |
543
+ | Attested method extras | positional `reencryptPubKey` / `reencryptKeypair` / `backoffConfig` | a single trailing `opts` object |
544
+ | Voucher methods | `ephemeralKeypair: Secp256k1Keypair` + positional `ethClient` | `ephemeralAccount: PrivateKeyAccount`, no `ethClient`, trailing `opts` |
545
+ | RPC config | `hostChainRpcUrl?: string` | `hostChainRpcUrls?: readonly string[]` (multiple URLs use viem `fallback()`) |
546
+ | Type names | `FheType`, `SupportedFheType`, `supportedFheTypes` | `TeeType`, `SupportedTeeType`, `supportedTeeTypes` |
547
+ | `AllowanceVoucher` | — | new required `warning: string` field (shown by wallets; verifier enforces text) |
548
+
549
+ Attested methods now take an options object instead of positional arguments:
550
+
551
+ ```diff
552
+ -await zap.attestedDecrypt(walletClient, handles, reencryptPubKey);
553
+ +await zap.attestedDecrypt(walletClient, handles, { reencryptPubKey });
554
+
555
+ -await zap.attestedDecrypt(walletClient, handles, reencryptPubKey, keypair, backoff);
556
+ +await zap.attestedDecrypt(walletClient, handles, {
557
+ + reencryptPubKey,
558
+ + reencryptKeypair: keypair,
559
+ + backoffConfig: backoff,
560
+ +});
561
+ ```
562
+
563
+ The voucher variants drop the `ethClient` argument and take a viem account for the ephemeral key:
564
+
565
+ ```diff
566
+ -await zap.attestedDecryptWithVoucher(ephemeralKeypair, voucher, ethClient, handles, reencryptPubKey);
567
+ +await zap.attestedDecryptWithVoucher(ephemeralAccount, voucher, handles, { reencryptPubKey });
568
+ ```
569
+
570
+ `attestedCompute` / `attestedComputeWithVoucher` change the same way, and `attestedReveal`'s trailing `backoffConfig` moves into the `opts` object.
571
+
572
+ **New in v1.0.0:** `Lightning.baseMainnet()` and `grantCustomSessionKeyAllowanceVoucher()`.
573
+
574
+ ---
575
+
576
+ ## Further Reading
577
+
578
+ - [Inco Documentation](https://docs.inco.org)
579
+ - [Encryption Guide](https://docs.inco.org/js-sdk/encryption)
580
+ - [Attested Decrypt](https://docs.inco.org/js-sdk/attestations/attested-decrypt)
581
+ - [Attested Compute](https://docs.inco.org/js-sdk/attestations/attested-compute)
582
+ - [Attested Reveal](https://docs.inco.org/js-sdk/attestations/attested-reveal)
583
+ - [Allowance Vouchers](https://docs.inco.org/js-sdk/voucher/allowance-voucher)
584
+
585
+ ## License
586
+
587
+ [Apache-2.0](./LICENSE)
@@ -0,0 +1,2 @@
1
+ export * from './session-key.js';
2
+ export * from './types.js';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./session-key.js"), exports);
18
+ __exportStar(require("./types.js"), exports);
19
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvYWR2YW5jZWRhY2wvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLG1EQUFpQztBQUNqQyw2Q0FBMkIifQ==