@inco/lightning 0.6.8 → 0.7.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 (87) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +29 -2
  3. package/manifest.yaml +35 -42
  4. package/package.json +5 -2
  5. package/src/CreateXHelper.sol +3 -1
  6. package/src/DeployUtils.sol +36 -71
  7. package/src/Errors.sol +1 -1
  8. package/src/IIncoLightning.sol +2 -0
  9. package/src/IncoLightning.sol +5 -17
  10. package/src/IncoVerifier.sol +12 -18
  11. package/src/Lib.alphanet.sol +1 -1
  12. package/src/Lib.sol +1 -1
  13. package/src/Lib.template.sol +35 -153
  14. package/src/Types.sol +231 -97
  15. package/src/interfaces/IIncoLightning.sol +2 -0
  16. package/src/interfaces/IIncoVerifier.sol +6 -12
  17. package/src/interfaces/automata-interfaces/BELE.sol +2 -0
  18. package/src/interfaces/automata-interfaces/IAutomataEnclaveIdentityDao.sol +9 -11
  19. package/src/interfaces/automata-interfaces/IFmspcTcbDao.sol +3 -3
  20. package/src/interfaces/automata-interfaces/IPCCSRouter.sol +13 -47
  21. package/src/interfaces/automata-interfaces/IPCCSRouterExtended.sol +2 -0
  22. package/src/interfaces/automata-interfaces/IPcsDao.sol +6 -11
  23. package/src/interfaces/automata-interfaces/IQuoteVerifier.sol +4 -7
  24. package/src/interfaces/automata-interfaces/Types.sol +7 -6
  25. package/src/libs/incoLightning_alphanet_v2_976644394.sol +478 -0
  26. package/src/libs/incoLightning_devnet_v1_887305889.sol +5 -3
  27. package/src/libs/incoLightning_testnet_v1_938327937.sol +5 -3
  28. package/src/lightning-parts/AccessControl/AdvancedAccessControl.sol +39 -72
  29. package/src/lightning-parts/AccessControl/BaseAccessControlList.sol +31 -62
  30. package/src/lightning-parts/AccessControl/interfaces/IAdvancedAccessControl.sol +8 -15
  31. package/src/lightning-parts/AccessControl/interfaces/IBaseAccessControlList.sol +5 -12
  32. package/src/lightning-parts/AccessControl/test/TestAdvancedAccessControl.t.sol +44 -84
  33. package/src/lightning-parts/AccessControl/test/TestBaseAccessControl.t.sol +2 -0
  34. package/src/lightning-parts/DecryptionAttester.sol +14 -28
  35. package/src/lightning-parts/EncryptedInput.sol +23 -52
  36. package/src/lightning-parts/EncryptedOperations.sol +96 -438
  37. package/src/lightning-parts/Fee.sol +3 -1
  38. package/src/lightning-parts/TEELifecycle.sol +94 -223
  39. package/src/lightning-parts/TEELifecycle.types.sol +4 -3
  40. package/src/lightning-parts/TrivialEncryption.sol +6 -20
  41. package/src/lightning-parts/interfaces/IDecryptionAttester.sol +7 -2
  42. package/src/lightning-parts/interfaces/IEncryptedInput.sol +5 -12
  43. package/src/lightning-parts/interfaces/IEncryptedOperations.sol +17 -61
  44. package/src/lightning-parts/interfaces/ITEELifecycle.sol +7 -11
  45. package/src/lightning-parts/interfaces/ITrivialEncryption.sol +2 -0
  46. package/src/lightning-parts/primitives/EventCounter.sol +7 -8
  47. package/src/lightning-parts/primitives/HandleGeneration.sol +20 -32
  48. package/src/lightning-parts/primitives/HandleMetadata.sol +7 -17
  49. package/src/lightning-parts/primitives/LightningAddressGetter.sol +3 -0
  50. package/src/lightning-parts/primitives/SignatureVerifier.sol +91 -27
  51. package/src/lightning-parts/primitives/VerifierAddressGetter.sol +3 -0
  52. package/src/lightning-parts/primitives/interfaces/IEventCounter.sol +2 -0
  53. package/src/lightning-parts/primitives/interfaces/IHandleGeneration.sol +10 -2
  54. package/src/lightning-parts/primitives/interfaces/ISignatureVerifier.sol +4 -2
  55. package/src/lightning-parts/primitives/interfaces/IVerifierAddressGetter.sol +2 -0
  56. package/src/lightning-parts/primitives/test/SignatureVerifier.t.sol +838 -0
  57. package/src/lightning-parts/test/Fee.t.sol +6 -6
  58. package/src/lightning-parts/test/HandleMetadata.t.sol +21 -76
  59. package/src/lightning-parts/test/InputsFee.t.sol +7 -28
  60. package/src/lightning-parts/test/TestDecryptionAttestationInSynchronousFlow.t.sol +16 -48
  61. package/src/pasted-dependencies/CreateX.sol +154 -455
  62. package/src/pasted-dependencies/ICreateX.sol +55 -102
  63. package/src/periphery/SessionVerifier.sol +10 -8
  64. package/src/shared/IOwnable.sol +3 -0
  65. package/src/shared/IUUPSUpgradable.sol +5 -1
  66. package/src/shared/JsonUtils.sol +3 -5
  67. package/src/shared/TestUtils.sol +15 -13
  68. package/src/test/AddTwo.sol +9 -7
  69. package/src/test/FakeIncoInfra/FakeComputeServer.sol +11 -53
  70. package/src/test/FakeIncoInfra/FakeDecryptionAttester.sol +35 -119
  71. package/src/test/FakeIncoInfra/FakeIncoInfraBase.sol +31 -48
  72. package/src/test/FakeIncoInfra/FakeQuoteVerifier.sol +4 -7
  73. package/src/test/FakeIncoInfra/KVStore.sol +2 -0
  74. package/src/test/FakeIncoInfra/MockOpHandler.sol +9 -31
  75. package/src/test/FakeIncoInfra/MockRemoteAttestation.sol +50 -21
  76. package/src/test/IncoTest.sol +22 -9
  77. package/src/test/OpsTest.sol +438 -0
  78. package/src/test/TEELifecycle/TEELifecycleMockTest.t.sol +57 -104
  79. package/src/test/TestAddTwo.t.sol +4 -3
  80. package/src/test/TestDeploy.t.sol +5 -6
  81. package/src/test/TestExtractDataOfEventTooLarge.t.sol +7 -9
  82. package/src/test/TestFakeInfra.t.sol +15 -38
  83. package/src/test/TestUpgrade.t.sol +40 -135
  84. package/src/test/TestVersion.t.sol +6 -5
  85. package/src/version/IncoLightningConfig.sol +2 -2
  86. package/src/version/Version.sol +46 -48
  87. package/src/version/interfaces/IVersion.sol +6 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.0
