TEE System Architecture and Schematics for Beginners
1. Introduction to TEE Architecture
Trusted Execution Environments (TEEs) can be complex to understand, especially for newcomers to the field. This visual guide aims to simplify the core concepts and show how TEEs integrate with blockchain technology and AI systems in Web3 applications.
What is a TEE in Simple Terms?
Think of a TEE as a secure vault inside your computer's processor. This vault:
Has its own locks that even the computer's owner can't open
Can process sensitive data without exposing it
Can prove to remote parties that it hasn't been tampered with
2. Basic TEE Architecture (Simplified)
The Two-World Model
┌─────────────────────────────────────────────────────────────┐
│ COMPUTER PROCESSOR │
│ │
│ ┌─────────────────────────┐ ┌─────────────────────────┐ │
│ │ │ │ │ │
│ │ NORMAL WORLD │ │ SECURE WORLD │ │
│ │ │ │ │ │
│ │ ┌─────────────────┐ │ │ ┌─────────────────┐ │ │
│ │ │ │ │ │ │ │ │ │
│ │ │ Regular Apps │ │ │ │ Secure Apps │ │ │
│ │ │ & OS │ │ │ │ & TEE OS │ │ │
│ │ │ │ │ │ │ │ │ │
│ │ └─────────────────┘ │ │ └─────────────────┘ │ │
│ │ │ │ │ │
│ │ • Visible to users │ │ • Invisible to users │ │
│ │ • Can be monitored │ │ • Protected memory │ │
│ │ • Potentially insecure │ │ • Encrypted processing │ │
│ │ │ │ │ │
│ └──────────┬──────────────┘ └────────────┬────────────┘ │
│ │ │ │
│ │ HARDWARE BARRIER │ │
│ └───────────────┬───────────────┘ │
│ │ │
└─────────────────────────────────────────────────────────────┘
│
▼
Controlled Communication
Key Components Explained
Normal World:
The regular operating environment you interact with daily
Runs your regular operating system and applications
Can be monitored, hacked, or compromised
Secure World:
Isolated environment protected by hardware-level security
Has its own mini operating system
Protected from the normal world (even from the computer's administrator)
Encrypts data in memory and during processing
Hardware Barrier:
Physical separation enforced by the processor hardware
Prevents normal world from accessing secure world memory
Controls what data can enter and exit the secure environment
Controlled Communication:
Limited, strictly defined channels for data to move between worlds
All communication is authenticated and monitored
Only permitted operations are allowed
3. How Data Flows Through a TEE System
┌─────────────────┐ ┌─────────────────────────┐ ┌─────────────────┐
│ │ │ │ │ │
│ │ │ │ │ │
│ User Device │ │ TEE System │ │ Blockchain │
│ │ │ │ │ │
│ │ │ │ │ │
└────────┬────────┘ └────────────┬────────────┘ └────────┬────────┘
│ │ │
▼ ▼ ▼
┌──────────────────┐ ┌────────────────────┐ ┌───────────────────┐
│ │ │ │ │ │
│ 1. User sends │ │ 3. Data enters │ │ 7. Verified │
│ encrypted data │─────►│ secure enclave │ │ results stored │
│ │ │ │ │ on-chain │
└──────────────────┘ └──────────┬─────────┘ └───────────────────┘
│ ▲
▼ │
┌────────────────────┐ │
│ │ │
│ 4. Secure │ │
│ processing occurs │ │
│ │ │
└──────────┬─────────┘ │
│ │
▼ │
┌────────────────────┐ ┌───────────────────┐
│ │ │ │
│ 5. Generate │ │ 6. Attestation │
│ attestation proof │─────►│ verified by │
│ │ │ blockchain │
└────────────────────┘ └───────────────────┘
Data Flow Process Explained:
Data Submission: User encrypts sensitive data and sends it to the TEE system
Authentication: System verifies the user's identity and request
Secure Entry: Data enters the secure enclave, where it's decrypted
Protected Processing: Operations are performed inside the TEE's protected memory
Attestation: TEE generates cryptographic proof that processing was done correctly
Verification: Blockchain or third parties can verify the attestation proof
Result Storage: Encrypted results or verification hashes are stored on-chain
4. TEE Integration with Web3 Stack
┌─────────────────────────────────────────────────────────────────┐
│ WEB3 APPLICATION │
│ │
│ ┌─────────────────┐ ┌──────────────────┐ ┌──────────────┐ │
│ │ │ │ │ │ │ │
│ │ User Interface │ │ Business Logic │ │ Blockchain │ │
│ │ (Frontend) │ │ (Smart │ │ (Solana) │ │
│ │ │ │ Contracts) │ │ │ │
│ └─────────┬───────┘ └────────┬─────────┘ └──────┬───────┘ │
│ │ │ │ │
└────────────┼────────────────────┼────────────────────┼──────────┘
│ │ │
▼ ▼ ▼
┌────────────────────────────────────────────────────────────────┐
│ TEE MIDDLEWARE │
│ │
│ ┌─────────────────┐ ┌──────────────────┐ ┌──────────────┐ │
│ │ │ │ │ │ │ │
│ │ Secure UI │ │ Private │ │ Attestation │ │
│ │ Rendering │ │ Computation │ │ Service │ │
│ │ │ │ │ │ │ │
│ └─────────────────┘ └──────────────────┘ └──────────────┘ │
│ │
└────────────────────────────────────────────────────────────────┘
│ │ │
▼ ▼ ▼
┌────────────────────────────────────────────────────────────────┐
│ SECURE HARDWARE LAYER │
│ │
│ ┌─────────────────┐ ┌──────────────────┐ ┌──────────────┐ │
│ │ │ │ │ │ │ │
│ │ Intel SGX │ │ ARM TrustZone │ │ AMD SEV │ │
│ │ Enclaves │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ └─────────────────┘ └──────────────────┘ └──────────────┘ │
│ │
└────────────────────────────────────────────────────────────────┘
5. TeeTerminal Architecture Diagram
┌─────────────────────────────────────────────────────────────────────┐
│ TEETERMINAL SYSTEM │
└─────────────────────────────────────────────────────────────────────┘
│
┌─────────────────────────────────┼─────────────────────────────────┐
│ │ │
│ ┌──────────────────────────────────────────────────────────────┐ │
│ │ CLIENT APPLICATION │ │
│ │ │ │
│ │ ┌───────────────┐ ┌───────────────┐ ┌──────────────┐ │ │
│ │ │ Terminal UI │ │ Wallet │ │ Encryption │ │ │
│ │ │ (React/ │◄───┤ Connection │ │ Module │ │ │
│ │ │ Next.js) │ │ (Phantom) │ │ │ │ │
│ │ └───────┬───────┘ └───────────────┘ └──────┬───────┘ │ │
│ │ │ │ │ │
│ │ │ │ │ │
│ │ ▼ ▼ │ │
│ │ ┌───────────────┐ ┌──────────────────┐ │ │
│ │ │ Command │ │ Client-side TEE │ │ │
│ │ │ Processor │◄─────────────────────┤ Agent │ │ │
│ │ │ │ │ │ │ │
│ │ └───────┬───────┘ └──────────────────┘ │ │
│ │ │ ▲ │ │
│ └──────────┼────────────────────────────────────────┼──────────┘ │
│ │ │ │
│ ▼ │ │
│ ┌─────────────────────┐ ┌────────────────────┐ │
│ │ │ │ │ │
│ │ SOLANA BLOCKCHAIN │ │ ASTRADB STORAGE │ │
│ │ │ │ │ │
│ └─────────┬───────────┘ └──────────┬─────────┘ │
│ │ │ │
└────────────┼────────────────────────────────────────┼─────────────┘
│ │
▼ ▼
┌────────────────────────────────────────────────────────────────────┐
│ TEE SERVER NETWORK │
│ │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
│ │ │ │ │ │ │ │
│ │ AI Model │ │ Validator │ │ Proof │ │
│ │ Execution │ │ Nodes │ │ Generation │ │
│ │ │ │ │ │ │ │
│ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
│ │
└────────────────────────────────────────────────────────────────────┘
6. TEE Security Model Visualization
┌────────────────────────────────────────────────────────────────┐
│ TEE SECURITY LAYERS │
└────────────────────────────────────────────────────────────────┘
│
▼
┌────────────────────────────────────────────────────────────────┐
│ HARDWARE ROOT OF TRUST │
│ │
│ The foundation of TEE security is special hardware that │
│ provides physical isolation and tamper resistance. │
│ │
└────────────────────────────────────────────────────────────────┘
│
▼
┌────────────────────────────────────────────────────────────────┐
│ SECURE BOOT PROCESS │
│ │
│ Each component in the boot chain is verified before execution, │
│ ensuring only authorized code runs in the TEE. │
│ │
└────────────────────────────────────────────────────────────────┘
│
▼
┌────────────────────────────────────────────────────────────────┐
│ MEMORY ENCRYPTION │
│ │
│ All data in TEE memory is encrypted, protecting against │
│ physical attacks like cold boot or memory probing. │
│ │
└────────────────────────────────────────────────────────────────┘
│
▼
┌────────────────────────────────────────────────────────────────┐
│ CODE ATTESTATION │
│ │
│ The TEE can prove to remote parties that it's running │
│ authentic, unmodified code in a genuine secure environment. │
│ │
└────────────────────────────────────────────────────────────────┘
│
▼
┌────────────────────────────────────────────────────────────────┐
│ SEALED STORAGE │
│ │
│ Data can be encrypted in a way that only the same TEE │
│ running the same code can decrypt it later. │
│ │
└────────────────────────────────────────────────────────────────┘
7. TEE in Web3 Application Flow
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ │ │ │ │ │
│ USER │ │ DAPP │ │ BLOCKCHAIN │
│ │ │ │ │ │
└───────┬───────┘ └───────┬───────┘ └───────┬───────┘
│ │ │
│ 1. Initiate action │ │
│ ─────────────────────► │ │
│ │ │
│ │ 2. Request TEE │
│ │ processing │
│ │ ───────────────────────┤
│ │ │ ┌───────────────┐
│ │ │ │ │
│ │ │ │ TEE NODE │
│ │ │ │ │
│ │ │ └───────┬───────┘
│ │ │ │
│ │ │ 3. Execute in │
│ │ │ secure │
│ │ │ enclave │
│ │ │ ◄───────────────┤
│ │ │ │
│ │ │ 4. Generate │
│ │ 5. Verify TEE │ attestation │
│ │ attestation │ ◄───────────────┤
│ │ ◄─────────────────────-┤ │
│ │ │ │
│ 6. Return verified │ │ │
│ result │ │ │
│ ◄─────────────────────-┤ │ │
│ │ │ │
8. TEE Execution Flow in Detail
┌─────────────────────────────────────────────────────────────────────┐
│ TEE EXECUTION LIFECYCLE │
└─────────────────────────────────────────────────────────────────────┘
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ │ │ │ │ │
│ INITIALIZE ├────►│ LOAD ├────►│ EXECUTE │
│ │ │ │ │ │
└─────────────┘ └─────────────┘ └──────┬──────┘
│
┌─────────────┐ ┌─────────────┐ │
│ │ │ │ │
│ ATTEST │◄────┤ SEAL │◄──────────┘
│ │ │ │
└──────┬──────┘ └─────────────┘
│
▼
┌─────────────┐
│ │
│ TERMINATE │
│ │
└─────────────┘
┌────────────────────────────────────────────────────────────────────┐
│ INITIALIZE: │
│ - TEE environment is started │
│ - Security parameters are established │
│ - Memory areas are allocated and protected │
└────────────────────────────────────────────────────────────────────┘
┌────────────────────────────────────────────────────────────────────┐
│ LOAD: │
│ - Code is verified with digital signatures │
│ - Verified code is loaded into protected memory │
│ - Input data is securely transferred into the enclave │
└────────────────────────────────────────────────────────────────────┘
┌────────────────────────────────────────────────────────────────────┐
│ EXECUTE: │
│ - Code runs in the isolated environment │
│ - Operations are performed on sensitive data │
│ - Results are generated within the protected memory │
└────────────────────────────────────────────────────────────────────┘
┌────────────────────────────────────────────────────────────────────┐
│ SEAL: │
│ - Results are encrypted with enclave-specific keys │
│ - Only the same enclave or authorized entities can decrypt │
│ - Provides confidentiality for data at rest │
└────────────────────────────────────────────────────────────────────┘
┌────────────────────────────────────────────────────────────────────┐
│ ATTEST: │
│ - TEE creates cryptographic proof of its state │
│ - Proof verifies hardware authenticity, code integrity │
│ - Remote parties can verify the enclave is trustworthy │
└────────────────────────────────────────────────────────────────────┘
┌────────────────────────────────────────────────────────────────────┐
│ TERMINATE: │
│ - Secure wiping of sensitive data from memory │
│ - Resources are released │
│ - Protected memory is cleared │
└────────────────────────────────────────────────────────────────────┘
9. TeeTerminal User Interaction Flow
┌─────────────────────────────────────────────────────────────────────┐
│ TEETERMINAL USER JOURNEY │
└─────────────────────────────────────────────────────────────────────┘
┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ │ │ │ │ │ │ │
│ CONNECT ├────►│ AUTHENTICATE├────►│ ISSUE ├────►│ RECEIVE │
│ WALLET │ │ │ │ COMMAND │ │ RESPONSE │
│ │ │ │ │ │ │ │
└─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘
│
│
┌─────────────┐ ┌─────────────┐ │
│ │ │ │ │
│ VERIFY │◄────┤ PROCESS │◄─────────────────────────────┘
│ RESULT │ │ RESULT │
│ │ │ │
└─────────────┘ └─────────────┘
10. Practical Example: TEE-Secured AI Chat
┌───────────────────────────────────────────────────────────────────┐
│ TEE-SECURED AI CHAT FLOW │
└───────────────────────────────────────────────────────────────────┘
┌─────────────────┐ ┌─────────────────┐
│ │ │ │
│ USER A │ │ USER B │
│ │ │ │
└────────┬────────┘ └────────┬────────┘
│ │
│ │
▼ ▼
┌─────────────────┐ ┌─────────────────┐
│ │ │ │
│ USER A DEVICE │ │ USER B DEVICE │
│ WITH TEE │ │ WITH TEE │
│ │ │ │
└────────┬────────┘ └────────┬────────┘
│ │
│ Encrypt with Encrypt with │
│ User B's User A's │
│ public key public key │
│ │
▼ ▼
┌───────────────────────────────────────────────────────────────────┐
│ │
│ BLOCKCHAIN NETWORK │
│ │
│ ┌─────────────────────────────────────────────────────────────┐ │
│ │ │ │
│ │ ENCRYPTED MESSAGE STORAGE │ │
│ │ │ │
│ └─────────────────────────────────────────────────────────────┘ │
│ │ │
└───────────────────────────────┼────────────────────────────────────┘
│
▼
┌───────────────────────────────────────────────────────────────────┐
│ │
│ TEE-SECURED AI SERVER │
│ │
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────┐ │
│ │ │ │ │ │ │ │
│ │ AI MODEL │ │ PRIVACY │ │ ATTESTATION │ │
│ │ (IN ENCLAVE) │ │ FILTERS │ │ SERVICE │ │
│ │ │ │ │ │ │ │
│ └─────────────────┘ └─────────────────┘ └─────────────┘ │
│ │
└───────────────────────────────────────────────────────────────────┘
11. TEE Implementation Components for Developers
Hardware Options
┌───────────────────────────────────────────────────────────────────┐
│ TEE HARDWARE OPTIONS │
└───────────────────────────────────────────────────────────────────┘
┌─────────────────────┐ ┌─────────────────────┐ ┌─────────────────────┐
│ │ │ │ │ │
│ INTEL SGX │ │ ARM TRUSTZONE │ │ AMD SEV │
│ │ │ │ │ │
├─────────────────────┤ ├─────────────────────┤ ├─────────────────────┤
│ • Enclaves │ │ • Secure/Normal │ │ • VM Memory │
│ • Memory encryption │ │ world separation │ │ encryption │
│ • Attestation │ │ • Mobile focused │ │ • Cloud focused │
│ • Desktop/server │ │ • Built into ARM │ │ • AMD EPYC CPUs │
│ │ │ processors │ │ │
└─────────────────────┘ └─────────────────────┘ └─────────────────────┘
Software Frameworks
┌───────────────────────────────────────────────────────────────────┐
│ TEE SOFTWARE FRAMEWORKS │
└───────────────────────────────────────────────────────────────────┘
┌─────────────────────┐ ┌─────────────────────┐ ┌─────────────────────┐
│ │ │ │ │ │
│ OPEN ENCLAVE │ │ GRAMINE │ │ TEACLAVE │
│ │ │ │ │ │
├─────────────────────┤ ├─────────────────────┤ ├─────────────────────┤
│ • Multi-TEE SDK │ │ • Library OS │ │ • Rust-based │
│ • C/C++ support │ │ • Run unmodified │ │ • Apache project │
│ • Cross-platform │ │ applications │ │ • Function-as-a- │
│ • Microsoft-backed │ │ • Linux support │ │ service platform │
│ │ │ │ │ │
└─────────────────────┘ └─────────────────────┘ └─────────────────────┘
12. Conclusion
TEEs provide a powerful foundation for secure, private computation in Web3 applications. By understanding these architectural concepts, even beginners can grasp how TEEs enable confidential smart contracts, private AI, and other privacy-preserving applications in the blockchain ecosystem.
The key takeaway is that TEEs create a hardware-enforced "bubble" of security within otherwise open systems, allowing sensitive operations to occur with both privacy and verifiability - qualities that are essential for next-generation Web3 applications.
Last updated