Created
October 17, 2025 14:38
-
-
Save Melvillian/61cc263657642f8a9b65e32ac3e3a5cb to your computer and use it in GitHub Desktop.
an example implementation of a contract with a single function that fetches Automata TDX svn values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //SPDX-License-Identifier: MIT | |
| pragma solidity ^0.8.0; | |
| import {PCCSRouter} from "../PCCSRouter.sol"; | |
| import {ECDSAQuoteV4AuthData} from "../types/V4Structs.sol"; | |
| import {QuoteVerifierBase} from "../bases/QuoteVerifierBase.sol"; | |
| contract ECDSAQuoteV4AuthDataGetter is QuoteVerifierBase { | |
| constructor(address _router) QuoteVerifierBase(_router, 4) {} | |
| function getECDSAQuoteV4AuthData(bytes memory rawAuthData) | |
| external | |
| view | |
| returns (bool success, ECDSAQuoteV4AuthData memory authDataV4, bytes memory rawQeReport) | |
| { | |
| authDataV4.ecdsa256BitSignature = rawAuthData[0:64]; | |
| authDataV4.ecdsaAttestationKey = rawAuthData[64:128]; | |
| uint256 qeReportCertType = BELE.leBytesToBeUint(rawAuthData[128:130]); | |
| if (qeReportCertType != 6) { | |
| return (false, authDataV4, rawQeReport); | |
| } | |
| uint256 qeReportCertSize = BELE.leBytesToBeUint(rawAuthData[130:134]); | |
| rawQeReport = rawAuthData[134:518]; | |
| authDataV4.qeReportCertData.qeReportSignature = rawAuthData[518:582]; | |
| uint16 qeAuthDataSize = uint16(BELE.leBytesToBeUint(rawAuthData[582:584])); | |
| authDataV4.qeReportCertData.qeAuthData.parsedDataSize = qeAuthDataSize; | |
| uint256 offset = 584; | |
| authDataV4.qeReportCertData.qeAuthData.data = rawAuthData[offset:offset + qeAuthDataSize]; | |
| offset += qeAuthDataSize; | |
| uint16 certType = uint16(BELE.leBytesToBeUint(rawAuthData[offset:offset + 2])); | |
| // we only support certType == 5 for now... | |
| if (certType != 5) { | |
| return (false, authDataV4, rawQeReport); | |
| } | |
| authDataV4.qeReportCertData.certification.certType = certType; | |
| offset += 2; | |
| uint32 certDataSize = uint32(BELE.leBytesToBeUint(rawAuthData[offset:offset + 4])); | |
| offset += 4; | |
| authDataV4.qeReportCertData.certification.certDataSize = certDataSize; | |
| bytes memory rawCertData = rawAuthData[offset:offset + certDataSize]; | |
| offset += certDataSize; | |
| if (offset - 134 != qeReportCertSize) { | |
| return (false, authDataV4, rawQeReport); | |
| } | |
| // parsing complete, now we need to decode some raw data | |
| (success, authDataV4.qeReportCertData.qeReport) = parseEnclaveReport(rawQeReport); | |
| if (!success) { | |
| return (false, authDataV4, rawQeReport); | |
| } | |
| (success, authDataV4.qeReportCertData.certification.pck) = | |
| getPckCollateral(pccsRouter.pckHelperAddr(), certType, rawCertData); | |
| if (!success) { | |
| return (false, authDataV4, rawQeReport); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment