Skip to content

Verify the attestation

GET /v1/attestation returns a fresh proof of the enclave that serves confidential keys, bound to a nonce you choose. Everything in it can be checked against Intel’s root of trust, so you do not have to take Belarel’s word for it. Run this check when you onboard, and periodically or whenever you see a new enclave_key or measurements value on your answers.

You need a confidential key with the inference scope. Belarel checks the key first, as on every call: a key without the inference scope gets 403 scope_denied. A valid key that is not confidential then gets 403 confidential_key_required. A sandbox confidential key works too and gets a real proof. Each request counts against the key’s rate limit.

  1. Generate a nonce. Use 32 random bytes, written as 64 lowercase hexadecimal characters. Belarel lowercases the nonce before using it, and the proof binds the lowercase form.

    Terminal window
    NONCE=$(openssl rand -hex 32)
  2. Request the proof. Pass the nonce as the nonce query parameter.

    Terminal window
    curl "https://api.belarel.com/v1/attestation?nonce=$NONCE" \
    -H "Authorization: Bearer $BELAREL_API_KEY"

    The answer contains object: "attestation", your nonce echoed back, tee: "intel_tdx", verifier: "intel_dcap", verified_at, tcb_status, quote (base64), collateral, event_log (base64, or null), report_data: "sha512(nonce)", enclave_key, key_possession, measurements, measurements_status, measurements_approved and intel_token (or null). First check that nonce is exactly the value you sent.

  3. Check that the quote binds your nonce. Decode quote from base64. Its REPORTDATA field (64 bytes) must equal SHA-512 of the nonce’s ASCII bytes: the hash of the 64-character hex string itself, not of the 32 bytes it encodes. While you have the quote open, check that it is a version 4 TDX quote and that the debug attribute is off. Offsets, in the raw quote:

    Field Bytes Expected
    Version 0–1, little-endian 4
    TEE type 4–7, little-endian 0x81 (TDX)
    TD_ATTRIBUTES, debug bit (bit 0) 168 0 (not debuggable)
    MRTD 184–231 measurements.mrtd
    MRCONFIGID 232–279 measurements.mrconfigid
    RTMR0–3 376–567, 48 bytes each measurements.rtmr0 … rtmr3
    REPORTDATA 568–631 SHA-512(nonce ASCII)

    The script below does this step and steps 5 and 6.

  4. Verify the quote and its collateral with a DCAP verifier. Give quote and collateral to any Intel DCAP quote verifier. collateral is the Intel-signed collateral Belarel verified the quote with: the PCK certificate chain, the PCK and root CA revocation lists, and the TCB info and QE identity with their signatures and issuer chains. Your verifier must confirm that:

    • the PCK certificate chain ends at Intel’s root CA, using your own copy of Intel’s root certificate, never one taken from the response;
    • the quote’s signature and the quoting enclave’s report verify, so the measurements and REPORTDATA you read in step 3 are the ones Intel’s chain covers;
    • the TCB info and QE identity signatures verify, and no certificate is revoked;
    • the TCB status it computes matches tcb_status, which Belarel computed on this same quote with this collateral (with newer collateral from Intel, it may be worse). Belarel serves calls on UpToDate and SWHardeningNeeded, and also on a host behind on Intel’s patches (OutOfDate, ConfigurationNeeded, ConfigurationAndSWHardeningNeeded, OutOfDateConfigurationNeeded), which it is alerted about; only Revoked, or any other status, is refused. You can apply a stricter policy;
    • the TD is not debuggable, if your verifier reports TD attributes.

    collateral is a JSON object. The certificate chains (the …_issuer_chain fields and pck_certificate_chain), tcb_info and qe_identity are strings. root_ca_crl, pck_crl, tcb_info_signature and qe_identity_signature are arrays of byte values (numbers from 0 to 255). If your DCAP quote verifier expects bytes, convert those four arrays first: the two revocation lists are DER, and the two signatures are Intel’s raw signature bytes.

    Collateral has a validity period. If you verify long after the request, or prefer not to use the collateral Belarel returned, let your verifier fetch current collateral from Intel.

  5. Check the measurements. The measurements in the response must match the quote (step 3). Then read measurements_status:

    • approved: Belarel has reviewed and approved this combination.
    • pending: the combination is new — a new deployment of the enclave, or a new host type — and Belarel has not reviewed it yet. The proof is real, and confidential calls are served, unless another recently seen replica runs a revoked combination. Since 2026-10-05, a combination can be approved only from a DCAP-verified quote; combinations approved before keep their status.
    • revoked: Belarel refused this combination. The proof is still returned so you can inspect it, but confidential calls answer 503 attestation_unavailable while a replica running it has been seen in the last 15 minutes (instances are sampled, not enumerated).

    Here measurements_approved is true only when measurements_status is approved: it describes the instance that answered. On an answer’s belarel.attestation block, the same field says whether every combination the enclave fleet was seen with in the last 15 minutes is approved. Record the values you accept. Different enclave instances can report different combinations, each reviewed separately, so compare against the set you have seen rather than a single value. The measurements on your answers’ belarel.attestation block should belong to that set.

  6. Check the key that signed your nonce. key_possession.signature is an RS256 signature (RSASSA-PKCS1-v1_5 with SHA-256), in base64, over the same input as REPORTDATA: the nonce’s 64 ASCII bytes (key_possession.input: "nonce"). Verify it with enclave_key.public_key_pem. Then compute SHA-256 of that key’s DER SubjectPublicKeyInfo, in lowercase hex: it must equal enclave_key.spki_sha256, the value every confidential call’s TLS connection is pinned to. This shows that the holder of enclave_key signed your nonce; it does not, on its own, show that the key lives in the enclave (see below).

  7. Optional: check intel_token. When Belarel has Intel Trust Authority configured, intel_token is a JWT signed by Intel Trust Authority for the same quote and nonce; otherwise it is null, which is normal and never a failure. If present, first check that its iss claim equals Intel Trust Authority’s portal URL, https://portal.trustauthority.intel.com, then verify its signature (PS384 or RS256) with the keys you fetch yourself from https://portal.trustauthority.intel.com/certs. Never take keys from a jku header or from an issuer the token names itself: if iss is not that URL, or the signature does not verify, reject the token. Then check its claims — under tdx in recent token versions: tdx_report_data equals the quote’s REPORTDATA, tdx_mrtd, tdx_mrconfigid and tdx_rtmr0–3 equal measurements, tdx_is_debuggable is false, and attester_tcb_status is acceptable to you.

