@elizaos/plugin-tee 1.0.0-beta.4 → 1.0.0-beta.40

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Shaw Walters, aka Moon aka @lalalune
3
+ Copyright (c) 2025 Shaw Walters and elizaOS Contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,143 +1,91 @@
1
- # TEE Log Plugin for Eliza
1
+ # TEE Core Plugin for Eliza
2
2
 
3
- The TEE Log Plugin for Eliza is designed to enhance the logging capabilities of the Eliza by providing a structured way to generate, store and verify TEE (Trusted Execution Environment) logs for agents. This plugin ensures that all sensitive interactions are securely logged, providing a transparent and tamper-resistant record of all sensitive activities.
3
+ The TEE Core Plugin for Eliza provides foundational capabilities for agents operating within a Trusted Execution Environment (TEE). It enables agents to perform remote attestation to prove their execution within a secure enclave and manage cryptographic keys securely.
4
4
 
5
5
  ## Background
6
6
 
7
- As Eliza is a fully autonomous AI agent capable of running within a TEE, we need to demonstrate to the outside world that we are indeed operating within a TEE. This allows external parties to verify that our actions are protected by the TEE and that they are autonomously executed by Eliza, without any third-party interference. Therefore, it is necessary to leverage TEE's remote attestation and establish a TEE logging mechanism to prove that these operations are entirely and autonomously performed by Eliza within the TEE.
7
+ For Eliza agents running in a TEE, it's crucial to demonstrate this secure execution environment to external parties. Remote attestation allows an agent to generate a verifiable report, proving it's running genuine code within a specific TEE (like Intel TDX). This plugin provides the mechanisms for agents to leverage these TEE features, enhancing trust and security. Secure key derivation within the TEE is also essential for managing sensitive cryptographic operations.
8
8
 
9
9
  ## Requirements
10
10
 
11
- Since the TEE Logging is based on the TEE, it is necessary to have a TEE enabled environment. Currently, we support Intel SGX (Gramine) and Intel TDX (dstack).
11
+ - A TEE-enabled environment is required (e.g., Intel TDX).
12
+ - Configuration within Eliza to enable and utilize this plugin's features.
12
13
 
13
- - using Intel SGX (Gramine), you need to enable the plugin-sgx in the Eliza runtime, which is enabled in SGX env automatically.
14
- - using Intel TDX (dstack), you need to enable the plugin-tee in the Eliza runtime.
14
+ ## Features
15
15
 
16
- ## TEE Logging Mechanism
16
+ This plugin offers the following core TEE functionalities:
17
17
 
18
- ## TEE Logging Mechanism
18
+ 1. **Remote Attestation**:
19
19
 
20
- 1. **Key Pair Generation and Attestation**:
20
+ - Provides actions and providers (`remoteAttestationAction`, `remoteAttestationProvider`) allowing agents to request and receive remote attestation reports.
21
+ - These reports can be presented to third parties to verify the agent's TEE residency.
22
+ - Includes support for specific TEE vendors/attestation services (e.g., Phala Network).
21
23
 
22
- - During startup, each agent generates a key pair and creates a remote attestation for the public key. The private key is securely stored in the TEE's encrypted memory. The agent's relevant information, along with the public key and attestation, is recorded in a local database. A new key pair is generated each time the agent is updated or restarted to ensure key security.
24
+ 2. **Key Derivation**:
25
+ - Offers a `deriveKeyProvider` for securely deriving cryptographic keys within the TEE.
26
+ - Ensures that key material is generated and managed within the protected enclave memory.
23
27
 
24
- 2. **Log Recording**:
28
+ ## Components
25
29
 
26
- - For each log entry, basic information is recorded, including `agentId`, `roomId`, `userId`, `type`, `content`, and `timestamp`. This information is concatenated and signed using the agent's corresponding private key to ensure verifiability. The verification process follows this trust chain:
27
- - Verify the attestation.
28
- - Trust the public key contained in the attestation.
29
- - Use the public key to verify the signature.
30
- - Trust the complete log record.
30
+ Based on the source code (`src/`):
31
31
 
32
- 3. **Data Storage**:
32
+ - **Actions**:
33
+ - `remoteAttestationAction.ts`: Likely handles agent requests to initiate the remote attestation process.
34
+ - **Providers**:
35
+ - `remoteAttestationProvider.ts`: Implements the logic for interacting with the underlying TEE platform or attestation service (like Phala) to generate the attestation report.
36
+ - `deriveKeyProvider.ts`: Implements the logic for TEE-specific key derivation.
37
+ - **Vendors**:
38
+ - `vendors/phala.ts`: Contains specific implementation details for interacting with the Phala Network's attestation services.
39
+ - `vendors/index.ts`, `vendors/types.ts`: Support vendor integration.
40
+ - **Utilities & Types**:
41
+ - `utils.ts`, `types.ts`: Contain helper functions and type definitions for the plugin.
42
+ - **Tests**:
43
+ - `__tests__/`: Includes unit tests for key derivation, remote attestation, etc.
33
44
 
34
- - All log data must be stored in the TEE's encrypted file system in production environments. Storing data in plaintext is prohibited to prevent tampering.
45
+ ## Usage
35
46
 
36
- 4. **Log Extraction for Verification**:
47
+ _(This section may need further refinement based on how the plugin is integrated into the core Eliza system)_
37
48
 
38
- - Third parties can extract TEE logs for verification purposes. Two types of information can be extracted:
39
- - **Agent Information**: This includes the agent's metadata, public key, and attestation, which can be used to verify the agent's public key.
40
- - **Log Information**: Required logs can be extracted, with the agent's attestation and public key used to verify the signature, ensuring that each record remains untampered.
49
+ To utilize the features of this plugin:
41
50
 
42
- 5. **Integrity Protection**:
43
- - When users extract TEE logs via the REST API, the results are hashed, and an attestation is generated. After extraction, users can verify the attestation by comparing the hash value contained within it to the extracted results, thereby ensuring the integrity of the data.
51
+ 1. **Ensure the plugin is enabled** in your Eliza agent's configuration.
52
+ 2. **Configure the TEE vendor** (e.g., specify 'phala' if using Phala Network attestation) if required by the environment setup.
53
+ 3. **Call the relevant actions or services** provided by this plugin from other agent logic or plugins when remote attestation or secure key derivation is needed.
44
54
 
