@inco/lightning 0.4.0 → 0.5.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/README.md +2 -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 +2 -15
- package/src/Lib.sol +2 -15
- 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_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 +4 -3
- 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,59 +0,0 @@
|
|
|
1
|
-
/// SPDX-License-Identifier: No License
|
|
2
|
-
pragma solidity ^0.8;
|
|
3
|
-
|
|
4
|
-
import { euint256, ebool, EOps, SenderNotAllowedForHandle, ETypes, isTypeSupported, typeToBitMask } from "../Types.sol";
|
|
5
|
-
import { BaseAccessControlList } from "./AccessControl/BaseAccessControlList.sol";
|
|
6
|
-
import { EventCounter } from "./primitives/EventCounter.sol";
|
|
7
|
-
import { HandleGeneration } from "./primitives/HandleGeneration.sol";
|
|
8
|
-
|
|
9
|
-
interface IEncryptedOperationsGen {
|
|
10
|
-
function eAdd(euint256 lhs, euint256 rhs) external returns (euint256 result);
|
|
11
|
-
|
|
12
|
-
function eSub(euint256 lhs, euint256 rhs) external returns (euint256 result);
|
|
13
|
-
|
|
14
|
-
function eMul(euint256 lhs, euint256 rhs) external returns (euint256 result);
|
|
15
|
-
|
|
16
|
-
function eDiv(euint256 lhs, euint256 rhs) external returns (euint256 result);
|
|
17
|
-
|
|
18
|
-
function eRem(euint256 lhs, euint256 rhs) external returns (euint256 result);
|
|
19
|
-
|
|
20
|
-
function eBitAnd(bytes32 lhs, bytes32 rhs) external returns (bytes32 result);
|
|
21
|
-
|
|
22
|
-
function eBitOr(bytes32 lhs, bytes32 rhs) external returns (bytes32 result);
|
|
23
|
-
|
|
24
|
-
function eBitXor(bytes32 lhs, bytes32 rhs) external returns (bytes32 result);
|
|
25
|
-
|
|
26
|
-
function eShl(euint256 lhs, euint256 rhs) external returns (euint256 result);
|
|
27
|
-
|
|
28
|
-
function eShr(euint256 lhs, euint256 rhs) external returns (euint256 result);
|
|
29
|
-
|
|
30
|
-
function eRotl(euint256 lhs, euint256 rhs) external returns (euint256 result);
|
|
31
|
-
|
|
32
|
-
function eRotr(euint256 lhs, euint256 rhs) external returns (euint256 result);
|
|
33
|
-
|
|
34
|
-
function eEq(bytes32 lhs, bytes32 rhs) external returns (ebool result);
|
|
35
|
-
|
|
36
|
-
function eNe(bytes32 lhs, bytes32 rhs) external returns (ebool result);
|
|
37
|
-
|
|
38
|
-
function eGe(euint256 lhs, euint256 rhs) external returns (ebool result);
|
|
39
|
-
|
|
40
|
-
function eGt(euint256 lhs, euint256 rhs) external returns (ebool result);
|
|
41
|
-
|
|
42
|
-
function eLe(euint256 lhs, euint256 rhs) external returns (ebool result);
|
|
43
|
-
|
|
44
|
-
function eLt(euint256 lhs, euint256 rhs) external returns (ebool result);
|
|
45
|
-
|
|
46
|
-
function eMin(euint256 lhs, euint256 rhs) external returns (euint256 result);
|
|
47
|
-
|
|
48
|
-
function eMax(euint256 lhs, euint256 rhs) external returns (euint256 result);
|
|
49
|
-
|
|
50
|
-
function eNot(ebool operand) external returns (ebool result);
|
|
51
|
-
|
|
52
|
-
function eCast(bytes32 ct, ETypes toType) external returns (bytes32 result);
|
|
53
|
-
|
|
54
|
-
function eRand(ETypes randType) external returns (bytes32 result);
|
|
55
|
-
|
|
56
|
-
function eRandBounded(bytes32 upperBound, ETypes randType) external returns (bytes32 result);
|
|
57
|
-
|
|
58
|
-
function eIfThenElse(ebool control, bytes32 ifTrue, bytes32 ifFalse) external returns (bytes32 result);
|
|
59
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/// SPDX-License-Identifier: No License
|
|
2
|
-
pragma solidity ^0.8.19;
|
|
3
|
-
|
|
4
|
-
import "./TEELifecycle.types.sol";
|
|
5
|
-
import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
|
|
6
|
-
import { EIP712 } from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
|
|
7
|
-
import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
|
|
8
|
-
import { IQuoteVerifier } from "automata-dcap-attestation/interfaces/IQuoteVerifier.sol";
|
|
9
|
-
import { BELE } from "automata-dcap-attestation/utils/BELE.sol";
|
|
10
|
-
import { HEADER_LENGTH } from "automata-dcap-attestation/types/Constants.sol";
|
|
11
|
-
import { TD10ReportBody, Header } from "automata-dcap-attestation/types/V4Structs.sol";
|
|
12
|
-
import { EIP712Upgradeable } from "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol";
|
|
13
|
-
import { EnclaveIdentityJsonObj, IdentityObj } from "@automata-network/on-chain-pccs/helpers/EnclaveIdentityHelper.sol";
|
|
14
|
-
import { TcbInfoJsonObj } from "@automata-network/on-chain-pccs/helpers/FmspcTcbHelper.sol";
|
|
15
|
-
import { AutomataFmspcTcbDao } from "@automata-network/on-chain-pccs/automata_pccs/AutomataFmspcTcbDao.sol";
|
|
16
|
-
import { AutomataEnclaveIdentityDao } from "@automata-network/on-chain-pccs/automata_pccs/AutomataEnclaveIdentityDao.sol";
|
|
17
|
-
|
|
18
|
-
interface ITEELifecycleGen {
|
|
19
|
-
function initialize(address owner, string memory eip712Name, string memory eip712Version, address quoteVerifierAddress) external;
|
|
20
|
-
|
|
21
|
-
/// @notice Uploads the collateral to the contract
|
|
22
|
-
/// @param tcbInfo - The TCB info to upload
|
|
23
|
-
/// @param identity - The identity to upload
|
|
24
|
-
function uploadCollateral(TcbInfoJsonObj memory tcbInfo, EnclaveIdentityJsonObj memory identity) external;
|
|
25
|
-
|
|
26
|
-
/// @notice Verifies the bootstrap data against the provided quote and signature
|
|
27
|
-
/// @param bootstrapResult - The bootstrap data to verify
|
|
28
|
-
/// @param quote - The quote to verify against
|
|
29
|
-
/// @param signature - The signature to verify against
|
|
30
|
-
function verifyBootstrapResult(BootstrapResult calldata bootstrapResult, bytes calldata quote, bytes calldata signature) external;
|
|
31
|
-
|
|
32
|
-
/// @notice Approves a new TEE version and updates the TEEVersionHistory
|
|
33
|
-
/// @param newMRTD - The MRTD bytes of the new TEE version
|
|
34
|
-
/// @dev This function increments the version number automatically based on the current history
|
|
35
|
-
function approveNewTEEVersion(bytes calldata newMRTD) external;
|
|
36
|
-
|
|
37
|
-
/// @notice Adds a new covalidator to the contract state
|
|
38
|
-
/// @param quote - The quote from the new covalidator that contains the current MRTD and the eoa address of the new party in the report data
|
|
39
|
-
function addNewCovalidator(bytes calldata quote) external;
|
|
40
|
-
|
|
41
|
-
/// @notice Checks if the bootstrap is complete, meaning that there is an active TEE version.
|
|
42
|
-
/// @return true if the bootstrap is complete, false otherwise
|
|
43
|
-
function isBootstrapComplete() external view returns (bool);
|
|
44
|
-
|
|
45
|
-
/// @notice From https://github.com/automata-network/automata-dcap-attestation/blob/evm-v1.0.0/evm/contracts/verifiers/V4QuoteVerifier.sol#L309
|
|
46
|
-
/// @notice Parses the TD10 report body from the raw quote
|
|
47
|
-
/// @param rawQuote - The raw quote bytes
|
|
48
|
-
/// @return report - The parsed TD10 report body
|
|
49
|
-
function parseTD10ReportBody(bytes calldata rawQuote) external pure returns (TD10ReportBody memory report);
|
|
50
|
-
|
|
51
|
-
/// @notice Parses the TD10 report to extract the report data and MRTD
|
|
52
|
-
/// @param tdReport - The TD10 report body
|
|
53
|
-
/// @return reportDataSigner - The signing address of the report data signer
|
|
54
|
-
/// @return reportMRTD - The MRTD bytes from the report
|
|
55
|
-
function parseReport(TD10ReportBody memory tdReport) external pure returns (address, bytes memory);
|
|
56
|
-
|
|
57
|
-
function bootstrapResultDigest(BootstrapResult memory bootstrapResult) external view returns (bytes32);
|
|
58
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/// SPDX-License-Identifier: No License
|
|
2
|
-
pragma solidity ^0.8;
|
|
3
|
-
|
|
4
|
-
import { EventCounter } from "./primitives/EventCounter.sol";
|
|
5
|
-
import { euint256, ebool, eaddress, EOps, ETypes } from "../Types.sol";
|
|
6
|
-
import { BaseAccessControlList } from "./AccessControl/BaseAccessControlList.sol";
|
|
7
|
-
import { HandleGeneration } from "./primitives/HandleGeneration.sol";
|
|
8
|
-
|
|
9
|
-
interface ITrivialEncryptionGen {
|
|
10
|
-
function asEuint256(uint256 value) external returns (euint256 newEuint256);
|
|
11
|
-
|
|
12
|
-
function asEbool(bool value) external returns (ebool newEbool);
|
|
13
|
-
|
|
14
|
-
function asEaddress(address value) external returns (eaddress newEaddress);
|
|
15
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/// SPDX-License-Identifier: No License
|
|
2
|
-
pragma solidity ^0.8;
|
|
3
|
-
|
|
4
|
-
import { ETypes, EOps, EVM_HOST_CHAIN_PREFIX, HANDLE_INDEX } from "../../Types.sol";
|
|
5
|
-
import { HandleMetadata } from "./HandleMetadata.sol";
|
|
6
|
-
|
|
7
|
-
interface IHandleGenerationGen {
|
|
8
|
-
function getTrivialEncryptHandle(bytes32 plaintextBytes, ETypes handleType) external view returns (bytes32 generatedHandle);
|
|
9
|
-
|
|
10
|
-
function getInputHandle(bytes memory ciphertext, address user, address contractAddress, ETypes inputType) external view returns (bytes32 generatedHandle);
|
|
11
|
-
|
|
12
|
-
function getOpResultHandle(EOps op, ETypes returnType, bytes32 lhs, bytes32 rhs) external pure returns (bytes32 generatedHandle);
|
|
13
|
-
|
|
14
|
-
function getOpResultHandle(EOps op, ETypes returnType, uint256 counter, bytes32 upperBound) external pure returns (bytes32 generatedHandle);
|
|
15
|
-
|
|
16
|
-
function getOpResultHandle(EOps op, ETypes returnType, bytes32 value) external pure returns (bytes32 generatedHandle);
|
|
17
|
-
|
|
18
|
-
function getOpResultHandle(EOps op, ETypes returnType, bytes32 inputA, bytes32 inputB, bytes32 inputC) external pure returns (bytes32 generatedHandle);
|
|
19
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/// SPDX-License-Identifier: No License
|
|
2
|
-
pragma solidity ^0.8;
|
|
3
|
-
|
|
4
|
-
import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
|
|
5
|
-
import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
|
|
6
|
-
import { TEELifecycle } from "../TEELifecycle.sol";
|
|
7
|
-
|
|
8
|
-
interface ISignatureVerifierGen {
|
|
9
|
-
function addSigner(address signerAddress) external;
|
|
10
|
-
|
|
11
|
-
function removeSigner(address signerAddress) external;
|
|
12
|
-
|
|
13
|
-
function isSigner(address signerAddress) external view returns (bool);
|
|
14
|
-
|
|
15
|
-
function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bool);
|
|
16
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: No License
|
|
2
|
-
pragma solidity ^0.8;
|
|
3
|
-
|
|
4
|
-
import {IncoLightning} from "../IncoLightning.sol";
|
|
5
|
-
import {euint256} from "../Types.sol";
|
|
6
|
-
|
|
7
|
-
contract FibonacciDecrypt {
|
|
8
|
-
IncoLightning immutable inco;
|
|
9
|
-
|
|
10
|
-
constructor(IncoLightning _inco) {
|
|
11
|
-
inco = _inco;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// Stores the result of the last callback.
|
|
15
|
-
uint256 public lastResult;
|
|
16
|
-
|
|
17
|
-
function fib(
|
|
18
|
-
uint256 n
|
|
19
|
-
) external returns (uint256 lastRequestId, euint256 nthTerm) {
|
|
20
|
-
require(address(inco) != address(0), "IncoLightning not set");
|
|
21
|
-
euint256 prev = inco.asEuint256(0);
|
|
22
|
-
lastRequestId = emitTerm(prev);
|
|
23
|
-
nthTerm = inco.asEuint256(1);
|
|
24
|
-
lastRequestId = emitTerm(nthTerm);
|
|
25
|
-
for (uint256 i = 0; i < n-2; i++) {
|
|
26
|
-
euint256 temp = nthTerm;
|
|
27
|
-
nthTerm = inco.eAdd(prev, nthTerm);
|
|
28
|
-
prev = temp;
|
|
29
|
-
lastRequestId = emitTerm(nthTerm);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function emitTerm(euint256 term) internal returns (uint256 requestId) {
|
|
34
|
-
requestId = inco.requestDecryption(
|
|
35
|
-
this.callback.selector,
|
|
36
|
-
block.timestamp + 2 hours,
|
|
37
|
-
euint256.unwrap(term),
|
|
38
|
-
""
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function callback(
|
|
43
|
-
uint256 /* requestId */,
|
|
44
|
-
uint256 result,
|
|
45
|
-
bytes memory /* data */
|
|
46
|
-
) external {
|
|
47
|
-
lastResult = result;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: No License
|
|
2
|
-
pragma solidity ^0.8;
|
|
3
|
-
|
|
4
|
-
import "forge-std/Test.sol";
|
|
5
|
-
|
|
6
|
-
import "../../lightning-parts/TEELifecycle.types.sol";
|
|
7
|
-
import "../../lightning-parts/TEELifecycle.sol";
|
|
8
|
-
import "../../DeployUtils.sol";
|
|
9
|
-
import "../../DeployTEE.sol";
|
|
10
|
-
import {TestUtils} from "@inco/shared/src/TestUtils.sol";
|
|
11
|
-
|
|
12
|
-
import {EnclaveIdentityJsonObj} from "@automata-network/on-chain-pccs/helpers/EnclaveIdentityHelper.sol";
|
|
13
|
-
import {TcbInfoJsonObj} from "@automata-network/on-chain-pccs/helpers/FmspcTcbHelper.sol";
|
|
14
|
-
import {IQuoteVerifier} from "automata-dcap-attestation/interfaces/IQuoteVerifier.sol";
|
|
15
|
-
|
|
16
|
-
contract TEELifecycleHWTest is DeployUtils , TestUtils, DeployTEE {
|
|
17
|
-
using stdStorage for StdStorage;
|
|
18
|
-
|
|
19
|
-
// This is the MRTD from Adrian's v0 TDX VM running on GCP that was used to generate the test data.
|
|
20
|
-
bytes public v0mrtd = hex"409c0cd3e63d9ea54d817cf851983a220131262664ac8cd02cc6a2e19fd291d2fdd0cc035d7789b982a43a92a4424c99";
|
|
21
|
-
|
|
22
|
-
// This is the address that is used as the lifecycle contract address in Adrian's v0 TDX VM.
|
|
23
|
-
address lifecycleAddress = 0x63D8135aF4D393B1dB43B649010c8D3EE19FC9fd;
|
|
24
|
-
|
|
25
|
-
// Avoid expired collateral and certificate errors by setting time to
|
|
26
|
-
// the date when the test data was generated.
|
|
27
|
-
uint256 collateral_timestamp = 1754498833;
|
|
28
|
-
|
|
29
|
-
// This is the location of the bootstrap and add node and test data files
|
|
30
|
-
string bootstrapDir;
|
|
31
|
-
string addNodeDir;
|
|
32
|
-
|
|
33
|
-
TEELifecycle lifecycle;
|
|
34
|
-
|
|
35
|
-
address immutable owner;
|
|
36
|
-
|
|
37
|
-
constructor() {
|
|
38
|
-
owner = getLabeledAddress("owner");
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function setUp() public {
|
|
42
|
-
// This test data was generate by running the TEELifecycle binary in a real TDX environment
|
|
43
|
-
// to generate the quote and other files.
|
|
44
|
-
bootstrapDir = string.concat(vm.projectRoot(), "/src/test/TEELifecycle/bootstrap_data/");
|
|
45
|
-
addNodeDir = string.concat(vm.projectRoot(), "/src/test/TEELifecycle/addnode_data/");
|
|
46
|
-
string memory certDir = string.concat(vm.projectRoot(), "/src/test/TEELifecycle/test_cert/");
|
|
47
|
-
|
|
48
|
-
vm.warp(collateral_timestamp);
|
|
49
|
-
vm.startPrank(owner);
|
|
50
|
-
|
|
51
|
-
// PCCS Setup
|
|
52
|
-
deployP256();
|
|
53
|
-
deployPCCS(owner, certDir);
|
|
54
|
-
IQuoteVerifier quoteVerifier = deployQuoteVerifier();
|
|
55
|
-
|
|
56
|
-
bytes memory lifecycleCode = address(deployTEELifecycle(owner, address(quoteVerifier))).code;
|
|
57
|
-
// Make sure the verifyingContract for the EIP217 domain matches the one in the test data
|
|
58
|
-
// By using vm.etch to deploy the TEELifecycle contract at a specific address
|
|
59
|
-
vm.etch(lifecycleAddress, lifecycleCode);
|
|
60
|
-
lifecycle = TEELifecycle(lifecycleAddress);
|
|
61
|
-
|
|
62
|
-
// Make sure the name and version for the EIP712 domain matches the one in the test data
|
|
63
|
-
lifecycle.initialize(owner, "IncoTeeLifecycleBootstrap", "1.0.0", address(quoteVerifier));
|
|
64
|
-
|
|
65
|
-
vm.stopPrank();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function test_LifecycleBootstrap() public {
|
|
69
|
-
_uploadCollateral(bootstrapDir);
|
|
70
|
-
string memory expected_address_string = vm.readFile(string.concat(bootstrapDir, "eoa.txt"));
|
|
71
|
-
address expected_address = vm.parseAddress(expected_address_string);
|
|
72
|
-
|
|
73
|
-
vm.startPrank(owner);
|
|
74
|
-
bytes memory pubkey = vm.readFileBinary(string.concat(bootstrapDir, "ecies_pubkey.bin"));
|
|
75
|
-
BootstrapResult memory bootstrapResult = BootstrapResult({ecies_pubkey: pubkey});
|
|
76
|
-
bytes memory quote = vm.readFileBinary(string.concat(bootstrapDir, "quote.bin"));
|
|
77
|
-
bytes memory sig = vm.readFileBinary(string.concat(bootstrapDir, "eip712_signature.bin"));
|
|
78
|
-
lifecycle.approveNewTEEVersion(v0mrtd);
|
|
79
|
-
lifecycle.verifyBootstrapResult(bootstrapResult, quote, sig);
|
|
80
|
-
|
|
81
|
-
(bytes memory mrtd,) = lifecycle.TEEVersionHistory(0);
|
|
82
|
-
assert(keccak256(mrtd) == keccak256(v0mrtd));
|
|
83
|
-
assert(lifecycle.isBootstrapComplete() == true);
|
|
84
|
-
assert(keccak256(lifecycle.ECIESPubkey()) == keccak256(pubkey));
|
|
85
|
-
assert(lifecycle.EOASigners(expected_address));
|
|
86
|
-
vm.stopPrank();
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function test_LifecycleNewEOA() public {
|
|
90
|
-
// This test assumes that the lifecycle bootstrap is already completed
|
|
91
|
-
test_LifecycleBootstrap();
|
|
92
|
-
|
|
93
|
-
string memory expected_address_string = vm.readFile(string.concat(addNodeDir, "eoa.txt"));
|
|
94
|
-
address expected_address = vm.parseAddress(expected_address_string);
|
|
95
|
-
|
|
96
|
-
vm.startPrank(owner);
|
|
97
|
-
bytes memory quote2 = vm.readFileBinary(string.concat(addNodeDir, "quote.bin"));
|
|
98
|
-
lifecycle.addNewCovalidator(quote2);
|
|
99
|
-
vm.stopPrank();
|
|
100
|
-
|
|
101
|
-
assert(lifecycle.EOASigners(expected_address));
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function _uploadCollateral(string memory collateralDir) private {
|
|
105
|
-
vm.startPrank(owner);
|
|
106
|
-
// upload collateral
|
|
107
|
-
string memory tcbInfoStr = vm.readFile(string.concat(collateralDir, "tcb_info"));
|
|
108
|
-
bytes memory tcbInfoSig = vm.readFileBinary(string.concat(collateralDir, "tcb_info_signature.bin"));
|
|
109
|
-
TcbInfoJsonObj memory tcbInfo = TcbInfoJsonObj(tcbInfoStr, tcbInfoSig);
|
|
110
|
-
|
|
111
|
-
string memory qeIdStr = vm.readFile(string.concat(collateralDir, "qe_identity"));
|
|
112
|
-
bytes memory qeIdSig = vm.readFileBinary(string.concat(collateralDir, "qe_identity_signature.bin"));
|
|
113
|
-
EnclaveIdentityJsonObj memory identityJson = EnclaveIdentityJsonObj(qeIdStr, qeIdSig);
|
|
114
|
-
|
|
115
|
-
lifecycle.uploadCollateral(tcbInfo, identityJson);
|
|
116
|
-
|
|
117
|
-
vm.stopPrank();
|
|
118
|
-
}
|
|
119
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0x32B70C13186E3B81137ec09c0CB3ee8e14e69f64
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
�@��3��X���r�F��[s�X"�t��$��
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
�a�[O$��������G�s#������@ZH �W#��3�-`�x'r�U�?G�)|H3}�K;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0x8461984E47D19e9B86702F398982a5c2747A734D
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"id":"TD_QE","version":2,"issueDate":"2025-08-06T16:32:25Z","nextUpdate":"2025-09-05T16:32:25Z","tcbEvaluationDataNumber":17,"miscselect":"00000000","miscselectMask":"FFFFFFFF","attributes":"11000000000000000000000000000000","attributesMask":"FBFFFFFFFFFFFFFF0000000000000000","mrsigner":"DC9E2A7C6F948F17474E34A7FC43ED030F7C1563F1BABDDF6340C82E0E54A8C5","isvprodid":2,"tcbLevels":[{"tcb":{"isvsvn":4},"tcbDate":"2024-03-13T00:00:00Z","tcbStatus":"UpToDate"}]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
ETw���bwޱ�˧����-ĭ�%u#O�Po�����'�ࣳE&T�d�.F�����|��
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"id":"TDX","version":3,"issueDate":"2025-08-06T16:25:19Z","nextUpdate":"2025-09-05T16:25:19Z","fmspc":"00806F050000","pceId":"0000","tcbType":0,"tcbEvaluationDataNumber":17,"tdxModule":{"mrsigner":"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","attributes":"0000000000000000","attributesMask":"FFFFFFFFFFFFFFFF"},"tdxModuleIdentities":[{"id":"TDX_03","mrsigner":"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","attributes":"0000000000000000","attributesMask":"FFFFFFFFFFFFFFFF","tcbLevels":[{"tcb":{"isvsvn":3},"tcbDate":"2024-03-13T00:00:00Z","tcbStatus":"UpToDate"}]},{"id":"TDX_01","mrsigner":"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","attributes":"0000000000000000","attributesMask":"FFFFFFFFFFFFFFFF","tcbLevels":[{"tcb":{"isvsvn":4},"tcbDate":"2024-03-13T00:00:00Z","tcbStatus":"UpToDate"},{"tcb":{"isvsvn":2},"tcbDate":"2023-08-09T00:00:00Z","tcbStatus":"OutOfDate"}]}],"tcbLevels":[{"tcb":{"sgxtcbcomponents":[{"svn":7,"category":"BIOS","type":"Early Microcode Update"},{"svn":7,"category":"OS/VMM","type":"SGX Late Microcode Update"},{"svn":2,"category":"OS/VMM","type":"TXT SINIT"},{"svn":2,"category":"BIOS"},{"svn":3,"category":"BIOS"},{"svn":1,"category":"BIOS"},{"svn":0},{"svn":3,"category":"OS/VMM","type":"SEAMLDR ACM"},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0}],"pcesvn":11,"tdxtcbcomponents":[{"svn":5,"category":"OS/VMM","type":"TDX Module"},{"svn":0,"category":"OS/VMM","type":"TDX Module"},{"svn":7,"category":"OS/VMM","type":"TDX Late Microcode Update"},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0}]},"tcbDate":"2024-03-13T00:00:00Z","tcbStatus":"UpToDate"},{"tcb":{"sgxtcbcomponents":[{"svn":6,"category":"BIOS","type":"Early Microcode Update"},{"svn":6,"category":"OS/VMM","type":"SGX Late Microcode Update"},{"svn":2,"category":"OS/VMM","type":"TXT SINIT"},{"svn":2,"category":"BIOS"},{"svn":3,"category":"BIOS"},{"svn":1,"category":"BIOS"},{"svn":0},{"svn":3,"category":"OS/VMM","type":"SEAMLDR ACM"},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0}],"pcesvn":11,"tdxtcbcomponents":[{"svn":3,"category":"OS/VMM","type":"TDX Module"},{"svn":0,"category":"OS/VMM","type":"TDX Module"},{"svn":6,"category":"OS/VMM","type":"TDX Late Microcode Update"},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0}]},"tcbDate":"2023-08-09T00:00:00Z","tcbStatus":"OutOfDate","advisoryIDs":["INTEL-SA-00960","INTEL-SA-00982","INTEL-SA-00986"]},{"tcb":{"sgxtcbcomponents":[{"svn":5,"category":"BIOS","type":"Early Microcode Update"},{"svn":5,"category":"OS/VMM","type":"SGX Late Microcode Update"},{"svn":2,"category":"OS/VMM","type":"TXT SINIT"},{"svn":2,"category":"BIOS"},{"svn":3,"category":"BIOS"},{"svn":1,"category":"BIOS"},{"svn":0},{"svn":3,"category":"OS/VMM","type":"SEAMLDR ACM"},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0}],"pcesvn":11,"tdxtcbcomponents":[{"svn":3,"category":"OS/VMM","type":"TDX Module"},{"svn":0,"category":"OS/VMM","type":"TDX Module"},{"svn":5,"category":"OS/VMM","type":"TDX Late Microcode Update"},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0}]},"tcbDate":"2023-02-15T00:00:00Z","tcbStatus":"OutOfDate","advisoryIDs":["INTEL-SA-00837","INTEL-SA-00960","INTEL-SA-00982","INTEL-SA-00986"]},{"tcb":{"sgxtcbcomponents":[{"svn":5,"category":"BIOS","type":"Early Microcode Update"},{"svn":5,"category":"OS/VMM","type":"SGX Late Microcode Update"},{"svn":2,"category":"OS/VMM","type":"TXT SINIT"},{"svn":2,"category":"BIOS"},{"svn":3,"category":"BIOS"},{"svn":1,"category":"BIOS"},{"svn":0},{"svn":3,"category":"OS/VMM","type":"SEAMLDR ACM"},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0}],"pcesvn":5,"tdxtcbcomponents":[{"svn":3,"category":"OS/VMM","type":"TDX Module"},{"svn":0,"category":"OS/VMM","type":"TDX Module"},{"svn":5,"category":"OS/VMM","type":"TDX Late Microcode Update"},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0},{"svn":0}]},"tcbDate":"2018-01-04T00:00:00Z","tcbStatus":"OutOfDate","advisoryIDs":["INTEL-SA-00106","INTEL-SA-00115","INTEL-SA-00135","INTEL-SA-00203","INTEL-SA-00220","INTEL-SA-00233","INTEL-SA-00270","INTEL-SA-00293","INTEL-SA-00320","INTEL-SA-00329","INTEL-SA-00381","INTEL-SA-00389","INTEL-SA-00477","INTEL-SA-00837","INTEL-SA-00960","INTEL-SA-00982","INTEL-SA-00986"]}]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
��e�3?��b� \���@E\�B���2���v3��KLm�C����
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/// SPDX-License-Identifier: No License
|
|
2
|
-
pragma solidity ^0.8;
|
|
3
|
-
|
|
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";
|
|
7
|
-
|
|
8
|
-
interface IVersionGen {
|
|
9
|
-
function getVersionedName() external view returns (string memory);
|
|
10
|
-
|
|
11
|
-
function getVersion() external view returns (string memory);
|
|
12
|
-
|
|
13
|
-
function getName() external view returns (string memory);
|
|
14
|
-
}
|