@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 +183 -50
- package/dist/_esm-L4OBJJWB.js +3913 -0
- package/dist/_esm-L4OBJJWB.js.map +1 -0
- package/dist/ccip-MMGH6DXX.js +14 -0
- package/dist/ccip-MMGH6DXX.js.map +1 -0
- package/dist/chunk-4L6P6TY5.js +2556 -0
- package/dist/chunk-4L6P6TY5.js.map +1 -0
- package/dist/chunk-NTU6R7BC.js +4019 -0
- package/dist/chunk-NTU6R7BC.js.map +1 -0
- package/dist/chunk-PR4QN5HX.js +43 -0
- package/dist/chunk-PR4QN5HX.js.map +1 -0
- package/dist/index.js +1253 -2
- package/dist/index.js.map +1 -1
- package/dist/secp256k1-QUTB2QC2.js +14 -0
- package/dist/secp256k1-QUTB2QC2.js.map +1 -0
- package/package.json +40 -27
- package/tsup.config.ts +0 -28
package/README.md
CHANGED
|
@@ -1,16 +1,50 @@
|
|
|
1
|
-
#
|
|
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
|
-
##
|
|
5
|
+
## Overview
|
|
6
6
|
|
|
7
|
-
This plugin
|
|
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
|
-
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @elizaos/plugin-tee
|
|
18
|
+
```
|
|
10
19
|
|
|
11
|
-
|
|
20
|
+
## Configuration
|
|
12
21
|
|
|
13
|
-
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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`
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
87
|
+
## Development
|
|
88
|
+
|
|
89
|
+
### Building
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
npm run build
|
|
72
93
|
```
|
|
73
94
|
|
|
74
|
-
###
|
|
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
|
-
|
|
111
|
+
## Dependencies
|
|
85
112
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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.
|