4
+
5
+ - Add DecryptionAttester to IncoVerifier
6
+ - Merge EOA signers from SignatureVerifier and TEELifecycle
7
+ - IncoLightning to allow multiple signers + threshold
8
+
3
9
  ## 1.0.2
4
10
 
5
11
  - Inco Fees on:
package/README.md CHANGED
@@ -1,16 +1,43 @@
1
1
  # Inco lite
2
2
 
3
+ ![coverage](./coverage.svg)
4
+
3
5
  <!-- todo #1035 upgrade deployment and upgrade documentation now outdated @silasdavis -->
4
6
 
5
7
  ## Install dependencies
6
8
 
7
- `bun install`
9
+ ```sh
10
+ bun install
11
+ ```
8
12
 
9
13
  ## Build
10
14
 
11
15
  Use [forge](https://book.getfoundry.sh/getting-started/installation) version 1.0 or higher
12
16
 
13
- `forge build`
17
+ ```sh
18
+ forge build
19
+ ```
20
+
21
+ ## Test
22
+
23
+ To run all the unit tests:
24
+
25
+ ```sh
26
+ forge test
27
+ ```
28
+
29
+ ### Coverage
30
+
31
+ To run test coverage:
32
+
33
+ ```sh
34
+ make coverage
35
+ ```
36
+
37
+ > This generates an lcov report, filters out `node_modules`, autogenerated contracts and other contracts that we don't want to include in the report (`Lib.XXXnet.sol`, etc.). Eventually, it `genhtml` the filtered lcov in `coverage` and a `lcov-badge` visible in this readme. You can check the latest coverage stats [here](./coverage/index.html).
38
+
39
+ > Note: You need `lcov` for the `make coverage` to work
40
+ > For MacOS - `brew install lcov`
14
41
 
15
42
  ## Deploy
16
43
 
package/manifest.yaml CHANGED
@@ -1,3 +1,25 @@
1
+ incoLightning_alphanet_v2_976644394:
2
+ executor:
3
+ name: incoLightning_alphanet_v2_976644394
4
+ majorVersion: 2
5
+ deployer: "0x8202D2D747784Cb7D48868E44C42C4bf162a70BC"
6
+ pepper: alphanet
7
+ executorAddress: "0xc0d693DeEF0A91CE39208676b6da09B822abd199"
8
+ salt: "0x8202d2d747784cb7d48868e44c42c4bf162a70bc000822f11f6e30f933e76d2a"
9
+ deployments:
10
+ - name: incoLightningPreview_2_0_0__976644394
11
+ chainId: "84532"
12
+ chainName: Base Sepolia
13
+ version:
14
+ major: 2
15
+ minor: 0
16
+ patch: 0
17
+ shortSalt: "976644394"
18
+ blockNumber: "34459258"
19
+ deployDate: 2025-12-02T14:46:46.026Z
20
+ commit: v0.6.9-17-g217794f3-dirty
21
+ active: true
22
+ includesPreviewFeatures: true
1
23
  incoLightning_alphanet_v1_725458969:
2
24
  executor:
3
25
  name: incoLightning_alphanet_v1_725458969
@@ -7,6 +29,19 @@ incoLightning_alphanet_v1_725458969:
7
29
  executorAddress: "0x28676Cd3b10b03b2FDF105Ba280425b45a674F2A"
8
30
  salt: "0x8202d2d747784cb7d48868e44c42c4bf162a70bc004dfbe338c6966a22bcca19"
9
31
  deployments:
32
+ - name: incoLightningPreview_1_1_0__725458969
33
+ chainId: "84532"
34
+ chainName: Base Sepolia
35
+ version:
36
+ major: 1
37
+ minor: 1
38
+ patch: 0
39
+ shortSalt: "725458969"
40
+ blockNumber: "34456535"
41
+ deployDate: 2025-12-02T13:16:00.594Z
42
+ commit: v0.6.9-16-g428d1837-dirty
43
+ active: true
44
+ includesPreviewFeatures: true
10
45
  - name: incoLightningPreview_1_0_2__725458969
11
46
  chainId: "84532"
12
47
  chainName: Base Sepolia
@@ -15,8 +50,6 @@ incoLightning_alphanet_v1_725458969:
15
50
  minor: 0
16
51
  patch: 2
17
52
  shortSalt: "725458969"
18
- decryptSigner: "0x4736F8CE685760017eEc130AC3FFc6187f5A1F95"
19
- eciesPublicKey: "0x038a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b84095b1"
20
53
  blockNumber: "32124925"
21
54
  deployDate: 2025-10-09T13:55:42.997Z
22
55
  commit: v0.5.3-10-ga4f2312d
@@ -38,8 +71,6 @@ incoLightning_devnet_v1_904635675:
38
71
  minor: 0
39
72
  patch: 2
40
73
  shortSalt: "904635675"
41
- decryptSigner: "0x138AcbDC1FA02b955949d8Da09E546Ea7748710f"
42
- eciesPublicKey: "0x038a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b84095b1"
43
74
  blockNumber: "3696905"
44
75
  deployDate: 2025-10-03T13:24:44.682Z
45
76
  commit: v0.5.3-6-g8db0f27f-dirty
@@ -52,8 +83,6 @@ incoLightning_devnet_v1_904635675:
52
83
  minor: 0
53
84
  patch: 0
54
85
  shortSalt: "904635675"
55
- decryptSigner: "0x138AcbDC1FA02b955949d8Da09E546Ea7748710f"
56
- eciesPublicKey: "0x038a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b84095b1"
57
86
  blockNumber: "3344310"
58
87
  deployDate: 2025-09-29T11:14:02.599Z
59
88
  commit: v0.5.1-5-g4135c790-dirty
@@ -75,9 +104,6 @@ incoLightning_testnet_v0_183408998:
75
104
  minor: 2
76
105
  patch: 0
77
106
  shortSalt: "183408998"
78
- decryptSigner: "0xA8822DE8910f66D3d03F1eAfe2C0141dBc327Ee0"
79
- eciesPublicKey: "0x048a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b8\
80
- 4095b1e647a9e377175fcb66bda05087c93b05e1fd53a704d0914bb23a0b2a69e9f235"
81
107
  blockNumber: "26296576"
82
108
  deployDate: 2025-05-27T15:57:24.175Z
83
109
  commit: v5-3-gec8b6aae-dirty
@@ -90,9 +116,6 @@ incoLightning_testnet_v0_183408998:
90
116
  minor: 1
91
117
  patch: 29
92
118
  shortSalt: "183408998"
93
- decryptSigner: "0xA8822DE8910f66D3d03F1eAfe2C0141dBc327Ee0"
94
- eciesPublicKey: "0x048a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b8\
95
- 4095b1e647a9e377175fcb66bda05087c93b05e1fd53a704d0914bb23a0b2a69e9f235"
96
119
  blockNumber: "13464615"
97
120
  deployDate: 2025-04-22T16:01:14.380Z
98
121
  commit: v3-28-g93c05a49-dirty
@@ -105,9 +128,6 @@ incoLightning_testnet_v0_183408998:
105
128
  minor: 1
106
129
  patch: 29
107
130
  shortSalt: "183408998"
108
- decryptSigner: "0xA8822DE8910f66D3d03F1eAfe2C0141dBc327Ee0"
109
- eciesPublicKey: "0x048a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b8\
110
- 4095b1e647a9e377175fcb66bda05087c93b05e1fd53a704d0914bb23a0b2a69e9f235"
111
131
  blockNumber: "24784654"
112
132
  deployDate: 2025-04-22T16:00:02.028Z
113
133
  commit: v3-28-g93c05a49-dirty
@@ -129,9 +149,6 @@ incoLightning_demonet_v0_863421733:
129
149
  minor: 2
130
150
  patch: 0
131
151
  shortSalt: "863421733"
132
- decryptSigner: "0xA8822DE8910f66D3d03F1eAfe2C0141dBc327Ee0"
133
- eciesPublicKey: "0x048a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b8\
134
- 4095b1e647a9e377175fcb66bda05087c93b05e1fd53a704d0914bb23a0b2a69e9f235"
135
152
  blockNumber: "25737175"
136
153
  deployDate: 2025-05-14T17:10:44.285Z
137
154
  commit: v4-11-g4a1f413a-dirty
@@ -144,9 +161,6 @@ incoLightning_demonet_v0_863421733:
144
161
  minor: 1
145
162
  patch: 29
146
163
  shortSalt: "863421733"
147
- decryptSigner: "0xA8822DE8910f66D3d03F1eAfe2C0141dBc327Ee0"
148
- eciesPublicKey: "0x048a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b8\
149
- 4095b1e647a9e377175fcb66bda05087c93b05e1fd53a704d0914bb23a0b2a69e9f235"
150
164
  blockNumber: "25719113"
151
165
  deployDate: 2025-05-14T07:08:39.059Z
152
166
  commit: v4
@@ -168,9 +182,6 @@ incoLightning_alphanet_v0_297966649:
168
182
  minor: 2
169
183
  patch: 1
170
184
  shortSalt: "297966649"
171
- decryptSigner: "0x4736F8CE685760017eEc130AC3FFc6187f5A1F95"
172
- eciesPublicKey: "0x048a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b8\
173
- 4095b1e647a9e377175fcb66bda05087c93b05e1fd53a704d0914bb23a0b2a69e9f235"
174
185
  blockNumber: "27543410"
175
186
  deployDate: 2025-06-25T12:38:32.856Z
176
187
  commit: v5-17-ga03e4b32-dirty
@@ -183,9 +194,6 @@ incoLightning_alphanet_v0_297966649:
183
194
  minor: 2
184
195
  patch: 0
185
196
  shortSalt: "297966649"
186
- decryptSigner: "0x4736F8CE685760017eEc130AC3FFc6187f5A1F95"
187
- eciesPublicKey: "0x048a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b8\
188
- 4095b1e647a9e377175fcb66bda05087c93b05e1fd53a704d0914bb23a0b2a69e9f235"
189
197
  blockNumber: "26894782"
190
198
  deployDate: 2025-06-10T12:17:35.790Z
191
199
  commit: v5-13-gd6b19c10-dirty
@@ -207,8 +215,6 @@ incoLightning_devnet_v0_340846814:
207
215
  minor: 2
208
216
  patch: 1
209
217
  shortSalt: "340846814"
210
- decryptSigner: "0x138AcbDC1FA02b955949d8Da09E546Ea7748710f"
211
- eciesPublicKey: "0x038a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b84095b1"
212
218
  blockNumber: "1718868"
213
219
  deployDate: 2025-09-10T15:20:25.654Z
214
220
  commit: v6-7-gf96f358e-dirty
@@ -221,8 +227,6 @@ incoLightning_devnet_v0_340846814:
221
227
  minor: 2
222
228
  patch: 1
223
229
  shortSalt: "340846814"
224
- decryptSigner: "0x138AcbDC1FA02b955949d8Da09E546Ea7748710f"
225
- eciesPublicKey: "0x038a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b84095b1"
226
230
  blockNumber: "1717229"
227
231
  deployDate: 2025-09-10T14:53:07.218Z
228
232
  commit: v6-7-gf96f358e-dirty
@@ -235,8 +239,6 @@ incoLightning_devnet_v0_340846814:
235
239
  minor: 2
236
240
  patch: 1
237
241
  shortSalt: "340846814"
238
- decryptSigner: "0x138AcbDC1FA02b955949d8Da09E546Ea7748710f"
239
- eciesPublicKey: "0x038a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b84095b1"
240
242
  blockNumber: "17365942"
241
243
  deployDate: 2025-08-15T17:35:15.208Z
242
244
  commit: v0.2.17-35-g8cca6b4e-dirty
@@ -249,9 +251,6 @@ incoLightning_devnet_v0_340846814:
249
251
  minor: 2
250
252
  patch: 0
251
253
  shortSalt: "340846814"
252
- decryptSigner: "0x138AcbDC1FA02b955949d8Da09E546Ea7748710f"
253
- eciesPublicKey: "0x048a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b8\
254
- 4095b1e647a9e377175fcb66bda05087c93b05e1fd53a704d0914bb23a0b2a69e9f235"
255
254
  blockNumber: "26122863"
256
255
  deployDate: 2025-05-23T15:26:57.031Z
257
256
  commit: v5-2-g8957c16b-dirty
@@ -264,9 +263,6 @@ incoLightning_devnet_v0_340846814:
264
263
  minor: 1
265
264
  patch: 29
266
265
  shortSalt: "340846814"
267
- decryptSigner: "0xA8822DE8910f66D3d03F1eAfe2C0141dBc327Ee0"
268
- eciesPublicKey: "0x048a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b8\
269
- 4095b1e647a9e377175fcb66bda05087c93b05e1fd53a704d0914bb23a0b2a69e9f235"
270
266
  blockNumber: "13464197"
271
267
  deployDate: 2025-04-22T15:57:26.862Z
272
268
  commit: v3-28-g93c05a49-dirty
@@ -279,9 +275,6 @@ incoLightning_devnet_v0_340846814:
279
275
  minor: 1
280
276
  patch: 29
281
277
  shortSalt: "340846814"
282
- decryptSigner: "0xA8822DE8910f66D3d03F1eAfe2C0141dBc327Ee0"
283
- eciesPublicKey: "0x048a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b8\
284
- 4095b1e647a9e377175fcb66bda05087c93b05e1fd53a704d0914bb23a0b2a69e9f235"
285
278
  blockNumber: "24784527"
286
279
  deployDate: 2025-04-22T15:55:47.828Z
287
280
  commit: v3-28-g93c05a49-dirty
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inco/lightning",
3
- "version": "0.6.8",
3
+ "version": "0.7.0",
4
4
  "repository": "https://github.com/Inco-fhevm/inco-monorepo",
5
5
  "files": [
6
6
  "src/",
@@ -9,6 +9,8 @@
9
9
  "manifest.yaml"
10
10
  ],
11
11
  "scripts": {
12
+ "lint": "forge lint && forge fmt --check",
13
+ "lint:fix": "forge fmt",
12
14
  "generate": "bun run generate:libraries",
13
15
  "generate:libraries": "bun run ../pega/lib/deployment/cmd/generate-libraries.ts",
14
16
  "publish:github": "bun publish --registry=https://npm.pkg.github.com",
@@ -24,7 +26,8 @@
24
26
  "tsx": "^4.19.3"
25
27
  },
26
28
  "devDependencies": {
27
- "@types/bun": "latest"
29
+ "@types/bun": "latest",
30
+ "lcov-badge2": "^1.1.2"
28
31
  },
29
32
  "publishConfig": {
30
33
  "registry": "https://npm.pkg.github.com"
@@ -6,9 +6,11 @@ import {CreateX} from "./pasted-dependencies/CreateX.sol";
6
6
  // See: https://github.com/pcaversaccio/createx/issues/140 apparently this is as good as it gets if you fully compute
7
7
  // the address from a salt since the internal _guard function is an essential part of the derivation
8
8
  contract CreateXHelper is CreateX {
9
+
9
10
  address internal constant _CREATEX = 0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed;
10
11
 
11
12
  function computeCreate3DeployAddress(bytes32 salt) public view returns (address computedAddress) {
12
- return CreateX(_CREATEX).computeCreate3Address({salt: _guard(salt) });
13
+ return CreateX(_CREATEX).computeCreate3Address({salt: _guard(salt)});
13
14
  }
15
+
14
16
  }
@@ -4,18 +4,9 @@ pragma solidity ^0.8;
4
4
  import {IncoLightning} from "./IncoLightning.sol";
5
5
  import {Script} from "forge-std/Script.sol";
6
6
  import {IIncoLightning} from "./interfaces/IIncoLightning.sol";
7
- import {Vm} from "forge-std/Vm.sol";
8
- import {
9
- CreateX,
10
- createXAddress,
11
- createXDeployer
12
- } from "./pasted-dependencies/CreateX.sol";
7
+ import {CreateX, CREATE_X_ADDRESS, CREATE_X_DEPLOYER} from "./pasted-dependencies/CreateX.sol";
13
8
  import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
14
- import {
15
- CONTRACT_NAME,
16
- MAJOR_VERSION,
17
- VERIFIER_NAME
18
- } from "./version/IncoLightningConfig.sol";
9
+ import {CONTRACT_NAME, MAJOR_VERSION, VERIFIER_NAME} from "./version/IncoLightningConfig.sol";
19
10
  import {IncoVerifier} from "./IncoVerifier.sol";
20
11
  import {IIncoVerifier} from "./interfaces/IIncoVerifier.sol";
21
12
  import {console} from "forge-std/console.sol";
@@ -24,44 +15,39 @@ import {IQuoteVerifier} from "./interfaces/automata-interfaces/IQuoteVerifier.so
24
15
 
25
16
  // can be set to 0x01 so the inco address can exist on only one chain, we want the same contract at the same address
26
17
  // on all chains
27
- bytes1 constant crossChainDeployAuthorizedFlag = 0x00;
18
+ bytes1 constant CROSS_CHAIN_DEPLOY_AUTHORIZED_FLAG = 0x00;
28
19
 
29
20
  // GLOSSARY
30
21
  // Pepper: a deployment-time string mixed into the salt hash function, used to avoid address collision on deploying
31
22
  // the same contract twice with the same deployer address, name and version
32
23
  // Salt: a hash of the contract name, version, deployer address, and pepper.
33
24
  // in the context of deployment using create3 with createX, the salt determines the address of the contract, and
34
- // using the crossChainDeployAuthorizedFlag, it prevents the contract from being deployed by someone other than
25
+ // using the CROSS_CHAIN_DEPLOY_AUTHORIZED_FLAG, it prevents the contract from being deployed by someone other than
35
26
  // the deployer at the expected address
36
27
 
37
28
  /// @dev not a script in itself, use this contract in tests or scripts to get new instances of IncoLightning
38
29
  contract DeployUtils is Script {
30
+
39
31
  /// @dev CreateX is deployed on most chains, use this method for the testing environment
40
32
  function deployCreateX() public returns (CreateX createX) {
41
- vm.prank(createXDeployer);
33
+ vm.prank(CREATE_X_DEPLOYER);
42
34
  createX = new CreateX();
43
- require(createXAddress == address(createX));
35
+ require(CREATE_X_ADDRESS == address(createX));
44
36
  return createX;
45
37
  }
46
38
 
47
- function getSalt(
48
- string memory name,
49
- uint8 majorVersionNumber,
50
- address deployer,
51
- string memory pepper
52
- ) internal pure returns (bytes32) {
53
- return
54
- bytes32(
55
- abi.encodePacked(
56
- deployer,
57
- crossChainDeployAuthorizedFlag,
58
- bytes11(
59
- keccak256(
60
- abi.encodePacked(name, majorVersionNumber, pepper)
61
- )
62
- )
63
- )
64
- );
39
+ function getSalt(string memory name, uint8 majorVersionNumber, address deployer, string memory pepper)
40
+ internal
41
+ pure
42
+ returns (bytes32)
43
+ {
44
+ return bytes32(
45
+ abi.encodePacked(
46
+ deployer,
47
+ CROSS_CHAIN_DEPLOY_AUTHORIZED_FLAG,
48
+ bytes11(keccak256(abi.encodePacked(name, majorVersionNumber, pepper)))
49
+ )
50
+ );
65
51
  }
66
52
 
67
53
  /// @notice Computes the address of the contract using CreateX based on the deployer and pepper
@@ -77,25 +63,13 @@ contract DeployUtils is Script {
77
63
  /// @param deployer MUST be the signer of the transaction
78
64
  /// @param pepper a value used to avoid address collision on deploying the same contract twice with the same deployer
79
65
  /// @param quoteVerifier the address of the QuoteVerifier contract to use in the contract
80
- function deployIncoLightningUsingConfig(
81
- address deployer,
82
- string memory pepper,
83
- IQuoteVerifier quoteVerifier
84
- )
66
+ function deployIncoLightningUsingConfig(address deployer, string memory pepper, IQuoteVerifier quoteVerifier)
85
67
  internal
86
68
  returns (IIncoLightning lightningProxy, IIncoVerifier verifierProxy)
87
69
  {
88
- (bytes32 lightningSalt, bytes32 verifierSalt) = getIncoSalts(
89
- deployer,
90
- pepper
91
- );
70
+ (bytes32 lightningSalt, bytes32 verifierSalt) = getIncoSalts(deployer, pepper);
92
71
  lightningProxy = deployLightning(lightningSalt, verifierSalt, deployer);
93
- verifierProxy = deployVerifier(
94
- verifierSalt,
95
- lightningProxy,
96
- deployer,
97
- quoteVerifier
98
- );
72
+ verifierProxy = deployVerifier(verifierSalt, lightningProxy, deployer, quoteVerifier);
99
73
  console.log(
100
74
  "Deploying Inco with executor: %s, deployerAddress: %s, lightning salt: %s",
101
75
  vm.toString(address(lightningProxy)),
@@ -104,10 +78,11 @@ contract DeployUtils is Script {
104
78
  );
105
79
  }
106
80
 
107
- function getIncoSalts(
108
- address deployer,
109
- string memory pepper
110
- ) internal pure returns (bytes32 lightningSalt, bytes32 verifierSalt) {
81
+ function getIncoSalts(address deployer, string memory pepper)
82
+ internal
83
+ pure
84
+ returns (bytes32 lightningSalt, bytes32 verifierSalt)
85
+ {
111
86
  lightningSalt = getSalt(CONTRACT_NAME, MAJOR_VERSION, deployer, pepper);
112
87
  verifierSalt = getSalt(VERIFIER_NAME, MAJOR_VERSION, deployer, pepper);
113
88
  }
@@ -116,16 +91,12 @@ contract DeployUtils is Script {
116
91
  /// @param lightningSalt The salt value that will be passed to CreateX
117
92
  /// @param verifierSalt The salt value that will be passed to CreateX
118
93
  /// @param deployer The address of the deployer
119
- function deployLightning(
120
- bytes32 lightningSalt,
121
- bytes32 verifierSalt,
122
- address deployer
123
- ) internal returns (IIncoLightning lightningProxy) {
94
+ function deployLightning(bytes32 lightningSalt, bytes32 verifierSalt, address deployer)
95
+ internal
96
+ returns (IIncoLightning lightningProxy)
97
+ {
124
98
  address verifierAddress = computeAddressFromSalt(verifierSalt);
125
- IncoLightning lightningImplem = new IncoLightning(
126
- lightningSalt,
127
- IIncoVerifier(verifierAddress)
128
- );
99
+ IncoLightning lightningImplem = new IncoLightning(lightningSalt, IIncoVerifier(verifierAddress));
129
100
  lightningProxy = IIncoLightning(
130
101
  deployProxy({
131
102
  salt: lightningSalt,
@@ -169,17 +140,11 @@ contract DeployUtils is Script {
169
140
  /// @notice deploys a ERC1967Proxy contract using CreateX (create3 pattern), gives the deployer the ownership of
170
141
  /// the proxy
171
142
  /// @dev deployer is made the owner of the contract
172
- function deployProxy(
173
- bytes32 salt,
174
- address implem,
175
- bytes memory initCall
176
- ) internal returns (address proxy) {
177
- CreateX createX = CreateX(createXAddress);
178
- bytes memory bytecode = abi.encodePacked(
179
- type(ERC1967Proxy).creationCode,
180
- abi.encode(implem, initCall)
181
- );
143
+ function deployProxy(bytes32 salt, address implem, bytes memory initCall) internal returns (address proxy) {
144
+ CreateX createX = CreateX(CREATE_X_ADDRESS);
145
+ bytes memory bytecode = abi.encodePacked(type(ERC1967Proxy).creationCode, abi.encode(implem, initCall));
182
146
  // todo: check if we don't have a double delegatecall cost issue
183
147
  proxy = createX.deployCreate3(salt, bytecode);
184
148
  }
149
+
185
150
  }
package/src/Errors.sol CHANGED
@@ -1,4 +1,4 @@
1
1
  // SPDX-License-Identifier: No License
2
2
  pragma solidity ^0.8;
3
3
 
4
- error HandleAlreadyExists(bytes32 handle);
4
+ error HandleAlreadyExists(bytes32 handle);
@@ -16,5 +16,7 @@ interface IIncoLightning is
16
16
  IHandleGeneration,
17
17
  IVersion
18
18
  {
19
+
19
20
  function initialize(address owner) external;
21
+
20
22
  }
@@ -2,12 +2,7 @@
2
2
  pragma solidity ^0.8;
3
3
 
4
4
  import {IIncoLightning} from "./interfaces/IIncoLightning.sol";
5
- import {
6
- CONTRACT_NAME,
7
- MAJOR_VERSION,
8
- MINOR_VERSION,
9
- PATCH_VERSION
10
- } from "./version/IncoLightningConfig.sol";
5
+ import {CONTRACT_NAME, MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION} from "./version/IncoLightningConfig.sol";
11
6
  import {EncryptedInput} from "./lightning-parts/EncryptedInput.sol";
12
7
  import {EncryptedOperations} from "./lightning-parts/EncryptedOperations.sol";
13
8
  import {TrivialEncryption} from "./lightning-parts/TrivialEncryption.sol";
@@ -31,18 +26,10 @@ contract IncoLightning is
31
26
  OwnableUpgradeable,
32
27
  Version
33
28
  {
29
+
34
30
  // salt embeds the deployer address, the contract name, the version and the pepper
35
- constructor(
36
- bytes32 salt,
37
- IIncoVerifier _incoVerifier
38
- )
39
- Version(
40
- MAJOR_VERSION,
41
- MINOR_VERSION,
42
- PATCH_VERSION,
43
- salt,
44
- CONTRACT_NAME
45
- )
31
+ constructor(bytes32 salt, IIncoVerifier _incoVerifier)
32
+ Version(MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION, salt, CONTRACT_NAME)
46
33
  VerifierAddressGetter(address(_incoVerifier))
47
34
  {}
48
35
 
@@ -55,4 +42,5 @@ contract IncoLightning is
55
42
  }
56
43
 
57
44
  fallback() external {} // must be included for createX deploy
45
+
58
46
  }
@@ -9,39 +9,33 @@ import {TEELifecycle} from "./lightning-parts/TEELifecycle.sol";
9
9
  import {IIncoVerifier} from "./interfaces/IIncoVerifier.sol";
10
10
  import {LightningAddressGetter} from "./lightning-parts/primitives/LightningAddressGetter.sol";
11
11
 
12
- /// @dev implicitely extends OwnableUpgradeable, EIP712Upgradeable, SignatureVerifier, LightningAddressGetter
12
+ /// @dev implicitly extends OwnableUpgradeable, EIP712Upgradeable, SignatureVerifier, LightningAddressGetter
13
13
  /// @dev NEVER deploy this contract on its own, always deploy as a joint process with IncoLightning
14
- contract IncoVerifier is
15
- IIncoVerifier,
16
- AdvancedAccessControl,
17
- DecryptionAttester,
18
- TEELifecycle,
19
- UUPSUpgradeable
20
- {
21
- constructor(
22
- address _incoLightningAddress
23
- ) LightningAddressGetter(_incoLightningAddress) {}
14
+ contract IncoVerifier is IIncoVerifier, AdvancedAccessControl, DecryptionAttester, TEELifecycle, UUPSUpgradeable {
15
+
16
+ constructor(address _incoLightningAddress) LightningAddressGetter(_incoLightningAddress) {}
24
17
 
25
18
  function _authorizeUpgrade(address) internal view override {
26
19
  require(msg.sender == owner());
27
20
  }
28
21
 
29
- function initialize(
30
- address owner,
31
- string memory name,
32
- string memory version,
33
- IQuoteVerifier quoteVerifier
34
- ) public initializer {
22
+ function initialize(address owner, string memory name, string memory version, IQuoteVerifier quoteVerifier)
23
+ public
24
+ initializer
25
+ {
35
26
  __Ownable_init(owner);
36
27
  __EIP712_init(name, version);
37
- __TEELifecycle_init(quoteVerifier);
28
+ __TeeLifecycle_init(quoteVerifier);
38
29
  }
39
30
 
31
+ // forge-lint: disable-next-line(mixed-case-function)
40
32
  function getEIP712Name() external view returns (string memory) {
41
33
  return _EIP712Name();
42
34
  }
43
35
 
36
+ // forge-lint: disable-next-line(mixed-case-function)
44
37
  function getEIP712Version() external view returns (string memory) {
45
38
  return _EIP712Version();
46
39
  }
40
+
47
41
  }
@@ -8,7 +8,7 @@ pragma solidity ^0.8;
8
8
  import { IncoLightning } from "./IncoLightning.sol";
9
9
  import { ebool, euint256, eaddress, ETypes } from "./Types.sol";
10
10
 
11
- IncoLightning constant inco = IncoLightning(0x28676Cd3b10b03b2FDF105Ba280425b45a674F2A);
11
+ IncoLightning constant inco = IncoLightning(0xc0d693DeEF0A91CE39208676b6da09B822abd199);
12
12
  address constant deployedBy = 0x8202D2D747784Cb7D48868E44C42C4bf162a70BC;
13
13
 
14
14
  function typeOf(bytes32 handle) pure returns (ETypes) {
package/src/Lib.sol CHANGED
@@ -8,7 +8,7 @@ pragma solidity ^0.8;
8
8
  import { IncoLightning } from "./IncoLightning.sol";
9
9
  import { ebool, euint256, eaddress, ETypes } from "./Types.sol";
10
10
 
11
- IncoLightning constant inco = IncoLightning(0x28676Cd3b10b03b2FDF105Ba280425b45a674F2A);
11
+ IncoLightning constant inco = IncoLightning(0xc0d693DeEF0A91CE39208676b6da09B822abd199);
12
12
  address constant deployedBy = 0x8202D2D747784Cb7D48868E44C42C4bf162a70BC;
13
13
 
14
14
  function typeOf(bytes32 handle) pure returns (ETypes) {