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

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