@elizaos/plugin-tee 0.1.7-alpha.2 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,16 +1,51 @@
1
- # Plugin TEE
1
+ # @elizaos/plugin-tee
2
2
 
3
- A plugin for handling Trusted Execution Environment (TEE) operations.
3
+ A plugin for handling Trusted Execution Environment (TEE) operations, providing secure key derivation and remote attestation capabilities.
4
4
 
5
- ## Providers
5
+ ## Overview
6
6
 
7
- This plugin includes several providers for handling different TEE-related operations.
7
+ This plugin provides functionality to:
8
8
 
9
- ### DeriveKeyProvider
9
+ - Generate secure keys within a TEE environment
10
+ - Derive Ed25519 keypairs for Solana
11
+ - Derive ECDSA keypairs for Ethereum
12
+ - Generate remote attestation quotes
13
+ - Manage wallet interactions with TEE-derived keys
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @elizaos/plugin-tee
19
+ ```
10
20
 
11
- The `DeriveKeyProvider` allows for secure key derivation within a TEE environment. It supports deriving keys for both Solana (Ed25519) and Ethereum (ECDSA) chains.
21
+ ## Configuration
22
+
23
+ The plugin requires the following environment variables:
24
+
25
+ ```env
26
+ TEE_MODE=LOCAL|DOCKER|PRODUCTION
27
+ WALLET_SECRET_SALT=your_secret_salt # Required for single agent deployments
28
+ DSTACK_SIMULATOR_ENDPOINT=your-endpoint-url # Optional, for simulator purposes
29
+ ```
12
30
 
13
- #### Usage
31
+ ## Usage
32
+
33
+ Import and register the plugin in your Eliza configuration:
34
+
35
+ ```typescript
36
+ import { teePlugin } from "@elizaos/plugin-tee";
37
+
38
+ export default {
39
+ plugins: [teePlugin],
40
+ // ... other configuration
41
+ };
42
+ ```
43
+
44
+ ## Features
45
+
46
+ ### DeriveKeyProvider
47
+
48
+ The `DeriveKeyProvider` allows for secure key derivation within a TEE environment:
14
49
 
15
50
  ```typescript
16
51
  import { DeriveKeyProvider } from "@elizaos/plugin-tee";
@@ -19,59 +54,52 @@ import { DeriveKeyProvider } from "@elizaos/plugin-tee";
19
54
  const provider = new DeriveKeyProvider();
20
55
 
21
56
  // Derive a raw key
22
- try {
23
- const rawKey = await provider.rawDeriveKey(
24
- "/path/to/derive",
25
- "subject-identifier"
26
- );
27
- // rawKey is a DeriveKeyResponse that can be used for further processing
28
- // to get the uint8Array do the following
29
- const rawKeyArray = rawKey.asUint8Array();
30
- } catch (error) {
31
- console.error("Raw key derivation failed:", error);
32
- }
57
+ const rawKey = await provider.rawDeriveKey(
58
+ "/path/to/derive",
59
+ "subject-identifier"
60
+ );
61
+ // rawKey is a DeriveKeyResponse that can be used for further processing
62
+ const rawKeyArray = rawKey.asUint8Array();
33
63
 
34
64
  // Derive a Solana keypair (Ed25519)
35
- try {
36
- const solanaKeypair = await provider.deriveEd25519Keypair(
37
- "/path/to/derive",
38
- "subject-identifier"
39
- );
40
- // solanaKeypair can now be used for Solana operations
41
- } catch (error) {
42
- console.error("Solana key derivation failed:", error);
43
- }
65
+ const solanaKeypair = await provider.deriveEd25519Keypair(
66
+ "/path/to/derive",
67
+ "subject-identifier"
68
+ );
44
69
 
45
70
  // Derive an Ethereum keypair (ECDSA)
46
- try {
47
- const evmKeypair = await provider.deriveEcdsaKeypair(
48
- "/path/to/derive",
49
- "subject-identifier"
50
- );
51
- // evmKeypair can now be used for Ethereum operations
52
- } catch (error) {
53
- console.error("EVM key derivation failed:", error);
54
- }
71
+ const evmKeypair = await provider.deriveEcdsaKeypair(
72
+ "/path/to/derive",
73
+ "subject-identifier"
74
+ );
55
75
  ```
56
76
 
57
77
  ### RemoteAttestationProvider
58
78
 
59
- The `RemoteAttestationProvider` allows for generating a remote attestation within a TEE environment.
60
-
61
- #### Usage
79
+ The `RemoteAttestationProvider` generates remote attestations within a TEE environment:
62
80
 
63
81
  ```typescript
82
+ import { RemoteAttestationProvider } from "@elizaos/plugin-tee";
83
+
64
84
  const provider = new RemoteAttestationProvider();
85
+ const attestation = await provider.generateAttestation("your-report-data");
86
+ ```
65
87
 
66
- try {
67
- const attestation = await provider.generateAttestation("your-report-data");
68
- console.log("Attestation:", attestation);
69
- } catch (error) {
70
- console.error("Failed to generate attestation:", error);
71
- }
88
+ ## Development
89
+
90
+ ### Building
91
+
92
+ ```bash
93
+ npm run build
94
+ ```
95
+
96
+ ### Testing
97
+
98
+ ```bash
99
+ npm run test
72
100
  ```
73
101
 
74
- ### Configuration
102
+ ## Local Development
75
103
 
76
104
  To get a TEE simulator for local testing, use the following commands:
77
105
 
@@ -81,9 +109,122 @@ docker pull phalanetwork/tappd-simulator:latest
81
109
  docker run --rm -p 8090:8090 phalanetwork/tappd-simulator:latest
82
110
  ```
