@enclave-e3/contracts 0.1.4 → 0.1.6

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 (467) hide show
  1. package/README.md +46 -2
  2. package/artifacts/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol/ProxyAdmin.json +135 -0
  3. package/artifacts/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol/artifacts.d.ts +27 -0
  4. package/artifacts/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/ITransparentUpgradeableProxy.json +77 -0
  5. package/artifacts/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.json +126 -0
  6. package/artifacts/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/artifacts.d.ts +43 -0
  7. package/artifacts/build-info/solc-0_8_28-5150b9e6b6cf4df4986fccba97bea37a16fdfebc.json +311 -0
  8. package/artifacts/build-info/solc-0_8_28-5150b9e6b6cf4df4986fccba97bea37a16fdfebc.output.json +1 -0
  9. package/artifacts/contracts/Enclave.sol/Enclave.json +239 -147
  10. package/artifacts/contracts/Enclave.sol/artifacts.d.ts +6 -6
  11. package/artifacts/contracts/interfaces/IBondingRegistry.sol/IBondingRegistry.json +881 -0
  12. package/artifacts/contracts/interfaces/IBondingRegistry.sol/artifacts.d.ts +27 -0
  13. package/artifacts/contracts/interfaces/ICiphernodeRegistry.sol/ICiphernodeRegistry.json +326 -10
  14. package/artifacts/contracts/interfaces/ICiphernodeRegistry.sol/artifacts.d.ts +2 -2
  15. package/artifacts/contracts/interfaces/IComputeProvider.sol/IComputeProvider.json +1 -1
  16. package/artifacts/contracts/interfaces/IComputeProvider.sol/artifacts.d.ts +1 -1
  17. package/artifacts/contracts/interfaces/IDecryptionVerifier.sol/IDecryptionVerifier.json +1 -1
  18. package/artifacts/contracts/interfaces/IDecryptionVerifier.sol/artifacts.d.ts +1 -1
  19. package/artifacts/contracts/interfaces/IE3Program.sol/IE3Program.json +21 -3
  20. package/artifacts/contracts/interfaces/IE3Program.sol/artifacts.d.ts +2 -2
  21. package/artifacts/contracts/interfaces/IEnclave.sol/IEnclave.json +247 -27
  22. package/artifacts/contracts/interfaces/IEnclave.sol/artifacts.d.ts +2 -2
  23. package/artifacts/contracts/interfaces/{IRegistryFilter.sol/IRegistryFilter.json → ISlashVerifier.sol/ISlashVerifier.json} +10 -10
  24. package/artifacts/contracts/interfaces/ISlashVerifier.sol/artifacts.d.ts +27 -0
  25. package/artifacts/contracts/interfaces/ISlashingManager.sol/ISlashingManager.json +759 -0
  26. package/artifacts/contracts/interfaces/ISlashingManager.sol/artifacts.d.ts +27 -0
  27. package/artifacts/contracts/lib/ExitQueueLib.sol/ExitQueueLib.json +116 -0
  28. package/artifacts/contracts/lib/ExitQueueLib.sol/artifacts.d.ts +27 -0
  29. package/artifacts/contracts/registry/BondingRegistry.sol/BondingRegistry.json +1217 -0
  30. package/artifacts/contracts/registry/BondingRegistry.sol/artifacts.d.ts +27 -0
  31. package/artifacts/contracts/registry/CiphernodeRegistryOwnable.sol/CiphernodeRegistryOwnable.json +351 -57
  32. package/artifacts/contracts/registry/CiphernodeRegistryOwnable.sol/artifacts.d.ts +6 -6
  33. package/artifacts/contracts/slashing/SlashingManager.sol/SlashingManager.json +1107 -0
  34. package/artifacts/contracts/slashing/SlashingManager.sol/artifacts.d.ts +27 -0
  35. package/artifacts/contracts/test/MockCiphernodeRegistry.sol/MockCiphernodeRegistry.json +328 -12
  36. package/artifacts/contracts/test/MockCiphernodeRegistry.sol/MockCiphernodeRegistryEmptyKey.json +328 -12
  37. package/artifacts/contracts/test/MockCiphernodeRegistry.sol/artifacts.d.ts +8 -8
  38. package/artifacts/contracts/test/MockComputeProvider.sol/MockComputeProvider.json +4 -4
  39. package/artifacts/contracts/test/MockComputeProvider.sol/artifacts.d.ts +4 -4
  40. package/artifacts/contracts/test/MockDecryptionVerifier.sol/MockDecryptionVerifier.json +3 -3
  41. package/artifacts/contracts/test/MockDecryptionVerifier.sol/artifacts.d.ts +3 -3
  42. package/artifacts/contracts/test/MockE3Program.sol/MockE3Program.json +26 -32
  43. package/artifacts/contracts/test/MockE3Program.sol/artifacts.d.ts +4 -4
  44. package/artifacts/contracts/test/MockSlashingVerifier.sol/MockSlashingVerifier.json +38 -0
  45. package/artifacts/contracts/test/MockSlashingVerifier.sol/artifacts.d.ts +27 -0
  46. package/artifacts/contracts/test/MockStableToken.sol/MockUSDC.json +425 -0
  47. package/artifacts/contracts/test/MockStableToken.sol/artifacts.d.ts +27 -0
  48. package/artifacts/contracts/token/EnclaveTicketToken.sol/EnclaveTicketToken.json +1222 -0
  49. package/artifacts/contracts/token/EnclaveTicketToken.sol/artifacts.d.ts +27 -0
  50. package/artifacts/contracts/token/EnclaveToken.sol/EnclaveToken.json +1460 -0
  51. package/artifacts/contracts/token/EnclaveToken.sol/artifacts.d.ts +27 -0
  52. package/artifacts/poseidon-solidity/PoseidonT3.sol/PoseidonT3.json +3 -3
  53. package/artifacts/poseidon-solidity/PoseidonT3.sol/artifacts.d.ts +3 -3
  54. package/contracts/Enclave.sol +230 -81
  55. package/contracts/interfaces/IBondingRegistry.sol +446 -0
  56. package/contracts/interfaces/ICiphernodeRegistry.sol +153 -9
  57. package/contracts/interfaces/IComputeProvider.sol +12 -2
  58. package/contracts/interfaces/IDecryptionVerifier.sol +11 -6
  59. package/contracts/interfaces/IE3.sol +21 -17
  60. package/contracts/interfaces/IE3Program.sol +30 -17
  61. package/contracts/interfaces/IEnclave.sol +95 -21
  62. package/contracts/interfaces/ISlashVerifier.sol +23 -0
  63. package/contracts/interfaces/ISlashingManager.sol +426 -0
  64. package/contracts/lib/ExitQueueLib.sol +490 -0
  65. package/contracts/registry/BondingRegistry.sol +737 -0
  66. package/contracts/registry/CiphernodeRegistryOwnable.sol +393 -26
  67. package/contracts/slashing/SlashingManager.sol +367 -0
  68. package/contracts/test/MockCiphernodeRegistry.sol +118 -24
  69. package/contracts/test/MockComputeProvider.sol +2 -2
  70. package/contracts/test/MockE3Program.sol +17 -14
  71. package/contracts/test/MockSlashingVerifier.sol +19 -0
  72. package/contracts/test/MockStableToken.sol +28 -0
  73. package/contracts/token/EnclaveTicketToken.sol +243 -0
  74. package/contracts/token/EnclaveToken.sol +267 -0
  75. package/dist/hardhat.config.d.ts.map +1 -1
  76. package/dist/hardhat.config.js +35 -16
  77. package/dist/ignition/modules/{mockInputValidator.d.ts → bondingRegistry.d.ts} +1 -1
  78. package/dist/ignition/modules/bondingRegistry.d.ts.map +1 -0
  79. package/dist/ignition/modules/bondingRegistry.js +35 -0
  80. package/dist/ignition/modules/ciphernodeRegistry.d.ts.map +1 -1
  81. package/dist/ignition/modules/ciphernodeRegistry.js +12 -2
  82. package/dist/ignition/modules/enclave.d.ts.map +1 -1
  83. package/dist/ignition/modules/enclave.js +16 -7
  84. package/dist/ignition/modules/{naiveRegistryFilter.d.ts → enclaveTicketToken.d.ts} +1 -1
  85. package/dist/ignition/modules/enclaveTicketToken.d.ts.map +1 -0
  86. package/dist/ignition/modules/enclaveTicketToken.js +17 -0
  87. package/dist/ignition/modules/enclaveToken.d.ts +3 -0
  88. package/dist/ignition/modules/enclaveToken.d.ts.map +1 -0
  89. package/dist/ignition/modules/{mockInputValidator.js → enclaveToken.js} +4 -4
  90. package/dist/ignition/modules/mockCiphernodeRegistry.d.ts.map +1 -1
  91. package/dist/ignition/modules/mockCiphernodeRegistry.js +0 -1
  92. package/dist/ignition/modules/mockCiphernodeRegistryEmptyKey.d.ts.map +1 -1
  93. package/dist/ignition/modules/mockCiphernodeRegistryEmptyKey.js +0 -1
  94. package/dist/ignition/modules/mockComputeProvider.d.ts.map +1 -1
  95. package/dist/ignition/modules/mockComputeProvider.js +0 -1
  96. package/dist/ignition/modules/mockDecryptionVerifier.d.ts.map +1 -1
  97. package/dist/ignition/modules/mockDecryptionVerifier.js +0 -1
  98. package/dist/ignition/modules/mockE3Program.d.ts.map +1 -1
  99. package/dist/ignition/modules/mockE3Program.js +1 -3
  100. package/dist/ignition/modules/mockSlashingVerifier.d.ts +3 -0
  101. package/dist/ignition/modules/mockSlashingVerifier.d.ts.map +1 -0
  102. package/dist/ignition/modules/mockSlashingVerifier.js +10 -0
  103. package/dist/ignition/modules/mockStableToken.d.ts +3 -0
  104. package/dist/ignition/modules/mockStableToken.d.ts.map +1 -0
  105. package/dist/ignition/modules/mockStableToken.js +11 -0
  106. package/dist/ignition/modules/poseidonT3.d.ts.map +1 -1
  107. package/dist/ignition/modules/poseidonT3.js +0 -1
  108. package/dist/ignition/modules/slashingManager.d.ts +3 -0
  109. package/dist/ignition/modules/slashingManager.d.ts.map +1 -0
  110. package/dist/ignition/modules/slashingManager.js +16 -0
  111. package/dist/scripts/cleanIgnitionState.d.ts +12 -0
  112. package/dist/scripts/cleanIgnitionState.d.ts.map +1 -0
  113. package/dist/scripts/cleanIgnitionState.js +41 -0
  114. package/dist/scripts/deployAndSave/bondingRegistry.d.ts +38 -0
  115. package/dist/scripts/deployAndSave/bondingRegistry.d.ts.map +1 -0
  116. package/dist/scripts/deployAndSave/bondingRegistry.js +133 -0
  117. package/dist/scripts/deployAndSave/ciphernodeRegistryOwnable.d.ts +11 -1
  118. package/dist/scripts/deployAndSave/ciphernodeRegistryOwnable.d.ts.map +1 -1
  119. package/dist/scripts/deployAndSave/ciphernodeRegistryOwnable.js +76 -19
  120. package/dist/scripts/deployAndSave/enclave.d.ts +16 -2
  121. package/dist/scripts/deployAndSave/enclave.d.ts.map +1 -1
  122. package/dist/scripts/deployAndSave/enclave.js +89 -22
  123. package/dist/scripts/deployAndSave/enclaveTicketToken.d.ts +20 -0
  124. package/dist/scripts/deployAndSave/enclaveTicketToken.d.ts.map +1 -0
  125. package/dist/scripts/deployAndSave/enclaveTicketToken.js +41 -0
  126. package/dist/scripts/deployAndSave/enclaveToken.d.ts +18 -0
  127. package/dist/scripts/deployAndSave/enclaveToken.d.ts.map +1 -0
  128. package/dist/scripts/deployAndSave/enclaveToken.js +57 -0
  129. package/dist/scripts/deployAndSave/mockComputeProvider.d.ts.map +1 -1
  130. package/dist/scripts/deployAndSave/mockComputeProvider.js +5 -5
  131. package/dist/scripts/deployAndSave/mockDecryptionVerifier.d.ts.map +1 -1
  132. package/dist/scripts/deployAndSave/mockDecryptionVerifier.js +5 -5
  133. package/dist/scripts/deployAndSave/mockProgram.d.ts +1 -2
  134. package/dist/scripts/deployAndSave/mockProgram.d.ts.map +1 -1
  135. package/dist/scripts/deployAndSave/mockProgram.js +7 -19
  136. package/dist/scripts/deployAndSave/mockStableToken.d.ts +18 -0
  137. package/dist/scripts/deployAndSave/mockStableToken.d.ts.map +1 -0
  138. package/dist/scripts/deployAndSave/mockStableToken.js +36 -0
  139. package/dist/scripts/deployAndSave/poseidonT3.d.ts +11 -0
  140. package/dist/scripts/deployAndSave/poseidonT3.d.ts.map +1 -0
  141. package/dist/scripts/deployAndSave/poseidonT3.js +41 -0
  142. package/dist/scripts/deployAndSave/slashingManager.d.ts +19 -0
  143. package/dist/scripts/deployAndSave/slashingManager.d.ts.map +1 -0
  144. package/dist/scripts/deployAndSave/slashingManager.js +38 -0
  145. package/dist/scripts/deployEnclave.d.ts.map +1 -1
  146. package/dist/scripts/deployEnclave.js +109 -23
  147. package/dist/scripts/deployMocks.d.ts +0 -1
  148. package/dist/scripts/deployMocks.d.ts.map +1 -1
  149. package/dist/scripts/deployMocks.js +3 -6
  150. package/dist/scripts/index.d.ts +7 -2
  151. package/dist/scripts/index.d.ts.map +1 -1
  152. package/dist/scripts/index.js +7 -2
  153. package/dist/scripts/proxy.d.ts +22 -0
  154. package/dist/scripts/proxy.d.ts.map +1 -0
  155. package/dist/scripts/proxy.js +36 -0
  156. package/dist/scripts/runVerification.d.ts +2 -0
  157. package/dist/scripts/runVerification.d.ts.map +1 -0
  158. package/dist/scripts/runVerification.js +16 -0
  159. package/dist/scripts/upgrade/bondingRegistry.d.ts +6 -0
  160. package/dist/scripts/upgrade/bondingRegistry.d.ts.map +1 -0
  161. package/dist/scripts/upgrade/bondingRegistry.js +49 -0
  162. package/dist/scripts/upgrade/ciphernodeRegistryOwnable.d.ts +6 -0
  163. package/dist/scripts/upgrade/ciphernodeRegistryOwnable.d.ts.map +1 -0
  164. package/dist/scripts/upgrade/ciphernodeRegistryOwnable.js +52 -0
  165. package/dist/scripts/upgrade/enclave.d.ts +6 -0
  166. package/dist/scripts/upgrade/enclave.d.ts.map +1 -0
  167. package/dist/scripts/upgrade/enclave.js +49 -0
  168. package/dist/scripts/utils.d.ts +51 -2
  169. package/dist/scripts/utils.d.ts.map +1 -1
  170. package/dist/scripts/utils.js +67 -4
  171. package/dist/scripts/verify.d.ts +6 -0
  172. package/dist/scripts/verify.d.ts.map +1 -0
  173. package/dist/scripts/verify.js +142 -0
  174. package/dist/tasks/ciphernode.d.ts +2 -0
  175. package/dist/tasks/ciphernode.d.ts.map +1 -1
  176. package/dist/tasks/ciphernode.js +290 -19
  177. package/dist/tasks/enclave.d.ts.map +1 -1
  178. package/dist/tasks/enclave.js +76 -31
  179. package/dist/test/Enclave.spec.js +377 -370
  180. package/dist/test/Registry/BondingRegistry.spec.d.ts +2 -0
  181. package/dist/test/Registry/BondingRegistry.spec.d.ts.map +1 -0
  182. package/dist/test/Registry/BondingRegistry.spec.js +684 -0
  183. package/dist/test/Registry/CiphernodeRegistryOwnable.spec.d.ts.map +1 -0
  184. package/dist/test/Registry/CiphernodeRegistryOwnable.spec.js +374 -0
  185. package/dist/test/Slashing/SlashingManager.spec.d.ts +2 -0
  186. package/dist/test/Slashing/SlashingManager.spec.d.ts.map +1 -0
  187. package/dist/test/Slashing/SlashingManager.spec.js +672 -0
  188. package/dist/types/@openzeppelin/contracts/index.d.ts +3 -0
  189. package/dist/types/@openzeppelin/contracts/index.d.ts.map +1 -0
  190. package/dist/types/@openzeppelin/contracts/proxy/index.d.ts +3 -0
  191. package/dist/types/@openzeppelin/contracts/proxy/index.d.ts.map +1 -0
  192. package/dist/types/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.d.ts +97 -0
  193. package/dist/types/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.d.ts.map +1 -0
  194. package/dist/types/{contracts/registry/NaiveRegistryFilter.js → @openzeppelin/contracts/proxy/transparent/ProxyAdmin.js} +0 -4
  195. package/dist/types/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/ITransparentUpgradeableProxy.d.ts +81 -0
  196. package/dist/types/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/ITransparentUpgradeableProxy.d.ts.map +1 -0
  197. package/dist/types/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/ITransparentUpgradeableProxy.js +12 -0
  198. package/dist/types/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.d.ts +52 -0
  199. package/dist/types/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.d.ts.map +1 -0
  200. package/dist/types/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.js +8 -0
  201. package/dist/types/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/index.d.ts +3 -0
  202. package/dist/types/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/index.d.ts.map +1 -0
  203. package/dist/types/@openzeppelin/contracts/proxy/transparent/index.d.ts +4 -0
  204. package/dist/types/@openzeppelin/contracts/proxy/transparent/index.d.ts.map +1 -0
  205. package/dist/types/@openzeppelin/index.d.ts +3 -0
  206. package/dist/types/@openzeppelin/index.d.ts.map +1 -0
  207. package/dist/types/contracts/Enclave.d.ts +126 -53
  208. package/dist/types/contracts/Enclave.d.ts.map +1 -1
  209. package/dist/types/contracts/Enclave.js +12 -0
  210. package/dist/types/contracts/index.d.ts +6 -0
  211. package/dist/types/contracts/index.d.ts.map +1 -1
  212. package/dist/types/contracts/interfaces/IBondingRegistry.d.ts +622 -0
  213. package/dist/types/contracts/interfaces/IBondingRegistry.d.ts.map +1 -0
  214. package/dist/types/contracts/interfaces/IBondingRegistry.js +24 -0
  215. package/dist/types/contracts/interfaces/ICiphernodeRegistry.d.ts +245 -15
  216. package/dist/types/contracts/interfaces/ICiphernodeRegistry.d.ts.map +1 -1
  217. package/dist/types/contracts/interfaces/ICiphernodeRegistry.js +16 -0
  218. package/dist/types/contracts/interfaces/IE3Program.d.ts +20 -10
  219. package/dist/types/contracts/interfaces/IE3Program.d.ts.map +1 -1
  220. package/dist/types/contracts/interfaces/IEnclave.d.ts +149 -20
  221. package/dist/types/contracts/interfaces/IEnclave.d.ts.map +1 -1
  222. package/dist/types/contracts/interfaces/IEnclave.js +12 -0
  223. package/dist/types/contracts/interfaces/{IRegistryFilter.d.ts → ISlashVerifier.d.ts} +16 -16
  224. package/dist/types/contracts/interfaces/ISlashVerifier.d.ts.map +1 -0
  225. package/dist/types/contracts/interfaces/ISlashVerifier.js +1 -0
  226. package/dist/types/contracts/interfaces/ISlashingManager.d.ts +384 -0
  227. package/dist/types/contracts/interfaces/ISlashingManager.d.ts.map +1 -0
  228. package/dist/types/contracts/interfaces/ISlashingManager.js +24 -0
  229. package/dist/types/contracts/interfaces/index.d.ts +3 -2
  230. package/dist/types/contracts/interfaces/index.d.ts.map +1 -1
  231. package/dist/types/contracts/lib/ExitQueueLib.d.ts +73 -0
  232. package/dist/types/contracts/lib/ExitQueueLib.d.ts.map +1 -0
  233. package/dist/types/contracts/lib/ExitQueueLib.js +12 -0
  234. package/dist/types/contracts/lib/index.d.ts +2 -0
  235. package/dist/types/contracts/lib/index.d.ts.map +1 -0
  236. package/dist/types/contracts/lib/index.js +1 -0
  237. package/dist/types/contracts/registry/BondingRegistry.d.ts +821 -0
  238. package/dist/types/contracts/registry/BondingRegistry.d.ts.map +1 -0
  239. package/dist/types/contracts/registry/BondingRegistry.js +44 -0
  240. package/dist/types/contracts/registry/CiphernodeRegistryOwnable.d.ts +194 -34
  241. package/dist/types/contracts/registry/CiphernodeRegistryOwnable.d.ts.map +1 -1
  242. package/dist/types/contracts/registry/CiphernodeRegistryOwnable.js +20 -0
  243. package/dist/types/contracts/registry/index.d.ts +1 -1
  244. package/dist/types/contracts/registry/index.d.ts.map +1 -1
  245. package/dist/types/contracts/slashing/SlashingManager.d.ts +592 -0
  246. package/dist/types/contracts/slashing/SlashingManager.d.ts.map +1 -0
  247. package/dist/types/contracts/slashing/SlashingManager.js +36 -0
  248. package/dist/types/contracts/slashing/index.d.ts +2 -0
  249. package/dist/types/contracts/slashing/index.d.ts.map +1 -0
  250. package/dist/types/contracts/slashing/index.js +1 -0
  251. package/dist/types/contracts/test/MockCiphernodeRegistry.sol/MockCiphernodeRegistry.d.ts +247 -17
  252. package/dist/types/contracts/test/MockCiphernodeRegistry.sol/MockCiphernodeRegistry.d.ts.map +1 -1
  253. package/dist/types/contracts/test/MockCiphernodeRegistry.sol/MockCiphernodeRegistry.js +16 -0
  254. package/dist/types/contracts/test/MockCiphernodeRegistry.sol/MockCiphernodeRegistryEmptyKey.d.ts +247 -17
  255. package/dist/types/contracts/test/MockCiphernodeRegistry.sol/MockCiphernodeRegistryEmptyKey.d.ts.map +1 -1
  256. package/dist/types/contracts/test/MockCiphernodeRegistry.sol/MockCiphernodeRegistryEmptyKey.js +16 -0
  257. package/dist/types/contracts/test/MockE3Program.d.ts +20 -14
  258. package/dist/types/contracts/test/MockE3Program.d.ts.map +1 -1
  259. package/dist/types/contracts/test/{MockInputValidator.d.ts → MockSlashingVerifier.d.ts} +15 -15
  260. package/dist/types/contracts/test/MockSlashingVerifier.d.ts.map +1 -0
  261. package/dist/types/contracts/test/MockSlashingVerifier.js +1 -0
  262. package/dist/types/contracts/test/MockStableToken.sol/MockUSDC.d.ts +227 -0
  263. package/dist/types/contracts/test/MockStableToken.sol/MockUSDC.d.ts.map +1 -0
  264. package/dist/types/contracts/test/MockStableToken.sol/MockUSDC.js +12 -0
  265. package/dist/types/contracts/test/MockStableToken.sol/index.d.ts +2 -0
  266. package/dist/types/contracts/test/MockStableToken.sol/index.d.ts.map +1 -0
  267. package/dist/types/contracts/test/MockStableToken.sol/index.js +1 -0
  268. package/dist/types/contracts/test/index.d.ts +3 -3
  269. package/dist/types/contracts/test/index.d.ts.map +1 -1
  270. package/dist/types/contracts/token/EnclaveTicketToken.d.ts +574 -0
  271. package/dist/types/contracts/token/EnclaveTicketToken.d.ts.map +1 -0
  272. package/dist/types/contracts/token/EnclaveTicketToken.js +24 -0
  273. package/dist/types/contracts/token/EnclaveToken.d.ts +775 -0
  274. package/dist/types/contracts/token/EnclaveToken.d.ts.map +1 -0
  275. package/dist/types/contracts/token/EnclaveToken.js +48 -0
  276. package/dist/types/contracts/token/index.d.ts +3 -0
  277. package/dist/types/contracts/token/index.d.ts.map +1 -0
  278. package/dist/types/contracts/token/index.js +1 -0
  279. package/dist/types/factories/@openzeppelin/contracts/index.d.ts +2 -0
  280. package/dist/types/factories/@openzeppelin/contracts/index.d.ts.map +1 -0
  281. package/dist/types/factories/@openzeppelin/contracts/index.js +4 -0
  282. package/dist/types/factories/@openzeppelin/contracts/proxy/index.d.ts +2 -0
  283. package/dist/types/factories/@openzeppelin/contracts/proxy/index.d.ts.map +1 -0
  284. package/dist/types/factories/@openzeppelin/contracts/proxy/index.js +4 -0
  285. package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/ProxyAdmin__factory.d.ts +118 -0
  286. package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/ProxyAdmin__factory.d.ts.map +1 -0
  287. package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/ProxyAdmin__factory.js +157 -0
  288. package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/ITransparentUpgradeableProxy__factory.d.ts +57 -0
  289. package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/ITransparentUpgradeableProxy__factory.d.ts.map +1 -0
  290. package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/ITransparentUpgradeableProxy__factory.js +78 -0
  291. package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy__factory.d.ts +105 -0
  292. package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy__factory.d.ts.map +1 -0
  293. package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy__factory.js +141 -0
  294. package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/index.d.ts +3 -0
  295. package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/index.d.ts.map +1 -0
  296. package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/index.js +5 -0
  297. package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/index.d.ts +3 -0
  298. package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/index.d.ts.map +1 -0
  299. package/dist/types/factories/@openzeppelin/contracts/proxy/transparent/index.js +5 -0
  300. package/dist/types/factories/@openzeppelin/index.d.ts +2 -0
  301. package/dist/types/factories/@openzeppelin/index.d.ts.map +1 -0
  302. package/dist/types/factories/@openzeppelin/index.js +4 -0
  303. package/dist/types/factories/contracts/Enclave__factory.d.ts +190 -104
  304. package/dist/types/factories/contracts/Enclave__factory.d.ts.map +1 -1
  305. package/dist/types/factories/contracts/Enclave__factory.js +241 -134
  306. package/dist/types/factories/contracts/index.d.ts +3 -0
  307. package/dist/types/factories/contracts/index.d.ts.map +1 -1
  308. package/dist/types/factories/contracts/index.js +3 -0
  309. package/dist/types/factories/contracts/interfaces/IBondingRegistry__factory.d.ts +678 -0
  310. package/dist/types/factories/contracts/interfaces/IBondingRegistry__factory.d.ts.map +1 -0
  311. package/dist/types/factories/contracts/interfaces/IBondingRegistry__factory.js +882 -0
  312. package/dist/types/factories/contracts/interfaces/ICiphernodeRegistry__factory.d.ts +253 -9
  313. package/dist/types/factories/contracts/interfaces/ICiphernodeRegistry__factory.d.ts.map +1 -1
  314. package/dist/types/factories/contracts/interfaces/ICiphernodeRegistry__factory.js +325 -9
  315. package/dist/types/factories/contracts/interfaces/IE3Program__factory.d.ts +16 -2
  316. package/dist/types/factories/contracts/interfaces/IE3Program__factory.d.ts.map +1 -1
  317. package/dist/types/factories/contracts/interfaces/IE3Program__factory.js +20 -2
  318. package/dist/types/factories/contracts/interfaces/IEnclave__factory.d.ts +190 -24
  319. package/dist/types/factories/contracts/interfaces/IEnclave__factory.d.ts.map +1 -1
  320. package/dist/types/factories/contracts/interfaces/IEnclave__factory.js +246 -26
  321. package/dist/types/factories/contracts/interfaces/ISlashVerifier__factory.d.ts +26 -0
  322. package/dist/types/factories/contracts/interfaces/ISlashVerifier__factory.d.ts.map +1 -0
  323. package/dist/types/factories/contracts/interfaces/{IRegistryFilter__factory.js → ISlashVerifier__factory.js} +7 -7
  324. package/dist/types/factories/contracts/interfaces/ISlashingManager__factory.d.ts +594 -0
  325. package/dist/types/factories/contracts/interfaces/ISlashingManager__factory.d.ts.map +1 -0
  326. package/dist/types/factories/contracts/interfaces/ISlashingManager__factory.js +760 -0
  327. package/dist/types/factories/contracts/interfaces/index.d.ts +3 -2
  328. package/dist/types/factories/contracts/interfaces/index.d.ts.map +1 -1
  329. package/dist/types/factories/contracts/interfaces/index.js +3 -2
  330. package/dist/types/factories/contracts/lib/ExitQueueLib__factory.d.ts +107 -0
  331. package/dist/types/factories/contracts/lib/ExitQueueLib__factory.d.ts.map +1 -0
  332. package/dist/types/factories/contracts/lib/ExitQueueLib__factory.js +138 -0
  333. package/dist/types/factories/contracts/lib/index.d.ts +2 -0
  334. package/dist/types/factories/contracts/lib/index.d.ts.map +1 -0
  335. package/dist/types/factories/contracts/lib/index.js +4 -0
  336. package/dist/types/factories/contracts/registry/BondingRegistry__factory.d.ts +958 -0
  337. package/dist/types/factories/contracts/registry/BondingRegistry__factory.d.ts.map +1 -0
  338. package/dist/types/factories/contracts/registry/BondingRegistry__factory.js +1239 -0
  339. package/dist/types/factories/contracts/registry/CiphernodeRegistryOwnable__factory.d.ts +272 -40
  340. package/dist/types/factories/contracts/registry/CiphernodeRegistryOwnable__factory.d.ts.map +1 -1
  341. package/dist/types/factories/contracts/registry/CiphernodeRegistryOwnable__factory.js +343 -49
  342. package/dist/types/factories/contracts/registry/index.d.ts +1 -1
  343. package/dist/types/factories/contracts/registry/index.d.ts.map +1 -1
  344. package/dist/types/factories/contracts/registry/index.js +1 -1
  345. package/dist/types/factories/contracts/slashing/SlashingManager__factory.d.ts +879 -0
  346. package/dist/types/factories/contracts/slashing/SlashingManager__factory.d.ts.map +1 -0
  347. package/dist/types/factories/contracts/slashing/SlashingManager__factory.js +1129 -0
  348. package/dist/types/factories/contracts/slashing/index.d.ts +2 -0
  349. package/dist/types/factories/contracts/slashing/index.d.ts.map +1 -0
  350. package/dist/types/factories/contracts/slashing/index.js +4 -0
  351. package/dist/types/factories/contracts/test/MockCiphernodeRegistry.sol/MockCiphernodeRegistryEmptyKey__factory.d.ts +254 -10
  352. package/dist/types/factories/contracts/test/MockCiphernodeRegistry.sol/MockCiphernodeRegistryEmptyKey__factory.d.ts.map +1 -1
  353. package/dist/types/factories/contracts/test/MockCiphernodeRegistry.sol/MockCiphernodeRegistryEmptyKey__factory.js +326 -10
  354. package/dist/types/factories/contracts/test/MockCiphernodeRegistry.sol/MockCiphernodeRegistry__factory.d.ts +254 -10
  355. package/dist/types/factories/contracts/test/MockCiphernodeRegistry.sol/MockCiphernodeRegistry__factory.d.ts.map +1 -1
  356. package/dist/types/factories/contracts/test/MockCiphernodeRegistry.sol/MockCiphernodeRegistry__factory.js +326 -10
  357. package/dist/types/factories/contracts/test/MockComputeProvider__factory.d.ts +2 -2
  358. package/dist/types/factories/contracts/test/MockComputeProvider__factory.d.ts.map +1 -1
  359. package/dist/types/factories/contracts/test/MockComputeProvider__factory.js +2 -2
  360. package/dist/types/factories/contracts/test/MockDecryptionVerifier__factory.d.ts +1 -1
  361. package/dist/types/factories/contracts/test/MockDecryptionVerifier__factory.d.ts.map +1 -1
  362. package/dist/types/factories/contracts/test/MockDecryptionVerifier__factory.js +1 -1
  363. package/dist/types/factories/contracts/test/MockE3Program__factory.d.ts +23 -27
  364. package/dist/types/factories/contracts/test/MockE3Program__factory.d.ts.map +1 -1
  365. package/dist/types/factories/contracts/test/MockE3Program__factory.js +28 -34
  366. package/dist/types/factories/contracts/test/MockSlashingVerifier__factory.d.ts +43 -0
  367. package/dist/types/factories/contracts/test/MockSlashingVerifier__factory.d.ts.map +1 -0
  368. package/dist/types/factories/contracts/test/MockSlashingVerifier__factory.js +60 -0
  369. package/dist/types/factories/contracts/test/MockStableToken.sol/MockUSDC__factory.d.ts +338 -0
  370. package/dist/types/factories/contracts/test/MockStableToken.sol/MockUSDC__factory.d.ts.map +1 -0
  371. package/dist/types/factories/contracts/test/MockStableToken.sol/MockUSDC__factory.js +447 -0
  372. package/dist/types/factories/contracts/test/MockStableToken.sol/index.d.ts +2 -0
  373. package/dist/types/factories/contracts/test/MockStableToken.sol/index.d.ts.map +1 -0
  374. package/dist/types/factories/contracts/test/MockStableToken.sol/index.js +4 -0
  375. package/dist/types/factories/contracts/test/index.d.ts +2 -2
  376. package/dist/types/factories/contracts/test/index.d.ts.map +1 -1
  377. package/dist/types/factories/contracts/test/index.js +2 -2
  378. package/dist/types/factories/contracts/token/EnclaveTicketToken__factory.d.ts +894 -0
  379. package/dist/types/factories/contracts/token/EnclaveTicketToken__factory.d.ts.map +1 -0
  380. package/dist/types/factories/contracts/token/EnclaveTicketToken__factory.js +1175 -0
  381. package/dist/types/factories/contracts/token/EnclaveToken__factory.d.ts +1101 -0
  382. package/dist/types/factories/contracts/token/EnclaveToken__factory.d.ts.map +1 -0
  383. package/dist/types/factories/contracts/token/EnclaveToken__factory.js +1439 -0
  384. package/dist/types/factories/contracts/token/index.d.ts +3 -0
  385. package/dist/types/factories/contracts/token/index.d.ts.map +1 -0
  386. package/dist/types/factories/contracts/token/index.js +5 -0
  387. package/dist/types/factories/index.d.ts +1 -0
  388. package/dist/types/factories/index.d.ts.map +1 -1
  389. package/dist/types/factories/index.js +1 -0
  390. package/dist/types/factories/poseidon-solidity/PoseidonT3__factory.d.ts +1 -1
  391. package/dist/types/factories/poseidon-solidity/PoseidonT3__factory.d.ts.map +1 -1
  392. package/dist/types/factories/poseidon-solidity/PoseidonT3__factory.js +1 -1
  393. package/dist/types/index.d.ts +28 -12
  394. package/dist/types/index.d.ts.map +1 -1
  395. package/dist/types/index.js +13 -6
  396. package/package.json +30 -21
  397. package/LICENSE.md +0 -165
  398. package/artifacts/build-info/solc-0_8_27-9aea5e3f6e25811e781e96c22e8edaf1eb1a01c5.json +0 -130
  399. package/artifacts/build-info/solc-0_8_27-9aea5e3f6e25811e781e96c22e8edaf1eb1a01c5.output.json +0 -1
  400. package/artifacts/contracts/interfaces/IInputValidator.sol/IInputValidator.json +0 -38
  401. package/artifacts/contracts/interfaces/IInputValidator.sol/artifacts.d.ts +0 -27
  402. package/artifacts/contracts/interfaces/IRegistryFilter.sol/artifacts.d.ts +0 -27
  403. package/artifacts/contracts/registry/NaiveRegistryFilter.sol/NaiveRegistryFilter.json +0 -309
  404. package/artifacts/contracts/registry/NaiveRegistryFilter.sol/artifacts.d.ts +0 -27
  405. package/artifacts/contracts/test/MockInputValidator.sol/MockInputValidator.json +0 -43
  406. package/artifacts/contracts/test/MockInputValidator.sol/artifacts.d.ts +0 -27
  407. package/artifacts/contracts/test/MockRegistryFilter.sol/IRegistry.json +0 -37
  408. package/artifacts/contracts/test/MockRegistryFilter.sol/MockNaiveRegistryFilter.json +0 -262
  409. package/artifacts/contracts/test/MockRegistryFilter.sol/artifacts.d.ts +0 -43
  410. package/contracts/interfaces/IInputValidator.sol +0 -18
  411. package/contracts/interfaces/IRegistryFilter.sol +0 -13
  412. package/contracts/registry/NaiveRegistryFilter.sol +0 -124
  413. package/contracts/test/MockInputValidator.sol +0 -29
  414. package/contracts/test/MockRegistryFilter.sol +0 -117
  415. package/dist/ignition/modules/mockInputValidator.d.ts.map +0 -1
  416. package/dist/ignition/modules/naiveRegistryFilter.d.ts.map +0 -1
  417. package/dist/ignition/modules/naiveRegistryFilter.js +0 -16
  418. package/dist/scripts/deployAndSave/mockInputValidator.d.ts +0 -6
  419. package/dist/scripts/deployAndSave/mockInputValidator.d.ts.map +0 -1
  420. package/dist/scripts/deployAndSave/mockInputValidator.js +0 -18
  421. package/dist/scripts/deployAndSave/naiveRegistryFilter.d.ts +0 -11
  422. package/dist/scripts/deployAndSave/naiveRegistryFilter.d.ts.map +0 -1
  423. package/dist/scripts/deployAndSave/naiveRegistryFilter.js +0 -41
  424. package/dist/test/CiphernodeRegistry/CiphernodeRegistryOwnable.spec.d.ts.map +0 -1
  425. package/dist/test/CiphernodeRegistry/CiphernodeRegistryOwnable.spec.js +0 -279
  426. package/dist/test/CiphernodeRegistry/NaiveRegistryFilter.spec.d.ts +0 -2
  427. package/dist/test/CiphernodeRegistry/NaiveRegistryFilter.spec.d.ts.map +0 -1
  428. package/dist/test/CiphernodeRegistry/NaiveRegistryFilter.spec.js +0 -160
  429. package/dist/types/contracts/interfaces/IInputValidator.d.ts +0 -36
  430. package/dist/types/contracts/interfaces/IInputValidator.d.ts.map +0 -1
  431. package/dist/types/contracts/interfaces/IRegistryFilter.d.ts.map +0 -1
  432. package/dist/types/contracts/registry/NaiveRegistryFilter.d.ts +0 -187
  433. package/dist/types/contracts/registry/NaiveRegistryFilter.d.ts.map +0 -1
  434. package/dist/types/contracts/test/MockInputValidator.d.ts.map +0 -1
  435. package/dist/types/contracts/test/MockRegistryFilter.sol/IRegistry.d.ts +0 -38
  436. package/dist/types/contracts/test/MockRegistryFilter.sol/IRegistry.d.ts.map +0 -1
  437. package/dist/types/contracts/test/MockRegistryFilter.sol/MockNaiveRegistryFilter.d.ts +0 -163
  438. package/dist/types/contracts/test/MockRegistryFilter.sol/MockNaiveRegistryFilter.d.ts.map +0 -1
  439. package/dist/types/contracts/test/MockRegistryFilter.sol/MockNaiveRegistryFilter.js +0 -8
  440. package/dist/types/contracts/test/MockRegistryFilter.sol/index.d.ts +0 -3
  441. package/dist/types/contracts/test/MockRegistryFilter.sol/index.d.ts.map +0 -1
  442. package/dist/types/factories/contracts/interfaces/IInputValidator__factory.d.ts +0 -26
  443. package/dist/types/factories/contracts/interfaces/IInputValidator__factory.d.ts.map +0 -1
  444. package/dist/types/factories/contracts/interfaces/IInputValidator__factory.js +0 -39
  445. package/dist/types/factories/contracts/interfaces/IRegistryFilter__factory.d.ts +0 -26
  446. package/dist/types/factories/contracts/interfaces/IRegistryFilter__factory.d.ts.map +0 -1
  447. package/dist/types/factories/contracts/registry/NaiveRegistryFilter__factory.d.ts +0 -251
  448. package/dist/types/factories/contracts/registry/NaiveRegistryFilter__factory.d.ts.map +0 -1
  449. package/dist/types/factories/contracts/registry/NaiveRegistryFilter__factory.js +0 -331
  450. package/dist/types/factories/contracts/test/MockInputValidator__factory.d.ts +0 -47
  451. package/dist/types/factories/contracts/test/MockInputValidator__factory.d.ts.map +0 -1
  452. package/dist/types/factories/contracts/test/MockInputValidator__factory.js +0 -65
  453. package/dist/types/factories/contracts/test/MockRegistryFilter.sol/IRegistry__factory.d.ts +0 -26
  454. package/dist/types/factories/contracts/test/MockRegistryFilter.sol/IRegistry__factory.d.ts.map +0 -1
  455. package/dist/types/factories/contracts/test/MockRegistryFilter.sol/IRegistry__factory.js +0 -38
  456. package/dist/types/factories/contracts/test/MockRegistryFilter.sol/MockNaiveRegistryFilter__factory.d.ts +0 -216
  457. package/dist/types/factories/contracts/test/MockRegistryFilter.sol/MockNaiveRegistryFilter__factory.d.ts.map +0 -1
  458. package/dist/types/factories/contracts/test/MockRegistryFilter.sol/MockNaiveRegistryFilter__factory.js +0 -284
  459. package/dist/types/factories/contracts/test/MockRegistryFilter.sol/index.d.ts +0 -3
  460. package/dist/types/factories/contracts/test/MockRegistryFilter.sol/index.d.ts.map +0 -1
  461. package/dist/types/factories/contracts/test/MockRegistryFilter.sol/index.js +0 -5
  462. /package/dist/test/{CiphernodeRegistry → Registry}/CiphernodeRegistryOwnable.spec.d.ts +0 -0
  463. /package/dist/types/{contracts/test/MockRegistryFilter.sol → @openzeppelin/contracts}/index.js +0 -0
  464. /package/dist/types/{contracts/interfaces/IInputValidator.js → @openzeppelin/contracts/proxy/index.js} +0 -0
  465. /package/dist/types/{contracts/interfaces/IRegistryFilter.js → @openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol/index.js} +0 -0
  466. /package/dist/types/{contracts/test/MockInputValidator.js → @openzeppelin/contracts/proxy/transparent/index.js} +0 -0
  467. /package/dist/types/{contracts/test/MockRegistryFilter.sol/IRegistry.js → @openzeppelin/index.js} +0 -0
