Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion contracts/solidity/TEEInferenceVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,25 @@ import "./precompiles/tee/ITEEVerifier.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";

/// @title TEEInferenceVerifier - Verification for TEE-signed inference outputs
/// @notice Reads TEE public keys from TEERegistry and verifies RSA-PSS signatures with timestamp validation.
/// @notice Stateless verifier that confirms an AI inference output was produced by a
/// registered, active TEE within an acceptable time window.
///
/// @dev ## How It Works
///
/// When a TEE runs an inference, it signs `keccak256(inputHash || outputHash || timestamp)`
/// with its RSA-PSS private key. Any party (settlement relay, on-chain consumer, etc.) can
/// then call `verifySignature` to confirm authenticity. The check is three-fold:
///
/// 1. **TEE status** — the TEE must be active in the `TEERegistry`.
/// 2. **Timestamp bounds** — the signed timestamp must be within
/// `[block.timestamp - MAX_INFERENCE_AGE, block.timestamp + FUTURE_TOLERANCE]`
/// to prevent replay of stale results and reject clock-skewed signatures.
/// 3. **Cryptographic proof** — the RSA-PSS signature is verified against the TEE's
/// on-chain public key via the 0x900 precompile.
///
/// The contract is intentionally read-only (no state mutations in `verifySignature`) so
/// it can be called from view contexts and composed freely by downstream contracts like
/// `InferenceSettlementRelay`.
contract TEEInferenceVerifier is AccessControl {

// ============ Constants ============
Expand Down
43 changes: 35 additions & 8 deletions contracts/solidity/TEERegistry.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@
"name": "NotTEEOwner",
"type": "error"
},
{
"inputs": [],
"name": "PCRAlreadyExists",
"type": "error"
},
{
"inputs": [],
"name": "PCRExpired",
Expand All @@ -71,6 +76,11 @@
"name": "PCRNotApproved",
"type": "error"
},
{
"inputs": [],
"name": "PCRTypeMismatch",
"type": "error"
},
{
"inputs": [],
"name": "TEEAlreadyExists",
Expand Down Expand Up @@ -118,6 +128,12 @@
"name": "pcrHash",
"type": "bytes32"
},
{
"indexed": true,
"internalType": "uint8",
"name": "teeType",
"type": "uint8"
},
{
"indexed": false,
"internalType": "string",
Expand All @@ -136,6 +152,12 @@
"internalType": "bytes32",
"name": "pcrHash",
"type": "bytes32"
},
{
"indexed": false,
"internalType": "uint256",
"name": "gracePeriod",
"type": "uint256"
}
],
"name": "PCRRevoked",
Expand Down Expand Up @@ -399,14 +421,9 @@
"type": "string"
},
{
"internalType": "bytes32",
"name": "previousPcrHash",
"type": "bytes32"
},
{
"internalType": "uint256",
"name": "gracePeriod",
"type": "uint256"
"internalType": "uint8",
"name": "teeType",
"type": "uint8"
}
],
"name": "approvePCR",
Expand All @@ -429,6 +446,11 @@
"name": "active",
"type": "bool"
},
{
"internalType": "uint8",
"name": "teeType",
"type": "uint8"
},
{
"internalType": "uint256",
"name": "approvedAt",
Expand Down Expand Up @@ -984,6 +1006,11 @@
"internalType": "bytes32",
"name": "pcrHash",
"type": "bytes32"
},
{
"internalType": "uint256",
"name": "gracePeriod",
"type": "uint256"
}
],
"name": "revokePCR",
Expand Down
Loading