Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: RP for plugin-tee-verifiable-log #1369

Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0bc127e
feat: add tee verifiable log plugin and apis
gene-sf Dec 22, 2024
4614e0e
feat: rollback
gene-zhan Dec 22, 2024
7ead94f
fix: rollback format
gene-zhan Dec 22, 2024
50f8639
fix: rollback format
gene-zhan Dec 22, 2024
fc321e6
Merge branch 'develop' into ai16zPR/tee-verifiable-log-api-from-develop
gene-zhan Dec 23, 2024
4ae81b3
Merge branch 'develop' into ai16zPR/tee-verifiable-log-api-from-develop
gene-zhan Dec 23, 2024
1851c04
fix: rollback format
gene-zhan Dec 23, 2024
73f5437
fix: catch error return false;
gene-zhan Dec 23, 2024
aaf7850
fix: PR conflict
gene-zhan Dec 24, 2024
38fcc69
Update package.json
gene-zhan Dec 24, 2024
e1a3c29
fix: PR conflict
gene-zhan Dec 24, 2024
ba5116f
fix: merge develop
gene-zhan Dec 29, 2024
4d74a7a
fix: merge develop
gene-zhan Dec 29, 2024
4ced6b0
fix: merge develop
gene-zhan Dec 29, 2024
2a8386d
Merge pull request #13 from 0xbeekeeper/goplus-security
cpppppp7 Jan 4, 2025
dcaafab
Merge branch 'elizaOS:develop' into develop
gene-zhan Jan 4, 2025
43d5f68
fix: merge tag v0.1.7
gene-zhan Jan 5, 2025
c9a22eb
fix: merge tag v0.1.7
gene-zhan Jan 5, 2025
86d7423
Merge branch 'elizaOS:develop' into develop
gene-zhan Jan 5, 2025
bcd934a
fix: package error
gene-zhan Jan 5, 2025
ba2da73
Merge branch 'elizaOS:develop' into develop
gene-zhan Jan 5, 2025
f35dbe3
fix: merge develop conflict
gene-zhan Jan 5, 2025
d13590b
feat: add dreiveProvider
gene-zhan Jan 5, 2025
5dfbaaa
feat: fix log
gene-zhan Jan 7, 2025
2a1fc6b
Merge remote-tracking branch 'upstream/develop' into ai16zPR/tee-veri…
cpppppp7 Jan 10, 2025
a422d7a
feat: update pnpm-lock
gene-zhan Jan 13, 2025
104202d
Merge remote-tracking branch 'upstream/develop' into ai16zPR/tee-veri…
cpppppp7 Jan 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,10 @@ ZEROG_FLOW_ADDRESS=
TEE_MODE=OFF # LOCAL | DOCKER | PRODUCTION
WALLET_SECRET_SALT= # ONLY define if you want to use TEE Plugin, otherwise it will throw errors


# TEE Verifiable Log Configuration
VLOG= # true/false; if you want to use TEE Verifiable Log, set this to "true"

# Galadriel Configuration
GALADRIEL_API_KEY=gal-* # Get from https://dashboard.galadriel.com/

Expand Down
1 change: 1 addition & 0 deletions agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"@elizaos/plugin-avalanche": "workspace:*",
"@elizaos/plugin-web-search": "workspace:*",
"@elizaos/plugin-genlayer": "workspace:*",
"@elizaos/plugin-tee-verifiable-log": "workspace:*",
"readline": "1.3.0",
"ws": "8.18.0",
"yargs": "17.7.2"
Expand Down
5 changes: 4 additions & 1 deletion agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ import net from "net";
import path from "path";
import { fileURLToPath } from "url";
import yargs from "yargs";

import { verifiableLogPlugin } from "@elizaos/plugin-tee-verifiable-log";
const __filename = fileURLToPath(import.meta.url); // get the resolved path to the file
const __dirname = path.dirname(__filename); // get the name of the directory

