Feat: support TEE logging and support running eliza in Intel SGX #1470
+1,361
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Relates to:
Keywords: TEE, Intel SGX, Logging, Attestation, Verification, Gramine.
Risks
Low
Background
What does this PR do?
This PR introduces support for TEE (Trusted Execution Environment) logging and enables the Eliza application to run within Intel SGX (Software Guard Extensions).
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 entirely 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.
Meanwhile, the existing plugin-tee only supports running Eliza in dstack TDX CVM. However, although TDX is more convenient to use, Intel SGX remains a highly popular TEE in production environments. With the help of Gramine LibOS, it is possible to support running Eliza in SGX, thereby enabling the deployment of Eliza in a broader range of TEE scenarios.
What kind of change is this?
Features
Details
TEE Logging Mechanism:
Key Pair Generation and Attestation:
Log Recording:
agentId
,roomId
,userId
,type
,content
, andtimestamp
. This information is concatenated and signed using the agent's corresponding private key to ensure verifiability. The verification process follows this trust chain:Data Storage:
Log Extraction for Verification:
Integrity Protection:
Documentation changes needed?
Need to add new documentation about TEE logging and how to run Eliza in SGX
Testing
Where should a reviewer start?
Detailed testing steps
Test SGX support
First, you need to prepare the SGX environment and install the Gramine dependencies according to https://gramine.readthedocs.io/en/stable/index.html
Then, start eliza in SGX:
Test TEE logging
To get started, prepare the TEE environment. Both dstack TDX and Gramine SGX are supported.
Next, enable TEE logging by configuring the .env file:
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:First, add plugin-tee-log to the dependencies of plugin-bootstrap:
Then, add the following code to the
Continue
action: