@inco/lightning 0.5.2 → 0.6.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.
- package/manifest.yaml +23 -9
- package/package.json +1 -2
- package/src/DeployUtils.sol +10 -19
- package/src/Lib.alphanet.sol +12 -6
- package/src/Lib.demonet.sol +12 -6
- package/src/Lib.devnet.sol +13 -7
- package/src/Lib.sol +13 -7
- package/src/Lib.template.sol +12 -6
- package/src/Lib.testnet.sol +12 -6
- package/src/Types.sol +4 -1
- package/src/libs/incoLightning_alphanet_v0_297966649.sol +12 -6
- package/src/libs/incoLightning_demonet_v0_863421733.sol +12 -6
- package/src/libs/incoLightning_devnet_v0_340846814.sol +12 -6
- package/src/libs/incoLightning_devnet_v1_904635675.sol +457 -0
- package/src/libs/incoLightning_testnet_v0_183408998.sol +12 -6
- package/src/lightning-parts/AccessControl/BaseAccessControlList.sol +21 -5
- package/src/lightning-parts/AccessControl/test/TestAdvancedAccessControl.t.sol +1 -0
- package/src/lightning-parts/EncryptedInput.sol +22 -6
- package/src/lightning-parts/EncryptedOperations.sol +6 -6
- package/src/lightning-parts/Fee.sol +41 -0
- package/src/lightning-parts/TEELifecycle.sol +170 -67
- package/src/lightning-parts/TEELifecycle.types.sol +9 -12
- package/src/lightning-parts/TrivialEncryption.sol +1 -1
- package/src/lightning-parts/interfaces/IEncryptedInput.sol +3 -3
- package/src/lightning-parts/interfaces/IEncryptedOperations.sol +48 -1
- package/src/lightning-parts/interfaces/ITEELifecycle.sol +2 -2
- package/src/lightning-parts/test/Fee.t.sol +101 -0
- package/src/lightning-parts/test/HandleMetadata.t.sol +4 -3
- package/src/lightning-parts/test/InputsFee.t.sol +65 -0
- package/src/lightning-parts/test/TestDecryptionAttestationInSynchronousFlow.t.sol +1 -0
- package/src/test/AddTwo.sol +18 -6
- package/src/test/FakeIncoInfra/FakeIncoInfraBase.sol +12 -0
- package/src/test/FakeIncoInfra/MockRemoteAttestation.sol +6 -0
- package/src/test/FakeIncoInfra/getOpForSelector.sol +5 -0
- package/src/test/IncoTest.sol +1 -0
- package/src/test/TEELifecycle/TEELifecycleMockTest.t.sol +21 -26
- package/src/test/TestAddTwo.t.sol +9 -1
- package/src/test/TestFakeInfra.t.sol +12 -3
- package/src/version/IncoLightningConfig.sol +3 -1
- package/src/test/TEELifecycle/README.md +0 -53
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// SPDX-License-Identifier: No License
|
|
2
|
+
pragma solidity ^0.8;
|
|
3
|
+
|
|
4
|
+
import {Test} from "forge-std/Test.sol";
|
|
5
|
+
import {EncryptedInput} from "../EncryptedInput.sol";
|
|
6
|
+
import {VerifierAddressGetter} from "../primitives/VerifierAddressGetter.sol";
|
|
7
|
+
import {FEE, Fee} from "../Fee.sol";
|
|
8
|
+
import {IncoTest} from "../../test/IncoTest.sol";
|
|
9
|
+
|
|
10
|
+
contract InputsTester is EncryptedInput {
|
|
11
|
+
constructor() VerifierAddressGetter(address(0)) {}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
contract TestInputsFee is IncoTest {
|
|
15
|
+
InputsTester inputsTester;
|
|
16
|
+
|
|
17
|
+
function setUp() public override {
|
|
18
|
+
inputsTester = new InputsTester();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function testPayOnInputs() public {
|
|
22
|
+
// should fail if no fee
|
|
23
|
+
vm.expectRevert(Fee.FeeNotPaid.selector);
|
|
24
|
+
inputsTester.newEuint256{value: 0}(
|
|
25
|
+
fakePrepareEuint256Ciphertext(12),
|
|
26
|
+
address(0)
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
// should fail if not enough fee
|
|
30
|
+
vm.expectRevert(Fee.FeeNotPaid.selector);
|
|
31
|
+
inputsTester.newEuint256{value: FEE - 1}(
|
|
32
|
+
fakePrepareEuint256Ciphertext(12),
|
|
33
|
+
address(0)
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
// should fail if too much fee
|
|
37
|
+
vm.expectRevert(Fee.FeeNotPaid.selector);
|
|
38
|
+
inputsTester.newEuint256{value: FEE + 1}(
|
|
39
|
+
fakePrepareEuint256Ciphertext(12),
|
|
40
|
+
address(0)
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
// should work with exact fee
|
|
44
|
+
inputsTester.newEuint256{value: FEE}(
|
|
45
|
+
fakePrepareEuint256Ciphertext(12),
|
|
46
|
+
address(0)
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function testPayForNewEbool() public {
|
|
51
|
+
// should work with exact fee
|
|
52
|
+
inputsTester.newEbool{value: FEE}(
|
|
53
|
+
fakePrepareEboolCiphertext(true),
|
|
54
|
+
address(0)
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function testPayForNewEaddress() public {
|
|
59
|
+
// should work with exact fee
|
|
60
|
+
inputsTester.newEaddress{value: FEE}(
|
|
61
|
+
fakePrepareEaddressCiphertext(address(this)),
|
|
62
|
+
address(0)
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -35,6 +35,7 @@ contract TestDecryptionAttestationInSynchronousFlow is IncoTest {
|
|
|
35
35
|
AllowanceProof emptyProof; // no proof needed when requester has the handle in persisted allowed pairs
|
|
36
36
|
function testSynchronousBurning() public {
|
|
37
37
|
TokenBurnCurrentBalance token = new TokenBurnCurrentBalance();
|
|
38
|
+
vm.deal(address(token), 100 ether);
|
|
38
39
|
token.confidentialTransfer(
|
|
39
40
|
alice,
|
|
40
41
|
fakePrepareEuint256Ciphertext(10 * GWEI),
|
package/src/test/AddTwo.sol
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
// SPDX-License-Identifier: No License
|
|
2
2
|
pragma solidity ^0.8;
|
|
3
3
|
|
|
4
|
-
import {euint256} from "../Types.sol";
|
|
4
|
+
import {euint256, ebool} from "../Types.sol";
|
|
5
5
|
import {IncoLightning} from "../IncoLightning.sol";
|
|
6
|
-
|
|
7
|
-
// import {console} from "forge-std/console.sol";
|
|
6
|
+
import {Fee} from "../lightning-parts/Fee.sol";
|
|
8
7
|
|
|
9
8
|
// To implement such a contract, we would normally import e form Lib.sol. For test purposes, we take inco as
|
|
10
9
|
// a constructor argument instead, so we can test it from other deployment addresses.
|
|
11
|
-
contract AddTwo {
|
|
10
|
+
contract AddTwo is Fee {
|
|
12
11
|
IncoLightning inco;
|
|
13
12
|
|
|
14
13
|
constructor(IncoLightning _inco) {
|
|
@@ -31,8 +30,11 @@ contract AddTwo {
|
|
|
31
30
|
|
|
32
31
|
function addTwoEOA(
|
|
33
32
|
bytes memory uint256EInput
|
|
34
|
-
) external returns (euint256 result, euint256 resultRevealed) {
|
|
35
|
-
euint256 value = inco.newEuint256(
|
|
33
|
+
) external payable refundUnspent returns (euint256 result, euint256 resultRevealed) {
|
|
34
|
+
euint256 value = inco.newEuint256{value: getFee()}(
|
|
35
|
+
uint256EInput,
|
|
36
|
+
msg.sender
|
|
37
|
+
);
|
|
36
38
|
result = addTwo(value);
|
|
37
39
|
|
|
38
40
|
inco.allow(euint256.unwrap(result), address(this));
|
|
@@ -43,4 +45,14 @@ contract AddTwo {
|
|
|
43
45
|
resultRevealed = addTwoAlt(value);
|
|
44
46
|
inco.reveal(euint256.unwrap(resultRevealed));
|
|
45
47
|
}
|
|
48
|
+
|
|
49
|
+
function getTrue() external returns (ebool) {
|
|
50
|
+
ebool trueHandle = inco.asEbool(true);
|
|
51
|
+
inco.reveal(ebool.unwrap(trueHandle));
|
|
52
|
+
return trueHandle;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
receive() external payable {
|
|
56
|
+
// Accept ETH payments
|
|
57
|
+
}
|
|
46
58
|
}
|
|
@@ -47,6 +47,18 @@ contract FakeIncoInfraBase is TestUtils, KVStore {
|
|
|
47
47
|
ciphertext = abi.encode(value);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
function fakePrepareEaddressCiphertext(
|
|
51
|
+
address value
|
|
52
|
+
) internal pure returns (bytes memory ciphertext) {
|
|
53
|
+
ciphertext = abi.encode(value);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function fakeDecryptEaddressCiphertext(
|
|
57
|
+
bytes memory ciphertext
|
|
58
|
+
) internal pure returns (address value) {
|
|
59
|
+
value = abi.decode(ciphertext, (address));
|
|
60
|
+
}
|
|
61
|
+
|
|
50
62
|
function fakeDecryptEboolCiphertext(
|
|
51
63
|
bytes memory ciphertext
|
|
52
64
|
) internal pure returns (bool value) {
|
|
@@ -9,6 +9,12 @@ import {
|
|
|
9
9
|
} from "../../interfaces/automata-interfaces/Types.sol";
|
|
10
10
|
|
|
11
11
|
contract MockRemoteAttestation is TestUtils {
|
|
12
|
+
/**
|
|
13
|
+
* @notice Creates a mock quote for the given MRTD and signer
|
|
14
|
+
* The RTMR0, RTMR1, RTMR2 are set to zeros
|
|
15
|
+
* @dev This function is the same as the non-TDX version of
|
|
16
|
+
* get_tdx_quote in attestation/src/remote_attestation.rs
|
|
17
|
+
*/
|
|
12
18
|
function createQuote(
|
|
13
19
|
bytes memory mrtd,
|
|
14
20
|
address signer
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: No License
|
|
2
2
|
pragma solidity ^0.8;
|
|
3
3
|
|
|
4
|
+
import {BaseAccessControlList} from "../../lightning-parts/AccessControl/BaseAccessControlList.sol";
|
|
4
5
|
import {EncryptedOperations} from "../../lightning-parts/EncryptedOperations.sol";
|
|
5
6
|
import {TrivialEncryption} from "../../lightning-parts/TrivialEncryption.sol";
|
|
6
7
|
import {EncryptedInput} from "../../lightning-parts/EncryptedInput.sol";
|
|
@@ -62,6 +63,10 @@ function getOpForSelector(bytes32 opEventSelector) pure returns (EOps) {
|
|
|
62
63
|
return EOps.Rand;
|
|
63
64
|
} else if (opEventSelector == EncryptedOperations.ERandBounded.selector) {
|
|
64
65
|
return EOps.RandBounded;
|
|
66
|
+
} else if (opEventSelector == BaseAccessControlList.Allow.selector) {
|
|
67
|
+
return EOps.Allow;
|
|
68
|
+
} else if (opEventSelector == BaseAccessControlList.Reveal.selector) {
|
|
69
|
+
return EOps.Reveal;
|
|
65
70
|
} else {
|
|
66
71
|
revert("getOpForSelector: Unsupported selector");
|
|
67
72
|
}
|
package/src/test/IncoTest.sol
CHANGED
|
@@ -32,6 +32,7 @@ contract IncoTest is MockOpHandler, DeployUtils, FakeDecryptionAttester {
|
|
|
32
32
|
(IIncoLightning proxy, ) = deployIncoLightningUsingConfig({
|
|
33
33
|
deployer: testDeployer,
|
|
34
34
|
// The highest precedent deployment
|
|
35
|
+
// We select the pepper that will be used that will be generated in the lib.sol (usually "testnet"), but currently "devnet" has higher major version
|
|
35
36
|
pepper: "devnet",
|
|
36
37
|
quoteVerifier: new FakeQuoteVerifier()
|
|
37
38
|
});
|
|
@@ -19,10 +19,10 @@ contract TEELifecycleMockTest is Test, MockRemoteAttestation, TEELifecycle {
|
|
|
19
19
|
,
|
|
20
20
|
bytes memory quote,
|
|
21
21
|
bytes memory signature,
|
|
22
|
-
|
|
22
|
+
bytes32 mrAggregated
|
|
23
23
|
) = successfulBootstrapResult();
|
|
24
24
|
vm.startPrank(this.owner());
|
|
25
|
-
this.approveNewTEEVersion(
|
|
25
|
+
this.approveNewTEEVersion(mrAggregated);
|
|
26
26
|
this.verifyBootstrapResult(bootstrapResult, quote, signature);
|
|
27
27
|
assertTrue(this.isBootstrapComplete(), "Bootstrap should be complete");
|
|
28
28
|
vm.stopPrank();
|
|
@@ -38,13 +38,13 @@ contract TEELifecycleMockTest is Test, MockRemoteAttestation, TEELifecycle {
|
|
|
38
38
|
address bootstrapPartyAddress,
|
|
39
39
|
bytes memory quote,
|
|
40
40
|
bytes memory signature,
|
|
41
|
-
|
|
41
|
+
bytes32 mrAggregated
|
|
42
42
|
) = successfulBootstrapResult();
|
|
43
43
|
|
|
44
44
|
quote = createQuote(badMrtd, bootstrapPartyAddress); // Replace with bad MRTD
|
|
45
45
|
vm.startPrank(this.owner());
|
|
46
|
-
this.approveNewTEEVersion(
|
|
47
|
-
vm.expectRevert(TEELifecycle.
|
|
46
|
+
this.approveNewTEEVersion(mrAggregated);
|
|
47
|
+
vm.expectRevert(TEELifecycle.InvalidReportMrAggregated.selector);
|
|
48
48
|
this.verifyBootstrapResult(bootstrapResult, quote, signature);
|
|
49
49
|
vm.stopPrank();
|
|
50
50
|
}
|
|
@@ -56,7 +56,7 @@ contract TEELifecycleMockTest is Test, MockRemoteAttestation, TEELifecycle {
|
|
|
56
56
|
,
|
|
57
57
|
bytes memory quote,
|
|
58
58
|
,
|
|
59
|
-
|
|
59
|
+
bytes32 mrAggregated
|
|
60
60
|
) = successfulBootstrapResult();
|
|
61
61
|
(uint256 bootstrapPartyFakePrivkey, ) = getLabeledKeyPair(
|
|
62
62
|
"bootstrapPartyFake"
|
|
@@ -66,8 +66,8 @@ contract TEELifecycleMockTest is Test, MockRemoteAttestation, TEELifecycle {
|
|
|
66
66
|
bootstrapPartyFakePrivkey
|
|
67
67
|
);
|
|
68
68
|
vm.startPrank(this.owner());
|
|
69
|
-
this.approveNewTEEVersion(
|
|
70
|
-
vm.expectRevert(TEELifecycle.
|
|
69
|
+
this.approveNewTEEVersion(mrAggregated);
|
|
70
|
+
vm.expectRevert(TEELifecycle.InvalidEIP712Signature.selector);
|
|
71
71
|
this.verifyBootstrapResult(bootstrapResult, quote, signatureInvalid);
|
|
72
72
|
vm.stopPrank();
|
|
73
73
|
}
|
|
@@ -79,29 +79,21 @@ contract TEELifecycleMockTest is Test, MockRemoteAttestation, TEELifecycle {
|
|
|
79
79
|
,
|
|
80
80
|
bytes memory quote,
|
|
81
81
|
bytes memory signature,
|
|
82
|
-
|
|
82
|
+
bytes32 mrAggregated
|
|
83
83
|
) = successfulBootstrapResult();
|
|
84
84
|
vm.startPrank(this.owner());
|
|
85
|
-
this.approveNewTEEVersion(
|
|
85
|
+
this.approveNewTEEVersion(mrAggregated);
|
|
86
86
|
this.verifyBootstrapResult(bootstrapResult, quote, signature);
|
|
87
87
|
vm.expectRevert(TEELifecycle.BootstrapAlreadyCompleted.selector);
|
|
88
88
|
this.verifyBootstrapResult(bootstrapResult, quote, signature);
|
|
89
89
|
vm.stopPrank();
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
function testApproveNewTEEInvalidMrtd() public {
|
|
93
|
-
bytes memory mrtd = hex"deadbeef";
|
|
94
|
-
vm.startPrank(this.owner());
|
|
95
|
-
vm.expectRevert(TEELifecycle.MrtdInvalidLength.selector);
|
|
96
|
-
this.approveNewTEEVersion(mrtd);
|
|
97
|
-
vm.stopPrank();
|
|
98
|
-
}
|
|
99
|
-
|
|
100
92
|
function testBootstrapNotCompleteNewCoval() public {
|
|
101
93
|
bytes
|
|
102
|
-
memory
|
|
94
|
+
memory mrAggregated = hex"2a90c8fa38672cafd791d994beb6836b99383b2563736858632284f0f760a6446efd1e7ec457cf08b629ea630f7b4525";
|
|
103
95
|
(, address newCoval) = getLabeledKeyPair("newCoval");
|
|
104
|
-
bytes memory quote = createQuote(
|
|
96
|
+
bytes memory quote = createQuote(mrAggregated, newCoval);
|
|
105
97
|
vm.startPrank(this.owner());
|
|
106
98
|
vm.expectRevert(TEELifecycle.BootstrapNotComplete.selector);
|
|
107
99
|
this.addNewCovalidator(quote);
|
|
@@ -115,17 +107,17 @@ contract TEELifecycleMockTest is Test, MockRemoteAttestation, TEELifecycle {
|
|
|
115
107
|
,
|
|
116
108
|
bytes memory quote,
|
|
117
109
|
bytes memory signature,
|
|
118
|
-
|
|
110
|
+
bytes32 mrAggregated
|
|
119
111
|
) = successfulBootstrapResult();
|
|
120
112
|
vm.startPrank(this.owner());
|
|
121
|
-
this.approveNewTEEVersion(
|
|
113
|
+
this.approveNewTEEVersion(mrAggregated);
|
|
122
114
|
this.verifyBootstrapResult(bootstrapResult, quote, signature);
|
|
123
115
|
bytes
|
|
124
116
|
memory badMrtd = hex"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef";
|
|
125
117
|
(, address newCoval) = getLabeledKeyPair("newCoval");
|
|
126
118
|
bytes memory quoteNew = createQuote(badMrtd, newCoval);
|
|
127
119
|
|
|
128
|
-
vm.expectRevert(TEELifecycle.
|
|
120
|
+
vm.expectRevert(TEELifecycle.TEEVersionNotFound.selector);
|
|
129
121
|
this.addNewCovalidator(quoteNew);
|
|
130
122
|
vm.stopPrank();
|
|
131
123
|
}
|
|
@@ -139,7 +131,7 @@ contract TEELifecycleMockTest is Test, MockRemoteAttestation, TEELifecycle {
|
|
|
139
131
|
address bootstrapPartyAddress,
|
|
140
132
|
bytes memory quote,
|
|
141
133
|
bytes memory signature,
|
|
142
|
-
|
|
134
|
+
bytes32 mrAggregated
|
|
143
135
|
)
|
|
144
136
|
{
|
|
145
137
|
(bootstrapPartyPrivkey, bootstrapPartyAddress) = getLabeledKeyPair(
|
|
@@ -147,8 +139,11 @@ contract TEELifecycleMockTest is Test, MockRemoteAttestation, TEELifecycle {
|
|
|
147
139
|
);
|
|
148
140
|
bytes
|
|
149
141
|
memory eciesPubkey = hex"04ff5c6dd72ad7583288b84ee2598e081fe0bc6ef543c342e925a5dfcff9afb2444d25454d7d5dcfadc9ed99477c245efa93caf58d7f58143300d81cc948e7bdf5";
|
|
150
|
-
|
|
151
|
-
|
|
142
|
+
// See DEFAULT_MRTD in attestation/src/remote_attestation.rs
|
|
143
|
+
bytes memory mrtd = hex"010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101";
|
|
144
|
+
// See DEFAULT_MR_AGGREGATED in attestation/src/remote_attestation.rs to
|
|
145
|
+
// see the calculation of the default value.
|
|
146
|
+
mrAggregated = hex"c3a67bac251d4946d7b17481d39631676042fe3afab06e70c22105ad8383c19f";
|
|
152
147
|
bootstrapResult = BootstrapResult({ecies_pubkey: eciesPubkey});
|
|
153
148
|
|
|
154
149
|
quote = createQuote(mrtd, bootstrapPartyAddress);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
pragma solidity ^0.8;
|
|
3
3
|
|
|
4
4
|
import {inco} from "../Lib.sol";
|
|
5
|
-
import {euint256} from "../Types.sol";
|
|
5
|
+
import {euint256, ebool} from "../Types.sol";
|
|
6
6
|
import {IncoTest} from "./IncoTest.sol";
|
|
7
7
|
import {AddTwo} from "./AddTwo.sol";
|
|
8
8
|
|
|
@@ -12,6 +12,7 @@ contract TestAddTwo is IncoTest {
|
|
|
12
12
|
function setUp() public override {
|
|
13
13
|
super.setUp();
|
|
14
14
|
addTwo = new AddTwo(inco);
|
|
15
|
+
vm.deal(address(addTwo), 1 ether);
|
|
15
16
|
vm.label(address(addTwo), "addTwo");
|
|
16
17
|
}
|
|
17
18
|
|
|
@@ -33,4 +34,11 @@ contract TestAddTwo is IncoTest {
|
|
|
33
34
|
assertFalse(inco.isAllowed(euint256.unwrap(result), bob));
|
|
34
35
|
assertTrue(inco.isAllowed(euint256.unwrap(revealedResult), bob));
|
|
35
36
|
}
|
|
37
|
+
|
|
38
|
+
function testTrueHandleReveal() public {
|
|
39
|
+
ebool trueVal = addTwo.getTrue();
|
|
40
|
+
processAllOperations();
|
|
41
|
+
assertEq(getBoolValue(trueVal), true);
|
|
42
|
+
assertTrue(inco.isAllowed(ebool.unwrap(trueVal), bob));
|
|
43
|
+
}
|
|
36
44
|
}
|
|
@@ -270,6 +270,7 @@ contract TestFakeInfra is IncoTest, MockRemoteAttestation {
|
|
|
270
270
|
|
|
271
271
|
function testEInput() public {
|
|
272
272
|
TakesEInput inputContract = new TakesEInput();
|
|
273
|
+
vm.deal(address(inputContract), 1 ether);
|
|
273
274
|
inputContract.setA(fakePrepareEuint256Ciphertext(12));
|
|
274
275
|
inputContract.setB(fakePrepareEboolCiphertext(true));
|
|
275
276
|
processAllOperations();
|
|
@@ -290,17 +291,25 @@ contract TestFakeInfra is IncoTest, MockRemoteAttestation {
|
|
|
290
291
|
a.add(euint256.wrap(randomHandle));
|
|
291
292
|
}
|
|
292
293
|
|
|
293
|
-
function testCreateQuote() public {
|
|
294
|
+
function testCreateQuote() public view {
|
|
294
295
|
bytes
|
|
295
296
|
memory mrtd = hex"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef";
|
|
296
297
|
address signer = address(0x1234567890123456789012345678901234567890);
|
|
297
298
|
bytes memory quote = createQuote(mrtd, signer);
|
|
298
299
|
TEELifecycle lifecycle = TEELifecycle(address(inco.incoVerifier()));
|
|
299
300
|
TD10ReportBody memory tdReport = lifecycle.parseTD10ReportBody(quote);
|
|
300
|
-
(address reportDataSigner,
|
|
301
|
+
(address reportDataSigner, bytes32 reportMrAggregated) = lifecycle
|
|
301
302
|
.parseReport(tdReport);
|
|
302
303
|
assertEq(reportDataSigner, signer);
|
|
303
|
-
assertEq(
|
|
304
|
+
assertEq(
|
|
305
|
+
reportMrAggregated,
|
|
306
|
+
lifecycle.computeMrAggregated(
|
|
307
|
+
tdReport.mrTd,
|
|
308
|
+
tdReport.rtMr0,
|
|
309
|
+
tdReport.rtMr1,
|
|
310
|
+
tdReport.rtMr2
|
|
311
|
+
)
|
|
312
|
+
);
|
|
304
313
|
assertEq(quote.length, MINIMUM_QUOTE_LENGTH);
|
|
305
314
|
}
|
|
306
315
|
}
|
|
@@ -9,6 +9,8 @@ pragma solidity ^0.8;
|
|
|
9
9
|
string constant CONTRACT_NAME = "incoLightning";
|
|
10
10
|
uint8 constant MAJOR_VERSION = 1;
|
|
11
11
|
uint8 constant MINOR_VERSION = 0;
|
|
12
|
-
|
|
12
|
+
// whenever a new major version is deployed, we need to pump this up
|
|
13
|
+
// otherwise make test_upgrade will fail
|
|
14
|
+
uint8 constant PATCH_VERSION = 2;
|
|
13
15
|
|
|
14
16
|
string constant VERIFIER_NAME = "incoVerifier";
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# TEE Lifecycle Test
|
|
2
|
-
|
|
3
|
-
## TEELifecycle HW Test
|
|
4
|
-
|
|
5
|
-
This test data was generated using Adrian's V0 TDX VM running in GCP. The data
|
|
6
|
-
was returned collected using the `agent-lib` tool.
|
|
7
|
-
|
|
8
|
-
* To generate new test data: for `test_LifecycleBootstrap`
|
|
9
|
-
|
|
10
|
-
```bash
|
|
11
|
-
cd agent-lib
|
|
12
|
-
|
|
13
|
-
cargo run --features hw -- start-bootstrap \
|
|
14
|
-
--expected-mrtd 0x409c0cd3e63d9ea54d817cf851983a220131262664ac8cd02cc6a2e19fd291d2fdd0cc035d7789b982a43a92a4424c99 \
|
|
15
|
-
--tee-lifecycle-grpc-url http://34.91.236.235:4321 \
|
|
16
|
-
--output-dir ../contracts/lightning/src/test/TEELifecycle/bootstrap_data
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
* To generate new test data for `test_LifecycleNewEOA`
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
cd agent-lib
|
|
23
|
-
|
|
24
|
-
# TODO: change this to add-node endpoint after https://github.com/Inco-fhevm/inco-monorepo/issues/889
|
|
25
|
-
cargo run --features hw -- start-bootstrap \
|
|
26
|
-
--expected-mrtd 0x409c0cd3e63d9ea54d817cf851983a220131262664ac8cd02cc6a2e19fd291d2fdd0cc035d7789b982a43a92a4424c99 \
|
|
27
|
-
--tee-lifecycle-grpc-url http://34.91.236.235:4321 \
|
|
28
|
-
--output-dir ../contracts/lightning/src/test/TEELifecycle/addnode_data
|
|
29
|
-
|
|
30
|
-
# Delete the unused output data since it is not used
|
|
31
|
-
# to add a node
|
|
32
|
-
rm ../contracts/lightning/src/test/TEELifecycle/addnode_data/ecies_pubkey.bin
|
|
33
|
-
rm ../contracts/lightning/src/test/TEELifecycle/addnode_data/eip712_signature.bin
|
|
34
|
-
rm ../contracts/lightning/src/test/TEELifecycle/addnode_data/qe_identity
|
|
35
|
-
rm ../contracts/lightning/src/test/TEELifecycle/addnode_data/qe_identity_signature.bin
|
|
36
|
-
rm ../contracts/lightning/src/test/TEELifecycle/addnode_data/tcb_info
|
|
37
|
-
rm ../contracts/lightning/src/test/TEELifecycle/addnode_data/tcb_info_signature.bin
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
* To generate the Intel root certificates
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
cd contracts/lightning/src/test/TEELifecycle/test_cert
|
|
44
|
-
python3 -m pip install -r ../../../../../lightning-deployment/script/tee/requirements.txt
|
|
45
|
-
python3 ../../../../../lightning-deployment/script/tee/get_ca_certs.py
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
* Hard code the block timestamp to the current time to ensure that there is no certificate out of date errors
|
|
49
|
-
by setting `uint256 collateral_timestamp =` in [TEELifecycleHWTest.t](TEELifecycleHWTest.t.sol#24) to the output of:
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
echo $(date +%s)
|
|
53
|
-
```
|