@inco/lightning 0.6.8 → 0.6.9

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 (83) hide show
  1. package/README.md +29 -2
  2. package/manifest.yaml +0 -42
  3. package/package.json +5 -2
  4. package/src/CreateXHelper.sol +3 -1
  5. package/src/DeployUtils.sol +36 -71
  6. package/src/Errors.sol +1 -1
  7. package/src/IIncoLightning.sol +2 -0
  8. package/src/IncoLightning.sol +5 -17
  9. package/src/IncoVerifier.sol +12 -18
  10. package/src/Lib.template.sol +40 -159
  11. package/src/Types.sol +233 -97
  12. package/src/interfaces/IIncoLightning.sol +2 -0
  13. package/src/interfaces/IIncoVerifier.sol +7 -12
  14. package/src/interfaces/automata-interfaces/BELE.sol +2 -0
  15. package/src/interfaces/automata-interfaces/IAutomataEnclaveIdentityDao.sol +9 -11
  16. package/src/interfaces/automata-interfaces/IFmspcTcbDao.sol +3 -3
  17. package/src/interfaces/automata-interfaces/IPCCSRouter.sol +13 -47
  18. package/src/interfaces/automata-interfaces/IPCCSRouterExtended.sol +2 -0
  19. package/src/interfaces/automata-interfaces/IPcsDao.sol +6 -11
  20. package/src/interfaces/automata-interfaces/IQuoteVerifier.sol +4 -7
  21. package/src/interfaces/automata-interfaces/Types.sol +7 -6
  22. package/src/libs/incoLightning_devnet_v1_887305889.sol +5 -3
  23. package/src/libs/incoLightning_testnet_v1_938327937.sol +5 -3
  24. package/src/lightning-parts/AccessControl/AdvancedAccessControl.sol +41 -75
  25. package/src/lightning-parts/AccessControl/BaseAccessControlList.sol +31 -62
  26. package/src/lightning-parts/AccessControl/interfaces/IAdvancedAccessControl.sol +8 -15
  27. package/src/lightning-parts/AccessControl/interfaces/IBaseAccessControlList.sol +5 -12
  28. package/src/lightning-parts/AccessControl/test/TestAdvancedAccessControl.t.sol +42 -83
  29. package/src/lightning-parts/AccessControl/test/TestBaseAccessControl.t.sol +2 -0
  30. package/src/lightning-parts/DecryptionAttester.sol +14 -28
  31. package/src/lightning-parts/EncryptedInput.sol +23 -52
  32. package/src/lightning-parts/EncryptedOperations.sol +93 -440
  33. package/src/lightning-parts/Fee.sol +3 -1
  34. package/src/lightning-parts/TEELifecycle.sol +95 -225
  35. package/src/lightning-parts/TEELifecycle.types.sol +4 -3
  36. package/src/lightning-parts/TrivialEncryption.sol +6 -20
  37. package/src/lightning-parts/interfaces/IDecryptionAttester.sol +7 -2
  38. package/src/lightning-parts/interfaces/IEncryptedInput.sol +5 -12
  39. package/src/lightning-parts/interfaces/IEncryptedOperations.sol +17 -61
  40. package/src/lightning-parts/interfaces/ITEELifecycle.sol +7 -11
  41. package/src/lightning-parts/interfaces/ITrivialEncryption.sol +2 -0
  42. package/src/lightning-parts/primitives/EventCounter.sol +7 -8
  43. package/src/lightning-parts/primitives/HandleGeneration.sol +20 -32
  44. package/src/lightning-parts/primitives/HandleMetadata.sol +7 -17
  45. package/src/lightning-parts/primitives/LightningAddressGetter.sol +3 -0
  46. package/src/lightning-parts/primitives/SignatureVerifier.sol +91 -27
  47. package/src/lightning-parts/primitives/VerifierAddressGetter.sol +3 -0
  48. package/src/lightning-parts/primitives/interfaces/IEventCounter.sol +2 -0
  49. package/src/lightning-parts/primitives/interfaces/IHandleGeneration.sol +10 -2
  50. package/src/lightning-parts/primitives/interfaces/ISignatureVerifier.sol +4 -2
  51. package/src/lightning-parts/primitives/interfaces/IVerifierAddressGetter.sol +2 -0
  52. package/src/lightning-parts/primitives/test/SignatureVerifier.t.sol +838 -0
  53. package/src/lightning-parts/test/Fee.t.sol +6 -6
  54. package/src/lightning-parts/test/HandleMetadata.t.sol +21 -76
  55. package/src/lightning-parts/test/InputsFee.t.sol +7 -28
  56. package/src/lightning-parts/test/TestDecryptionAttestationInSynchronousFlow.t.sol +16 -48
  57. package/src/pasted-dependencies/CreateX.sol +146 -419
  58. package/src/pasted-dependencies/ICreateX.sol +58 -102
  59. package/src/periphery/SessionVerifier.sol +5 -7
  60. package/src/shared/IOwnable.sol +3 -0
  61. package/src/shared/IUUPSUpgradable.sol +5 -1
  62. package/src/shared/JsonUtils.sol +3 -5
  63. package/src/shared/TestUtils.sol +14 -13
  64. package/src/test/AddTwo.sol +9 -7
  65. package/src/test/FakeIncoInfra/FakeComputeServer.sol +11 -53
  66. package/src/test/FakeIncoInfra/FakeDecryptionAttester.sol +35 -118
  67. package/src/test/FakeIncoInfra/FakeIncoInfraBase.sol +31 -48
  68. package/src/test/FakeIncoInfra/FakeQuoteVerifier.sol +4 -7
  69. package/src/test/FakeIncoInfra/KVStore.sol +2 -0
  70. package/src/test/FakeIncoInfra/MockOpHandler.sol +9 -31
  71. package/src/test/FakeIncoInfra/MockRemoteAttestation.sol +44 -21
  72. package/src/test/IncoTest.sol +15 -9
  73. package/src/test/OpsTest.sol +429 -0
  74. package/src/test/TEELifecycle/TEELifecycleMockTest.t.sol +58 -104
  75. package/src/test/TestAddTwo.t.sol +4 -3
  76. package/src/test/TestDeploy.t.sol +5 -6
  77. package/src/test/TestExtractDataOfEventTooLarge.t.sol +7 -14
  78. package/src/test/TestFakeInfra.t.sol +15 -38
  79. package/src/test/TestUpgrade.t.sol +40 -135
  80. package/src/test/TestVersion.t.sol +6 -5
  81. package/src/version/IncoLightningConfig.sol +1 -1
  82. package/src/version/Version.sol +48 -51
  83. package/src/version/interfaces/IVersion.sol +6 -0
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
@@ -15,8 +15,6 @@ incoLightning_alphanet_v1_725458969:
15
15
  minor: 0
