@inco/lightning 0.4.0 → 0.5.1

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 (110) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +2 -0
  3. package/manifest.yaml +23 -0
  4. package/package.json +2 -5
  5. package/src/DeployUtils.sol +113 -77
  6. package/src/IIncoLightning.sol +16 -9
  7. package/src/IncoLightning.sol +18 -9
  8. package/src/IncoVerifier.sol +47 -0
  9. package/src/Lib.alphanet.sol +2 -15
  10. package/src/Lib.demonet.sol +2 -15
  11. package/src/Lib.devnet.sol +3 -16
  12. package/src/Lib.sol +3 -16
  13. package/src/Lib.template.sol +3 -44
  14. package/src/Lib.testnet.sol +2 -15
  15. package/src/Types.sol +7 -0
  16. package/src/interfaces/IIncoLightning.sol +20 -0
  17. package/src/interfaces/IIncoVerifier.sol +24 -0
  18. package/src/interfaces/automata-interfaces/BELE.sol +20 -0
  19. package/src/interfaces/automata-interfaces/IAutomataEnclaveIdentityDao.sol +28 -0
  20. package/src/interfaces/automata-interfaces/IFmspcTcbDao.sol +10 -0
  21. package/src/interfaces/automata-interfaces/IPCCSRouter.sol +94 -0
  22. package/src/interfaces/automata-interfaces/IPCCSRouterExtended.sol +10 -0
  23. package/src/interfaces/automata-interfaces/IPcsDao.sol +18 -0
  24. package/src/interfaces/automata-interfaces/IQuoteVerifier.sol +34 -0
  25. package/src/interfaces/automata-interfaces/Types.sol +193 -0
  26. package/src/libs/incoLightning_alphanet_v0_297966649.sol +2 -15
  27. package/src/libs/incoLightning_demonet_v0_863421733.sol +2 -15
  28. package/src/libs/incoLightning_devnet_v0_340846814.sol +2 -15
  29. package/src/libs/incoLightning_devnet_v1_887305889.sol +451 -0
  30. package/src/libs/incoLightning_testnet_v0_183408998.sol +2 -15
  31. package/src/libs/incoLightning_testnet_v1_938327937.sol +451 -0
  32. package/src/lightning-parts/AccessControl/AdvancedAccessControl.sol +133 -0
  33. package/src/lightning-parts/AccessControl/AdvancedAccessControl.types.sol +18 -0
  34. package/src/lightning-parts/AccessControl/BaseAccessControlList.sol +22 -2
  35. package/src/lightning-parts/AccessControl/interfaces/IAdvancedAccessControl.sol +25 -0
  36. package/src/lightning-parts/AccessControl/interfaces/IBaseAccessControlList.sol +24 -0
  37. package/src/lightning-parts/AccessControl/test/TestAdvancedAccessControl.t.sol +234 -0
  38. package/src/lightning-parts/AccessControl/test/TestBaseAccessControl.t.sol +4 -3
  39. package/src/lightning-parts/DecryptionAttester.sol +45 -0
  40. package/src/lightning-parts/DecryptionAttester.types.sol +7 -0
  41. package/src/lightning-parts/EncryptedInput.sol +8 -13
  42. package/src/lightning-parts/EncryptedOperations.sol +2 -2
  43. package/src/lightning-parts/TEELifecycle.sol +180 -88
  44. package/src/lightning-parts/TrivialEncryption.sol +8 -10
  45. package/src/lightning-parts/interfaces/IDecryptionAttester.sol +9 -0
  46. package/src/lightning-parts/interfaces/IEncryptedInput.sol +19 -0
  47. package/src/lightning-parts/interfaces/IEncryptedOperations.sol +31 -0
  48. package/src/lightning-parts/interfaces/ITEELifecycle.sol +26 -0
  49. package/src/lightning-parts/interfaces/ITrivialEncryption.sol +10 -0
  50. package/src/lightning-parts/primitives/EventCounter.sol +2 -2
  51. package/src/lightning-parts/primitives/HandleGeneration.sol +8 -3
  52. package/src/lightning-parts/primitives/HandleMetadata.sol +1 -1
  53. package/src/lightning-parts/primitives/LightningAddressGetter.sol +10 -0
  54. package/src/lightning-parts/primitives/SignatureVerifier.sol +2 -9
  55. package/src/lightning-parts/primitives/VerifierAddressGetter.sol +13 -0
  56. package/src/lightning-parts/primitives/{EventCounter.gen.sol → interfaces/IEventCounter.sol} +2 -2
  57. package/src/lightning-parts/primitives/interfaces/IHandleGeneration.sol +41 -0
  58. package/src/lightning-parts/primitives/interfaces/ISignatureVerifier.sol +9 -0
  59. package/src/lightning-parts/primitives/interfaces/IVerifierAddressGetter.sol +8 -0
  60. package/src/lightning-parts/test/HandleMetadata.t.sol +25 -6
  61. package/src/lightning-parts/test/TestDecryptionAttestationInSynchronousFlow.t.sol +78 -0
  62. package/src/periphery/SessionVerifier.sol +63 -0
  63. package/src/test/AddTwo.sol +18 -33
  64. package/src/test/FakeIncoInfra/FakeDecryptionAttester.sol +198 -0
  65. package/src/test/FakeIncoInfra/FakeIncoInfraBase.sol +0 -15
  66. package/src/test/FakeIncoInfra/FakeQuoteVerifier.sol +10 -6
  67. package/src/test/FakeIncoInfra/MockOpHandler.sol +0 -7
  68. package/src/test/FakeIncoInfra/MockRemoteAttestation.sol +19 -7
  69. package/src/test/FakeIncoInfra/getOpForSelector.sol +0 -3
  70. package/src/test/IncoTest.sol +12 -11
  71. package/src/test/TEELifecycle/TEELifecycleMockTest.t.sol +98 -77
  72. package/src/test/TestAddTwo.t.sol +16 -9
  73. package/src/test/TestFakeInfra.t.sol +10 -27
  74. package/src/test/TestUpgrade.t.sol +11 -4
  75. package/src/test/TestVersion.t.sol +0 -7
  76. package/src/version/IncoLightningConfig.sol +5 -4
  77. package/src/version/SessionVerifierConfig.sol +8 -0
  78. package/src/version/Version.sol +7 -9
  79. package/src/version/interfaces/IVersion.sol +8 -0
  80. package/src/DeployTEE.sol +0 -153
  81. package/src/IncoLightning.gen.sol +0 -15
  82. package/src/lightning-parts/AccessControl/BaseAccessControlList.gen.sol +0 -24
  83. package/src/lightning-parts/DecryptionHandler.gen.sol +0 -54
  84. package/src/lightning-parts/DecryptionHandler.sol +0 -307
  85. package/src/lightning-parts/DecryptionHandler.types.sol +0 -34
  86. package/src/lightning-parts/EncryptedInput.gen.sol +0 -16
  87. package/src/lightning-parts/EncryptedOperations.gen.sol +0 -59
  88. package/src/lightning-parts/TEELifecycle.gen.sol +0 -58
  89. package/src/lightning-parts/TrivialEncryption.gen.sol +0 -15
  90. package/src/lightning-parts/primitives/HandleGeneration.gen.sol +0 -19
  91. package/src/lightning-parts/primitives/HandleMetadata.gen.sol +0 -4
  92. package/src/lightning-parts/primitives/SignatureVerifier.gen.sol +0 -16
  93. package/src/test/FibonacciDecrypt.sol +0 -49
  94. package/src/test/TEELifecycle/TEELifecycleHWTest.t.sol +0 -119
  95. package/src/test/TEELifecycle/addnode_data/eoa.txt +0 -1
  96. package/src/test/TEELifecycle/addnode_data/quote.bin +0 -0
  97. package/src/test/TEELifecycle/bootstrap_data/ecies_pubkey.bin +0 -1
  98. package/src/test/TEELifecycle/bootstrap_data/eip712_signature.bin +0 -1
  99. package/src/test/TEELifecycle/bootstrap_data/eoa.txt +0 -1
  100. package/src/test/TEELifecycle/bootstrap_data/qe_identity +0 -1
  101. package/src/test/TEELifecycle/bootstrap_data/qe_identity_signature.bin +0 -1
  102. package/src/test/TEELifecycle/bootstrap_data/quote.bin +0 -0
  103. package/src/test/TEELifecycle/bootstrap_data/tcb_info +0 -1
  104. package/src/test/TEELifecycle/bootstrap_data/tcb_info_signature.bin +0 -1
  105. package/src/test/TEELifecycle/test_cert/AttestationReportSigningCA.crl +0 -0
  106. package/src/test/TEELifecycle/test_cert/Intel_SGX_Attestation_RootCA.cer +0 -0
  107. package/src/test/TEELifecycle/test_cert/Intel_SGX_PCK_CRL.crl +0 -0
  108. package/src/test/TEELifecycle/test_cert/Intel_SGX_PCK_PlatformCA.cer +0 -0
  109. package/src/test/TEELifecycle/test_cert/Intel_SGX_TCB_Signing.cer +0 -0
  110. package/src/version/Version.gen.sol +0 -14
