From 0f48933b8b7a536aa587f90e9187bef2653e46d8 Mon Sep 17 00:00:00 2001 From: Shelven Zhou Date: Sun, 1 Dec 2024 16:39:06 +0800 Subject: [PATCH] add simulator tutor for plugin-tee docs --- docs/docs/packages/plugins.md | 82 +++-------------------------------- packages/plugin-tee/README.md | 8 ++++ 2 files changed, 13 insertions(+), 77 deletions(-) diff --git a/docs/docs/packages/plugins.md b/docs/docs/packages/plugins.md index ae9b9587ba8..092b6cecf33 100644 --- a/docs/docs/packages/plugins.md +++ b/docs/docs/packages/plugins.md @@ -538,86 +538,14 @@ try { **Configuration** -When using the provider through the runtime environment, ensure the following settings are configured: - -```env - # Optional, for simulator purposes if testing on mac or windows. Leave empty for Linux x86 machines. -DSTACK_SIMULATOR_ENDPOINT="http://host.docker.internal:8090" -WALLET_SECRET_SALT=your-secret-salt // Required to single agent deployments -``` - ---- - -#### 7. TEE Plugin (`@ai16z/plugin-tee`) - -Integrates [Dstack SDK](https://github.com/Dstack-TEE/dstack) to enable TEE (Trusted Execution Environment) functionality and deploy secure & privacy-enhanced Eliza Agents: - -**Providers:** - -- `deriveKeyProvider` - Allows for secure key derivation within a TEE environment. It supports deriving keys for both Solana (Ed25519) and Ethereum (ECDSA) chains. -- `remoteAttestationProvider` - Generate a Remote Attestation Quote based on `report_data`. - -**DeriveKeyProvider Usage** - -```typescript -import { DeriveKeyProvider } from "@ai16z/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); -} +To get a TEE simulator for local testing, use the following commands: -// 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 Usage** - -```typescript -import { RemoteAttestationProvider } from "@ai16z/plugin-tee"; -// Initialize the provider -const provider = new RemoteAttestationProvider(); -// Generate Remote Attestation -try { - const attestation = await provider.generateAttestation("your-report-data"); - console.log("Attestation:", attestation); -} catch (error) { - console.error("Failed to generate attestation:", error); -} +```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 ``` -**Configuration** - When using the provider through the runtime environment, ensure the following settings are configured: ```env diff --git a/packages/plugin-tee/README.md b/packages/plugin-tee/README.md index 4b256cdb460..5933b13b733 100644 --- a/packages/plugin-tee/README.md +++ b/packages/plugin-tee/README.md @@ -73,6 +73,14 @@ try { ### 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