This script performs steps 1, 2, 3, 5 and 6. Run your DCAP verifier (step 4) on the same quote and collateral.

import base64, hashlib, os, secrets
import requests
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric import padding
nonce = secrets.token_hex(32) # 64 lowercase hex characters
r = requests.get(
"https://api.belarel.com/v1/attestation",
params={"nonce": nonce},
headers={"Authorization": f"Bearer {os.environ['BELAREL_API_KEY']}"},
timeout=30,
)
r.raise_for_status()
proof = r.json()
assert proof["nonce"] == nonce
# Step 3 — the quote binds the nonce, is TDX v4, and is not debuggable.
quote = base64.b64decode(proof["quote"])
assert int.from_bytes(quote[0:2], "little") == 4
assert int.from_bytes(quote[4:8], "little") == 0x81
assert quote[168] & 1 == 0, "debuggable TD"
assert quote[568:632] == hashlib.sha512(nonce.encode("ascii")).digest(), "REPORTDATA"
# Step 5 — the measurements are the quote's; print their review status.
offsets = {"mrtd": 184, "mrconfigid": 232, "rtmr0": 376, "rtmr1": 424, "rtmr2": 472, "rtmr3": 520}
for name, start in offsets.items():
assert quote[start:start + 48].hex() == proof["measurements"][name], name
print("measurements_status:", proof["measurements_status"], "approved:", proof["measurements_approved"])
# Step 6 — the TLS key signed the nonce, and is the pinned key.
key = serialization.load_pem_public_key(proof["enclave_key"]["public_key_pem"].encode())
spki = key.public_bytes(serialization.Encoding.DER, serialization.PublicFormat.SubjectPublicKeyInfo)
assert hashlib.sha256(spki).hexdigest() == proof["enclave_key"]["spki_sha256"]
key.verify( # raises InvalidSignature on failure
base64.b64decode(proof["key_possession"]["signature"]),
nonce.encode("ascii"),
padding.PKCS1v15(),
hashes.SHA256(),
)
print("OK — now verify quote + collateral with your DCAP verifier")

What the proof shows, and what it does not

Section titled “What the proof shows, and what it does not”
  • It shows that a genuine Intel TDX enclave with these measurements, not debuggable and at the reported TCB level, produced a quote for your nonce, now; and that the holder of enclave_key signed the same nonce. What is attested is the TDX guest that terminates the connection: there is no GPU attestation, and the quote does not show, by itself, that the model runs inside the enclave.
  • The quote does not contain the key. REPORTDATA carries only the hash of your nonce. What ties enclave_key to the enclave is that the quote and the signature arrived over one TLS connection whose certificate carries that key. You can verify each half, but not the link: a relay by someone holding a certificate for the enclave’s domain is not excluded cryptographically. That link rests on the enclave operator.
  • One proof, one instance. A proof comes from the enclave instance that answered. Before serving calls, Belarel samples several instances, requires the same key on all of them, and refuses as soon as one runs a revoked combination. Every sampled instance goes through the nonce, debug mode, key, DCAP chain and TCB status checks before its measurements are recorded. The optional Intel Trust Authority cross-check (step 7) runs only on the instance that answers a proof — yours, or the first one of each verdict — and only when Belarel has it configured.

Every answer of a confidential key carries a belarel.attestation block: the verdict Belarel established with its own nonce, reused for up to 10 minutes. It has no quote or nonce, so it cannot be verified on its own. Use it to link your calls to a proof you verified:

  • enclave_key.spki_sha256 must equal the value you verified in step 6.
  • measurements must belong to the set you accepted in step 5.
  • tcb_status there is the worst status among the instances Belarel sampled for the verdict, so it can be worse than the status of the quote you verified: one instance answers your proof.
  • If either changes, run this check again before you trust the new values.
Code HTTP Meaning What to do
invalid_api_key 401 The key is missing, unknown, revoked, expired or disabled. Check the key.
invalid_request 400 nonce is missing or is not 64 hexadecimal characters (param: "nonce"). Send 32 random bytes as 64 hex characters.
confidential_key_required 403 The key is not a confidential key. Sent with x-should-retry: false. Use a confidential key.
scope_denied 403 The key lacks the inference scope. Checked before the data mode. Use a key with inference.
method_not_allowed 405 A method other than GET. Use GET.
rate_limited, too_many_in_flight 429 The key’s rate limit or in-flight cap was reached. Sent with Retry-After. Wait for Retry-After, then retry with a new nonce.
attestation_unavailable 503 The enclave could not be reached or a check failed on Belarel’s side. Sent with Retry-After: 30. Retry after the delay, with a new nonce.