forked from elizaOS/eliza
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2fc8990
commit 905e012
Showing
26 changed files
with
2,127 additions
and
961 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
* | ||
|
||
!dist/** | ||
!package.json | ||
!readme.md | ||
!tsup.config.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Plugin TEE | ||
|
||
A plugin for handling Trusted Execution Environment (TEE) operations. | ||
|
||
## Providers | ||
|
||
This plugin includes several providers for handling different TEE-related operations. | ||
|
||
### DeriveKeyProvider | ||
|
||
The `DeriveKeyProvider` allows for secure key derivation within a TEE environment. It supports deriving keys for both Solana (Ed25519) and Ethereum (ECDSA) chains. | ||
|
||
#### Usage | ||
|
||
```typescript | ||
import { DeriveKeyProvider } from "@elizaos/plugin-tee"; | ||
|
||
// Initialize the provider | ||
const provider = new DeriveKeyProvider(); | ||
|
||
// Derive a raw key | ||
try { | ||
const rawKey = await provider.rawDeriveKey( | ||
"/path/to/derive", | ||
"subject-identifier" | ||
); | ||
// rawKey is a DeriveKeyResponse that can be used for further processing | ||
// to get the uint8Array do the following | ||
const rawKeyArray = rawKey.asUint8Array(); | ||
} catch (error) { | ||
console.error("Raw key derivation failed:", error); | ||
} | ||
|
||
// Derive a Solana keypair (Ed25519) | ||
try { | ||
const solanaKeypair = await provider.deriveEd25519Keypair( | ||
"/path/to/derive", | ||
"subject-identifier" | ||
); | ||
// solanaKeypair can now be used for Solana operations | ||
} catch (error) { | ||
console.error("Solana key derivation failed:", error); | ||
} | ||
|
||
// Derive an Ethereum keypair (ECDSA) | ||
try { | ||
const evmKeypair = await provider.deriveEcdsaKeypair( | ||
"/path/to/derive", | ||
"subject-identifier" | ||
); | ||
// evmKeypair can now be used for Ethereum operations | ||
} catch (error) { | ||
console.error("EVM key derivation failed:", error); | ||
} | ||
``` | ||
|
||
### RemoteAttestationProvider | ||
|
||
The `RemoteAttestationProvider` allows for generating a remote attestation within a TEE environment. | ||
|
||
#### Usage | ||
|
||
```typescript | ||
const provider = new RemoteAttestationProvider(); | ||
|
||
try { | ||
const attestation = await provider.generateAttestation("your-report-data"); | ||
console.log("Attestation:", attestation); | ||
} catch (error) { | ||
console.error("Failed to generate attestation:", error); | ||
} | ||
``` | ||
|
||
### Configuration | ||
|
||
To get a TEE simulator for local testing, use the following commands: | ||
|
||
```bash | ||
docker pull phalanetwork/tappd-simulator:latest | ||
# by default the simulator is available in localhost:8090 | ||
docker run --rm -p 8090:8090 phalanetwork/tappd-simulator:latest | ||
``` | ||
|
||
When using the provider through the runtime environment, ensure the following settings are configured: | ||
|
||
```env | ||
DSTACK_SIMULATOR_ENDPOINT="your-endpoint-url" # Optional, for simulator purposes if testing on mac or windows | ||
WALLET_SECRET_SALT=your-secret-salt // Required to single agent deployments | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import eslintGlobalConfig from "../../eslint.config.mjs"; | ||
|
||
export default [...eslintGlobalConfig]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "@elizaos/plugin-cosmos-tee", | ||
"version": "0.1.7-alpha.1", | ||
"main": "dist/index.js", | ||
"type": "module", | ||
"types": "dist/index.d.ts", | ||
"dependencies": { | ||
"@elizaos/core": "workspace:*", | ||
"@phala/dstack-sdk": "0.1.6", | ||
"@solana/spl-token": "0.4.9", | ||
"@solana/web3.js": "1.95.8", | ||
"bignumber": "1.1.0", | ||
"bignumber.js": "9.1.2", | ||
"bs58": "6.0.0", | ||
"node-cache": "5.1.2", | ||
"pumpdotfun-sdk": "1.3.2", | ||
"tsup": "8.3.5", | ||
"viem": "2.21.53" | ||
}, | ||
"scripts": { | ||
"build": "tsup --format esm --dts", | ||
"dev": "tsup --format esm --dts --watch", | ||
"lint": "eslint --fix --cache ." | ||
}, | ||
"peerDependencies": { | ||
"whatwg-url": "7.1.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Plugin } from "@elizaos/core"; | ||
import { remoteAttestationProvider } from "./providers/remoteAttestationProvider"; | ||
import { deriveKeyProvider } from "./providers/deriveKeyProvider"; | ||
|
||
export { DeriveKeyProvider } from "./providers/deriveKeyProvider"; | ||
export { RemoteAttestationProvider } from "./providers/remoteAttestationProvider"; | ||
export { RemoteAttestationQuote, TEEMode } from "./types/tee"; | ||
|
||
export const teePlugin: Plugin = { | ||
name: "tee", | ||
description: | ||
"TEE plugin with actions to generate remote attestations and derive keys", | ||
actions: [ | ||
/* custom actions */ | ||
], | ||
evaluators: [ | ||
/* custom evaluators */ | ||
], | ||
providers: [ | ||
/* custom providers */ | ||
remoteAttestationProvider, | ||
deriveKeyProvider, | ||
], | ||
services: [ | ||
/* custom services */ | ||
], | ||
}; |
Oops, something went wrong.