Expand Down Expand Up @@ -587,6 +587,9 @@ export async function createAgent(
...(teeMode !== TEEMode.OFF && walletSecretSalt
? [teePlugin, solanaPlugin]
: []),
(teeMode !== TEEMode.OFF && walletSecretSalt &&getSecret(character,"VLOG")
? verifiableLogPlugin
: null),
getSecret(character, "COINBASE_API_KEY") &&
getSecret(character, "COINBASE_PRIVATE_KEY") &&
getSecret(character, "COINBASE_NOTIFICATION_URI")
Expand Down
1 change: 1 addition & 0 deletions packages/client-direct/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"dependencies": {
"@elizaos/core": "workspace:*",
"@elizaos/plugin-image-generation": "workspace:*",
"@elizaos/plugin-tee-verifiable-log": "workspace:*",
"@types/body-parser": "1.19.5",
"@types/cors": "2.8.17",
"@types/express": "5.0.0",
Expand Down
128 changes: 128 additions & 0 deletions packages/client-direct/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,131 @@ curl -X GET "http://localhost:3000/fine-tune/8566c47a-ada8-441c-95bc-7bb07656c4c
-H "Content-Type: application/json" \
-H "Authorization: Bearer jvBpxrTNqGqhnfQhSEqCdsG6aTSP8IBL".
```



## Verifiable Attestations

This function relies on [plugin-tee-verifiable-log](../../plugin-tee-verifiable-log/README.md)

Enable Verifiable Logs, Configuration variables in .env
```shell
TEE_MODE="DOCKER" # LOCAL | DOCKER | PRODUCTION
WALLET_SECRET_SALT= "<your wallet secret salt>" # ONLY define if you want to use TEE Plugin, otherwise it will throw errors
VLOG="true"
```
### APIs
### 1. Get verifiable agents
```shell
curl -X GET --location "http://localhost:3000/verifiable/agents"
```
* Response success result
```shell
{
"success": true,
"message": "Successfully get Agents",
"data": [
{
"id": "c4598810-61a2-4ac8-ab85-b746402692c4",
"created_at": 1734526797906,
"agent_id": "9c321604-e69e-0e4c-ab84-bec6fd6baf92",
"agent_name": "Capila",
"agent_keypair_path": "/keys/verifiable_key",
"agent_keypair_vlog_pk": "0x045b51a28c3b071104f3094b1934343eb831b8d56f16fc6..."
}
]
}
```
* Response failure result
```shell
{
"error": "failed to get agents registered ",
"details": "Cannot read properties of undefined (reading 'getService')",
"stack": "TypeError: Cannot read ..."
}
```

### 2.Query verifiable logs
```bash

curl -X POST --location "http://localhost:3000/verifiable/logs" \
-H "Content-Type: application/json" \
-d '{
"query": {
"contLike": "Twinkletwinkle"
},
"page": 1,
"pageSize": 10
}'
```
The query body that can be queried are:
>* idEq: string;
>* agentIdEq: string;
>* roomIdEq: string;
>* userIdEq: string;
>* typeEq: string;
>* contLike: string;
>* signatureEq: string;

* Response success result
```shell
{
"success": true,
"message": "Successfully retrieved logs",
"data": {
"page": 1,
"pageSize": 10,
"total": 1,
"data": [
{
"id": "b9ac4b2f-ecb5-4c5c-a981-d282b831e878",
"created_at": 1734526805664,
"agent_id": "9c321604-e69e-0e4c-ab84-bec6fd6baf92",
"room_id": "8c54580d-2c56-01e8-81e4-4160a02f3ee5",
"user_id": "9c321604-e69e-0e4c-ab84-bec6fd6baf92",
"type": "post tweet",
"content": "{\"text\":\"Twinkletwinkle, it's time to unlock your artistic values!\\n\\n My NFTs are here to bring the chill vibes to Web3.\\n\\n Let's wagmi and make this a day to remember!\",\"url\":\"https://twitter.com/....\"}",
"signature": "0x9ac77cfef9374bff3b41f96d0b0a8d61bfcf88e3a01f7bc20653494145ff31ef118a2a3cd94437481000a13500c6ed6714d8802bf2572a7da4de2e81a688d0b41c"
}
]
}
}
```
* Response failure result
```shell

{
"error": "Failed to Get Verifiable Logs",
"details": "Cannot read properties of undefined (reading 'getService')",
"stack": "TypeError: Cannot read ..."
}
```


### 3.Get Tee Attestation
```shell
curl -X POST --location "http://localhost:3000/verifiable/attestation" \
-H "Content-Type: application/json" \
-d '{
"agentId": "9c321604-e69e-0e4c-ab84-bec6fd6baf92",
"publicKey": "0x045b51a28c3b071104f3094b1934343eb831b8d56f16fc6e9a3304e9f051b24e584d806b20769b05eeade3a6c792db96f57b26cc38037907dd920e9be9f41f6184"
}'
```
* Response success result
```shell
{
"success": true,
"message": "Successfully get Attestation",
"data": "{\"quote\":\"0x04000300810000000e934d64208ed62112d13060cf062a398f78a9516b9f884ee7ad145e875b59592b09598ce02e4d4983ae4decab71f5147acd16a26326e01075a8d5b709727224bba449c9cd7fc2b490ea23d9e01cd932221d8b86a0a8a7be25c25571bceef0427131860fe0cb295b0d25e5ed1488d9a122c24ba4c1494c2a2578535c556752850c6bbd60c2482b5bb10b5157fe5f42b637457262fd4d8a92575b307f5453c1982a841b46cd60858a3f8ced7ca2ba1c02cf9fec3f23b30bbe8e30378e116bea58b4068bf0379964b6adcb2f680f4646b26a21bed6f8ac06f468cc356db0b2769638a02a7d6e0b69ae297304c62a1fd800703e8bfd340901b6ad412d9433eee04b67ab86311ebb4ee2f3a758ea3fda0e89f45c7ec9ca28e2d525fab6d3e62c3e2b6788dd9dec6e367975c0ac5f6c2aad436e14c75dd99a94c51d882efc0ea44ca8c251e3384b24a88af39ab070b65387ee5e0fd11212852663248c6f24a646c163273348ea03f99d028022b08e09b0b992d9b49c61246b298c3ec827af4973a57bc017a35e0f22750922f2cae660ed70797695c5c65104339f912e1da35a7c625e5fa470764228efe80309762e33ea295b8fd6bae7ef9e7f9a4210deaac322d26acf4e003aded3099c90d6f5c1caa6fb9d84e4f70da3ea1fbfd76c2c7bb544375f566a5182e142da67718a4db7b373ff7e8b4e14bf5a752c5cf88002555020a2a4938978849c1774810456a8fe89769a595676eb0fdadda83540d353efdd40a3efcfb80283abc942e9348d3fe04109fd9999ed6fae17b5d8de88dcd80e5d57cd576ffb7a21780bd6064b4e61f83d1ff1088e836f2a8aa4cdee685aa02303cb809a6e45997532d372b5b519d3ae03f08cb162020000f5672ea83d7b1e145824622fea621381d7b6a110b1b0fdda4e4e2c3565431d099e74829267a01345a2780d0387173419e23bdb72ea57294c696e14ac8198e0967e30dc93a361465d109c1a54f47c117adcba95fdc2cecbd2b35ba3fc7443d80f56e16499d4a85ae2970428848487f963c9366898b34ebbb349dc162d2127f2800000dc010000149f9a1f60ae565575037121aac4f9a10cf6d6e884df2aac1c2bb83f8cad17d0d27f7d4264bdb78a9fe056aba38ff666b22642a9471f351f04afa7ad727f80a1ecab742174c46b33f034fc43cdef08afde65b93aeb94db20b705b379407e50a648db3a3f5958ac29f9bcc32a46a3ea36be27bc049a1409e8543467926afce68eed7488c7120ff3bd6d79c61078111d285e13fc365c82da04469a77101e067bc24f0c4fd27c361430292b8af92f07ac2687532e36377a9c67fa65a17a1dedba2aabac079d3ee691fcdf3e10bf7a479ee58e27085f5ac700a2252899cd88ba13ab00b1cf12cbfca3bcdacaf870e904191bdf2e7426c86b092380fbb523086c294aaf64f3931c96ec7292e4a0aee03f4b0f0eb757d1dc96c7fd07dcad6d51622060e5db55cae0c45aab399caa785665302fff467b1caa98e4ef2bac9a02911388a44b69cf7f21bf3c2ce2da95f323ea3717eddfe97f486beb90dc7ff88377211dd8a89d2b77d044fae1423904839ad8b4662d8df7a414c9aec2c234c0df878093fc31714d2fee3c400cfbee9df0ee82df7d7361d53a7ce91b01e80d3dc9702eebb8dafa1cb3e2a5032fd64ded06e5f1bacd9c275604cedabbea82cec2cfa32384790a000000000000000000000078c50a00000000000000000000000000\",\"timestamp\":1734626127589}"
}
```

* Response failure result
```shell

