@elizaos/plugin-tee 1.0.1 → 2.0.0-alpha.1
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 +8 -1
- package/dist/index.js +32507 -402
- package/dist/index.js.map +202 -1
- package/dist/node/actions/index.d.ts +2 -0
- package/dist/node/actions/index.d.ts.map +1 -0
- package/dist/node/actions/index.js +1 -0
- package/dist/node/actions/remoteAttestation.d.ts +3 -0
- package/dist/node/actions/remoteAttestation.d.ts.map +1 -0
- package/dist/node/actions/remoteAttestation.js +115 -0
- package/dist/node/index.d.ts +10 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +34 -0
- package/dist/node/providers/base.d.ts +8 -0
- package/dist/node/providers/base.d.ts.map +1 -0
- package/dist/node/providers/base.js +4 -0
- package/dist/node/providers/deriveKey.d.ts +24 -0
- package/dist/node/providers/deriveKey.d.ts.map +1 -0
- package/dist/node/providers/deriveKey.js +143 -0
- package/dist/node/providers/index.d.ts +4 -0
- package/dist/node/providers/index.d.ts.map +1 -0
- package/dist/node/providers/index.js +3 -0
- package/dist/node/providers/remoteAttestation.d.ts +10 -0
- package/dist/node/providers/remoteAttestation.d.ts.map +1 -0
- package/dist/node/providers/remoteAttestation.js +73 -0
- package/dist/node/services/index.d.ts +2 -0
- package/dist/node/services/index.d.ts.map +1 -0
- package/dist/node/services/index.js +1 -0
- package/dist/node/services/tee.d.ts +24 -0
- package/dist/node/services/tee.d.ts.map +1 -0
- package/dist/node/services/tee.js +42 -0
- package/dist/node/types/index.d.ts +58 -0
- package/dist/node/types/index.d.ts.map +1 -0
- package/dist/node/types/index.js +35 -0
- package/dist/node/utils/index.d.ts +9 -0
- package/dist/node/utils/index.d.ts.map +1 -0
- package/dist/node/utils/index.js +61 -0
- package/dist/node/vendors/index.d.ts +5 -0
- package/dist/node/vendors/index.d.ts.map +1 -0
- package/dist/node/vendors/index.js +14 -0
- package/dist/node/vendors/phala.d.ts +10 -0
- package/dist/node/vendors/phala.d.ts.map +1 -0
- package/dist/node/vendors/phala.js +18 -0
- package/dist/node/vendors/types.d.ts +13 -0
- package/dist/node/vendors/types.d.ts.map +1 -0
- package/dist/node/vendors/types.js +3 -0
- package/package.json +57 -25
- package/README.md +0 -128
- package/dist/index.d.ts +0 -9
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export var TeeMode;
|
|
2
|
+
(function (TeeMode) {
|
|
3
|
+
TeeMode["LOCAL"] = "LOCAL";
|
|
4
|
+
TeeMode["DOCKER"] = "DOCKER";
|
|
5
|
+
TeeMode["PRODUCTION"] = "PRODUCTION";
|
|
6
|
+
})(TeeMode || (TeeMode = {}));
|
|
7
|
+
export var TeeVendor;
|
|
8
|
+
(function (TeeVendor) {
|
|
9
|
+
TeeVendor["PHALA"] = "phala";
|
|
10
|
+
})(TeeVendor || (TeeVendor = {}));
|
|
11
|
+
export var TeeType;
|
|
12
|
+
(function (TeeType) {
|
|
13
|
+
TeeType["SGX_GRAMINE"] = "sgx_gramine";
|
|
14
|
+
TeeType["TDX_DSTACK"] = "tdx_dstack";
|
|
15
|
+
})(TeeType || (TeeType = {}));
|
|
16
|
+
export function parseTeeMode(mode) {
|
|
17
|
+
switch (mode.toUpperCase()) {
|
|
18
|
+
case "LOCAL":
|
|
19
|
+
return TeeMode.LOCAL;
|
|
20
|
+
case "DOCKER":
|
|
21
|
+
return TeeMode.DOCKER;
|
|
22
|
+
case "PRODUCTION":
|
|
23
|
+
return TeeMode.PRODUCTION;
|
|
24
|
+
default:
|
|
25
|
+
throw new Error(`Invalid TEE_MODE: ${mode}. Must be one of: LOCAL, DOCKER, PRODUCTION`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export function parseTeeVendor(vendor) {
|
|
29
|
+
switch (vendor.toLowerCase()) {
|
|
30
|
+
case "phala":
|
|
31
|
+
return TeeVendor.PHALA;
|
|
32
|
+
default:
|
|
33
|
+
throw new Error(`Invalid TEE_VENDOR: ${vendor}. Must be one of: phala`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function hexToUint8Array(hex: string): Uint8Array;
|
|
2
|
+
export declare function uint8ArrayToHex(bytes: Uint8Array): string;
|
|
3
|
+
export declare function calculateSHA256(input: string): Buffer;
|
|
4
|
+
export declare function sha256Bytes(input: Uint8Array): Uint8Array;
|
|
5
|
+
export declare function getTeeEndpoint(mode: string): string | undefined;
|
|
6
|
+
export declare function uploadAttestationQuote(data: Uint8Array): Promise<{
|
|
7
|
+
checksum: string;
|
|
8
|
+
}>;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAEA,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAkBvD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAIzD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIrD;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAIzD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAW/D;AAED,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAiB5F"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
export function hexToUint8Array(hex) {
|
|
3
|
+
const hexString = hex.trim().replace(/^0x/, "");
|
|
4
|
+
if (!hexString) {
|
|
5
|
+
throw new Error("Invalid hex string: empty after stripping prefix");
|
|
6
|
+
}
|
|
7
|
+
if (hexString.length % 2 !== 0) {
|
|
8
|
+
throw new Error("Invalid hex string: odd number of characters");
|
|
9
|
+
}
|
|
10
|
+
const array = new Uint8Array(hexString.length / 2);
|
|
11
|
+
for (let i = 0; i < hexString.length; i += 2) {
|
|
12
|
+
const byte = Number.parseInt(hexString.slice(i, i + 2), 16);
|
|
13
|
+
if (Number.isNaN(byte)) {
|
|
14
|
+
throw new Error(`Invalid hex string: invalid byte at position ${i}`);
|
|
15
|
+
}
|
|
16
|
+
array[i / 2] = byte;
|
|
17
|
+
}
|
|
18
|
+
return array;
|
|
19
|
+
}
|
|
20
|
+
export function uint8ArrayToHex(bytes) {
|
|
21
|
+
return Array.from(bytes)
|
|
22
|
+
.map((b) => b.toString(16).padStart(2, "0"))
|
|
23
|
+
.join("");
|
|
24
|
+
}
|
|
25
|
+
export function calculateSHA256(input) {
|
|
26
|
+
const hash = createHash("sha256");
|
|
27
|
+
hash.update(input);
|
|
28
|
+
return hash.digest();
|
|
29
|
+
}
|
|
30
|
+
export function sha256Bytes(input) {
|
|
31
|
+
const hash = createHash("sha256");
|
|
32
|
+
hash.update(input);
|
|
33
|
+
return new Uint8Array(hash.digest());
|
|
34
|
+
}
|
|
35
|
+
export function getTeeEndpoint(mode) {
|
|
36
|
+
switch (mode.toUpperCase()) {
|
|
37
|
+
case "LOCAL":
|
|
38
|
+
return "http://localhost:8090";
|
|
39
|
+
case "DOCKER":
|
|
40
|
+
return "http://host.docker.internal:8090";
|
|
41
|
+
case "PRODUCTION":
|
|
42
|
+
return undefined;
|
|
43
|
+
default:
|
|
44
|
+
throw new Error(`Invalid TEE_MODE: ${mode}. Must be one of: LOCAL, DOCKER, PRODUCTION`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export async function uploadAttestationQuote(data) {
|
|
48
|
+
const blob = new Blob([data], {
|
|
49
|
+
type: "application/octet-stream",
|
|
50
|
+
});
|
|
51
|
+
const formData = new FormData();
|
|
52
|
+
formData.append("file", blob, "quote.bin");
|
|
53
|
+
const response = await fetch("https://proof.t16z.com/api/upload", {
|
|
54
|
+
method: "POST",
|
|
55
|
+
body: formData,
|
|
56
|
+
});
|
|
57
|
+
if (!response.ok) {
|
|
58
|
+
throw new Error(`Failed to upload attestation quote: ${response.statusText}`);
|
|
59
|
+
}
|
|
60
|
+
return response.json();
|
|
61
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type TeeVendorInterface, type TeeVendorName } from "./types";
|
|
2
|
+
export declare function getVendor(type: TeeVendorName): TeeVendorInterface;
|
|
3
|
+
export { PhalaVendor } from "./phala";
|
|
4
|
+
export { type TeeVendorInterface, type TeeVendorName, TeeVendorNames } from "./types";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vendors/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,aAAa,EAAkB,MAAM,SAAS,CAAC;AAMtF,wBAAgB,SAAS,CAAC,IAAI,EAAE,aAAa,GAAG,kBAAkB,CAMjE;AAED,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,aAAa,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PhalaVendor } from "./phala";
|
|
2
|
+
import { TeeVendorNames } from "./types";
|
|
3
|
+
const vendors = {
|
|
4
|
+
[TeeVendorNames.PHALA]: new PhalaVendor(),
|
|
5
|
+
};
|
|
6
|
+
export function getVendor(type) {
|
|
7
|
+
const vendor = vendors[type];
|
|
8
|
+
if (!vendor) {
|
|
9
|
+
throw new Error(`Unsupported TEE vendor: ${type}`);
|
|
10
|
+
}
|
|
11
|
+
return vendor;
|
|
12
|
+
}
|
|
13
|
+
export { PhalaVendor } from "./phala";
|
|
14
|
+
export { TeeVendorNames } from "./types";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Action, Provider } from "@elizaos/core";
|
|
2
|
+
import { type TeeVendorInterface } from "./types";
|
|
3
|
+
export declare class PhalaVendor implements TeeVendorInterface {
|
|
4
|
+
readonly type: "phala";
|
|
5
|
+
getActions(): Action[];
|
|
6
|
+
getProviders(): Provider[];
|
|
7
|
+
getName(): string;
|
|
8
|
+
getDescription(): string;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=phala.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phala.d.ts","sourceRoot":"","sources":["../../../src/vendors/phala.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGtD,OAAO,EAAE,KAAK,kBAAkB,EAAkB,MAAM,SAAS,CAAC;AAElE,qBAAa,WAAY,YAAW,kBAAkB;IACpD,QAAQ,CAAC,IAAI,UAAwB;IAErC,UAAU,IAAI,MAAM,EAAE;IAItB,YAAY,IAAI,QAAQ,EAAE;IAI1B,OAAO,IAAI,MAAM;IAIjB,cAAc,IAAI,MAAM;CAGzB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { remoteAttestationAction } from "../actions/remoteAttestation";
|
|
2
|
+
import { phalaDeriveKeyProvider, phalaRemoteAttestationProvider } from "../providers";
|
|
3
|
+
import { TeeVendorNames } from "./types";
|
|
4
|
+
export class PhalaVendor {
|
|
5
|
+
type = TeeVendorNames.PHALA;
|
|
6
|
+
getActions() {
|
|
7
|
+
return [remoteAttestationAction];
|
|
8
|
+
}
|
|
9
|
+
getProviders() {
|
|
10
|
+
return [phalaDeriveKeyProvider, phalaRemoteAttestationProvider];
|
|
11
|
+
}
|
|
12
|
+
getName() {
|
|
13
|
+
return "phala-tee-plugin";
|
|
14
|
+
}
|
|
15
|
+
getDescription() {
|
|
16
|
+
return "Phala Network TEE for secure agent execution";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Action, Provider } from "@elizaos/core";
|
|
2
|
+
export declare const TeeVendorNames: {
|
|
3
|
+
readonly PHALA: "phala";
|
|
4
|
+
};
|
|
5
|
+
export type TeeVendorName = (typeof TeeVendorNames)[keyof typeof TeeVendorNames];
|
|
6
|
+
export interface TeeVendorInterface {
|
|
7
|
+
readonly type: TeeVendorName;
|
|
8
|
+
getActions(): Action[];
|
|
9
|
+
getProviders(): Provider[];
|
|
10
|
+
getName(): string;
|
|
11
|
+
getDescription(): string;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/vendors/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEtD,eAAO,MAAM,cAAc;;CAEjB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;AAEjF,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,UAAU,IAAI,MAAM,EAAE,CAAC;IACvB,YAAY,IAAI,QAAQ,EAAE,CAAC;IAC3B,OAAO,IAAI,MAAM,CAAC;IAClB,cAAc,IAAI,MAAM,CAAC;CAC1B"}
|
package/package.json
CHANGED
|
@@ -1,29 +1,63 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elizaos/plugin-tee",
|
|
3
|
-
"version": "
|
|
4
|
-
"main": "dist/index.js",
|
|
3
|
+
"version": "2.0.0-alpha.1",
|
|
5
4
|
"type": "module",
|
|
5
|
+
"main": "dist/node/index.js",
|
|
6
|
+
"module": "dist/node/index.js",
|
|
6
7
|
"types": "dist/index.d.ts",
|
|
8
|
+
"description": "Trusted Execution Environment (TEE) integration plugin for elizaOS - Multi-language support (TypeScript, Python, Rust)",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/elizaos-plugins/plugin-tee.git"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
"./package.json": "./package.json",
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"node": {
|
|
18
|
+
"types": "./dist/node/index.d.ts",
|
|
19
|
+
"import": "./dist/node/index.js",
|
|
20
|
+
"default": "./dist/node/index.js"
|
|
21
|
+
},
|
|
22
|
+
"bun": {
|
|
23
|
+
"types": "./dist/node/index.d.ts",
|
|
24
|
+
"default": "./dist/node/index.js"
|
|
25
|
+
},
|
|
26
|
+
"default": "./dist/node/index.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"README.md",
|
|
32
|
+
"LICENSE"
|
|
33
|
+
],
|
|
34
|
+
"sideEffects": false,
|
|
7
35
|
"dependencies": {
|
|
8
|
-
"@elizaos/core": "
|
|
36
|
+
"@elizaos/core": "workspace:*",
|
|
9
37
|
"@phala/dstack-sdk": "0.1.11",
|
|
10
38
|
"@solana/web3.js": "1.98.2",
|
|
11
39
|
"viem": "2.29.4"
|
|
12
40
|
},
|
|
13
41
|
"devDependencies": {
|
|
14
|
-
"@types/node": "^
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"vitest": "^3.1.3"
|
|
42
|
+
"@types/node": "^25.0.3",
|
|
43
|
+
"typescript": "^5.9.3",
|
|
44
|
+
"vitest": "^4.0.0",
|
|
45
|
+
"@biomejs/biome": "^2.3.11"
|
|
19
46
|
},
|
|
20
47
|
"scripts": {
|
|
21
|
-
"build": "
|
|
22
|
-
"dev": "
|
|
23
|
-
"lint": "prettier --write ./src",
|
|
48
|
+
"build:typescript": "tsc -p tsconfig.build.json",
|
|
49
|
+
"dev": "bun --hot build.ts",
|
|
24
50
|
"clean": "rm -rf dist .turbo node_modules .turbo-tsconfig.json tsconfig.tsbuildinfo",
|
|
25
|
-
"format": "
|
|
26
|
-
"format:check": "
|
|
51
|
+
"format": "bunx @biomejs/biome format --write .",
|
|
52
|
+
"format:check": "bunx @biomejs/biome format .",
|
|
53
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
54
|
+
"test": "bun run test:typescript",
|
|
55
|
+
"test:typescript": "vitest run src/__tests__/",
|
|
56
|
+
"test:watch": "vitest",
|
|
57
|
+
"lint": "bunx @biomejs/biome check --write --unsafe .",
|
|
58
|
+
"lint:check": "bunx @biomejs/biome check .",
|
|
59
|
+
"build": "bun run build.ts",
|
|
60
|
+
"build:ts": "bun run build.ts"
|
|
27
61
|
},
|
|
28
62
|
"publishConfig": {
|
|
29
63
|
"access": "public"
|
|
@@ -34,26 +68,24 @@
|
|
|
34
68
|
"pluginParameters": {
|
|
35
69
|
"TEE_MODE": {
|
|
36
70
|
"type": "string",
|
|
37
|
-
"description": "Determines the Trusted Execution Environment operation mode (LOCAL, DOCKER, PRODUCTION)
|
|
71
|
+
"description": "Determines the Trusted Execution Environment operation mode (LOCAL, DOCKER, PRODUCTION) and is referenced in error handling to validate provided modes.",
|
|
38
72
|
"required": true,
|
|
39
73
|
"sensitive": false
|
|
40
74
|
},
|
|
75
|
+
"TEE_VENDOR": {
|
|
76
|
+
"type": "string",
|
|
77
|
+
"description": "Specifies which Trusted Execution Environment vendor to initialize (defaults to PHALA).",
|
|
78
|
+
"required": false,
|
|
79
|
+
"default": "PHALA",
|
|
80
|
+
"sensitive": false
|
|
81
|
+
},
|
|
41
82
|
"WALLET_SECRET_SALT": {
|
|
42
83
|
"type": "string",
|
|
43
|
-
"description": "Secret salt used
|
|
84
|
+
"description": "Secret salt used to deterministically derive Solana and EVM keypairs inside the TEE.",
|
|
44
85
|
"required": true,
|
|
45
86
|
"default": "secret_salt",
|
|
46
87
|
"sensitive": true
|
|
47
88
|
}
|
|
48
89
|
}
|
|
49
|
-
}
|
|
50
|
-
"repository": {
|
|
51
|
-
"type": "git",
|
|
52
|
-
"url": "git+https://github.com/elizaos-plugins/plugin-tee.git"
|
|
53
|
-
},
|
|
54
|
-
"files": [
|
|
55
|
-
"dist",
|
|
56
|
-
"README.md",
|
|
57
|
-
"LICENSE"
|
|
58
|
-
]
|
|
90
|
+
}
|
|
59
91
|
}
|
package/README.md
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
# TEE Core Plugin for Eliza
|
|
2
|
-
|
|
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
|
-
|
|
5
|
-
## Background
|
|
6
|
-
|
|
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
|
-
|
|
9
|
-
## Requirements
|
|
10
|
-
|
|
11
|
-
- A TEE-enabled environment is required (e.g., Intel TDX) use [Phala Cloud](https://cloud.phala.network) for easy deployment.
|
|
12
|
-
- Configuration within Eliza to enable and utilize this plugin's features.
|
|
13
|
-
|
|
14
|
-
The plugin requires the following environment variables:
|
|
15
|
-
|
|
16
|
-
```env
|
|
17
|
-
# For the environment you are running the TEE plugin. For local and container development, use `LOCAL` or `DOCKER`. For production deployments, use `PRODUCTION`.
|
|
18
|
-
TEE_MODE=LOCAL|DOCKER|PRODUCTION
|
|
19
|
-
# Secret salt for your default agent to generate a key from through the derive key provider
|
|
20
|
-
WALLET_SECRET_SALT=your_secret_salt
|
|
21
|
-
# TEE_VENDOR only supports Phala at this time, but adding a vendor is easy and can be done to support more TEE Vendors in the TEE Plugin
|
|
22
|
-
TEE_VENDOR=phala
|
|
23
|
-
|
|
24
|
-
## Features
|
|
25
|
-
|
|
26
|
-
This plugin offers the following core TEE functionalities:
|
|
27
|
-
|
|
28
|
-
1. **Remote Attestation**:
|
|
29
|
-
|
|
30
|
-
- Provides actions and providers (`remoteAttestationAction`, `remoteAttestationProvider`) allowing agents to request and receive remote attestation reports.
|
|
31
|
-
- These reports can be presented to third parties to verify the agent's TEE residency.
|
|
32
|
-
- Includes support for specific TEE vendors/attestation services (e.g., Phala Network).
|
|
33
|
-
|
|
34
|
-
2. **Key Derivation**:
|
|
35
|
-
- Offers a `deriveKeyProvider` for securely deriving cryptographic keys within the TEE.
|
|
36
|
-
- Ensures that key material is generated and managed within the protected enclave memory.
|
|
37
|
-
|
|
38
|
-
## Components
|
|
39
|
-
|
|
40
|
-
Based on the source code (`src/`):
|
|
41
|
-
|
|
42
|
-
- **Actions**:
|
|
43
|
-
- `remoteAttestationAction.ts`: Likely handles agent requests to initiate the remote attestation process.
|
|
44
|
-
- **Providers**:
|
|
45
|
-
- `remoteAttestationProvider.ts`: Implements the logic for interacting with the underlying TEE platform or attestation service (like Phala) to generate the attestation report.
|
|
46
|
-
- `deriveKeyProvider.ts`: Implements the logic for TEE-specific key derivation.
|
|
47
|
-
- **Services**
|
|
48
|
-
- `service.ts`: TEE Service to allow agents to generate keys from `deriveKeyProvider` for EVM, Solana, and raw `DeriveKeyResponse` that will return the `key`, `certificate_chain` and the `Uint8Array` with `asUint8Array(max_length?: number)`.
|
|
49
|
-
- **Vendors**:
|
|
50
|
-
- `vendors/phala.ts`: Contains specific implementation details for interacting with the Phala Network's attestation services.
|
|
51
|
-
- `vendors/index.ts`, `vendors/types.ts`: Support vendor integration.
|
|
52
|
-
- **Utilities & Types**:
|
|
53
|
-
- `utils.ts`, `types.ts`: Contain helper functions and type definitions for the plugin.
|
|
54
|
-
- **Tests**:
|
|
55
|
-
- `__tests__/`: Includes unit tests for key derivation, remote attestation, etc.
|
|
56
|
-
|
|
57
|
-
## Usage
|
|
58
|
-
|
|
59
|
-
_(This section may need further refinement based on how the plugin is integrated into the core Eliza system)_
|
|
60
|
-
|
|
61
|
-
To utilize the features of this plugin:
|
|
62
|
-
|
|
63
|
-
1. **Ensure the plugin is enabled** in your Eliza agent's configuration.
|
|
64
|
-
2. **Configure the TEE vendor** (e.g., specify 'phala' if using Phala Network attestation) if required by the environment setup.
|
|
65
|
-
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.
|
|
66
|
-
|
|
67
|
-
Example (Conceptual):
|
|
68
|
-
|
|
69
|
-
```typescript
|
|
70
|
-
import import { PhalaDeriveKeyProvider, PhalaRemoteAttestationProvider } from '@elizaos/tee-plugin';
|
|
71
|
-
// Assuming access to the runtime and its services/actions
|
|
72
|
-
|
|
73
|
-
// Requesting remote attestation
|
|
74
|
-
async function getAttestation(
|
|
75
|
-
runtime: IAgentRuntime,
|
|
76
|
-
userData: string
|
|
77
|
-
): Promise<AttestationReport | null> {
|
|
78
|
-
try {
|
|
79
|
-
const provider = new PhalaRemoteAttestationProvider(teeMode);
|
|
80
|
-
|
|
81
|
-
const attestation = await provider.generateAttestation(userData);
|
|
82
|
-
const attestationData = hexToUint8Array(attestation.quote);
|
|
83
|
-
const raQuote = await uploadUint8Array(attestationData);
|
|
84
|
-
return attestation;
|
|
85
|
-
} catch (error) {
|
|
86
|
-
console.error('Failed to get remote attestation:', error);
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Deriving a key
|
|
92
|
-
async function deriveAgentKeys(
|
|
93
|
-
runtime: IAgentRuntime, salt: string
|
|
94
|
-
): Promise<ProviderResult | null> {
|
|
95
|
-
try {
|
|
96
|
-
// Potentially using a service/provider interface
|
|
97
|
-
const provider = new PhalaDeriveKeyProvider(teeMode)
|
|
98
|
-
const secretSalt = runtime.getSetting('WALLET_SECRET_SALT') || 'secret_salt';
|
|
99
|
-
const solanaKeypair = await provider.deriveEd25519Keypair(secretSalt, 'solana', agentId);
|
|
100
|
-
const evmKeypair = await provider.deriveEcdsaKeypair(secretSalt, 'evm', agentId);
|
|
101
|
-
|
|
102
|
-
// Original data structure
|
|
103
|
-
const walletData = {
|
|
104
|
-
solana: solanaKeypair.keypair.publicKey,
|
|
105
|
-
evm: evmKeypair.keypair.address,
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
// Values for template injection
|
|
109
|
-
const values = {
|
|
110
|
-
solana_public_key: solanaKeypair.keypair.publicKey.toString(),
|
|
111
|
-
evm_address: evmKeypair.keypair.address,
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
// Text representation
|
|
115
|
-
const text = `Solana Public Key: ${values.solana_public_key}\nEVM Address: ${values.evm_address}`;
|
|
116
|
-
|
|
117
|
-
return {
|
|
118
|
-
data: walletData,
|
|
119
|
-
values: values,
|
|
120
|
-
text: text,
|
|
121
|
-
};
|
|
122
|
-
return key;
|
|
123
|
-
} catch (error) {
|
|
124
|
-
console.error('Failed to derive key:', error);
|
|
125
|
-
return null;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
```
|
package/dist/index.d.ts
DELETED