@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.
- package/CHANGELOG.md +4 -0
- package/README.md +2 -0
- package/manifest.yaml +23 -0
- package/package.json +2 -5
- package/src/DeployUtils.sol +113 -77
- package/src/IIncoLightning.sol +16 -9
- package/src/IncoLightning.sol +18 -9
- package/src/IncoVerifier.sol +47 -0
- package/src/Lib.alphanet.sol +2 -15
- package/src/Lib.demonet.sol +2 -15
- package/src/Lib.devnet.sol +3 -16
- package/src/Lib.sol +3 -16
- package/src/Lib.template.sol +3 -44
- package/src/Lib.testnet.sol +2 -15
- package/src/Types.sol +7 -0
- package/src/interfaces/IIncoLightning.sol +20 -0
- package/src/interfaces/IIncoVerifier.sol +24 -0
- package/src/interfaces/automata-interfaces/BELE.sol +20 -0
- package/src/interfaces/automata-interfaces/IAutomataEnclaveIdentityDao.sol +28 -0
- package/src/interfaces/automata-interfaces/IFmspcTcbDao.sol +10 -0
- package/src/interfaces/automata-interfaces/IPCCSRouter.sol +94 -0
- package/src/interfaces/automata-interfaces/IPCCSRouterExtended.sol +10 -0
- package/src/interfaces/automata-interfaces/IPcsDao.sol +18 -0
- package/src/interfaces/automata-interfaces/IQuoteVerifier.sol +34 -0
- package/src/interfaces/automata-interfaces/Types.sol +193 -0
- package/src/libs/incoLightning_alphanet_v0_297966649.sol +2 -15
- package/src/libs/incoLightning_demonet_v0_863421733.sol +2 -15
- package/src/libs/incoLightning_devnet_v0_340846814.sol +2 -15
- package/src/libs/incoLightning_devnet_v1_887305889.sol +451 -0
- package/src/libs/incoLightning_testnet_v0_183408998.sol +2 -15
- package/src/libs/incoLightning_testnet_v1_938327937.sol +451 -0
- package/src/lightning-parts/AccessControl/AdvancedAccessControl.sol +133 -0
- package/src/lightning-parts/AccessControl/AdvancedAccessControl.types.sol +18 -0
- package/src/lightning-parts/AccessControl/BaseAccessControlList.sol +22 -2
- package/src/lightning-parts/AccessControl/interfaces/IAdvancedAccessControl.sol +25 -0
- package/src/lightning-parts/AccessControl/interfaces/IBaseAccessControlList.sol +24 -0
- package/src/lightning-parts/AccessControl/test/TestAdvancedAccessControl.t.sol +234 -0
- package/src/lightning-parts/AccessControl/test/TestBaseAccessControl.t.sol +4 -3
- package/src/lightning-parts/DecryptionAttester.sol +45 -0
- package/src/lightning-parts/DecryptionAttester.types.sol +7 -0
- package/src/lightning-parts/EncryptedInput.sol +8 -13
- package/src/lightning-parts/EncryptedOperations.sol +2 -2
- package/src/lightning-parts/TEELifecycle.sol +180 -88
- package/src/lightning-parts/TrivialEncryption.sol +8 -10
- package/src/lightning-parts/interfaces/IDecryptionAttester.sol +9 -0
- package/src/lightning-parts/interfaces/IEncryptedInput.sol +19 -0
- package/src/lightning-parts/interfaces/IEncryptedOperations.sol +31 -0
- package/src/lightning-parts/interfaces/ITEELifecycle.sol +26 -0
- package/src/lightning-parts/interfaces/ITrivialEncryption.sol +10 -0
- package/src/lightning-parts/primitives/EventCounter.sol +2 -2
- package/src/lightning-parts/primitives/HandleGeneration.sol +8 -3
- package/src/lightning-parts/primitives/HandleMetadata.sol +1 -1
- package/src/lightning-parts/primitives/LightningAddressGetter.sol +10 -0
- package/src/lightning-parts/primitives/SignatureVerifier.sol +2 -9
- package/src/lightning-parts/primitives/VerifierAddressGetter.sol +13 -0
- package/src/lightning-parts/primitives/{EventCounter.gen.sol → interfaces/IEventCounter.sol} +2 -2
- package/src/lightning-parts/primitives/interfaces/IHandleGeneration.sol +41 -0
- package/src/lightning-parts/primitives/interfaces/ISignatureVerifier.sol +9 -0
- package/src/lightning-parts/primitives/interfaces/IVerifierAddressGetter.sol +8 -0
- package/src/lightning-parts/test/HandleMetadata.t.sol +25 -6
- package/src/lightning-parts/test/TestDecryptionAttestationInSynchronousFlow.t.sol +78 -0
- package/src/periphery/SessionVerifier.sol +63 -0
- package/src/test/AddTwo.sol +18 -33
- package/src/test/FakeIncoInfra/FakeDecryptionAttester.sol +198 -0
- package/src/test/FakeIncoInfra/FakeIncoInfraBase.sol +0 -15
- package/src/test/FakeIncoInfra/FakeQuoteVerifier.sol +10 -6
- package/src/test/FakeIncoInfra/MockOpHandler.sol +0 -7
- package/src/test/FakeIncoInfra/MockRemoteAttestation.sol +19 -7
- package/src/test/FakeIncoInfra/getOpForSelector.sol +0 -3
- package/src/test/IncoTest.sol +12 -11
- package/src/test/TEELifecycle/TEELifecycleMockTest.t.sol +98 -77
- package/src/test/TestAddTwo.t.sol +16 -9
- package/src/test/TestFakeInfra.t.sol +10 -27
- package/src/test/TestUpgrade.t.sol +11 -4
- package/src/test/TestVersion.t.sol +0 -7
- package/src/version/IncoLightningConfig.sol +5 -4
- package/src/version/SessionVerifierConfig.sol +8 -0
- package/src/version/Version.sol +7 -9
- package/src/version/interfaces/IVersion.sol +8 -0
- package/src/DeployTEE.sol +0 -153
- package/src/IncoLightning.gen.sol +0 -15
- package/src/lightning-parts/AccessControl/BaseAccessControlList.gen.sol +0 -24
- package/src/lightning-parts/DecryptionHandler.gen.sol +0 -54
- package/src/lightning-parts/DecryptionHandler.sol +0 -307
- package/src/lightning-parts/DecryptionHandler.types.sol +0 -34
- package/src/lightning-parts/EncryptedInput.gen.sol +0 -16
- package/src/lightning-parts/EncryptedOperations.gen.sol +0 -59
- package/src/lightning-parts/TEELifecycle.gen.sol +0 -58
- package/src/lightning-parts/TrivialEncryption.gen.sol +0 -15
- package/src/lightning-parts/primitives/HandleGeneration.gen.sol +0 -19
- package/src/lightning-parts/primitives/HandleMetadata.gen.sol +0 -4
- package/src/lightning-parts/primitives/SignatureVerifier.gen.sol +0 -16
- package/src/test/FibonacciDecrypt.sol +0 -49
- package/src/test/TEELifecycle/TEELifecycleHWTest.t.sol +0 -119
- package/src/test/TEELifecycle/addnode_data/eoa.txt +0 -1
- package/src/test/TEELifecycle/addnode_data/quote.bin +0 -0
- package/src/test/TEELifecycle/bootstrap_data/ecies_pubkey.bin +0 -1
- package/src/test/TEELifecycle/bootstrap_data/eip712_signature.bin +0 -1
- package/src/test/TEELifecycle/bootstrap_data/eoa.txt +0 -1
- package/src/test/TEELifecycle/bootstrap_data/qe_identity +0 -1
- package/src/test/TEELifecycle/bootstrap_data/qe_identity_signature.bin +0 -1
- package/src/test/TEELifecycle/bootstrap_data/quote.bin +0 -0
- package/src/test/TEELifecycle/bootstrap_data/tcb_info +0 -1
- package/src/test/TEELifecycle/bootstrap_data/tcb_info_signature.bin +0 -1
- package/src/test/TEELifecycle/test_cert/AttestationReportSigningCA.crl +0 -0
- package/src/test/TEELifecycle/test_cert/Intel_SGX_Attestation_RootCA.cer +0 -0
- package/src/test/TEELifecycle/test_cert/Intel_SGX_PCK_CRL.crl +0 -0
- package/src/test/TEELifecycle/test_cert/Intel_SGX_PCK_PlatformCA.cer +0 -0
- package/src/test/TEELifecycle/test_cert/Intel_SGX_TCB_Signing.cer +0 -0
- 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
|
}
|
package/src/test/IncoTest.sol
CHANGED
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
pragma solidity ^0.8;
|
|
3
3
|
|
|
4
4
|
import {MockOpHandler} from "./FakeIncoInfra/MockOpHandler.sol";
|
|
5
|
-
import {
|
|
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
|
-
|
|
32
|
+
(IIncoLightning proxy, ) = deployIncoLightningUsingConfig({
|
|
31
33
|
deployer: testDeployer,
|
|
32
|
-
|
|
34
|
+
// The highest precedent deployment
|
|
33
35
|
pepper: "testnet",
|
|
34
|
-
|
|
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.
|
|
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 "
|
|
5
|
-
import "
|
|
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
|
|
19
|
-
(
|
|
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
|
-
|
|
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(
|
|
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
|
|
49
|
-
(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
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
|
|
64
|
-
(
|
|
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
|
-
|
|
69
|
-
|
|
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
|
|
92
|
+
function testApproveNewTEEInvalidMrtd() public {
|
|
82
93
|
bytes memory mrtd = hex"deadbeef";
|
|
83
94
|
vm.startPrank(this.owner());
|
|
84
|
-
vm.expectRevert(
|
|
95
|
+
vm.expectRevert(TEELifecycle.MrtdInvalidLength.selector);
|
|
85
96
|
this.approveNewTEEVersion(mrtd);
|
|
86
97
|
vm.stopPrank();
|
|
87
98
|
}
|
|
88
99
|
|
|
89
|
-
function
|
|
90
|
-
bytes
|
|
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(
|
|
106
|
+
vm.expectRevert(TEELifecycle.BootstrapNotComplete.selector);
|
|
95
107
|
this.addNewCovalidator(quote);
|
|
96
108
|
vm.stopPrank();
|
|
97
109
|
}
|
|
98
110
|
|
|
99
|
-
function
|
|
100
|
-
(
|
|
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
|
-
|
|
105
|
-
|
|
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(
|
|
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()
|
|
119
|
-
|
|
120
|
-
|
|
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
|
-
|
|
11
|
-
|
|
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
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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(
|
|
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
|
-
|
|
11
|
-
|
|
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
|
|
294
|
+
bytes
|
|
295
|
+
memory mrtd = hex"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef";
|
|
314
296
|
address signer = address(0x1234567890123456789012345678901234567890);
|
|
315
297
|
bytes memory quote = createQuote(mrtd, signer);
|
|
316
|
-
TEELifecycle lifecycle =
|
|
298
|
+
TEELifecycle lifecycle = TEELifecycle(address(inco.incoVerifier()));
|
|
317
299
|
TD10ReportBody memory tdReport = lifecycle.parseTD10ReportBody(quote);
|
|
318
|
-
(address reportDataSigner, bytes memory reportMrtd) = lifecycle
|
|
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()
|
|
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 =
|
|
12
|
-
uint8 constant MINOR_VERSION =
|
|
13
|
-
uint8 constant PATCH_VERSION =
|
|
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("");
|
package/src/version/Version.sol
CHANGED
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
pragma solidity ^0.8;
|
|
3
3
|
|
|
4
4
|
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
|
|
5
|
-
import {
|
|
6
|
-
|
|
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
|
|
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
|
+
}
|