16
16
  patch: 2
17
17
  shortSalt: "725458969"
18
- decryptSigner: "0x4736F8CE685760017eEc130AC3FFc6187f5A1F95"
19
- eciesPublicKey: "0x038a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b84095b1"
20
18
  blockNumber: "32124925"
21
19
  deployDate: 2025-10-09T13:55:42.997Z
22
20
  commit: v0.5.3-10-ga4f2312d
@@ -38,8 +36,6 @@ incoLightning_devnet_v1_904635675:
38
36
  minor: 0
39
37
  patch: 2
40
38
  shortSalt: "904635675"
41
- decryptSigner: "0x138AcbDC1FA02b955949d8Da09E546Ea7748710f"
42
- eciesPublicKey: "0x038a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b84095b1"
43
39
  blockNumber: "3696905"
44
40
  deployDate: 2025-10-03T13:24:44.682Z
45
41
  commit: v0.5.3-6-g8db0f27f-dirty
@@ -52,8 +48,6 @@ incoLightning_devnet_v1_904635675:
52
48
  minor: 0
53
49
  patch: 0
54
50
  shortSalt: "904635675"
55
- decryptSigner: "0x138AcbDC1FA02b955949d8Da09E546Ea7748710f"
56
- eciesPublicKey: "0x038a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b84095b1"
57
51
  blockNumber: "3344310"
58
52
  deployDate: 2025-09-29T11:14:02.599Z