@@ -1,7 +1,6 @@
1
1
  // SPDX-License-Identifier: No License
2
2
  pragma solidity ^0.8;
3
3
 
4
- import {DecryptionRequested} from "../../lightning-parts/DecryptionHandler.sol";
5
4
  import {EncryptedOperations} from "../../lightning-parts/EncryptedOperations.sol";
6
5
  import {TrivialEncryption} from "../../lightning-parts/TrivialEncryption.sol";
7
6
  import {EncryptedInput} from "../../lightning-parts/EncryptedInput.sol";
@@ -63,8 +62,6 @@ function getOpForSelector(bytes32 opEventSelector) pure returns (EOps) {
63
62
  return EOps.Rand;
64
63
  } else if (opEventSelector == EncryptedOperations.ERandBounded.selector) {
65
64
  return EOps.RandBounded;
66
- } else if (opEventSelector == DecryptionRequested.selector) {
67
- return EOps.DecryptionRequested;
68
65
  } else {
69
66
  revert("getOpForSelector: Unsupported selector");
70
67
  }
@@ -2,14 +2,16 @@
2
2
  pragma solidity ^0.8;
3
3
 
4
4
  import {MockOpHandler} from "./FakeIncoInfra/MockOpHandler.sol";
5
- import {IncoLightning} from "../IncoLightning.sol";
5
+ import {IIncoLightning} from "../interfaces/IIncoLightning.sol";
6
6
  import {inco} from "../Lib.sol";