83
111
 
84
- When using the provider through the runtime environment, ensure the following settings are configured:
112
+ ## Dependencies
85
113
 
86
- ```env
87
- DSTACK_SIMULATOR_ENDPOINT="your-endpoint-url" # Optional, for simulator purposes if testing on mac or windows
88
- WALLET_SECRET_SALT=your-secret-salt // Required to single agent deployments
114
+ - `@phala/dstack-sdk`: Core TEE functionality
115
+ - `@solana/web3.js`: Solana blockchain interaction
116
+ - `viem`: Ethereum interaction library
117
+ - Other standard dependencies listed in package.json
118
+
119
+ ## API Reference
120
+
121
+ ### Providers
122
+
123
+ - `deriveKeyProvider`: Manages secure key derivation within TEE
124
+ - `remoteAttestationProvider`: Handles generation of remote attestation quotes
125
+ - `walletProvider`: Manages wallet interactions with TEE-derived keys
126
+
127
+ ### Types
128
+
129
+ ```typescript
130
+ enum TEEMode {
131
+ OFF = "OFF",
132
+ LOCAL = "LOCAL", // For local development with simulator
133
+ DOCKER = "DOCKER", // For docker development with simulator
134
+ PRODUCTION = "PRODUCTION", // For production without simulator
135
+ }
136
+
137
+ interface RemoteAttestationQuote {
138
+ quote: string;
139
+ timestamp: number;
140
+ }
89
141
  ```
142
+
143
+ ## Future Enhancements
144
+
145
+ 1. **Key Management**
146
+
147
+ - Advanced key derivation schemes
148
+ - Multi-party computation support
149
+ - Key rotation automation
150
+ - Backup and recovery systems
151
+ - Hardware security module integration
152
+ - Custom derivation paths
153
+
154
+ 2. **Remote Attestation**
155
+
156
+ - Enhanced quote verification
157
+ - Multiple TEE provider support
158
+ - Automated attestation renewal
159
+ - Policy management system
160
+ - Compliance reporting
161
+ - Audit trail generation
162
+
163
+ 3. **Security Features**
164
+
165
+ - Memory encryption improvements
166
+ - Side-channel protection
167
+ - Secure state management
168
+ - Access control systems
169
+ - Threat detection
170
+ - Security monitoring
171
+
172
+ 4. **Chain Integration**
173
+
174
+ - Multi-chain support expansion
175
+ - Cross-chain attestation
176
+ - Chain-specific optimizations
177
+ - Custom signing schemes
178
+ - Transaction privacy
179
+ - Bridge security
180
+
181
+ 5. **Developer Tools**
182
+
183
+ - Enhanced debugging capabilities
184
+ - Testing framework
185
+ - Simulation environment
186
+ - Documentation generator
187
+ - Performance profiling
188
+ - Integration templates
189
+
190
+ 6. **Performance Optimization**
191
+ - Parallel processing
192
+ - Caching mechanisms
193
+ - Resource management
194
+ - Latency reduction
195
+ - Throughput improvements
196
+ - Load balancing
197
+
198
+ We welcome community feedback and contributions to help prioritize these enhancements.
199
+
200
+ ## Contributing
201
+
202
+ Contributions are welcome! Please see the [CONTRIBUTING.md](CONTRIBUTING.md) file for more information.
203
+
204
+ ## Credits
205
+
206
+ This plugin integrates with and builds upon several key technologies:
207
+
208
+ - [Phala Network](https://phala.network/): Confidential smart contract platform
209
+ - [@phala/dstack-sdk](https://www.npmjs.com/package/@phala/dstack-sdk): Core TEE functionality
210
+ - [@solana/web3.js](https://www.npmjs.com/package/@solana/web3.js): Solana blockchain interaction
211
+ - [viem](https://www.npmjs.com/package/viem): Ethereum interaction library
212
+ - [Intel SGX](https://www.intel.com/content/www/us/en/developer/tools/software-guard-extensions/overview.html): Trusted Execution Environment technology
213
+
214
+ Special thanks to:
215
+
216
+ - The Phala Network team for their TEE infrastructure
217
+ - The Intel SGX team for TEE technology
218
+ - The dStack SDK maintainers
219
+ - The Eliza community for their contributions and feedback
220
+
221
+ For more information about TEE capabilities:
222
+
223
+ - [Phala Documentation](https://docs.phala.network/)
224
+ - [Intel SGX Documentation](https://www.intel.com/content/www/us/en/developer/tools/software-guard-extensions/documentation.html)
225
+ - [TEE Security Best Practices](https://docs.phala.network/developers/phat-contract/security-notes)
226
+ - [dStack SDK Reference](https://docs.phala.network/developers/dstack-sdk)
227
+
228
+ ## License
229
+
230
+ This plugin is part of the Eliza project. See the main project repository for license information.