59
53
  commit: v0.5.1-5-g4135c790-dirty
@@ -75,9 +69,6 @@ incoLightning_testnet_v0_183408998:
75
69
  minor: 2
76
70
  patch: 0
77
71
  shortSalt: "183408998"
78
- decryptSigner: "0xA8822DE8910f66D3d03F1eAfe2C0141dBc327Ee0"
79
- eciesPublicKey: "0x048a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b8\
80
- 4095b1e647a9e377175fcb66bda05087c93b05e1fd53a704d0914bb23a0b2a69e9f235"
81
72
  blockNumber: "26296576"
82
73
  deployDate: 2025-05-27T15:57:24.175Z
83
74
  commit: v5-3-gec8b6aae-dirty
@@ -90,9 +81,6 @@ incoLightning_testnet_v0_183408998:
90
81
  minor: 1
91
82
  patch: 29
92
83
  shortSalt: "183408998"
93
- decryptSigner: "0xA8822DE8910f66D3d03F1eAfe2C0141dBc327Ee0"
94
- eciesPublicKey: "0x048a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b8\
95
- 4095b1e647a9e377175fcb66bda05087c93b05e1fd53a704d0914bb23a0b2a69e9f235"
96
84
  blockNumber: "13464615"
97
85
  deployDate: 2025-04-22T16:01:14.380Z
98
86
  commit: v3-28-g93c05a49-dirty
@@ -105,9 +93,6 @@ incoLightning_testnet_v0_183408998:
105
93
  minor: 1
106
94
  patch: 29
107
95
  shortSalt: "183408998"
108
- decryptSigner: "0xA8822DE8910f66D3d03F1eAfe2C0141dBc327Ee0"
109
- eciesPublicKey: "0x048a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b8\
110
- 4095b1e647a9e377175fcb66bda05087c93b05e1fd53a704d0914bb23a0b2a69e9f235"
111
96
  blockNumber: "24784654"
112
97
  deployDate: 2025-04-22T16:00:02.028Z
113
98
  commit: v3-28-g93c05a49-dirty
@@ -129,9 +114,6 @@ incoLightning_demonet_v0_863421733:
129
114
  minor: 2
130
115
  patch: 0
131
116
  shortSalt: "863421733"
132
- decryptSigner: "0xA8822DE8910f66D3d03F1eAfe2C0141dBc327Ee0"
133
- eciesPublicKey: "0x048a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b8\
134
- 4095b1e647a9e377175fcb66bda05087c93b05e1fd53a704d0914bb23a0b2a69e9f235"
135
117
  blockNumber: "25737175"
136
118
  deployDate: 2025-05-14T17:10:44.285Z
137
119
  commit: v4-11-g4a1f413a-dirty
@@ -144,9 +126,6 @@ incoLightning_demonet_v0_863421733:
144
126
  minor: 1
145
127
  patch: 29
146
128
  shortSalt: "863421733"
147
- decryptSigner: "0xA8822DE8910f66D3d03F1eAfe2C0141dBc327Ee0"
148
- eciesPublicKey: "0x048a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b8\
149
- 4095b1e647a9e377175fcb66bda05087c93b05e1fd53a704d0914bb23a0b2a69e9f235"
150
129
  blockNumber: "25719113"
151
130
  deployDate: 2025-05-14T07:08:39.059Z
152
131
  commit: v4
@@ -168,9 +147,6 @@ incoLightning_alphanet_v0_297966649:
168
147
  minor: 2
169
148
  patch: 1
170
149
  shortSalt: "297966649"
171
- decryptSigner: "0x4736F8CE685760017eEc130AC3FFc6187f5A1F95"
172
- eciesPublicKey: "0x048a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b8\
173
- 4095b1e647a9e377175fcb66bda05087c93b05e1fd53a704d0914bb23a0b2a69e9f235"
174
150
  blockNumber: "27543410"
175
151
  deployDate: 2025-06-25T12:38:32.856Z
176
152
  commit: v5-17-ga03e4b32-dirty
@@ -183,9 +159,6 @@ incoLightning_alphanet_v0_297966649:
183
159
  minor: 2
184
160
  patch: 0