{
"error": "Failed to Get Verifiable Logs",
"details": "Cannot read properties of undefined (reading 'getService')",
"stack": "TypeError: Cannot read ..."
}
```
6 changes: 6 additions & 0 deletions packages/client-direct/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import { settings } from "@elizaos/core";
import { createApiRouter } from "./api.ts";
import * as fs from "fs";
import * as path from "path";
import { createVerifiableLogApiRouter } from "./verifiable-log-api.ts";


const storage = multer.diskStorage({
destination: (req, file, cb) => {
Expand Down Expand Up @@ -101,6 +103,10 @@ export class DirectClient {
const apiRouter = createApiRouter(this.agents, this);
this.app.use(apiRouter);


const apiLogRouter = createVerifiableLogApiRouter(this.agents);
this.app.use(apiLogRouter);

// Define an interface that extends the Express Request interface
interface CustomRequest extends ExpressRequest {
file?: Express.Multer.File;
Expand Down
119 changes: 119 additions & 0 deletions packages/client-direct/src/verifiable-log-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import express from "express";
import bodyParser from "body-parser";
import cors from "cors";

import { AgentRuntime, elizaLogger, ServiceType } from "@elizaos/core";
import {
VerifiableLogService,
VerifiableLogQuery,
} from "@elizaos/plugin-tee-verifiable-log";

export function createVerifiableLogApiRouter(
agents: Map<string, AgentRuntime>
) {
const router = express.Router();
router.use(cors());
router.use(bodyParser.json());
router.use(bodyParser.urlencoded({ extended: true }));

router.get(
"/verifiable/agents",
async (req: express.Request, res: express.Response) => {
try {
// call the listAgent method
const agentRuntime: AgentRuntime | undefined = agents.values().next().value;
const pageQuery = await agentRuntime
.getService<VerifiableLogService>(
ServiceType.VERIFIABLE_LOGGING
)
.listAgent();

res.json({
success: true,
message: "Successfully get Agents",
data: pageQuery,
});
} catch (error) {
elizaLogger.error("Detailed error:", error);
res.status(500).json({
error: "failed to get agents registered ",
details: error.message,
stack: error.stack,
});
}
}
);
router.post(
"/verifiable/attestation",
async (req: express.Request, res: express.Response) => {
try {
const query = req.body || {};

const verifiableLogQuery = {
agentId: query.agentId || "",
publicKey: query.publicKey || "",
};
const agentRuntime: AgentRuntime | undefined = agents.values().next().value;
const pageQuery = await agentRuntime
.getService<VerifiableLogService>(
ServiceType.VERIFIABLE_LOGGING
)
.generateAttestation(verifiableLogQuery);

res.json({
success: true,
message: "Successfully get Attestation",
data: pageQuery,
});
} catch (error) {
elizaLogger.error("Detailed error:", error);
res.status(500).json({
error: "Failed to Get Attestation",
details: error.message,
stack: error.stack,
});
}
}
);
router.post(
"/verifiable/logs",
async (req: express.Request, res: express.Response) => {
try {
const query = req.body.query || {};
const page = parseInt(req.body.page) || 1;
const pageSize = parseInt(req.body.pageSize) || 10;

const verifiableLogQuery: VerifiableLogQuery = {
idEq: query.idEq || "",
agentIdEq: query.agentIdEq || "",
roomIdEq: query.roomIdEq || "",
userIdEq: query.userIdEq || "",
typeEq: query.typeEq || "",
contLike: query.contLike || "",
signatureEq: query.signatureEq || "",
};
const agentRuntime: AgentRuntime | undefined = agents.values().next().value;
const pageQuery = await agentRuntime
.getService<VerifiableLogService>(
ServiceType.VERIFIABLE_LOGGING
)
.pageQueryLogs(verifiableLogQuery, page, pageSize);

res.json({
success: true,
message: "Successfully retrieved logs",
data: pageQuery,
});
} catch (error) {
elizaLogger.error("Detailed error:", error);
res.status(500).json({
error: "Failed to Get Verifiable Logs",
details: error.message,
stack: error.stack,
});
}
}
);

return router;
}
2 changes: 2 additions & 0 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,8 @@ export enum ServiceType {
AWS_S3 = "aws_s3",
BUTTPLUG = "buttplug",
SLACK = "slack",
VERIFIABLE_LOGGING = "verifiable_logging",
GOPLUS_SECURITY = "goplus_security",
}

export enum LoggingLevel {
Expand Down
6 changes: 6 additions & 0 deletions packages/plugin-goplus/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*

!dist/**
!package.json
!readme.md
!tsup.config.ts
3 changes: 3 additions & 0 deletions packages/plugin-goplus/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import eslintGlobalConfig from "../../eslint.config.mjs";

export default [...eslintGlobalConfig];
21 changes: 21 additions & 0 deletions packages/plugin-goplus/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "@elizaos/plugin-goplus",
"version": "0.1.7-alpha.2",
"main": "dist/index.js",
"type": "module",
"types": "dist/index.d.ts",
"dependencies": {
"@elizaos/core": "workspace:*",
"tsup": "^8.3.5",
"ws": "^8.18.0"
},
"scripts": {
"build": "tsup --format esm --dts",
"dev": "tsx watch src/index.ts",
"lint": "eslint --fix --cache ."
},
"devDependencies": {
"@types/ws": "^8.5.13",
"tsx": "^4.19.2"
}
}
17 changes: 17 additions & 0 deletions packages/plugin-goplus/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Plugin } from "@elizaos/core";
import GoplusSecurityService from "./services/GoplusSecurityService";

export * from "./services/GoplusSecurityService";


export const goplusPlugin: Plugin = {
name: "goplus",
description:
"goplus Plugin for Eliza - Enables WebSocket communication for AI-driven market insights",
actions: [],
evaluators: [],
providers: [],
services: [new GoplusSecurityService()],
};

export default goplusPlugin;
Loading
Loading