7
7
  import {DeployUtils} from "../DeployUtils.sol";
8
8
  import {deployedBy} from "../Lib.sol";
9
+ import {FakeDecryptionAttester} from "./FakeIncoInfra/FakeDecryptionAttester.sol";
9
10
  import {console} from "forge-std/console.sol";
10
11
  import {FakeQuoteVerifier} from "./FakeIncoInfra/FakeQuoteVerifier.sol";
12
+ import {IOwnable} from "@inco/shared/src/IOwnable.sol";
11
13
 
12
- contract IncoTest is MockOpHandler, DeployUtils {
14
+ contract IncoTest is MockOpHandler, DeployUtils, FakeDecryptionAttester {
13
15
  address immutable owner;
14
16
  address immutable testDeployer;
15
17
 
@@ -27,16 +29,14 @@ contract IncoTest is MockOpHandler, DeployUtils {
27
29
  deployCreateX();
28
30
  vm.startPrank(testDeployer);
29
31
  vm.setEnv("USE_TDX_HW", "false"); // results in the test deployment using the FakeQuoteVerifier
30
- IncoLightning proxy = deployIncoLightningUsingConfig({
32
+ (IIncoLightning proxy, ) = deployIncoLightningUsingConfig({
31
33
  deployer: testDeployer,
32
- // The highest precedent deployment
34
+ // The highest precedent deployment
33
35
  pepper: "testnet",
34
- minorVersionForSalt: 1,
35
- patchVersionForSalt: 29,
36
- includePreviewFeatures: false,
37
- teeLifecycleAddress: address(0)
36
+ quoteVerifier: new FakeQuoteVerifier()
38
37
  });
39
- proxy.transferOwnership(owner);
38
+ IOwnable(address(proxy)).transferOwnership(owner);
39
+ IOwnable(address(inco.incoVerifier())).transferOwnership(owner);
40
40
  vm.stopPrank();
41
41
  console.log(
42
42
  "Deployed %s (proxy) to: %s",
@@ -48,8 +48,9 @@ contract IncoTest is MockOpHandler, DeployUtils {
48
48
  address(proxy) == address(inco),
49
49
  "generated inco address in Lib.sol does not match address of inco deployed by IncoTest"
50
50
  );
51
- vm.prank(owner);
52
- inco.addSigner(teePubkeyAddress);
51
+ vm.startPrank(owner);
52
+ inco.incoVerifier().addSigner(teePubkeyAddress);
53
+ vm.stopPrank();
53
54
  vm.recordLogs();
54
55
  }
55
56
  }
@@ -1,145 +1,166 @@
1
1
  // SPDX-License-Identifier: UNLICENSED
2
2
  pragma solidity ^0.8.0;
3
3
 
4
- import "@inco/lightning/src/lightning-parts/TEELifecycle.sol";
5
- import "@inco/lightning/src/lightning-parts/TEELifecycle.types.sol";
4
+ import {TEELifecycle} from "../../lightning-parts/TEELifecycle.sol";
5
+ import {BootstrapResult} from "../../lightning-parts/TEELifecycle.types.sol";
6
6
  import {MockRemoteAttestation} from "../FakeIncoInfra/MockRemoteAttestation.sol";
7
7
  import {FakeQuoteVerifier} from "../FakeIncoInfra/FakeQuoteVerifier.sol";
8
-
9
- import "forge-std/Vm.sol";
10
- import "forge-std/Test.sol";
8
+ import {Test} from "forge-std/Test.sol";
11
9
 
12
10
  contract TEELifecycleMockTest is Test, MockRemoteAttestation, TEELifecycle {
13
-
14
11
  function setUp() public {
15
12
  quoteVerifier = new FakeQuoteVerifier();
16
13
  }
17
14
 
18
- function test_successfulBootstrap() public {
19
- (BootstrapResult memory bootstrapResult, , , bytes memory quote, bytes memory signature, bytes memory mrtd) = successfulBootstrapResult();
15
+ function testSuccessfulBootstrap() public {
16
+ (
17
+ BootstrapResult memory bootstrapResult,
18
+ ,
19
+ ,
20
+ bytes memory quote,
21
+ bytes memory signature,
22
+ bytes memory mrtd
23
+ ) = successfulBootstrapResult();
20
24
  vm.startPrank(this.owner());
21
25
  this.approveNewTEEVersion(mrtd);
22
- this.verifyBootstrapResult(
23
- bootstrapResult,
24
- quote,
25
- signature
26
- );
26
+ this.verifyBootstrapResult(bootstrapResult, quote, signature);
27
27
  assertTrue(this.isBootstrapComplete(), "Bootstrap should be complete");
28
28
  vm.stopPrank();
29
29
  }
30
-
31
- function test_invalidMrtd() public {
32
- bytes memory badMrtd = hex"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef";
33
30
 
34
- (BootstrapResult memory bootstrapResult, , address bootstrapPartyAddress, bytes memory quote, bytes memory signature, bytes memory mrtd) = successfulBootstrapResult();
31
+ function testInvalidMrtd() public {
32
+ bytes
33
+ memory badMrtd = hex"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef";
34
+
35
+ (
36
+ BootstrapResult memory bootstrapResult,
37
+ ,
38
+ address bootstrapPartyAddress,
39
+ bytes memory quote,
40
+ bytes memory signature,
41
+ bytes memory mrtd
42
+ ) = successfulBootstrapResult();
35
43
 
36
44
  quote = createQuote(badMrtd, bootstrapPartyAddress); // Replace with bad MRTD
37
45
  vm.startPrank(this.owner());
38
46
  this.approveNewTEEVersion(mrtd);
39
- vm.expectRevert(bytes("Invalid report MRTD"));
40
- this.verifyBootstrapResult(
41
- bootstrapResult,
42
- quote,
43
- signature
44
- );
47
+ vm.expectRevert(TEELifecycle.InvalidReportMRTD.selector);
48
+ this.verifyBootstrapResult(bootstrapResult, quote, signature);
45
49
  vm.stopPrank();
46
50
  }
47
51
 
48
- function test_invalidSignature() public {
49
- (BootstrapResult memory bootstrapResult, , , bytes memory quote, , bytes memory mrtd) = successfulBootstrapResult();
50
- (uint256 bootstrapPartyFakePrivkey, ) = getLabeledKeyPair("bootstrapPartyFake");
51
- bytes memory signatureInvalid = signBootstrapResult(bootstrapResult, bootstrapPartyFakePrivkey);
52
- vm.startPrank(this.owner());
53
- this.approveNewTEEVersion(mrtd);
54
- vm.expectRevert(bytes("Invalid signature for bootstrap data"));
55
- this.verifyBootstrapResult(
52
+ function testInvalidSignature() public {
53
+ (
54
+ BootstrapResult memory bootstrapResult,
55
+ ,
56
+ ,
57
+ bytes memory quote,
58
+ ,
59
+ bytes memory mrtd
60
+ ) = successfulBootstrapResult();
61
+ (uint256 bootstrapPartyFakePrivkey, ) = getLabeledKeyPair(
62
+ "bootstrapPartyFake"
63
+ );
64
+ bytes memory signatureInvalid = signBootstrapResult(
56
65
  bootstrapResult,
57
- quote,
58
- signatureInvalid
66
+ bootstrapPartyFakePrivkey
59
67
  );
68
+ vm.startPrank(this.owner());
69
+ this.approveNewTEEVersion(mrtd);
70
+ vm.expectRevert(TEELifecycle.InvalidBootstrapDataSignature.selector);
71
+ this.verifyBootstrapResult(bootstrapResult, quote, signatureInvalid);
60
72
  vm.stopPrank();
61
73
  }
62
74
 
63
- function test_bootstrapAlreadyComplete() public {
64
- (BootstrapResult memory bootstrapResult, , , bytes memory quote, bytes memory signature, bytes memory mrtd) = successfulBootstrapResult();
75
+ function testBootstrapAlreadyComplete() public {
76
+ (
77
+ BootstrapResult memory bootstrapResult,
78
+ ,
79
+ ,
80
+ bytes memory quote,
81
+ bytes memory signature,
82
+ bytes memory mrtd
83
+ ) = successfulBootstrapResult();
65
84
  vm.startPrank(this.owner());
66
85
  this.approveNewTEEVersion(mrtd);
67
- this.verifyBootstrapResult(
68
- bootstrapResult,
69
- quote,
70
- signature
71
- );
72
- vm.expectRevert(bytes("Bootstrap already completed"));
73
- this.verifyBootstrapResult(
74
- bootstrapResult,
75
- quote,
76
- signature
77
- );
86
+ this.verifyBootstrapResult(bootstrapResult, quote, signature);
87
+ vm.expectRevert(TEELifecycle.BootstrapAlreadyCompleted.selector);
88
+ this.verifyBootstrapResult(bootstrapResult, quote, signature);
78
89
  vm.stopPrank();
79
90
  }
80
91
 
81
- function test_approveNewTEEInvalidMrtd() public {
92
+ function testApproveNewTEEInvalidMrtd() public {
82
93
  bytes memory mrtd = hex"deadbeef";
83
94
  vm.startPrank(this.owner());
84
- vm.expectRevert(bytes("MRTD must be 48 bytes"));
95
+ vm.expectRevert(TEELifecycle.MrtdInvalidLength.selector);
85
96
  this.approveNewTEEVersion(mrtd);
86
97
  vm.stopPrank();
87
98
  }
88
99
 
89
- function test_bootstrapNotCompleteNewCoval() public {
90
- bytes memory mrtd = hex"2a90c8fa38672cafd791d994beb6836b99383b2563736858632284f0f760a6446efd1e7ec457cf08b629ea630f7b4525";
100
+ function testBootstrapNotCompleteNewCoval() public {
101
+ bytes
102
+ memory mrtd = hex"2a90c8fa38672cafd791d994beb6836b99383b2563736858632284f0f760a6446efd1e7ec457cf08b629ea630f7b4525";
91
103
  (, address newCoval) = getLabeledKeyPair("newCoval");
92
104
  bytes memory quote = createQuote(mrtd, newCoval);
93
105
  vm.startPrank(this.owner());
94
- vm.expectRevert(bytes("Bootstrap not complete"));
106
+ vm.expectRevert(TEELifecycle.BootstrapNotComplete.selector);
95
107
  this.addNewCovalidator(quote);
96
108
  vm.stopPrank();
97
109
  }
98
110
 
99
- function test_invalidMrtdNewCoval() public {
100
- (BootstrapResult memory bootstrapResult, , , bytes memory quote, bytes memory signature, bytes memory mrtd) = successfulBootstrapResult();
111
+ function testInvalidMrtdNewCoval() public {
112
+ (
113
+ BootstrapResult memory bootstrapResult,
114
+ ,
115
+ ,
116
+ bytes memory quote,
117
+ bytes memory signature,
118
+ bytes memory mrtd
119
+ ) = successfulBootstrapResult();
101
120
  vm.startPrank(this.owner());
102
121
  this.approveNewTEEVersion(mrtd);
103
- this.verifyBootstrapResult(
104
- bootstrapResult,
105
- quote,
106
- signature
107
- );
108
- bytes memory badMrtd = hex"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef";
122
+ this.verifyBootstrapResult(bootstrapResult, quote, signature);
123
+ bytes
124
+ memory badMrtd = hex"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef";
109
125
  (, address newCoval) = getLabeledKeyPair("newCoval");
110
126
  bytes memory quoteNew = createQuote(badMrtd, newCoval);
111
-
112
- vm.expectRevert(bytes("Invalid report MRTD"));
127
+
128
+ vm.expectRevert(TEELifecycle.InvalidMrtdReport.selector);
113
129
  this.addNewCovalidator(quoteNew);
114
130
  vm.stopPrank();
115
131
  }
116
132
 
117
133
  // Helper function to create a successful bootstrap result
118
- function successfulBootstrapResult() internal returns (BootstrapResult memory bootstrapResult, uint256 bootstrapPartyPrivkey, address bootstrapPartyAddress, bytes memory quote, bytes memory signature, bytes memory mrtd) {
119
- (bootstrapPartyPrivkey, bootstrapPartyAddress) = getLabeledKeyPair("bootstrapParty");
120
- bytes memory eciesPubkey = hex"04ff5c6dd72ad7583288b84ee2598e081fe0bc6ef543c342e925a5dfcff9afb2444d25454d7d5dcfadc9ed99477c245efa93caf58d7f58143300d81cc948e7bdf5";
134
+ function successfulBootstrapResult()
135
+ internal
136
+ returns (
137
+ BootstrapResult memory bootstrapResult,
138
+ uint256 bootstrapPartyPrivkey,
139
+ address bootstrapPartyAddress,
140
+ bytes memory quote,
141
+ bytes memory signature,
142
+ bytes memory mrtd
143
+ )
144
+ {
145
+ (bootstrapPartyPrivkey, bootstrapPartyAddress) = getLabeledKeyPair(
146
+ "bootstrapParty"
147
+ );
148
+ bytes
149
+ memory eciesPubkey = hex"04ff5c6dd72ad7583288b84ee2598e081fe0bc6ef543c342e925a5dfcff9afb2444d25454d7d5dcfadc9ed99477c245efa93caf58d7f58143300d81cc948e7bdf5";
121
150
  mrtd = hex"2a90c8fa38672cafd791d994beb6836b99383b2563736858632284f0f760a6446efd1e7ec457cf08b629ea630f7b4525";
122
151
 
123
- bootstrapResult = BootstrapResult({
124
- ecies_pubkey: eciesPubkey
125
- });
152
+ bootstrapResult = BootstrapResult({ecies_pubkey: eciesPubkey});
126
153
 
127
- quote = createQuote(
128
- mrtd,
129
- bootstrapPartyAddress
130
- );
154
+ quote = createQuote(mrtd, bootstrapPartyAddress);
131
155
  signature = signBootstrapResult(bootstrapResult, bootstrapPartyPrivkey);
132
156
  }
133
-
157
+
134
158
  // Helper function to sign the bootstrap result
135
159
  function signBootstrapResult(
136
160
  BootstrapResult memory bootstrapResult,
137
161
  uint256 privateKey
138
162
  ) internal view returns (bytes memory) {
139
- bytes32 bootstrapResultDigest = bootstrapResultDigest(
140
- bootstrapResult
141
- );
163
+ bytes32 bootstrapResultDigest = bootstrapResultDigest(bootstrapResult);
142
164
  return getSignatureForDigest(bootstrapResultDigest, privateKey);
143
165
  }
144
-
145
- }
166
+ }
@@ -7,9 +7,15 @@ import {IncoTest} from "./IncoTest.sol";
7
7
  import {AddTwo} from "./AddTwo.sol";
8
8
 
9
9
  contract TestAddTwo is IncoTest {
10
- function testAddTwo() public {
11
- AddTwo addTwo = new AddTwo(inco);
10
+ AddTwo addTwo;
11
+
12
+ function setUp() public override {
13
+ super.setUp();
14
+ addTwo = new AddTwo(inco);
12
15
  vm.label(address(addTwo), "addTwo");
16
+ }
17
+
18
+ function testAddTwo() public {
13
19
  euint256 a = inco.asEuint256(3);
14
20
  inco.allow(euint256.unwrap(a), address(addTwo));
15
21
  euint256 b = addTwo.addTwo(a);
@@ -17,13 +23,14 @@ contract TestAddTwo is IncoTest {
17
23
  assertEq(getUint256Value(b), 5);
18
24
  }
19
25
 
20
- function testAddTwoScalar() public {
21
- AddTwo addTwo = new AddTwo(inco);
22
- vm.label(address(addTwo), "addTwoScalar");
23
- euint256 a = inco.asEuint256(3);
24
- inco.allow(euint256.unwrap(a), address(addTwo));
25
- euint256 b = addTwo.addTwoScalar(a);
26
+ function testAddTwoEoaAndPublicReveal() public {
27
+ (euint256 result, euint256 revealedResult) = addTwo.addTwoEOA(
28
+ fakePrepareEuint256Ciphertext(3)
29
+ );
26
30
  processAllOperations();
27
- assertEq(getUint256Value(b), 5);
31
+ assertEq(getUint256Value(result), 5);
32
+ assertEq(getUint256Value(revealedResult), 5);
33
+ assertFalse(inco.isAllowed(euint256.unwrap(result), bob));
34
+ assertTrue(inco.isAllowed(euint256.unwrap(revealedResult), bob));
28
35
  }
29
36
  }
@@ -2,13 +2,14 @@
2
2
  pragma solidity ^0.8;
3
3
 
4
4
  import {IncoTest} from "./IncoTest.sol";
5
- import {e, euint256, ebool, eaddress} from "../Lib.sol";
5
+ import {e, euint256, ebool, eaddress, inco} from "../Lib.sol";
6
6
  import {SenderNotAllowedForHandle} from "../Types.sol";
7
7
  import {TEELifecycle} from "../lightning-parts/TEELifecycle.sol";
8
8
  import {MockRemoteAttestation} from "./FakeIncoInfra/MockRemoteAttestation.sol";
9
-
10
- import {MINIMUM_QUOTE_LENGTH} from "@automata-network/dcap-attestation/types/Constants.sol";
11
- import {TD10ReportBody} from "@automata-network/dcap-attestation/types/V4Structs.sol";
9
+ import {
10
+ TD10ReportBody,
11
+ MINIMUM_QUOTE_LENGTH
12
+ } from "../interfaces/automata-interfaces/Types.sol";
12
13
 
13
14
  contract TakesEInput {
14
15
  using e for bytes;
@@ -26,18 +27,6 @@ contract TakesEInput {
26
27
  function setB(bytes memory boolEInput) external {
27
28
  b = boolEInput.newEbool(msg.sender);
28
29
  }
29
-
30
- function decryptA() external {
31
- a.requestDecryption(this.aDecryptionCallback.selector, "");
32
- }
33
-
34
- function aDecryptionCallback(
35
- uint256,
36
- uint256 _decryptedA,
37
- bytes memory
38
- ) external {
39
- decryptedA = _decryptedA;
40
- }
41
30
  }
42
31
 
43
32
  // its meta: this is testing correct behavior of our testing infrastructure
@@ -288,14 +277,6 @@ contract TestFakeInfra is IncoTest, MockRemoteAttestation {
288
277
  assertEq(getBoolValue(inputContract.b()), true);
289
278
  }
290
279
 
291
- function testDecryption() public {
292
- TakesEInput inputContract = new TakesEInput();
293
- inputContract.setA(fakePrepareEuint256Ciphertext(37));
294
- inputContract.decryptA();
295
- processAllOperations();
296
- assertEq(inputContract.decryptedA(), 37);
297
- }
298
-
299
280
  function testUninitializedHandleIsDisallowed() public {
300
281
  bytes32 randomHandle = keccak256("random handle");
301
282
  euint256 a = e.asEuint256(12);
@@ -310,12 +291,14 @@ contract TestFakeInfra is IncoTest, MockRemoteAttestation {
310
291
  }
311
292
 
312
293
  function testCreateQuote() public {
313
- bytes memory mrtd = hex"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef";
294
+ bytes
295
+ memory mrtd = hex"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef";
314
296
  address signer = address(0x1234567890123456789012345678901234567890);
315
297
  bytes memory quote = createQuote(mrtd, signer);
316
- TEELifecycle lifecycle = new TEELifecycle();
298
+ TEELifecycle lifecycle = TEELifecycle(address(inco.incoVerifier()));
317
299
  TD10ReportBody memory tdReport = lifecycle.parseTD10ReportBody(quote);
318
- (address reportDataSigner, bytes memory reportMrtd) = lifecycle.parseReport(tdReport);
300
+ (address reportDataSigner, bytes memory reportMrtd) = lifecycle
301
+ .parseReport(tdReport);
319
302
  assertEq(reportDataSigner, signer);
320
303
  assertEq(keccak256(reportMrtd), keccak256(mrtd));
321
304
  assertEq(quote.length, MINIMUM_QUOTE_LENGTH);
@@ -9,6 +9,9 @@ import {IOwnerManager} from "safe-smart-account/interfaces/IOwnerManager.sol";
9
9
  import {IncoTest} from "./IncoTest.sol";
10
10
  import {inco} from "../Lib.sol";
11
11
  import {IncoLightning} from "../IncoLightning.sol";
12
+ import {IVersion} from "../version/interfaces/IVersion.sol";
13
+ import {Version} from "../version/Version.sol";
14
+ import {IIncoVerifier} from "../interfaces/IIncoVerifier.sol";
12
15
  import {
13
16
  MAJOR_VERSION,
14
17
  MINOR_VERSION,
@@ -27,9 +30,15 @@ contract IncoLightningV2 is IncoLightning {
27
30
  uint8 constant MINOR_VERSION_MOCK = 255;
28
31
  uint8 constant PATCH_VERSION_MOCK = 255;
29
32
 
30
- constructor(bytes32 salt) IncoLightning(salt) {}
33
+ constructor(bytes32 salt) IncoLightning(salt, IIncoVerifier(address(0))) {}
31
34
 
32
- function getVersion() public view virtual override returns (string memory) {
35
+ function getVersion()
36
+ public
37
+ view
38
+ virtual
39
+ override(IVersion, Version)
40
+ returns (string memory)
41
+ {
33
42
  return
34
43
  versionString(
35
44
  MAJOR_VERSION_MOCK,
@@ -86,8 +95,6 @@ contract TestUpgrade is IncoTest {
86
95
  bytes32 salt = getSalt(
87
96
  "IncoLightningV2",
88
97
  255,
89
- 255,
90
- 255,
91
98
  testDeployer,
92
99
  "testnet"
93
100
  );
@@ -26,11 +26,4 @@ contract TestVersion is Test {
26
26
  "SomeContract_1_2_3__12345678"
27
27
  );
28
28
  }
29
-
30
- function testVersionEip712() public view {
31
- (, string memory name, string memory version, , , , ) = someContract
32
- .eip712Domain();
33
- assertEq(name, "SomeContract");
34
- assertEq(version, "1_2_3");
35
- }
36
29
  }
@@ -4,10 +4,11 @@ pragma solidity ^0.8;
4
4
  // Change these constants for new contracts
5
5
  // Since this file only contains these constants, it could be generated reacting to cli inputs
6
6
 
7
- // IMPORTANT if you are changing this file, run `make update_config` afterwards for it to take effect
8
7
  // UPDATE the CHANGELOG on new versions
9
8
 
10
9
  string constant CONTRACT_NAME = "incoLightning";
11
- uint8 constant MAJOR_VERSION = 0;
12
- uint8 constant MINOR_VERSION = 2;
13
- uint8 constant PATCH_VERSION = 1;
10
+ uint8 constant MAJOR_VERSION = 1;
11
+ uint8 constant MINOR_VERSION = 0;
12
+ uint8 constant PATCH_VERSION = 0;
13
+
14
+ string constant VERIFIER_NAME = "incoVerifier";
@@ -0,0 +1,8 @@
1
+ // SPDX-License-Identifier: No License
2
+ pragma solidity ^0.8;
3
+
4
+ string constant SESSION_VERIFIER_NAME = "sessionVerifier";
5
+ uint8 constant SESSION_VERIFIER_MAJOR_VERSION = 0;
6
+ uint8 constant SESSION_VERIFIER_MINOR_VERSION = 1;
7
+ uint8 constant SESSION_VERIFIER_PATCH_VERSION = 2;
8
+ bytes32 constant SESSION_VERIFIER_PEPPER = keccak256("");
@@ -2,10 +2,13 @@
2
2
  pragma solidity ^0.8;
3
3
 
4
4
  import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
5
- import {EIP712} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
6
- import {ShortStrings, ShortString} from "@openzeppelin/contracts/utils/ShortStrings.sol";
5
+ import {
6
+ ShortStrings,
7
+ ShortString
8
+ } from "@openzeppelin/contracts/utils/ShortStrings.sol";
9
+ import {IVersion} from "./interfaces/IVersion.sol";
7
10
 
8
- contract Version is EIP712 {
11
+ contract Version is IVersion {
9
12
  using ShortStrings for ShortString;
10
13
  using ShortStrings for string;
11
14
 
@@ -21,12 +24,7 @@ contract Version is EIP712 {
21
24
  uint8 _patchVersion,
22
25
  bytes32 _salt,
23
26
  string memory _name
24
- )
25
- EIP712(
26
- _name,
27
- versionString(_majorVersion, _minorVersion, _patchVersion)
28
- )
29
- {
27
+ ) {
30
28
  majorVersion = _majorVersion;
31
29
  minorVersion = _minorVersion;
32
30
  patchVersion = _patchVersion;
@@ -0,0 +1,8 @@
1
+ /// SPDX-License-Identifier: No License
2
+ pragma solidity ^0.8;
3
+
4
+ interface IVersion {
5
+ function getVersionedName() external view returns (string memory);
6
+ function getVersion() external view returns (string memory);
7
+ function getName() external view returns (string memory);
8
+ }