
Automata DCAP Attestation
This contract currently supports verification of quotes in all formats below:
SGX Quote V3
SGX and TDX Quote V4
SGX and TDX Quote V5
Upon successful verification, the contract returns bytes value that encode the VerifiedOutput structure, providing information about the verification status of the input quote.
struct Output {
uint16 quoteVersion; // serialized as BE, for EVM compatibility
uint16 quoteBodyType; // serialized as BE, for EVM compatibility
uint8 tcbStatus;
bytes6 fmspcBytes;
bytes quoteBody;
string[] advisoryIDs;
}The values are encoded in the exact order of the fields defined in the structure above. All field values are concatenated together with a known length (the quoteBody length can be inferred from quoteBodyType), except for advisory IDs which is ABI-encoded as Solidity string array.
Onchain Verification
function verifyAndAttestOnChain(bytes calldata rawQuote)
external
returns (bool success, bytes memory output);Verifies a quote fully onchain using collaterals at standard TCB Evaluation Data Number.
Parameters:
rawQuote (bytes): The raw quote data
Returns:
success (bool): Whether the quote has been successfully verified or not
output (bytes):
If success == true, the encoded
VerifiedOutputraw bytes.Else, UTF-8 encoded string error message.
function verifyAndAttestOnChain(bytes calldata rawQuote, uint32 tcbEvaluationDataNumber)
external
returns (bool success, bytes memory output);Same as the above, but users can specify the TCB Evaluation Data Number for collaterals to use for verification.
Zero Knowledge Proof Verification
The ZkCoProcessorType enum is defined to indicate the zkVM that is used to execute the DCAP Guest Program and generate proofs.
enum ZkCoProcessorType {
None,
RiscZero,
Succinct,
Pico // available for local testing only
}Each zkVM Configuration may support one or more DCAP Guest Program Identifiers and/or zkVM Verifiers. This is especially useful in providing grace period for users to migrate from one zkVM circuit version to another (e.g. often because of security patch updates).
To identify the program identifier for the latest version of the DCAP guest programs, you may call:
function programIdentifier(ZkCoProcessorType zkCoProcessorType) external view returns (bytes32);Or, if you would like to see the full list of supported program identifiers:
function programIdentifiers(ZkCoProcessorType zkCoProcessorType) external view returns (bytes32[] memory);By convention, the first 4 bytes of the proof data, known as the proof selector, is often used to identify the zkVM circuit version which is used to generate the proof data.
When a specific circuit version is deprecated because of security vulnerabilities, it will be frozen by the zkVM verifier directly, which can result in verification failure.
To check whether a proof whose selector had been frozen or not:
function zkVerifier(ZkCoProcessorType zkCoProcessorType, bytes4 selector) external view returns (address);The function reverts if the given selector were frozen, otherwise it returns the address of the verifier contract.
Once you have obtained a valid program identifier and proofs, you may call one of the methods below.
function verifyAndAttestWithZKProof(
bytes calldata output,
ZkCoProcessorType zkCoprocessor,
bytes calldata proofBytes
) external payable returns (bool success, bytes memory verifiedOutput);Verifies a quote with ZK proofs by executing the DCAP Guest Program in a specific zkVM using collaterals at standard TCB Evaluation Data Number.
Parameters:
output (bytes): The public
VerifiedOutputvalue returned by the DCAP Guest ProgramzkCoProcessor (enum): Indicates the zkVM used for execution
proofBytes (bytes): SNARK proof of execution)
Returns:
success (bool): Whether the quote has been successfully verified or not
output (bytes):
If success == true, the encoded
VerifiedOutputraw bytes.Else, UTF-8 encoded string error message.
function verifyAndAttestWithZKProof(
bytes calldata output,
ZkCoProcessorType zkCoprocessor,
bytes calldata proofBytes,
bytes32 programIdentifier,
uint32 tcbEvaluationDataNumber
) external payable returns (bool success, bytes memory verifiedOutput);SSame as the above, but this function is intended for users whom may not want to use the latest DCAP Guest Program and/or standard TCB Evaluation Data Number.
Parameters:
output (bytes): The public
VerifiedOutputvalue returned by the DCAP Guest ProgramzkCoProcessor (enum): Indicates the zkVM used for execution
proofBytes (bytes): SNARK proof of execution)
programIdentifier (bytes): The program identifier of the DCAP Guest Program
tcbEvaluationDataNumber(uint32): TCB Evaluation Data Number
Returns:
success (bool): Whether the quote has been successfully verified or not
output (bytes):
If success == true, the encoded
VerifiedOutputraw bytes.Else, UTF-8 encoded string error message.
Last updated
Was this helpful?