|
9 | 9 |
|
10 | 10 | **Example applications for [dstack](https://github.com/Dstack-TEE/dstack) - Deploy containerized apps to TEEs with end-to-end security in minutes** |
11 | 11 |
|
12 | | -[Getting Started](#getting-started) • [Examples](#examples) • [Contributing](CONTRIBUTING.md) • [Documentation](#documentation) • [Community](#community) |
| 12 | +[Use Cases](#use-cases) • [Architecture Walkthrough](#architecture-walkthrough) • [Dev Tools](#dev-scaffolding) • [Documentation](#documentation) |
13 | 13 |
|
14 | 14 | </div> |
15 | 15 |
|
|
19 | 19 |
|
20 | 20 | This repository contains ready-to-deploy examples demonstrating how to build and run applications on [dstack](https://github.com/Dstack-TEE/dstack), the developer-friendly SDK for deploying containerized apps in Trusted Execution Environments (TEE). |
21 | 21 |
|
22 | | -### What You'll Find Here |
23 | | - |
24 | | -- **Security Features** - Remote attestation, verification, and privacy-preserving apps |
25 | | -- **Secret Management** - Secure handling of credentials and sensitive data in TEE environments |
26 | | -- **Networking Patterns** - HTTPS termination, custom domains, port forwarding in the cloud |
27 | | -- **Best Practices** - Production-ready implementations following TEE security principles |
| 22 | +The examples are organized to follow the **TEE+EVM design patterns** from [ERC-733](https://erc733.org), walking through the key architectural layers: attestation, gateway/interoperability, key management, and on-chain interaction. |
28 | 23 |
|
29 | 24 | ## Prerequisites |
30 | 25 |
|
31 | | -Before you begin, ensure you have: |
32 | | - |
33 | | -- Access to a dstack environment |
| 26 | +- Access to a dstack environment (self-hosted or [Phala Cloud](https://cloud.phala.network)) |
34 | 27 | - Basic understanding of [TEE concepts](https://docs.phala.network/dstack) |
35 | | -- Basic familiarity with Docker Compose configuration files |
| 28 | +- Basic familiarity with Docker Compose |
36 | 29 | - Git for cloning the repository |
37 | 30 |
|
38 | | -You can deploy dstack on your own server, or use [Phala Cloud](https://cloud.phala.network). |
39 | | - |
40 | | -## Getting Started |
41 | | - |
42 | | -### Quick Start |
43 | | - |
44 | 31 | ```bash |
45 | | -# Clone the repository |
46 | 32 | git clone https://github.com/Dstack-TEE/dstack-examples.git |
47 | 33 | cd dstack-examples |
| 34 | +``` |
48 | 35 |
|
49 | | -# Choose an example |
50 | | -cd attestation/configid-based |
| 36 | +--- |
51 | 37 |
|
52 | | -# Copy the docker-compose.yaml content to your dstack deployment |
53 | | -# Follow the example-specific README for deployment instructions |
54 | | -``` |
| 38 | +## Use Cases |
55 | 39 |
|
56 | | -## Examples |
| 40 | +Real-world applications that serve as **reference implementations** for ERC-733 TEE+EVM patterns. |
| 41 | + |
| 42 | +| Example | Description | Status | |
| 43 | +|---------|-------------|--------| |
| 44 | +| [8004-agent](./8004-agent) | Trustless AI agent (ERC-8004) with on-chain attestation, LLM access via TLS | Coming Soon | |
| 45 | +| [oracle](./oracle) | TEE oracle returning JSON + signature + attestation bundle | Coming Soon | |
| 46 | +| [mcp-server](./mcp-server) | Attested MCP tool server behind gateway | Coming Soon | |
| 47 | +| [telegram-agent](./telegram-agent) | Telegram bot with TEE wallet and verified execution | Coming Soon | |
| 48 | + |
| 49 | +--- |
| 50 | + |
| 51 | +## Architecture Walkthrough |
| 52 | + |
| 53 | +These examples teach the **layered TEE+EVM architecture** from ERC-733. Work through them in order to understand how dstack applications are built. |
| 54 | + |
| 55 | +### 1. Attestation Layer |
| 56 | + |
| 57 | +The foundation: establish trust by verifying and committing the enclave's code measurement on-chain. |
57 | 58 |
|
58 | | -### Security & Attestation |
59 | 59 | | Example | Description | |
60 | 60 | |---------|-------------| |
61 | 61 | | [attestation/configid-based](./attestation/configid-based) | ConfigID-based remote attestation verification | |
62 | | -| [attestation/rtmr3-based](./attestation/rtmr3-based) | RTMR3-based attestation (legacy) | |
| 62 | +| [timelock-nts](./timelock-nts) | Timelock decryption using NTS (Network Time Security) | |
| 63 | + |
| 64 | +**What you learn:** Code measurement, attestation documents, X.509 verification, secp256k1 enclave keys. |
| 65 | + |
| 66 | +### 2. Gateway Layer |
| 67 | + |
| 68 | +Interoperability: TLS termination inside the enclave, domain routing, external connectivity. |
63 | 69 |
|
64 | | -### Networking & Domains |
65 | 70 | | Example | Description | |
66 | 71 | |---------|-------------| |
67 | | -| [custom-domain](./custom-domain) | Set up custom domain with automatic TLS certificate management via zt-https | |
| 72 | +| [custom-domain](./custom-domain) | Custom domain with automatic TLS via zt-https (model of dstack gateway) | |
| 73 | + |
| 74 | +**What you learn:** TLS termination in enclave, DNS → TLS → route pattern, reverse proxy. |
| 75 | + |
| 76 | +### 3. Keys & Replication Layer |
| 77 | + |
| 78 | +Production reality: persistent keys across machines, crash recovery, upgrades. |
| 79 | + |
| 80 | +| Example | Description | Status | |
| 81 | +|---------|-------------|--------| |
| 82 | +| [get-key-basic](./get-key-basic) | `dstack.get_key()` — same key identity across deployments | Coming Soon | |
| 83 | + |
| 84 | +**What you learn:** KMS interaction, secrets replication, upgrade policies, dev-proofness. |
| 85 | + |
| 86 | +### 4. On-Chain Interaction Layer |
| 87 | + |
| 88 | +Blockchain integration: light client for reading chain state, coprocessor pattern for anchoring outputs. |
| 89 | + |
| 90 | +| Example | Description | |
| 91 | +|---------|-------------| |
| 92 | +| [lightclient](./lightclient) | Ethereum light client (Helios) running in enclave | |
| 93 | + |
| 94 | +**What you learn:** Light client in TEE, verifying on-chain state, coprocessor receipts. |
| 95 | + |
| 96 | +--- |
| 97 | + |
| 98 | +## Dev Scaffolding |
| 99 | + |
| 100 | +Development and debugging tools. **Not for production** — useful during development. |
| 101 | + |
| 102 | +| Example | Description | |
| 103 | +|---------|-------------| |
| 104 | +| [webshell](./webshell) | Web-based shell access for debugging | |
68 | 105 | | [ssh-over-gateway](./ssh-over-gateway) | SSH tunneling through dstack gateway | |
69 | 106 | | [tcp-port-forwarding](./tcp-port-forwarding) | Arbitrary TCP port forwarding | |
70 | | -| [tor-hidden-service](./tor-hidden-service) | Run Tor hidden services in TEEs | |
71 | 107 |
|
72 | | -### Development Tools |
| 108 | +--- |
| 109 | + |
| 110 | +## Tech Demos |
| 111 | + |
| 112 | +Interesting demonstrations — cool tech but not yet fully developed use cases with clear security stories. |
| 113 | + |
73 | 114 | | Example | Description | |
74 | 115 | |---------|-------------| |
75 | | -| [launcher](./launcher) | Generic launcher pattern for Docker Compose apps | |
76 | | -| [webshell](./webshell) | Web-based shell access for debugging | |
77 | | -| [prelaunch-script](./prelaunch-script) | Pre-launch script patterns used by Phala Cloud | |
| 116 | +| [tor-hidden-service](./tor-hidden-service) | Run Tor hidden services in TEEs | |
| 117 | + |
| 118 | +--- |
| 119 | + |
| 120 | +## Details |
| 121 | + |
| 122 | +Implementation details and infrastructure patterns. Not primary use cases. |
78 | 123 |
|
79 | | -### Advanced Use Cases |
80 | 124 | | Example | Description | |
81 | 125 | |---------|-------------| |
82 | | -| [lightclient](./lightclient) | Blockchain light client integration | |
83 | | -| [timelock-nts](./timelock-nts) | Timelock decryption with NTS | |
| 126 | +| [launcher](./launcher) | Generic launcher pattern for Docker Compose apps | |
| 127 | +| [prelaunch-script](./prelaunch-script) | Pre-launch script patterns (Phala Cloud) | |
84 | 128 | | [private-docker-image-deployment](./private-docker-image-deployment) | Using private Docker registries | |
| 129 | +| [attestation/rtmr3-based](./attestation/rtmr3-based) | RTMR3-based attestation (legacy) | |
| 130 | + |
| 131 | +--- |
85 | 132 |
|
86 | 133 | ## Documentation |
87 | 134 |
|
88 | 135 | - **[dstack Documentation](https://docs.phala.network/dstack)** - Official platform documentation |
89 | 136 | - **[Main Repository](https://github.com/Dstack-TEE/dstack)** - Core dstack framework |
90 | | -- **[Security Guide](SECURITY.md)** - Security best practices |
| 137 | +- **[ERC-733](https://erc733.org)** - TEE+EVM design patterns standard |
91 | 138 | - **[Contributing Guide](CONTRIBUTING.md)** - How to contribute |
92 | 139 |
|
93 | 140 | ## Development |
94 | 141 |
|
95 | | -Use the `dev.sh` script for validation and development tasks: |
96 | | - |
97 | 142 | ```bash |
98 | 143 | ./dev.sh help # Show available commands |
99 | 144 | ./dev.sh validate <example> # Validate a specific example |
100 | 145 | ./dev.sh validate-all # Validate all examples |
101 | | -./dev.sh security # Run security checks |
102 | | -./dev.sh lint # Run linting checks |
103 | | -./dev.sh check-all # Run all checks |
104 | 146 | ``` |
105 | 147 |
|
106 | | -## Contributing |
107 | | - |
108 | | -We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details. |
109 | | - |
110 | 148 | ## Community |
111 | 149 |
|
112 | | -### Getting Help |
113 | | - |
114 | 150 | - **Telegram**: [Join our community](https://t.me/+UO4bS4jflr45YmUx) |
115 | 151 | - **Issues**: [GitHub Issues](https://github.com/Dstack-TEE/dstack-examples/issues) |
116 | 152 |
|
117 | | -### Reporting Issues |
118 | | - |
119 | | -When reporting issues, please include: |
120 | | - |
121 | | -1. Example name and version |
122 | | -2. Steps to reproduce |
123 | | -3. Expected vs actual behavior |
124 | | -4. Relevant logs and error messages |
125 | | - |
126 | 153 | ## License |
127 | 154 |
|
128 | | -This project is licensed under the Apache 2.0 License - see the [LICENSE](LICENSE) file for details. |
| 155 | +Apache 2.0 — see [LICENSE](LICENSE). |
129 | 156 |
|
130 | 157 | --- |
131 | 158 |
|
|
0 commit comments