Page cover

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 VerifiedOutput raw bytes.

    • Else, UTF-8 encoded string error message.

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.

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:

Or, if you would like to see the full list of supported program identifiers:

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:

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.

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 VerifiedOutput value returned by the DCAP Guest Program

  • zkCoProcessor (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 VerifiedOutput raw bytes.

    • Else, UTF-8 encoded string error message.

Same 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 VerifiedOutput value returned by the DCAP Guest Program

  • zkCoProcessor (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 VerifiedOutput raw bytes.

    • Else, UTF-8 encoded string error message.

Last updated

Was this helpful?