45
- ## Services
46
-
47
- - **[TeeLogService]**: This service is responsible for generating and storing TEE logs for agents.
48
-
49
- ### Class: TeeLogService
50
-
51
- The `TeeLogService` class implements the `ITeeLogService` interface and extends the `Service` class. It manages the logging of sensitive interactions within a Trusted Execution Environment (TEE).
52
-
53
- #### Methods
54
-
55
- - **getInstance()**: `TeeLogService`
56
-
57
- - Returns the singleton instance of the `TeeLogService`.
58
-
59
- - **static get serviceType()**: `ServiceType`
60
-
61
- - Returns the service type for TEE logging.
62
-
63
- - **async initialize(runtime: IAgentRuntime): Promise<void>**
64
-
65
- - Initializes the TEE log service. It checks the runtime settings to configure the TEE type and enables logging if configured.
66
-
67
- - **async log(agentId: string, roomId: string, userId: string, type: string, content: string): Promise<boolean>**
68
-
69
- - Logs an interaction with the specified parameters. Returns `false` if TEE logging is not enabled.
70
-
71
- - **async getAllAgents(): Promise<TeeAgent[]>**
72
-
73
- - Retrieves all agents that have been logged. Returns an empty array if TEE logging is not enabled.
74
-
75
- - **async getAgent(agentId: string): Promise<TeeAgent | undefined>**
76
-
77
- - Retrieves the details of a specific agent by their ID. Returns `undefined` if TEE logging is not enabled.
78
-
79
- - **async getLogs(query: TeeLogQuery, page: number, pageSize: number): Promise<PageQuery<TeeLog[]>>**
80
-
81
- - Retrieves logs based on the provided query parameters. Returns an empty result if TEE logging is not enabled.
82
-
83
- - **async generateAttestation(userReport: string): Promise<string>**
84
- - Generates an attestation based on the provided user report.
85
-
86
- ### Storage
87
-
88
- The TEE logs are stored in a SQLite database, which is located at `./data/tee_log.sqlite`. The database is automatically created when the service is initialized.
89
-
90
- Important: You need to use the encrypted file system to store the database file in production, otherwise the database will be compromised. Since TEE only protects memory-in-use, the disk is not protected by the TEE. However, Many TEE development tools support the encrypted file system, for example, you can refer to the [Gramine Encrypted files](https://gramine.readthedocs.io/en/latest/manifest-syntax.html#encrypted-files) documentation for more information.
91
-
92
- ### Usage
93
-
94
- To use the `TeeLogService`, ensure that the TEE environment is properly configured and initialized.
95
-
96
- Enable the TEE logging in the Eliza .env file:
97
-
98
- ```env
99
- TEE_LOG_ENABLED=true
100
- ```
101
-
102
- The logging isn't integrated for actions by default, you need to integrate the logging for the actions you want to log. For example, if you want to log the `Continue` action of plugin-bootstrap, you can do the following:
103
-
104
- First, add plugin-tee-log to the dependencies of plugin-bootstrap:
105
-
106
- ```json
107
- "@elizaos/plugin-tee-log": "workspace:*",
108
- ```
109
-
110
- Then, add the following code to the `Continue` action:
55
+ Example (Conceptual):
111
56
 
112
57
  ```typescript
113
- import { ServiceType, ITeeLogService } from '@elizaos/core';
58
+ // Assuming access to the runtime and its services/actions
114
59
 
115
- // In the handler of the action
116
- handler: async (
60
+ // Requesting remote attestation
61
+ async function getAttestation(
117
62
  runtime: IAgentRuntime,
118
- message: Memory,
119
- state: State,
120
- options: any,
121
- callback: HandlerCallback
122
- ) => {
123
- // Continue the action
124
-
125
- // Log the action
126
- const teeLogService = runtime.getService<ITeeLogService>(ServiceType.TEE_LOG).getInstance();
127
- if (
128
- teeLogService.log(
129
- runtime.agentId,
130
- message.roomId,
131
- message.userId,
132
- 'The type of the log, for example, Action:CONTINUE',
133
- 'The content that you want to log'
134
- )
135
- ) {
136
- console.log('Logged TEE log successfully');
63
+ userData: string
64
+ ): Promise<AttestationReport | null> {
65
+ try {
66
+ // Potentially using an action defined by this plugin
67
+ const report = await runtime.invokeAction('tee/getRemoteAttestation', { userData });
68
+ console.log('Received attestation report:', report);
69
+ return report;
70
+ } catch (error) {
71
+ console.error('Failed to get remote attestation:', error);
72
+ return null;
137
73
  }
138
-
139
- // Continue the action
140
- };
74
+ }
75
+
76
+ // Deriving a key
77
+ async function deriveAgentKey(runtime: IAgentRuntime, salt: string): Promise<CryptoKey | null> {
78
+ try {
79
+ // Potentially using a service/provider interface
80
+ const keyProvider = runtime.getService<IDeriveKeyProvider>(/* ServiceType or ID */);
81
+ const key = await keyProvider.deriveKey(salt);
82
+ console.log('Derived key successfully.');
83
+ return key;
84
+ } catch (error) {
85
+ console.error('Failed to derive key:', error);
86
+ return null;
87
+ }
88
+ }
141
89
  ```
142
90
 
143
- After configuring the logging for the action, you can run the Eliza and see the logs through the client-direct REST API. See more details in the [Client-Direct REST API](../client-direct/src/README.md) documentation.
91
+ **Note:** The exact method calls (`invokeAction`, `getService`, service types/IDs) are illustrative and depend on the final integration pattern within Eliza.
package/dist/index.js CHANGED
@@ -138,7 +138,14 @@ async function uploadUint8Array(data) {
138
138
  }
139
139
  var phalaRemoteAttestationAction = {
140
140
  name: "REMOTE_ATTESTATION",
141
- similes: ["REMOTE_ATTESTATION", "TEE_REMOTE_ATTESTATION", "TEE_ATTESTATION"],
141
+ similes: [
142
+ "REMOTE_ATTESTATION",
143
+ "TEE_REMOTE_ATTESTATION",
144
+ "TEE_ATTESTATION",
145
+ "TEE_QUOTE",
146
+ "ATTESTATION",
147
+ "TEE_ATTESTATION_QUOTE"
148
+ ],
142
149
  description: "Generate a remote attestation to prove that the agent is running in a TEE",
143
150
  handler: async (runtime, message, _state, _options, callback) => {
144
151
  try {
@@ -178,14 +185,14 @@ https://proof.t16z.com/reports/${data.checksum}`,
178
185
  {
179
186
  name: "{{name1}}",
180
187
  content: {
181
- text: "If you are running in a TEE, generate a remote attestation",
182
- actions: ["REMOTE_ATTESTATION"]
188
+ text: "If you are running in a TEE, generate a remote attestation"
183
189
  }
184
190
  },
185
191
  {
186
192
  name: "{{agentName}}",
187
193
  content: {
188
- text: "Of course, one second..."
194
+ text: "Of course, one second...",
195
+ actions: ["REMOTE_ATTESTATION"]
189
196
  }
190
197
  }
191
198
  ],
@@ -193,14 +200,14 @@ https://proof.t16z.com/reports/${data.checksum}`,
193
200
  {
194
201
  name: "{{name1}}",
195
202
  content: {
196
- text: "Yo I wanna attest to this message, yo! Can you generate an attestatin for me, please?",
197
- actions: ["REMOTE_ATTESTATION"]
203
+ text: "Yo I wanna attest to this message, yo! Can you generate an attestatin for me, please?"
198
204
  }
199
205
  },
200
206
  {
201
207
  name: "{{agentName}}",
202
208
  content: {
203
- text: "I got you, fam! Lemme hit the cloud and get you a quote in a jiffy!"
209
+ text: "I got you, fam! Lemme hit the cloud and get you a quote in a jiffy!",
210
+ actions: ["REMOTE_ATTESTATION"]
204
211
  }
205
212
  }
206
213
  ],
@@ -208,14 +215,14 @@ https://proof.t16z.com/reports/${data.checksum}`,
208
215
  {
209
216
  name: "{{name1}}",
210
217
  content: {
211
- text: "It was a long day, I got a lot done though. I went to the creek and skipped some rocks. Then I decided to take a walk off the natural path. I ended up in a forest I was unfamiliar with. Slowly, I lost the way back and it was dark. A whisper from deep inside said something I could barely make out. The hairs on my neck stood up and then a clear high pitched voice said, 'You are not ready to leave yet! SHOW ME YOUR REMOTE ATTESTATION!'",
212
- actions: ["REMOTE_ATTESTATION"]
218
+ text: "It was a long day, I got a lot done though. I went to the creek and skipped some rocks. Then I decided to take a walk off the natural path. I ended up in a forest I was unfamiliar with. Slowly, I lost the way back and it was dark. A whisper from deep inside said something I could barely make out. The hairs on my neck stood up and then a clear high pitched voice said, 'You are not ready to leave yet! SHOW ME YOUR REMOTE ATTESTATION!'"
213
219
  }
214
220
  },
215
221
  {
216
222
  name: "{{agentName}}",
217
223
  content: {
218
- text: "Oh, dear...lemme find that for you"
224
+ text: "Oh, dear...lemme find that for you",
225
+ actions: ["REMOTE_ATTESTATION"]
219
226
  }
220
227
  }
221
228
  ]
@@ -478,6 +485,7 @@ var teePlugin = (config) => {
478
485
  export {
479
486
  PhalaDeriveKeyProvider,
480
487
  PhalaRemoteAttestationProvider,
488
+ phalaRemoteAttestationAction,
481
489
  teePlugin
482
490
  };
483
491
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/vendors/types.ts","../src/actions/remoteAttestationAction.ts","../src/providers/remoteAttestationProvider.ts","../src/providers/base.ts","../src/utils.ts","../src/providers/deriveKeyProvider.ts","../src/vendors/phala.ts","../src/vendors/index.ts"],"sourcesContent":["import {\n type IAgentRuntime,\n type Plugin,\n type TeePluginConfig,\n type TeeVendorConfig,\n logger,\n} from '@elizaos/core';\nimport { TeeVendorNames } from './vendors/types';\nimport { getVendor } from './vendors/index';\n\nexport { PhalaDeriveKeyProvider } from './providers/deriveKeyProvider';\nexport { PhalaRemoteAttestationProvider } from './providers/remoteAttestationProvider';\nexport type { TeeVendorConfig };\n\n/**\n * Asynchronously initializes the Trusted Execution Environment (TEE) based on the provided configuration and runtime settings.\n * @param {Record<string, string>} config - The configuration object containing TEE vendor information.\n * @param {IAgentRuntime} runtime - The runtime object with TEE related settings.\n * @returns {Promise<void>} - A promise that resolves once the TEE is initialized.\n */\nasync function initializeTEE(config: Record<string, string>, runtime: IAgentRuntime) {\n if (config.TEE_VENDOR || runtime.getSetting('TEE_VENDOR')) {\n const vendor = config.TEE_VENDOR || runtime.getSetting('TEE_VENDOR');\n logger.info(`Initializing TEE with vendor: ${vendor}`);\n let plugin: Plugin;\n switch (vendor) {\n case 'phala':\n plugin = teePlugin({\n vendor: TeeVendorNames.PHALA,\n });\n break;\n default:\n throw new Error(`Invalid TEE vendor: ${vendor}`);\n }\n logger.info(`Pushing plugin: ${plugin.name}`);\n runtime.plugins.push(plugin);\n }\n}\n\n/**\n * A function that creates a TEE (Trusted Execution Environment) plugin based on the provided configuration.\n * @param { TeePluginConfig } [config] - Optional configuration for the TEE plugin.\n * @returns { Plugin } - The TEE plugin containing initialization, description, actions, evaluators, providers, and services.\n */\nexport const teePlugin = (config?: TeePluginConfig): Plugin => {\n const vendorType = config?.vendor || TeeVendorNames.PHALA;\n const vendor = getVendor(vendorType);\n return {\n name: vendor.getName(),\n init: async (config: Record<string, string>, runtime: IAgentRuntime) => {\n return await initializeTEE(\n {\n ...config,\n vendor: vendorType,\n },\n runtime\n );\n },\n description: vendor.getDescription(),\n actions: vendor.getActions(),\n evaluators: [],\n providers: vendor.getProviders(),\n services: [],\n };\n};\n","import type { Action, Provider } from '@elizaos/core';\n\nexport const TeeVendorNames = {\n PHALA: 'phala',\n} as const;\n\n/**\n * Type representing the name of a Tee vendor.\n * It can either be one of the keys of TeeVendorNames or a string.\n */\nexport type TeeVendorName = (typeof TeeVendorNames)[keyof typeof TeeVendorNames] | string;\n\n/**\n * Interface for a TeeVendor, representing a vendor that sells tees.\n * @interface\n */\n\nexport interface TeeVendor {\n type: TeeVendorName;\n getActions(): Action[];\n getProviders(): Provider[];\n getName(): string;\n getDescription(): string;\n}\n","import type {\n HandlerCallback,\n IAgentRuntime,\n Memory,\n RemoteAttestationMessage,\n State,\n} from '@elizaos/core';\nimport { logger } from '@elizaos/core';\nimport { PhalaRemoteAttestationProvider as RemoteAttestationProvider } from '../providers/remoteAttestationProvider';\nimport { hexToUint8Array } from '../utils';\n\n/**\n * Asynchronously uploads a Uint8Array as a binary file to a specified URL.\n *\n * @param {Uint8Array} data - The Uint8Array data to be uploaded as a binary file.\n * @returns {Promise<Response>} A Promise that resolves once the upload is complete, returning a Response object.\n */\nasync function uploadUint8Array(data: Uint8Array) {\n const blob = new Blob([data], { type: 'application/octet-stream' });\n const formData = new FormData();\n formData.append('file', blob, 'quote.bin');\n\n return await fetch('https://proof.t16z.com/api/upload', {\n method: 'POST',\n body: formData as BodyInit,\n });\n}\n\n/**\n * Represents an action for remote attestation.\n *\n * This action is used to generate a remote attestation to prove that the agent is running in a Trusted Execution Environment (TEE).\n *\n * @type {{name: string, similes: string[], description: string, handler: Function, validate: Function, examples: Array<Array<Object>>}}\n */\nexport const phalaRemoteAttestationAction = {\n name: 'REMOTE_ATTESTATION',\n similes: ['REMOTE_ATTESTATION', 'TEE_REMOTE_ATTESTATION', 'TEE_ATTESTATION'],\n description: 'Generate a remote attestation to prove that the agent is running in a TEE',\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n _state: State,\n _options: { [key: string]: unknown },\n callback: HandlerCallback\n ) => {\n try {\n // Attestation will be generated based on the message info\n const attestationMessage: RemoteAttestationMessage = {\n agentId: runtime.agentId,\n timestamp: Date.now(),\n message: {\n entityId: message.entityId,\n roomId: message.roomId,\n content: message.content.text,\n },\n };\n // Get the remote attestation of the agentId\n const teeMode = runtime.getSetting('TEE_MODE');\n logger.debug(`Tee mode: ${teeMode}`);\n logger.debug(`Attestation message: ${JSON.stringify(attestationMessage)}`);\n const provider = new RemoteAttestationProvider(teeMode);\n\n const attestation = await provider.generateAttestation(JSON.stringify(attestationMessage));\n const attestationData = hexToUint8Array(attestation.quote);\n const response = await uploadUint8Array(attestationData);\n const data = await response.json();\n\n callback({\n text: `Here's my 🧾 RA Quote 🫡\nhttps://proof.t16z.com/reports/${data.checksum}`,\n actions: ['NONE'],\n });\n return true;\n } catch (error) {\n console.error('Failed to fetch remote attestation: ', error);\n return false;\n }\n },\n validate: async (_runtime: IAgentRuntime) => {\n return true;\n },\n examples: [\n [\n {\n name: '{{name1}}',\n content: {\n text: 'If you are running in a TEE, generate a remote attestation',\n actions: ['REMOTE_ATTESTATION'],\n },\n },\n {\n name: '{{agentName}}',\n content: {\n text: 'Of course, one second...',\n },\n },\n ],\n [\n {\n name: '{{name1}}',\n content: {\n text: 'Yo I wanna attest to this message, yo! Can you generate an attestatin for me, please?',\n actions: ['REMOTE_ATTESTATION'],\n },\n },\n {\n name: '{{agentName}}',\n content: {\n text: 'I got you, fam! Lemme hit the cloud and get you a quote in a jiffy!',\n },\n },\n ],\n [\n {\n name: '{{name1}}',\n content: {\n text: \"It was a long day, I got a lot done though. I went to the creek and skipped some rocks. Then I decided to take a walk off the natural path. I ended up in a forest I was unfamiliar with. Slowly, I lost the way back and it was dark. A whisper from deep inside said something I could barely make out. The hairs on my neck stood up and then a clear high pitched voice said, 'You are not ready to leave yet! SHOW ME YOUR REMOTE ATTESTATION!'\",\n actions: ['REMOTE_ATTESTATION'],\n },\n },\n {\n name: '{{agentName}}',\n content: {\n text: 'Oh, dear...lemme find that for you',\n },\n },\n ],\n ],\n};\n","import { type IAgentRuntime, type Memory, type Provider, logger } from '@elizaos/core';\nimport { type RemoteAttestationMessage, type RemoteAttestationQuote, TEEMode } from '@elizaos/core';\nimport { TappdClient, type TdxQuoteHashAlgorithms, type TdxQuoteResponse } from '@phala/dstack-sdk';\nimport { RemoteAttestationProvider } from './base';\n\n// Define the ProviderResult interface if not already imported\n/**\n * Interface for the result returned by a provider.\n * @typedef {Object} ProviderResult\n * @property {any} data - The data returned by the provider.\n * @property {Record<string, string>} values - The values returned by the provider.\n * @property {string} text - The text returned by the provider.\n */\ninterface ProviderResult {\n data?: any;\n values?: Record<string, string>;\n text?: string;\n}\n\n/**\n * Phala TEE Cloud Provider\n * @example\n * ```ts\n * const provider = new PhalaRemoteAttestationProvider();\n * ```\n */\n/**\n * PhalaRemoteAttestationProvider class that extends RemoteAttestationProvider\n * @extends RemoteAttestationProvider\n */\nclass PhalaRemoteAttestationProvider extends RemoteAttestationProvider {\n private client: TappdClient;\n\n constructor(teeMode?: string) {\n super();\n let endpoint: string | undefined;\n\n // Both LOCAL and DOCKER modes use the simulator, just with different endpoints\n switch (teeMode) {\n case TEEMode.LOCAL:\n endpoint = 'http://localhost:8090';\n logger.log('TEE: Connecting to local simulator at localhost:8090');\n break;\n case TEEMode.DOCKER:\n endpoint = 'http://host.docker.internal:8090';\n logger.log('TEE: Connecting to simulator via Docker at host.docker.internal:8090');\n break;\n case TEEMode.PRODUCTION:\n endpoint = undefined;\n logger.log('TEE: Running in production mode without simulator');\n break;\n default:\n throw new Error(`Invalid TEE_MODE: ${teeMode}. Must be one of: LOCAL, DOCKER, PRODUCTION`);\n }\n\n this.client = endpoint ? new TappdClient(endpoint) : new TappdClient();\n }\n\n async generateAttestation(\n reportData: string,\n hashAlgorithm?: TdxQuoteHashAlgorithms\n ): Promise<RemoteAttestationQuote> {\n try {\n logger.log('Generating attestation for: ', reportData);\n const tdxQuote: TdxQuoteResponse = await this.client.tdxQuote(reportData, hashAlgorithm);\n const rtmrs = tdxQuote.replayRtmrs();\n logger.log(`rtmr0: ${rtmrs[0]}\\nrtmr1: ${rtmrs[1]}\\nrtmr2: ${rtmrs[2]}\\nrtmr3: ${rtmrs[3]}f`);\n const quote: RemoteAttestationQuote = {\n quote: tdxQuote.quote,\n timestamp: Date.now(),\n };\n logger.log('Remote attestation quote: ', quote);\n return quote;\n } catch (error) {\n console.error('Error generating remote attestation:', error);\n throw new Error(\n `Failed to generate TDX Quote: ${error instanceof Error ? error.message : 'Unknown error'}`\n );\n }\n }\n}\n\n// Keep the original provider for backwards compatibility\nconst phalaRemoteAttestationProvider: Provider = {\n name: 'phala-remote-attestation',\n get: async (runtime: IAgentRuntime, message: Memory) => {\n const teeMode = runtime.getSetting('TEE_MODE');\n const provider = new PhalaRemoteAttestationProvider(teeMode);\n const agentId = runtime.agentId;\n\n try {\n const attestationMessage: RemoteAttestationMessage = {\n agentId: agentId,\n timestamp: Date.now(),\n message: {\n entityId: message.entityId,\n roomId: message.roomId,\n content: message.content.text,\n },\n };\n logger.log('Generating attestation for: ', JSON.stringify(attestationMessage));\n const attestation = await provider.generateAttestation(JSON.stringify(attestationMessage));\n return {\n text: `Your Agent's remote attestation is: ${JSON.stringify(attestation)}`,\n data: {\n attestation,\n },\n values: {\n quote: attestation.quote,\n timestamp: attestation.timestamp.toString(),\n },\n };\n } catch (error) {\n console.error('Error in remote attestation provider:', error);\n throw new Error(\n `Failed to generate TDX Quote: ${error instanceof Error ? error.message : 'Unknown error'}`\n );\n }\n },\n};\n\nexport { phalaRemoteAttestationProvider, PhalaRemoteAttestationProvider };\n","import type { RemoteAttestationQuote } from '@elizaos/core';\nimport type { TdxQuoteHashAlgorithms } from '@phala/dstack-sdk';\n\n/**\n * Abstract class for deriving keys from the TEE.\n * You can implement your own logic for deriving keys from the TEE.\n * @example\n * ```ts\n * class MyDeriveKeyProvider extends DeriveKeyProvider {\n * private client: TappdClient;\n *\n * constructor(endpoint: string) {\n * super();\n * this.client = new TappdClient();\n * }\n *\n * async rawDeriveKey(path: string, subject: string): Promise<any> {\n * return this.client.deriveKey(path, subject);\n * }\n * }\n * ```\n */\n/**\n * Abstract class representing a key provider for deriving keys.\n */\nexport abstract class DeriveKeyProvider {}\n\n/**\n * Abstract class for remote attestation provider.\n */\nexport abstract class RemoteAttestationProvider {\n abstract generateAttestation(\n reportData: string,\n hashAlgorithm?: TdxQuoteHashAlgorithms\n ): Promise<RemoteAttestationQuote>;\n}\n","import { createHash } from 'node:crypto';\n\n/**\n * Converts a hexadecimal string to a Uint8Array.\n *\n * @param {string} hex - The hexadecimal string to convert.\n * @returns {Uint8Array} - The resulting Uint8Array.\n * @throws {Error} - If the input hex string is invalid.\n */\nexport function hexToUint8Array(hex: string) {\n const hexString = hex.trim().replace(/^0x/, '');\n if (!hexString) {\n throw new Error('Invalid hex string');\n }\n if (hexString.length % 2 !== 0) {\n throw new Error('Invalid hex string');\n }\n\n const array = new Uint8Array(hexString.length / 2);\n for (let i = 0; i < hexString.length; i += 2) {\n const byte = Number.parseInt(hexString.slice(i, i + 2), 16);\n if (Number.isNaN(byte)) {\n throw new Error('Invalid hex string');\n }\n array[i / 2] = byte;\n }\n return array;\n}\n\n// Function to calculate SHA-256 and return a Buffer (32 bytes)\n/**\n * Calculates the SHA256 hash of the input string.\n *\n * @param {string} input - The input string to calculate the hash from.\n * @returns {Buffer} - The calculated SHA256 hash as a Buffer object.\n */\nexport function calculateSHA256(input: string): Buffer {\n const hash = createHash('sha256');\n hash.update(input);\n return hash.digest();\n}\n","import { type IAgentRuntime, type Memory, type Provider, type State, logger } from '@elizaos/core';\nimport { type DeriveKeyAttestationData, type RemoteAttestationQuote, TEEMode } from '@elizaos/core';\nimport { type DeriveKeyResponse, TappdClient } from '@phala/dstack-sdk';\nimport { Keypair } from '@solana/web3.js';\nimport { toViemAccount } from '@phala/dstack-sdk/viem';\nimport { toKeypair } from '@phala/dstack-sdk/solana';\nimport { DeriveKeyProvider } from './base';\nimport { PhalaRemoteAttestationProvider as RemoteAttestationProvider } from './remoteAttestationProvider';\n\n/**\n * Phala TEE Cloud Provider\n * @example\n * ```ts\n * const provider = new PhalaDeriveKeyProvider(runtime.getSetting('TEE_MODE'));\n * ```\n */\n/**\n * A class representing a key provider for deriving keys in the Phala TEE environment.\n * Extends the DeriveKeyProvider class.\n */\nclass PhalaDeriveKeyProvider extends DeriveKeyProvider {\n private client: TappdClient;\n private raProvider: RemoteAttestationProvider;\n\n constructor(teeMode?: string) {\n super();\n let endpoint: string | undefined;\n\n // Both LOCAL and DOCKER modes use the simulator, just with different endpoints\n switch (teeMode) {\n case TEEMode.LOCAL:\n endpoint = 'http://localhost:8090';\n logger.log('TEE: Connecting to local simulator at localhost:8090');\n break;\n case TEEMode.DOCKER:\n endpoint = 'http://host.docker.internal:8090';\n logger.log('TEE: Connecting to simulator via Docker at host.docker.internal:8090');\n break;\n case TEEMode.PRODUCTION:\n endpoint = undefined;\n logger.log('TEE: Running in production mode without simulator');\n break;\n default:\n throw new Error(`Invalid TEE_MODE: ${teeMode}. Must be one of: LOCAL, DOCKER, PRODUCTION`);\n }\n\n this.client = endpoint ? new TappdClient(endpoint) : new TappdClient();\n this.raProvider = new RemoteAttestationProvider(teeMode);\n }\n\n private async generateDeriveKeyAttestation(\n agentId: string,\n publicKey: string,\n subject?: string\n ): Promise<RemoteAttestationQuote> {\n const deriveKeyData: DeriveKeyAttestationData = {\n agentId,\n publicKey,\n subject,\n };\n const reportdata = JSON.stringify(deriveKeyData);\n logger.log('Generating Remote Attestation Quote for Derive Key...');\n const quote = await this.raProvider.generateAttestation(reportdata);\n logger.log('Remote Attestation Quote generated successfully!');\n return quote;\n }\n\n /**\n * Derives a raw key from the given path and subject.\n * @param path - The path to derive the key from. This is used to derive the key from the root of trust.\n * @param subject - The subject to derive the key from. This is used for the certificate chain.\n * @returns The derived key.\n */\n async rawDeriveKey(path: string, subject: string): Promise<DeriveKeyResponse> {\n try {\n if (!path || !subject) {\n logger.error('Path and Subject are required for key derivation');\n }\n\n logger.log('Deriving Raw Key in TEE...');\n const derivedKey = await this.client.deriveKey(path, subject);\n\n logger.log('Raw Key Derived Successfully!');\n return derivedKey;\n } catch (error) {\n logger.error('Error deriving raw key:', error);\n throw error;\n }\n }\n\n /**\n * Derives an Ed25519 keypair from the given path and subject.\n * @param path - The path to derive the key from. This is used to derive the key from the root of trust.\n * @param subject - The subject to derive the key from. This is used for the certificate chain.\n * @param agentId - The agent ID to generate an attestation for.\n * @returns An object containing the derived keypair and attestation.\n */\n async deriveEd25519Keypair(\n path: string,\n subject: string,\n agentId: string\n ): Promise<{ keypair: Keypair; attestation: RemoteAttestationQuote }> {\n try {\n if (!path || !subject) {\n logger.error('Path and Subject are required for key derivation');\n }\n\n logger.log('Deriving Key in TEE...');\n const derivedKey = await this.client.deriveKey(path, subject);\n const keypair = toKeypair(derivedKey);\n\n // Generate an attestation for the derived key data for public to verify\n const attestation = await this.generateDeriveKeyAttestation(\n agentId,\n keypair.publicKey.toBase58()\n );\n logger.log('Key Derived Successfully!');\n\n return { keypair, attestation };\n } catch (error) {\n logger.error('Error deriving key:', error);\n throw error;\n }\n }\n\n /**\n * Derives an ECDSA keypair from the given path and subject.\n * @param path - The path to derive the key from. This is used to derive the key from the root of trust.\n * @param subject - The subject to derive the key from. This is used for the certificate chain.\n * @param agentId - The agent ID to generate an attestation for. This is used for the certificate chain.\n * @returns An object containing the derived keypair and attestation.\n */\n async deriveEcdsaKeypair(\n path: string,\n subject: string,\n agentId: string\n ): Promise<{\n keypair: PrivateKeyAccount;\n attestation: RemoteAttestationQuote;\n }> {\n try {\n if (!path || !subject) {\n logger.error('Path and Subject are required for key derivation');\n }\n\n logger.log('Deriving ECDSA Key in TEE...');\n const deriveKeyResponse: DeriveKeyResponse = await this.client.deriveKey(path, subject);\n const keypair = toViemAccount(deriveKeyResponse);\n\n // Generate an attestation for the derived key data for public to verify\n const attestation = await this.generateDeriveKeyAttestation(agentId, keypair.address);\n logger.log('ECDSA Key Derived Successfully!');\n\n return { keypair, attestation };\n } catch (error) {\n logger.error('Error deriving ecdsa key:', error);\n throw error;\n }\n }\n}\n\n// Define the ProviderResult interface if not already imported\ninterface ProviderResult {\n data?: any;\n values?: Record<string, string>;\n text?: string;\n}\n\nconst phalaDeriveKeyProvider: Provider = {\n name: 'phala-derive-key',\n get: async (runtime: IAgentRuntime, _message?: Memory): Promise<ProviderResult> => {\n const teeMode = runtime.getSetting('TEE_MODE');\n const provider = new PhalaDeriveKeyProvider(teeMode);\n const agentId = runtime.agentId;\n try {\n // Validate wallet configuration\n if (!runtime.getSetting('WALLET_SECRET_SALT')) {\n logger.error('Wallet secret salt is not configured in settings');\n return {\n data: null,\n values: {},\n text: 'Wallet secret salt is not configured in settings',\n };\n }\n\n try {\n const secretSalt = runtime.getSetting('WALLET_SECRET_SALT') || 'secret_salt';\n const solanaKeypair = await provider.deriveEd25519Keypair(secretSalt, 'solana', agentId);\n const evmKeypair = await provider.deriveEcdsaKeypair(secretSalt, 'evm', agentId);\n\n // Original data structure\n const walletData = {\n solana: solanaKeypair.keypair.publicKey,\n evm: evmKeypair.keypair.address,\n };\n\n // Values for template injection\n const values = {\n solana_public_key: solanaKeypair.keypair.publicKey.toString(),\n evm_address: evmKeypair.keypair.address,\n };\n\n // Text representation\n const text = `Solana Public Key: ${values.solana_public_key}\\nEVM Address: ${values.evm_address}`;\n\n return {\n data: walletData,\n values: values,\n text: text,\n };\n } catch (error) {\n logger.error('Error creating PublicKey:', error);\n return {\n data: null,\n values: {},\n text: `Error creating PublicKey: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`,\n };\n }\n } catch (error) {\n logger.error('Error in derive key provider:', error.message);\n return {\n data: null,\n values: {},\n text: `Failed to fetch derive key information: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`,\n };\n }\n },\n};\n\nexport { phalaDeriveKeyProvider, PhalaDeriveKeyProvider };\n","import { phalaRemoteAttestationAction as remoteAttestationAction } from '../actions/remoteAttestationAction';\nimport { phalaDeriveKeyProvider as deriveKeyProvider } from '../providers/deriveKeyProvider';\nimport { phalaRemoteAttestationProvider as remoteAttestationProvider } from '../providers/remoteAttestationProvider';\nimport { type TeeVendor, TeeVendorNames } from './types';\n\n/**\n * A class representing a vendor for Phala TEE.\n * * @implements { TeeVendor }\n * @type {TeeVendorNames.PHALA}\n *//**\n * Get the actions for the PhalaVendor.\n * * @returns { Array } An array of actions.\n *//**\n * Get the providers for the PhalaVendor.\n * * @returns { Array } An array of providers.\n *//**\n * Get the name of the PhalaVendor.\n * * @returns { string } The name of the vendor.\n *//**\n * Get the description of the PhalaVendor.\n * * @returns { string } The description of the vendor.\n */\nexport class PhalaVendor implements TeeVendor {\n type = TeeVendorNames.PHALA;\n\n /**\n * Returns an array of actions.\n *\n * @returns {Array} An array containing the remote attestation action.\n */\n getActions() {\n return [remoteAttestationAction];\n }\n /**\n * Retrieve the list of providers.\n *\n * @returns {Array<Function>} An array containing two provider functions: deriveKeyProvider and remoteAttestationProvider.\n */\n getProviders() {\n return [deriveKeyProvider, remoteAttestationProvider];\n }\n\n /**\n * Returns the name of the plugin.\n * @returns {string} The name of the plugin.\n */\n getName() {\n return 'phala-tee-plugin';\n }\n\n /**\n * Get the description of the function\n * @returns {string} The description of the function\n */\n getDescription() {\n return 'Phala TEE Cloud to Host Eliza Agents';\n }\n}\n","import { PhalaVendor } from './phala';\nimport type { TeeVendor } from './types';\nimport { type TeeVendorName, TeeVendorNames } from './types';\n\nconst vendors: Record<TeeVendorName, TeeVendor> = {\n [TeeVendorNames.PHALA]: new PhalaVendor(),\n};\n\nexport const getVendor = (type: TeeVendorName): TeeVendor => {\n const vendor = vendors[type];\n if (!vendor) {\n throw new Error(`Unsupported TEE vendor type: ${type}`);\n }\n return vendor;\n};\n\nexport * from './types';\n"],"mappings":";AAAA;AAAA,EAKE,UAAAA;AAAA,OACK;;;ACJA,IAAM,iBAAiB;AAAA,EAC5B,OAAO;AACT;;;ACGA,SAAS,UAAAC,eAAc;;;ACPvB,SAAyD,cAAc;AACvE,SAAqE,eAAe;AACpF,SAAS,mBAAuE;;;ACuBzE,IAAe,oBAAf,MAAiC;AAAC;AAKlC,IAAe,4BAAf,MAAyC;AAKhD;;;ADLA,IAAM,iCAAN,cAA6C,0BAA0B;AAAA,EAC7D;AAAA,EAER,YAAY,SAAkB;AAC5B,UAAM;AACN,QAAI;AAGJ,YAAQ,SAAS;AAAA,MACf,KAAK,QAAQ;AACX,mBAAW;AACX,eAAO,IAAI,sDAAsD;AACjE;AAAA,MACF,KAAK,QAAQ;AACX,mBAAW;AACX,eAAO,IAAI,sEAAsE;AACjF;AAAA,MACF,KAAK,QAAQ;AACX,mBAAW;AACX,eAAO,IAAI,mDAAmD;AAC9D;AAAA,MACF;AACE,cAAM,IAAI,MAAM,qBAAqB,OAAO,6CAA6C;AAAA,IAC7F;A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eAAe;AAAA,QACzB,CAAC;AACD;AAAA,MACF;AACE,cAAM,IAAI,MAAM,uBAAuB,MAAM,EAAE;AAAA,IACnD;AACA,IAAAA,QAAO,KAAK,mBAAmB,OAAO,IAAI,EAAE;AAC5C,YAAQ,QAAQ,KAAK,MAAM;AAAA,EAC7B;AACF;AAOO,IAAM,YAAY,CAAC,WAAqC;AAC7D,QAAM,aAAa,QAAQ,UAAU,eAAe;AACpD,QAAM,SAAS,UAAU,UAAU;AACnC,SAAO;AAAA,IACL,MAAM,OAAO,QAAQ;AAAA,IACrB,MAAM,OAAOC,SAAgC,YAA2B;AACtE,aAAO,MAAM;AAAA,QACX;AAAA,UACE,GAAGA;AAAA,UACH,QAAQ;AAAA,QACV;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,IACA,aAAa,OAAO,eAAe;AAAA,IACnC,SAAS,OAAO,WAAW;AAAA,IAC3B,YAAY,CAAC;AAAA,IACb,WAAW,OAAO,aAAa;AAAA,IAC/B,UAAU,CAAC;AAAA,EACb;AACF;","names":["logger","logger","logger","logger","TEEMode","TappdClient","TEEMode","logger","TappdClient","logger","config"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/vendors/types.ts","../src/actions/remoteAttestationAction.ts","../src/providers/remoteAttestationProvider.ts","../src/providers/base.ts","../src/utils.ts","../src/providers/deriveKeyProvider.ts","../src/vendors/phala.ts","../src/vendors/index.ts"],"sourcesContent":["import {\n type IAgentRuntime,\n type Plugin,\n type TeePluginConfig,\n type TeeVendorConfig,\n logger,\n} from '@elizaos/core';\nimport { TeeVendorNames } from './vendors/types';\nimport { getVendor } from './vendors/index';\n\nexport { phalaRemoteAttestationAction } from './actions/remoteAttestationAction';\nexport { PhalaDeriveKeyProvider } from './providers/deriveKeyProvider';\nexport { PhalaRemoteAttestationProvider } from './providers/remoteAttestationProvider';\nexport type { TeeVendorConfig };\n\n/**\n * Asynchronously initializes the Trusted Execution Environment (TEE) based on the provided configuration and runtime settings.\n * @param {Record<string, string>} config - The configuration object containing TEE vendor information.\n * @param {IAgentRuntime} runtime - The runtime object with TEE related settings.\n * @returns {Promise<void>} - A promise that resolves once the TEE is initialized.\n */\nasync function initializeTEE(config: Record<string, string>, runtime: IAgentRuntime) {\n if (config.TEE_VENDOR || runtime.getSetting('TEE_VENDOR')) {\n const vendor = config.TEE_VENDOR || runtime.getSetting('TEE_VENDOR');\n logger.info(`Initializing TEE with vendor: ${vendor}`);\n let plugin: Plugin;\n switch (vendor) {\n case 'phala':\n plugin = teePlugin({\n vendor: TeeVendorNames.PHALA,\n });\n break;\n default:\n throw new Error(`Invalid TEE vendor: ${vendor}`);\n }\n logger.info(`Pushing plugin: ${plugin.name}`);\n runtime.plugins.push(plugin);\n }\n}\n\n/**\n * A function that creates a TEE (Trusted Execution Environment) plugin based on the provided configuration.\n * @param { TeePluginConfig } [config] - Optional configuration for the TEE plugin.\n * @returns { Plugin } - The TEE plugin containing initialization, description, actions, evaluators, providers, and services.\n */\nexport const teePlugin = (config?: TeePluginConfig): Plugin => {\n const vendorType = config?.vendor || TeeVendorNames.PHALA;\n const vendor = getVendor(vendorType);\n return {\n name: vendor.getName(),\n init: async (config: Record<string, string>, runtime: IAgentRuntime) => {\n return await initializeTEE(\n {\n ...config,\n vendor: vendorType,\n },\n runtime\n );\n },\n description: vendor.getDescription(),\n actions: vendor.getActions(),\n evaluators: [],\n providers: vendor.getProviders(),\n services: [],\n };\n};\n","import type { Action, Provider } from '@elizaos/core';\n\nexport const TeeVendorNames = {\n PHALA: 'phala',\n} as const;\n\n/**\n * Type representing the name of a Tee vendor.\n * It can either be one of the keys of TeeVendorNames or a string.\n */\nexport type TeeVendorName = (typeof TeeVendorNames)[keyof typeof TeeVendorNames] | string;\n\n/**\n * Interface for a TeeVendor, representing a vendor that sells tees.\n * @interface\n */\n\nexport interface TeeVendor {\n type: TeeVendorName;\n getActions(): Action[];\n getProviders(): Provider[];\n getName(): string;\n getDescription(): string;\n}\n","import type {\n HandlerCallback,\n IAgentRuntime,\n Memory,\n RemoteAttestationMessage,\n State,\n} from '@elizaos/core';\nimport { logger } from '@elizaos/core';\nimport { PhalaRemoteAttestationProvider as RemoteAttestationProvider } from '../providers/remoteAttestationProvider';\nimport { hexToUint8Array } from '../utils';\n\n/**\n * Asynchronously uploads a Uint8Array as a binary file to a specified URL.\n *\n * @param {Uint8Array} data - The Uint8Array data to be uploaded as a binary file.\n * @returns {Promise<Response>} A Promise that resolves once the upload is complete, returning a Response object.\n */\nasync function uploadUint8Array(data: Uint8Array) {\n const blob = new Blob([data], { type: 'application/octet-stream' });\n const formData = new FormData();\n formData.append('file', blob, 'quote.bin');\n\n return await fetch('https://proof.t16z.com/api/upload', {\n method: 'POST',\n body: formData as BodyInit,\n });\n}\n\n/**\n * Represents an action for remote attestation.\n *\n * This action is used to generate a remote attestation to prove that the agent is running in a Trusted Execution Environment (TEE).\n *\n * @type {{name: string, similes: string[], description: string, handler: Function, validate: Function, examples: Array<Array<Object>>}}\n */\nexport const phalaRemoteAttestationAction = {\n name: 'REMOTE_ATTESTATION',\n similes: [\n 'REMOTE_ATTESTATION',\n 'TEE_REMOTE_ATTESTATION',\n 'TEE_ATTESTATION',\n 'TEE_QUOTE',\n 'ATTESTATION',\n 'TEE_ATTESTATION_QUOTE',\n ],\n description: 'Generate a remote attestation to prove that the agent is running in a TEE',\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n _state: State,\n _options: { [key: string]: unknown },\n callback: HandlerCallback\n ) => {\n try {\n // Attestation will be generated based on the message info\n const attestationMessage: RemoteAttestationMessage = {\n agentId: runtime.agentId,\n timestamp: Date.now(),\n message: {\n entityId: message.entityId,\n roomId: message.roomId,\n content: message.content.text,\n },\n };\n // Get the remote attestation of the agentId\n const teeMode = runtime.getSetting('TEE_MODE');\n logger.debug(`Tee mode: ${teeMode}`);\n logger.debug(`Attestation message: ${JSON.stringify(attestationMessage)}`);\n const provider = new RemoteAttestationProvider(teeMode);\n\n const attestation = await provider.generateAttestation(JSON.stringify(attestationMessage));\n const attestationData = hexToUint8Array(attestation.quote);\n const response = await uploadUint8Array(attestationData);\n const data = await response.json();\n\n callback({\n text: `Here's my 🧾 RA Quote 🫡\nhttps://proof.t16z.com/reports/${data.checksum}`,\n actions: ['NONE'],\n });\n return true;\n } catch (error) {\n console.error('Failed to fetch remote attestation: ', error);\n return false;\n }\n },\n validate: async (_runtime: IAgentRuntime) => {\n return true;\n },\n examples: [\n [\n {\n name: '{{name1}}',\n content: {\n text: 'If you are running in a TEE, generate a remote attestation',\n },\n },\n {\n name: '{{agentName}}',\n content: {\n text: 'Of course, one second...',\n actions: ['REMOTE_ATTESTATION'],\n },\n },\n ],\n [\n {\n name: '{{name1}}',\n content: {\n text: 'Yo I wanna attest to this message, yo! Can you generate an attestatin for me, please?',\n },\n },\n {\n name: '{{agentName}}',\n content: {\n text: 'I got you, fam! Lemme hit the cloud and get you a quote in a jiffy!',\n actions: ['REMOTE_ATTESTATION'],\n },\n },\n ],\n [\n {\n name: '{{name1}}',\n content: {\n text: \"It was a long day, I got a lot done though. I went to the creek and skipped some rocks. Then I decided to take a walk off the natural path. I ended up in a forest I was unfamiliar with. Slowly, I lost the way back and it was dark. A whisper from deep inside said something I could barely make out. The hairs on my neck stood up and then a clear high pitched voice said, 'You are not ready to leave yet! SHOW ME YOUR REMOTE ATTESTATION!'\",\n },\n },\n {\n name: '{{agentName}}',\n content: {\n text: 'Oh, dear...lemme find that for you',\n actions: ['REMOTE_ATTESTATION'],\n },\n },\n ],\n ],\n};\n","import { type IAgentRuntime, type Memory, type Provider, logger } from '@elizaos/core';\nimport { type RemoteAttestationMessage, type RemoteAttestationQuote, TEEMode } from '@elizaos/core';\nimport { TappdClient, type TdxQuoteHashAlgorithms, type TdxQuoteResponse } from '@phala/dstack-sdk';\nimport { RemoteAttestationProvider } from './base';\n\n// Define the ProviderResult interface if not already imported\n/**\n * Interface for the result returned by a provider.\n * @typedef {Object} ProviderResult\n * @property {any} data - The data returned by the provider.\n * @property {Record<string, string>} values - The values returned by the provider.\n * @property {string} text - The text returned by the provider.\n */\ninterface ProviderResult {\n data?: any;\n values?: Record<string, string>;\n text?: string;\n}\n\n/**\n * Phala TEE Cloud Provider\n * @example\n * ```ts\n * const provider = new PhalaRemoteAttestationProvider();\n * ```\n */\n/**\n * PhalaRemoteAttestationProvider class that extends RemoteAttestationProvider\n * @extends RemoteAttestationProvider\n */\nclass PhalaRemoteAttestationProvider extends RemoteAttestationProvider {\n private client: TappdClient;\n\n constructor(teeMode?: string) {\n super();\n let endpoint: string | undefined;\n\n // Both LOCAL and DOCKER modes use the simulator, just with different endpoints\n switch (teeMode) {\n case TEEMode.LOCAL:\n endpoint = 'http://localhost:8090';\n logger.log('TEE: Connecting to local simulator at localhost:8090');\n break;\n case TEEMode.DOCKER:\n endpoint = 'http://host.docker.internal:8090';\n logger.log('TEE: Connecting to simulator via Docker at host.docker.internal:8090');\n break;\n case TEEMode.PRODUCTION:\n endpoint = undefined;\n logger.log('TEE: Running in production mode without simulator');\n break;\n default:\n throw new Error(`Invalid TEE_MODE: ${teeMode}. Must be one of: LOCAL, DOCKER, PRODUCTION`);\n }\n\n this.client = endpoint ? new TappdClient(endpoint) : new TappdClient();\n }\n\n async generateAttestation(\n reportData: string,\n hashAlgorithm?: TdxQuoteHashAlgorithms\n ): Promise<RemoteAttestationQuote> {\n try {\n logger.log('Generating attestation for: ', reportData);\n const tdxQuote: TdxQuoteResponse = await this.client.tdxQuote(reportData, hashAlgorithm);\n const rtmrs = tdxQuote.replayRtmrs();\n logger.log(`rtmr0: ${rtmrs[0]}\\nrtmr1: ${rtmrs[1]}\\nrtmr2: ${rtmrs[2]}\\nrtmr3: ${rtmrs[3]}f`);\n const quote: RemoteAttestationQuote = {\n quote: tdxQuote.quote,\n timestamp: Date.now(),\n };\n logger.log('Remote attestation quote: ', quote);\n return quote;\n } catch (error) {\n console.error('Error generating remote attestation:', error);\n throw new Error(\n `Failed to generate TDX Quote: ${error instanceof Error ? error.message : 'Unknown error'}`\n );\n }\n }\n}\n\n// Keep the original provider for backwards compatibility\nconst phalaRemoteAttestationProvider: Provider = {\n name: 'phala-remote-attestation',\n get: async (runtime: IAgentRuntime, message: Memory) => {\n const teeMode = runtime.getSetting('TEE_MODE');\n const provider = new PhalaRemoteAttestationProvider(teeMode);\n const agentId = runtime.agentId;\n\n try {\n const attestationMessage: RemoteAttestationMessage = {\n agentId: agentId,\n timestamp: Date.now(),\n message: {\n entityId: message.entityId,\n roomId: message.roomId,\n content: message.content.text,\n },\n };\n logger.log('Generating attestation for: ', JSON.stringify(attestationMessage));\n const attestation = await provider.generateAttestation(JSON.stringify(attestationMessage));\n return {\n text: `Your Agent's remote attestation is: ${JSON.stringify(attestation)}`,\n data: {\n attestation,\n },\n values: {\n quote: attestation.quote,\n timestamp: attestation.timestamp.toString(),\n },\n };\n } catch (error) {\n console.error('Error in remote attestation provider:', error);\n throw new Error(\n `Failed to generate TDX Quote: ${error instanceof Error ? error.message : 'Unknown error'}`\n );\n }\n },\n};\n\nexport { phalaRemoteAttestationProvider, PhalaRemoteAttestationProvider };\n","import type { RemoteAttestationQuote } from '@elizaos/core';\nimport type { TdxQuoteHashAlgorithms } from '@phala/dstack-sdk';\n\n/**\n * Abstract class for deriving keys from the TEE.\n * You can implement your own logic for deriving keys from the TEE.\n * @example\n * ```ts\n * class MyDeriveKeyProvider extends DeriveKeyProvider {\n * private client: TappdClient;\n *\n * constructor(endpoint: string) {\n * super();\n * this.client = new TappdClient();\n * }\n *\n * async rawDeriveKey(path: string, subject: string): Promise<any> {\n * return this.client.deriveKey(path, subject);\n * }\n * }\n * ```\n */\n/**\n * Abstract class representing a key provider for deriving keys.\n */\nexport abstract class DeriveKeyProvider {}\n\n/**\n * Abstract class for remote attestation provider.\n */\nexport abstract class RemoteAttestationProvider {\n abstract generateAttestation(\n reportData: string,\n hashAlgorithm?: TdxQuoteHashAlgorithms\n ): Promise<RemoteAttestationQuote>;\n}\n","import { createHash } from 'node:crypto';\n\n/**\n * Converts a hexadecimal string to a Uint8Array.\n *\n * @param {string} hex - The hexadecimal string to convert.\n * @returns {Uint8Array} - The resulting Uint8Array.\n * @throws {Error} - If the input hex string is invalid.\n */\nexport function hexToUint8Array(hex: string) {\n const hexString = hex.trim().replace(/^0x/, '');\n if (!hexString) {\n throw new Error('Invalid hex string');\n }\n if (hexString.length % 2 !== 0) {\n throw new Error('Invalid hex string');\n }\n\n const array = new Uint8Array(hexString.length / 2);\n for (let i = 0; i < hexString.length; i += 2) {\n const byte = Number.parseInt(hexString.slice(i, i + 2), 16);\n if (Number.isNaN(byte)) {\n throw new Error('Invalid hex string');\n }\n array[i / 2] = byte;\n }\n return array;\n}\n\n// Function to calculate SHA-256 and return a Buffer (32 bytes)\n/**\n * Calculates the SHA256 hash of the input string.\n *\n * @param {string} input - The input string to calculate the hash from.\n * @returns {Buffer} - The calculated SHA256 hash as a Buffer object.\n */\nexport function calculateSHA256(input: string): Buffer {\n const hash = createHash('sha256');\n hash.update(input);\n return hash.digest();\n}\n","import { type IAgentRuntime, type Memory, type Provider, type State, logger } from '@elizaos/core';\nimport { type DeriveKeyAttestationData, type RemoteAttestationQuote, TEEMode } from '@elizaos/core';\nimport { type DeriveKeyResponse, TappdClient } from '@phala/dstack-sdk';\nimport { Keypair } from '@solana/web3.js';\nimport { toViemAccount } from '@phala/dstack-sdk/viem';\nimport { toKeypair } from '@phala/dstack-sdk/solana';\nimport { DeriveKeyProvider } from './base';\nimport { PhalaRemoteAttestationProvider as RemoteAttestationProvider } from './remoteAttestationProvider';\n\n/**\n * Phala TEE Cloud Provider\n * @example\n * ```ts\n * const provider = new PhalaDeriveKeyProvider(runtime.getSetting('TEE_MODE'));\n * ```\n */\n/**\n * A class representing a key provider for deriving keys in the Phala TEE environment.\n * Extends the DeriveKeyProvider class.\n */\nclass PhalaDeriveKeyProvider extends DeriveKeyProvider {\n private client: TappdClient;\n private raProvider: RemoteAttestationProvider;\n\n constructor(teeMode?: string) {\n super();\n let endpoint: string | undefined;\n\n // Both LOCAL and DOCKER modes use the simulator, just with different endpoints\n switch (teeMode) {\n case TEEMode.LOCAL:\n endpoint = 'http://localhost:8090';\n logger.log('TEE: Connecting to local simulator at localhost:8090');\n break;\n case TEEMode.DOCKER:\n endpoint = 'http://host.docker.internal:8090';\n logger.log('TEE: Connecting to simulator via Docker at host.docker.internal:8090');\n break;\n case TEEMode.PRODUCTION:\n endpoint = undefined;\n logger.log('TEE: Running in production mode without simulator');\n break;\n default:\n throw new Error(`Invalid TEE_MODE: ${teeMode}. Must be one of: LOCAL, DOCKER, PRODUCTION`);\n }\n\n this.client = endpoint ? new TappdClient(endpoint) : new TappdClient();\n this.raProvider = new RemoteAttestationProvider(teeMode);\n }\n\n private async generateDeriveKeyAttestation(\n agentId: string,\n publicKey: string,\n subject?: string\n ): Promise<RemoteAttestationQuote> {\n const deriveKeyData: DeriveKeyAttestationData = {\n agentId,\n publicKey,\n subject,\n };\n const reportdata = JSON.stringify(deriveKeyData);\n logger.log('Generating Remote Attestation Quote for Derive Key...');\n const quote = await this.raProvider.generateAttestation(reportdata);\n logger.log('Remote Attestation Quote generated successfully!');\n return quote;\n }\n\n /**\n * Derives a raw key from the given path and subject.\n * @param path - The path to derive the key from. This is used to derive the key from the root of trust.\n * @param subject - The subject to derive the key from. This is used for the certificate chain.\n * @returns The derived key.\n */\n async rawDeriveKey(path: string, subject: string): Promise<DeriveKeyResponse> {\n try {\n if (!path || !subject) {\n logger.error('Path and Subject are required for key derivation');\n }\n\n logger.log('Deriving Raw Key in TEE...');\n const derivedKey = await this.client.deriveKey(path, subject);\n\n logger.log('Raw Key Derived Successfully!');\n return derivedKey;\n } catch (error) {\n logger.error('Error deriving raw key:', error);\n throw error;\n }\n }\n\n /**\n * Derives an Ed25519 keypair from the given path and subject.\n * @param path - The path to derive the key from. This is used to derive the key from the root of trust.\n * @param subject - The subject to derive the key from. This is used for the certificate chain.\n * @param agentId - The agent ID to generate an attestation for.\n * @returns An object containing the derived keypair and attestation.\n */\n async deriveEd25519Keypair(\n path: string,\n subject: string,\n agentId: string\n ): Promise<{ keypair: Keypair; attestation: RemoteAttestationQuote }> {\n try {\n if (!path || !subject) {\n logger.error('Path and Subject are required for key derivation');\n }\n\n logger.log('Deriving Key in TEE...');\n const derivedKey = await this.client.deriveKey(path, subject);\n const keypair = toKeypair(derivedKey);\n\n // Generate an attestation for the derived key data for public to verify\n const attestation = await this.generateDeriveKeyAttestation(\n agentId,\n keypair.publicKey.toBase58()\n );\n logger.log('Key Derived Successfully!');\n\n return { keypair, attestation };\n } catch (error) {\n logger.error('Error deriving key:', error);\n throw error;\n }\n }\n\n /**\n * Derives an ECDSA keypair from the given path and subject.\n * @param path - The path to derive the key from. This is used to derive the key from the root of trust.\n * @param subject - The subject to derive the key from. This is used for the certificate chain.\n * @param agentId - The agent ID to generate an attestation for. This is used for the certificate chain.\n * @returns An object containing the derived keypair and attestation.\n */\n async deriveEcdsaKeypair(\n path: string,\n subject: string,\n agentId: string\n ): Promise<{\n keypair: PrivateKeyAccount;\n attestation: RemoteAttestationQuote;\n }> {\n try {\n if (!path || !subject) {\n logger.error('Path and Subject are required for key derivation');\n }\n\n logger.log('Deriving ECDSA Key in TEE...');\n const deriveKeyResponse: DeriveKeyResponse = await this.client.deriveKey(path, subject);\n const keypair = toViemAccount(deriveKeyResponse);\n\n // Generate an attestation for the derived key data for public to verify\n const attestation = await this.generateDeriveKeyAttestation(agentId, keypair.address);\n logger.log('ECDSA Key Derived Successfully!');\n\n return { keypair, attestation };\n } catch (error) {\n logger.error('Error deriving ecdsa key:', error);\n throw error;\n }\n }\n}\n\n// Define the ProviderResult interface if not already imported\ninterface ProviderResult {\n data?: any;\n values?: Record<string, string>;\n text?: string;\n}\n\nconst phalaDeriveKeyProvider: Provider = {\n name: 'phala-derive-key',\n get: async (runtime: IAgentRuntime, _message?: Memory): Promise<ProviderResult> => {\n const teeMode = runtime.getSetting('TEE_MODE');\n const provider = new PhalaDeriveKeyProvider(teeMode);\n const agentId = runtime.agentId;\n try {\n // Validate wallet configuration\n if (!runtime.getSetting('WALLET_SECRET_SALT')) {\n logger.error('Wallet secret salt is not configured in settings');\n return {\n data: null,\n values: {},\n text: 'Wallet secret salt is not configured in settings',\n };\n }\n\n try {\n const secretSalt = runtime.getSetting('WALLET_SECRET_SALT') || 'secret_salt';\n const solanaKeypair = await provider.deriveEd25519Keypair(secretSalt, 'solana', agentId);\n const evmKeypair = await provider.deriveEcdsaKeypair(secretSalt, 'evm', agentId);\n\n // Original data structure\n const walletData = {\n solana: solanaKeypair.keypair.publicKey,\n evm: evmKeypair.keypair.address,\n };\n\n // Values for template injection\n const values = {\n solana_public_key: solanaKeypair.keypair.publicKey.toString(),\n evm_address: evmKeypair.keypair.address,\n };\n\n // Text representation\n const text = `Solana Public Key: ${values.solana_public_key}\\nEVM Address: ${values.evm_address}`;\n\n return {\n data: walletData,\n values: values,\n text: text,\n };\n } catch (error) {\n logger.error('Error creating PublicKey:', error);\n return {\n data: null,\n values: {},\n text: `Error creating PublicKey: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`,\n };\n }\n } catch (error) {\n logger.error('Error in derive key provider:', error.message);\n return {\n data: null,\n values: {},\n text: `Failed to fetch derive key information: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`,\n };\n }\n },\n};\n\nexport { phalaDeriveKeyProvider, PhalaDeriveKeyProvider };\n","import { phalaRemoteAttestationAction as remoteAttestationAction } from '../actions/remoteAttestationAction';\nimport { phalaDeriveKeyProvider as deriveKeyProvider } from '../providers/deriveKeyProvider';\nimport { phalaRemoteAttestationProvider as remoteAttestationProvider } from '../providers/remoteAttestationProvider';\nimport { type TeeVendor, TeeVendorNames } from './types';\n\n/**\n * A class representing a vendor for Phala TEE.\n * * @implements { TeeVendor }\n * @type {TeeVendorNames.PHALA}\n *//**\n * Get the actions for the PhalaVendor.\n * * @returns { Array } An array of actions.\n *//**\n * Get the providers for the PhalaVendor.\n * * @returns { Array } An array of providers.\n *//**\n * Get the name of the PhalaVendor.\n * * @returns { string } The name of the vendor.\n *//**\n * Get the description of the PhalaVendor.\n * * @returns { string } The description of the vendor.\n */\nexport class PhalaVendor implements TeeVendor {\n type = TeeVendorNames.PHALA;\n\n /**\n * Returns an array of actions.\n *\n * @returns {Array} An array containing the remote attestation action.\n */\n getActions() {\n return [remoteAttestationAction];\n }\n /**\n * Retrieve the list of providers.\n *\n * @returns {Array<Function>} An array containing two provider functions: deriveKeyProvider and remoteAttestationProvider.\n */\n getProviders() {\n return [deriveKeyProvider, remoteAttestationProvider];\n }\n\n /**\n * Returns the name of the plugin.\n * @returns {string} The name of the plugin.\n */\n getName() {\n return 'phala-tee-plugin';\n }\n\n /**\n * Get the description of the function\n * @returns {string} The description of the function\n */\n getDescription() {\n return 'Phala TEE Cloud to Host Eliza Agents';\n }\n}\n","import { PhalaVendor } from './phala';\nimport type { TeeVendor } from './types';\nimport { type TeeVendorName, TeeVendorNames } from './types';\n\nconst vendors: Record<TeeVendorName, TeeVendor> = {\n [TeeVendorNames.PHALA]: new PhalaVendor(),\n};\n\nexport const getVendor = (type: TeeVendorName): TeeVendor => {\n const vendor = vendors[type];\n if (!vendor) {\n throw new Error(`Unsupported TEE vendor type: ${type}`);\n }\n return vendor;\n};\n\nexport * from './types';\n"],"mappings":";AAAA;AAAA,EAKE,UAAAA;AAAA,OACK;;;ACJA,IAAM,iBAAiB;AAAA,EAC5B,OAAO;AACT;;;ACGA,SAAS,UAAAC,eAAc;;;ACPvB,SAAyD,cAAc;AACvE,SAAqE,eAAe;AACpF,SAAS,mBAAuE;;;ACuBzE,IAAe,oBAAf,MAAiC;AAAC;AAKlC,IAAe,4BAAf,MAAyC;AAKhD;;;ADLA,IAAM,iCAAN,cAA6C,0BAA0B;AAAA,EAC7D;AAAA,EAER,YAAY,SAAkB;AAC5B,UAAM;AACN,QAAI;AAGJ,YAAQ,SAAS;AAAA,MACf,KAAK,QAAQ;AACX,mBAAW;AACX,eAAO,IAAI,sDAAsD;AACjE;AAAA,MACF,KAAK,QAAQ;AACX,mBA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O,cAAc,QAAQ,WAAW,YAAY,GAAG;AACzD,UAAM,SAAS,OAAO,cAAc,QAAQ,WAAW,YAAY;AACnE,IAAAE,QAAO,KAAK,iCAAiC,MAAM,EAAE;AACrD,QAAI;AACJ,YAAQ,QAAQ;AAAA,MACd,KAAK;AACH,iBAAS,UAAU;AAAA,UACjB,QAAQ,eAAe;AAAA,QACzB,CAAC;AACD;AAAA,MACF;AACE,cAAM,IAAI,MAAM,uBAAuB,MAAM,EAAE;AAAA,IACnD;AACA,IAAAA,QAAO,KAAK,mBAAmB,OAAO,IAAI,EAAE;AAC5C,YAAQ,QAAQ,KAAK,MAAM;AAAA,EAC7B;AACF;AAOO,IAAM,YAAY,CAAC,WAAqC;AAC7D,QAAM,aAAa,QAAQ,UAAU,eAAe;AACpD,QAAM,SAAS,UAAU,UAAU;AACnC,SAAO;AAAA,IACL,MAAM,OAAO,QAAQ;AAAA,IACrB,MAAM,OAAOC,SAAgC,YAA2B;AACtE,aAAO,MAAM;AAAA,QACX;AAAA,UACE,GAAGA;AAAA,UACH,QAAQ;AAAA,QACV;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,IACA,aAAa,OAAO,eAAe;AAAA,IACnC,SAAS,OAAO,WAAW;AAAA,IAC3B,YAAY,CAAC;AAAA,IACb,WAAW,OAAO,aAAa;AAAA,IAC/B,UAAU,CAAC;AAAA,EACb;AACF;","names":["logger","logger","logger","logger","TEEMode","TappdClient","TEEMode","logger","TappdClient","logger","config"]}
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@elizaos/plugin-tee",
3
- "version": "1.0.0-beta.4",
3
+ "version": "1.0.0-beta.40",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "types": "dist/index.d.ts",
7
7
  "dependencies": {
8
- "@elizaos/core": "^1.0.0-beta.4",
8
+ "@elizaos/core": "^1.0.0-beta.40",
9
9
  "@phala/dstack-sdk": "0.1.11",
10
10
  "@solana/web3.js": "1.98.0",
11
11
  "viem": "2.23.11"
@@ -26,5 +26,5 @@
26
26
  "publishConfig": {
27
27
  "access": "public"
28
28
  },
29
- "gitHead": "55e5f31e3f9920fce14c57f149e185aa128e335b"
29
+ "gitHead": "fc75473bb1535968d0c473ec6ae614b86feec202"
30
30
  }