185
161
  shortSalt: "297966649"
186
- decryptSigner: "0x4736F8CE685760017eEc130AC3FFc6187f5A1F95"
187
- eciesPublicKey: "0x048a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b8\
188
- 4095b1e647a9e377175fcb66bda05087c93b05e1fd53a704d0914bb23a0b2a69e9f235"
189
162
  blockNumber: "26894782"
190
163
  deployDate: 2025-06-10T12:17:35.790Z
191
164
  commit: v5-13-gd6b19c10-dirty
@@ -207,8 +180,6 @@ incoLightning_devnet_v0_340846814:
207
180
  minor: 2
208
181
  patch: 1
209
182
  shortSalt: "340846814"
210
- decryptSigner: "0x138AcbDC1FA02b955949d8Da09E546Ea7748710f"
211
- eciesPublicKey: "0x038a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b84095b1"
212
183
  blockNumber: "1718868"
213
184
  deployDate: 2025-09-10T15:20:25.654Z
214
185
  commit: v6-7-gf96f358e-dirty
@@ -221,8 +192,6 @@ incoLightning_devnet_v0_340846814:
221
192
  minor: 2
222
193
  patch: 1
223
194
  shortSalt: "340846814"
224
- decryptSigner: "0x138AcbDC1FA02b955949d8Da09E546Ea7748710f"
225
- eciesPublicKey: "0x038a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b84095b1"
226
195
  blockNumber: "1717229"
227
196
  deployDate: 2025-09-10T14:53:07.218Z
228
197
  commit: v6-7-gf96f358e-dirty
@@ -235,8 +204,6 @@ incoLightning_devnet_v0_340846814:
235
204
  minor: 2
236
205
  patch: 1
237
206
  shortSalt: "340846814"
238
- decryptSigner: "0x138AcbDC1FA02b955949d8Da09E546Ea7748710f"
239
- eciesPublicKey: "0x038a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b84095b1"
240
207
  blockNumber: "17365942"
241
208
  deployDate: 2025-08-15T17:35:15.208Z
242
209
  commit: v0.2.17-35-g8cca6b4e-dirty
@@ -249,9 +216,6 @@ incoLightning_devnet_v0_340846814:
249
216
  minor: 2
250
217
  patch: 0
251
218
  shortSalt: "340846814"
252
- decryptSigner: "0x138AcbDC1FA02b955949d8Da09E546Ea7748710f"
253
- eciesPublicKey: "0x048a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b8\
254
- 4095b1e647a9e377175fcb66bda05087c93b05e1fd53a704d0914bb23a0b2a69e9f235"
255
219
  blockNumber: "26122863"
256
220
  deployDate: 2025-05-23T15:26:57.031Z
257
221
  commit: v5-2-g8957c16b-dirty
@@ -264,9 +228,6 @@ incoLightning_devnet_v0_340846814:
264
228
  minor: 1
265
229
  patch: 29
266
230
  shortSalt: "340846814"
267
- decryptSigner: "0xA8822DE8910f66D3d03F1eAfe2C0141dBc327Ee0"
268
- eciesPublicKey: "0x048a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b8\
269
- 4095b1e647a9e377175fcb66bda05087c93b05e1fd53a704d0914bb23a0b2a69e9f235"
270
231
  blockNumber: "13464197"
271
232
  deployDate: 2025-04-22T15:57:26.862Z
272
233
  commit: v3-28-g93c05a49-dirty
@@ -279,9 +240,6 @@ incoLightning_devnet_v0_340846814:
279
240
  minor: 1
280
241
  patch: 29
281
242
  shortSalt: "340846814"
282
- decryptSigner: "0xA8822DE8910f66D3d03F1eAfe2C0141dBc327Ee0"
283
- eciesPublicKey: "0x048a582d29083c2f3fefe024bf4dd9ab913ab8973716977da5f01106e0b8\
284
- 4095b1e647a9e377175fcb66bda05087c93b05e1fd53a704d0914bb23a0b2a69e9f235"
285
243
  blockNumber: "24784527"
286
244
  deployDate: 2025-04-22T15:55:47.828Z
287
245
  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.6.9",
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
  }