@@ -6,20 +6,24 @@
6
6
  pragma solidity >=0.8.27;
7
7
 
8
8
  import { IEnclave, E3, IE3Program } from "./interfaces/IEnclave.sol";
9
- import { IInputValidator } from "./interfaces/IInputValidator.sol";
10
9
  import { ICiphernodeRegistry } from "./interfaces/ICiphernodeRegistry.sol";
10
+ import { IBondingRegistry } from "./interfaces/IBondingRegistry.sol";
11
11
  import { IDecryptionVerifier } from "./interfaces/IDecryptionVerifier.sol";
12
12
  import {
13
13
  OwnableUpgradeable
14
14
  } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
15
15
  import {
16
- InternalLeanIMT,
17
- LeanIMTData,
18
- PoseidonT3
19
- } from "@zk-kit/lean-imt.sol/InternalLeanIMT.sol";
20
-
16
+ SafeERC20
17
+ } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
18
+ import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
19
+
20
+ /**
21
+ * @title Enclave
22
+ * @notice Main contract for managing Encrypted Execution Environments (E3)
23
+ * @dev Coordinates E3 lifecycle including request, activation, input publishing, and output verification
24
+ */
21
25
  contract Enclave is IEnclave, OwnableUpgradeable {
22
- using InternalLeanIMT for LeanIMTData;
26
+ using SafeERC20 for IERC20;
23
27
 
24
28
  ////////////////////////////////////////////////////////////
25
29
  // //
@@ -27,95 +31,180 @@ contract Enclave is IEnclave, OwnableUpgradeable {
27
31
  // //
28
32
  ////////////////////////////////////////////////////////////
29
33
 
30
- ICiphernodeRegistry public ciphernodeRegistry; // address of the Ciphernode registry.
31
- uint256 public maxDuration; // maximum duration of a computation in seconds.
32
- uint256 public nexte3Id; // ID of the next E3.
34
+ /// @notice Address of the Ciphernode Registry contract.
35
+ /// @dev Manages the pool of ciphernodes and committee selection.
36
+ ICiphernodeRegistry public ciphernodeRegistry;
33
37
 
34
- // Mapping of allowed E3 Programs.
35
- mapping(IE3Program e3Program => bool allowed) public e3Programs;
38
+ /// @notice Address of the Bonding Registry contract.
39
+ /// @dev Handles staking and reward distribution for ciphernodes.
40
+ IBondingRegistry public bondingRegistry;
36
41
 
37
- // Mapping of E3s.
38
- mapping(uint256 e3Id => E3 e3) public e3s;
42
+ /// @notice Address of the ERC20 token used for E3 fees.
43
+ /// @dev All E3 request fees must be paid in this token.
44
+ IERC20 public feeToken;
45
+
46
+ /// @notice Maximum allowed duration for an E3 computation in seconds.
47
+ /// @dev Requests with duration exceeding this value will be rejected.
48
+ uint256 public maxDuration;
49
+
50
+ /// @notice ID counter for the next E3 to be created.
51
+ /// @dev Incremented after each successful E3 request.
52
+ uint256 public nexte3Id;
39
53
 
40
- // Mapping of input merkle trees.
41
- mapping(uint256 e3Id => LeanIMTData imt) public inputs;
54
+ /// @notice Mapping of allowed E3 Programs.
55
+ /// @dev Only enabled E3 Programs can be used in computation requests.
56
+ mapping(IE3Program e3Program => bool allowed) public e3Programs;
42
57
 
43
- // Mapping counting the number of inputs for each E3.
44
- mapping(uint256 e3Id => uint256 inputCount) public inputCounts;
58
+ /// @notice Mapping storing all E3 instances by their ID.
59
+ /// @dev Contains the full state and configuration of each E3.
60
+ mapping(uint256 e3Id => E3 e3) public e3s;
45
61
 
46
- // Mapping of enabled encryption schemes.
62
+ /// @notice Mapping of enabled encryption schemes to their decryption verifiers.
63
+ /// @dev Each encryption scheme ID maps to a contract that can verify decrypted outputs.
47
64
  mapping(bytes32 encryptionSchemeId => IDecryptionVerifier decryptionVerifier)
48
65
  public decryptionVerifiers;
49
66
 
50
- /// Mapping that stores the valid E3 program ABI encoded parameter sets (e.g., BFV).
67
+ /// @notice Mapping storing valid E3 program ABI encoded parameter sets.
68
+ /// @dev Stores allowed encryption scheme parameters (e.g., BFV parameters).
51
69
  mapping(bytes e3ProgramParams => bool allowed) public e3ProgramsParams;
52
70
 
71
+ /// @notice Mapping tracking fee payments for each E3.
72
+ /// @dev Stores the amount paid for an E3, distributed to committee upon completion.
73
+ mapping(uint256 e3Id => uint256 e3Payment) public e3Payments;
74
+
53
75
  ////////////////////////////////////////////////////////////
54
76
  // //
55
77
  // Errors //
56
78
  // //
57
79
  ////////////////////////////////////////////////////////////
58
80
 
81
+ /// @notice Thrown when committee selection fails during E3 request or activation.
59
82
  error CommitteeSelectionFailed();
83
+
84
+ /// @notice Thrown when an E3 request uses a program that is not enabled.
85
+ /// @param e3Program The E3 program address that is not allowed.
60
86
  error E3ProgramNotAllowed(IE3Program e3Program);
87
+
88
+ /// @notice Thrown when attempting to activate an E3 that is already activated.
89
+ /// @param e3Id The ID of the E3 that is already activated.
61
90
  error E3AlreadyActivated(uint256 e3Id);
91
+
92
+ /// @notice Thrown when the E3 start window or computation period has expired.
62
93
  error E3Expired();
94
+
95
+ /// @notice Thrown when attempting operations on an E3 that has not been activated yet.
96
+ /// @param e3Id The ID of the E3 that is not activated.
63
97
  error E3NotActivated(uint256 e3Id);
98
+
99
+ /// @notice Thrown when attempting to activate an E3 before its start window begins.
64
100
  error E3NotReady();
101
+
102
+ /// @notice Thrown when attempting to access an E3 that does not exist.
103
+ /// @param e3Id The ID of the non-existent E3.
65
104
  error E3DoesNotExist(uint256 e3Id);
105
+
106
+ /// @notice Thrown when attempting to enable a module or program that is already enabled.
107
+ /// @param module The address of the module that is already enabled.
66
108
  error ModuleAlreadyEnabled(address module);
109
+
110
+ /// @notice Thrown when attempting to disable a module or program that is not enabled.
111
+ /// @param module The address of the module that is not enabled.
67
112
  error ModuleNotEnabled(address module);
113
+
114
+ /// @notice Thrown when an invalid or disabled encryption scheme is used.
115
+ /// @param encryptionSchemeId The ID of the invalid encryption scheme.
68
116
  error InvalidEncryptionScheme(bytes32 encryptionSchemeId);
117
+
118
+ /// @notice Thrown when attempting to publish input after the computation deadline has passed.
119
+ /// @param e3Id The ID of the E3.
120
+ /// @param expiration The expiration timestamp that has passed.
69
121
  error InputDeadlinePassed(uint256 e3Id, uint256 expiration);
122
+
123
+ /// @notice Thrown when attempting to publish output before the input deadline has passed.
124
+ /// @param e3Id The ID of the E3.
125
+ /// @param expiration The expiration timestamp that has not yet passed.
70
126
  error InputDeadlineNotPassed(uint256 e3Id, uint256 expiration);
71
- error InvalidComputationRequest(IInputValidator inputValidator);
127
+
128
+ /// @notice Thrown when attempting to set an invalid ciphernode registry address.
129
+ /// @param ciphernodeRegistry The invalid ciphernode registry address.
72
130
  error InvalidCiphernodeRegistry(ICiphernodeRegistry ciphernodeRegistry);
131
+
132
+ /// @notice Thrown when the requested duration exceeds maxDuration or is zero.
133
+ /// @param duration The invalid duration value.
73
134
  error InvalidDuration(uint256 duration);
135
+
136
+ /// @notice Thrown when output verification fails.
137
+ /// @param output The invalid output data.
74
138
  error InvalidOutput(bytes output);
139
+
140
+ /// @notice Thrown when input data is invalid.
75
141
  error InvalidInput();
142
+
143
+ /// @notice Thrown when the start window parameters are invalid.
76
144
  error InvalidStartWindow();
145
+
146
+ /// @notice Thrown when the threshold parameters are invalid (e.g., M > N or M = 0).
147
+ /// @param threshold The invalid threshold array [M, N].
77
148
  error InvalidThreshold(uint32[2] threshold);
149
+
150
+ /// @notice Thrown when attempting to publish ciphertext output that has already been published.
151
+ /// @param e3Id The ID of the E3.
78
152
  error CiphertextOutputAlreadyPublished(uint256 e3Id);
153
+
154
+ /// @notice Thrown when attempting to publish plaintext output before ciphertext output.
155
+ /// @param e3Id The ID of the E3.
79
156
  error CiphertextOutputNotPublished(uint256 e3Id);
157
+
158
+ /// @notice Thrown when payment is required but not provided or insufficient.
159
+ /// @param value The required payment amount.
80
160
  error PaymentRequired(uint256 value);
161
+
162
+ /// @notice Thrown when attempting to publish plaintext output that has already been published.
163
+ /// @param e3Id The ID of the E3.
81
164
  error PlaintextOutputAlreadyPublished(uint256 e3Id);
82
165
 
166
+ /// @notice Thrown when attempting to set an invalid bonding registry address.
167
+ /// @param bondingRegistry The invalid bonding registry address.
168
+ error InvalidBondingRegistry(IBondingRegistry bondingRegistry);
169
+
170
+ /// @notice Thrown when attempting to set an invalid fee token address.
171
+ /// @param feeToken The invalid fee token address.
172
+ error InvalidFeeToken(IERC20 feeToken);
173
+
83
174
  ////////////////////////////////////////////////////////////
84
175
  // //
85
176
  // Initialization //
86
177
  // //
87
178
  ////////////////////////////////////////////////////////////
88
179
 
89
- /// @param _owner The owner of this contract
90
- /// @param _maxDuration The maximum duration of a computation in seconds
91
- /// @param _e3ProgramsParams Array of ABI encoded E3 encryption scheme parameters sets (e.g., for BFV)
92
- constructor(
93
- address _owner,
94
- ICiphernodeRegistry _ciphernodeRegistry,
95
- uint256 _maxDuration,
96
- bytes[] memory _e3ProgramsParams
97
- ) {
98
- initialize(
99
- _owner,
100
- _ciphernodeRegistry,
101
- _maxDuration,
102
- _e3ProgramsParams
103
- );
180
+ /// @notice Constructor that disables initializers.
181
+ /// @dev Prevents the implementation contract from being initialized. Initialization is performed
182
+ /// via the initialize() function when deployed behind a proxy.
183
+ constructor() {
184
+ _disableInitializers();
104
185
  }
105
186
 
106
- /// @param _owner The owner of this contract
107
- /// @param _ciphernodeRegistry The address of the ciphernode registry
108
- /// @param _maxDuration The maximum duration of a computation in seconds
109
- /// @param _e3ProgramsParams Array of ABI encoded E3 encryption scheme parameters sets (e.g., for BFV)
187
+ /// @notice Initializes the Enclave contract with initial configuration.
188
+ /// @dev This function can only be called once due to the initializer modifier. Sets up core dependencies.
189
+ /// @param _owner The owner address of this contract.
190
+ /// @param _ciphernodeRegistry The address of the Ciphernode Registry contract.
191
+ /// @param _bondingRegistry The address of the Bonding Registry contract.
192
+ /// @param _feeToken The address of the ERC20 token used for E3 fees.
193
+ /// @param _maxDuration The maximum duration of a computation in seconds.
194
+ /// @param _e3ProgramsParams Array of ABI encoded E3 encryption scheme parameters sets (e.g., for BFV).
110
195
  function initialize(
111
196
  address _owner,
112
197
  ICiphernodeRegistry _ciphernodeRegistry,
198
+ IBondingRegistry _bondingRegistry,
199
+ IERC20 _feeToken,
113
200
  uint256 _maxDuration,
114
201
  bytes[] memory _e3ProgramsParams
115
202
  ) public initializer {
116
203
  __Ownable_init(msg.sender);
117
204
  setMaxDuration(_maxDuration);
118
205
  setCiphernodeRegistry(_ciphernodeRegistry);
206
+ setBondingRegistry(_bondingRegistry);
207
+ setFeeToken(_feeToken);
119
208
  setE3ProgramsParams(_e3ProgramsParams);
120
209
  if (_owner != owner()) transferOwnership(_owner);
121
210
  }
@@ -126,12 +215,11 @@ contract Enclave is IEnclave, OwnableUpgradeable {
126
215
  // //
127
216
  ////////////////////////////////////////////////////////////
128
217
 
218
+ /// @inheritdoc IEnclave
129
219
  function request(
130
220
  E3RequestParams calldata requestParams
131
- ) external payable returns (uint256 e3Id, E3 memory e3) {
132
- // TODO: allow for other payment methods or only native tokens?
133
- // TODO: should payment checks be somewhere else? Perhaps in the E3 Program or ciphernode registry?
134
- require(msg.value > 0, PaymentRequired(msg.value));
221
+ ) external returns (uint256 e3Id, E3 memory e3) {
222
+ uint256 e3Fee = getE3Quote(requestParams);
135
223
  require(
136
224
  requestParams.threshold[1] >= requestParams.threshold[0] &&
137
225
  requestParams.threshold[0] > 0,
@@ -165,19 +253,17 @@ contract Enclave is IEnclave, OwnableUpgradeable {
165
253
  e3.expiration = 0;
166
254
  e3.e3Program = requestParams.e3Program;
167
255
  e3.e3ProgramParams = requestParams.e3ProgramParams;
256
+ e3.customParams = requestParams.customParams;
168
257
  e3.committeePublicKey = hex"";
169
258
  e3.ciphertextOutput = hex"";
170
259
  e3.plaintextOutput = hex"";
171
260
 
172
- (
173
- bytes32 encryptionSchemeId,
174
- IInputValidator inputValidator
175
- ) = requestParams.e3Program.validate(
176
- e3Id,
177
- seed,
178
- requestParams.e3ProgramParams,
179
- requestParams.computeProviderParams
180
- );
261
+ bytes32 encryptionSchemeId = requestParams.e3Program.validate(
262
+ e3Id,
263
+ seed,
264
+ requestParams.e3ProgramParams,
265
+ requestParams.computeProviderParams
266
+ );
181
267
  IDecryptionVerifier decryptionVerifier = decryptionVerifiers[
182
268
  encryptionSchemeId
183
269
  ];
@@ -187,34 +273,28 @@ contract Enclave is IEnclave, OwnableUpgradeable {
187
273
  IDecryptionVerifier(address(0)),
188
274
  InvalidEncryptionScheme(encryptionSchemeId)
189
275
  );
190
- require(
191
- address(inputValidator) != address(0),
192
- InvalidComputationRequest(inputValidator)
193
- );
194
276
 
195
277
  e3.encryptionSchemeId = encryptionSchemeId;
196
- e3.inputValidator = inputValidator;
197
278
  e3.decryptionVerifier = decryptionVerifier;
198
279
 
199
280
  e3s[e3Id] = e3;
281
+ e3Payments[e3Id] = e3Fee;
282
+
283
+ feeToken.safeTransferFrom(msg.sender, address(this), e3Fee);
200
284
 
201
285
  require(
202
286
  ciphernodeRegistry.requestCommittee(
203
287
  e3Id,
204
- requestParams.filter,
288
+ seed,
205
289
  requestParams.threshold
206
290
  ),
207
291
  CommitteeSelectionFailed()
208
292
  );
209
293
 
210
- emit E3Requested(
211
- e3Id,
212
- e3,
213
- requestParams.filter,
214
- requestParams.e3Program
215
- );
294
+ emit E3Requested(e3Id, e3, requestParams.e3Program);
216
295
  }
217
296
 
297
+ /// @inheritdoc IEnclave
218
298
  function activate(
219
299
  uint256 e3Id,
220
300
  bytes calldata publicKey
@@ -240,6 +320,7 @@ contract Enclave is IEnclave, OwnableUpgradeable {
240
320
  return true;
241
321
  }
242
322
 
323
+ /// @inheritdoc IEnclave
243
324
  function publishInput(
244
325
  uint256 e3Id,
245
326
  bytes calldata data
@@ -254,20 +335,12 @@ contract Enclave is IEnclave, OwnableUpgradeable {
254
335
  InputDeadlinePassed(e3Id, e3.expiration)
255
336
  );
256
337
 
257
- uint256 inputIndex = inputCounts[e3Id];
258
- inputCounts[e3Id] = inputIndex + 1;
259
-
260
- bytes memory input = e3.inputValidator.validate(msg.sender, data);
338
+ e3.e3Program.validateInput(e3Id, msg.sender, data);
261
339
 
262
- uint256 inputHash = PoseidonT3.hash(
263
- [uint256(keccak256(input)), inputIndex]
264
- );
265
- inputs[e3Id]._insert(inputHash);
266
340
  success = true;
267
-
268
- emit InputPublished(e3Id, input, inputHash, inputIndex);
269
341
  }
270
342
 
343
+ /// @inheritdoc IEnclave
271
344
  function publishCiphertextOutput(
272
345
  uint256 e3Id,
273
346
  bytes calldata ciphertextOutput,
@@ -297,6 +370,7 @@ contract Enclave is IEnclave, OwnableUpgradeable {
297
370
  emit CiphertextOutputPublished(e3Id, ciphertextOutput);
298
371
  }
299
372
 
373
+ /// @inheritdoc IEnclave
300
374
  function publishPlaintextOutput(
301
375
  uint256 e3Id,
302
376
  bytes calldata plaintextOutput,
@@ -324,15 +398,55 @@ contract Enclave is IEnclave, OwnableUpgradeable {
324
398
  );
325
399
  require(success, InvalidOutput(plaintextOutput));
326
400
 
401
+ _distributeRewards(e3Id);
402
+
327
403
  emit PlaintextOutputPublished(e3Id, plaintextOutput);
328
404
  }
329
405
 
406
+ ////////////////////////////////////////////////////////////
407
+ // //
408
+ // Internal Functions //
409
+ // //
410
+ ////////////////////////////////////////////////////////////
411
+
412
+ /// @notice Distributes rewards to committee members after successful E3 completion.
413
+ /// @dev Divides the E3 payment equally among all committee members and transfers via bonding registry.
414
+ /// @dev Emits RewardsDistributed event upon successful distribution.
415
+ /// @param e3Id The ID of the E3 for which to distribute rewards.
416
+ function _distributeRewards(uint256 e3Id) internal {
417
+ address[] memory committeeNodes = ciphernodeRegistry.getCommitteeNodes(
418
+ e3Id
419
+ );
420
+ uint256 committeeLength = committeeNodes.length;
421
+ uint256[] memory amounts = new uint256[](committeeLength);
422
+
423
+ // TODO: do we need to pay different amounts to different nodes?
424
+ // For now, we'll pay the same amount to all nodes.
425
+ uint256 amount = e3Payments[e3Id] / committeeLength;
426
+ for (uint256 i = 0; i < committeeLength; i++) {
427
+ amounts[i] = amount;
428
+ }
429
+
430
+ uint256 totalAmount = e3Payments[e3Id];
431
+ e3Payments[e3Id] = 0;
432
+
433
+ feeToken.approve(address(bondingRegistry), totalAmount);
434
+
435
+ bondingRegistry.distributeRewards(feeToken, committeeNodes, amounts);
436
+
437
+ // TODO: decide where does dust go? Treasury maybe?
438
+ feeToken.approve(address(bondingRegistry), 0);
439
+
440
+ emit RewardsDistributed(e3Id, committeeNodes, amounts);
441
+ }
442
+
330
443
  ////////////////////////////////////////////////////////////
331
444
  // //
332
445
  // Set Functions //
333
446
  // //
334
447
  ////////////////////////////////////////////////////////////
335
448
 
449
+ /// @inheritdoc IEnclave
336
450
  function setMaxDuration(
337
451
  uint256 _maxDuration
338
452
  ) public onlyOwner returns (bool success) {
@@ -341,6 +455,7 @@ contract Enclave is IEnclave, OwnableUpgradeable {
341
455
  emit MaxDurationSet(_maxDuration);
342
456
  }
343
457
 
458
+ /// @inheritdoc IEnclave
344
459
  function setCiphernodeRegistry(
345
460
  ICiphernodeRegistry _ciphernodeRegistry
346
461
  ) public onlyOwner returns (bool success) {
@@ -354,6 +469,34 @@ contract Enclave is IEnclave, OwnableUpgradeable {
354
469
  emit CiphernodeRegistrySet(address(_ciphernodeRegistry));
355
470
  }
356
471
 
472
+ /// @inheritdoc IEnclave
473
+ function setBondingRegistry(
474
+ IBondingRegistry _bondingRegistry
475
+ ) public onlyOwner returns (bool success) {
476
+ require(
477
+ address(_bondingRegistry) != address(0) &&
478
+ _bondingRegistry != bondingRegistry,
479
+ InvalidBondingRegistry(_bondingRegistry)
480
+ );
481
+ bondingRegistry = _bondingRegistry;
482
+ success = true;
483
+ emit BondingRegistrySet(address(_bondingRegistry));
484
+ }
485
+
486
+ /// @inheritdoc IEnclave
487
+ function setFeeToken(
488
+ IERC20 _feeToken
489
+ ) public onlyOwner returns (bool success) {
490
+ require(
491
+ address(_feeToken) != address(0) && _feeToken != feeToken,
492
+ InvalidFeeToken(_feeToken)
493
+ );
494
+ feeToken = _feeToken;
495
+ success = true;
496
+ emit FeeTokenSet(address(_feeToken));
497
+ }
498
+
499
+ /// @inheritdoc IEnclave
357
500
  function enableE3Program(
358
501
  IE3Program e3Program
359
502
  ) public onlyOwner returns (bool success) {
@@ -366,6 +509,7 @@ contract Enclave is IEnclave, OwnableUpgradeable {
366
509
  emit E3ProgramEnabled(e3Program);
367
510
  }
368
511
 
512
+ /// @inheritdoc IEnclave
369
513
  function disableE3Program(
370
514
  IE3Program e3Program
371
515
  ) public onlyOwner returns (bool success) {
@@ -375,6 +519,7 @@ contract Enclave is IEnclave, OwnableUpgradeable {
375
519
  emit E3ProgramDisabled(e3Program);
376
520
  }
377
521
 
522
+ /// @inheritdoc IEnclave
378
523
  function setDecryptionVerifier(
379
524
  bytes32 encryptionSchemeId,
380
525
  IDecryptionVerifier decryptionVerifier
@@ -389,6 +534,7 @@ contract Enclave is IEnclave, OwnableUpgradeable {
389
534
  emit EncryptionSchemeEnabled(encryptionSchemeId);
390
535
  }
391
536
 
537
+ /// @inheritdoc IEnclave
392
538
  function disableEncryptionScheme(
393
539
  bytes32 encryptionSchemeId
394
540
  ) public onlyOwner returns (bool success) {
@@ -404,6 +550,7 @@ contract Enclave is IEnclave, OwnableUpgradeable {
404
550
  emit EncryptionSchemeDisabled(encryptionSchemeId);
405
551
  }
406
552
 
553
+ /// @inheritdoc IEnclave
407
554
  function setE3ProgramsParams(
408
555
  bytes[] memory _e3ProgramsParams
409
556
  ) public onlyOwner returns (bool success) {
@@ -424,19 +571,21 @@ contract Enclave is IEnclave, OwnableUpgradeable {
424
571
  // //
425
572
  ////////////////////////////////////////////////////////////
426
573
 
574
+ /// @inheritdoc IEnclave
427
575
  function getE3(uint256 e3Id) public view returns (E3 memory e3) {
428
576
  e3 = e3s[e3Id];
429
577
  require(e3.e3Program != IE3Program(address(0)), E3DoesNotExist(e3Id));
430
578
  }
431
579
 
432
- function getInputRoot(uint256 e3Id) public view returns (uint256) {
433
- require(
434
- e3s[e3Id].e3Program != IE3Program(address(0)),
435
- E3DoesNotExist(e3Id)
436
- );
437
- return InternalLeanIMT._root(inputs[e3Id]);
580
+ /// @inheritdoc IEnclave
581
+ function getE3Quote(
582
+ E3RequestParams calldata
583
+ ) public pure returns (uint256 fee) {
584
+ fee = 1 * 10 ** 6;
585
+ require(fee > 0, PaymentRequired(fee));
438
586
  }
439
587
 
588
+ /// @inheritdoc IEnclave
440
589
  function getDecryptionVerifier(
441
590
  bytes32 encryptionSchemeId
442
591
  ) public view returns (IDecryptionVerifier) {