@elizaos/plugin-tee 0.1.8 → 0.1.9
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 +2 -2
- package/dist/{ccip-IAE5UWYX.js → ccip-MMGH6DXX.js} +2 -2
- package/dist/{chunk-KSHJJL6X.js → chunk-NTU6R7BC.js} +18 -18
- package/dist/chunk-NTU6R7BC.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +54 -16
- package/dist/index.js.map +1 -1
- package/package.json +39 -39
- package/dist/chunk-KSHJJL6X.js.map +0 -1
- /package/dist/{ccip-IAE5UWYX.js.map → ccip-MMGH6DXX.js.map} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -19,11 +19,31 @@ declare class DeriveKeyProvider {
|
|
|
19
19
|
private raProvider;
|
|
20
20
|
constructor(teeMode?: string);
|
|
21
21
|
private generateDeriveKeyAttestation;
|
|
22
|
+
/**
|
|
23
|
+
* Derives a raw key from the given path and subject.
|
|
24
|
+
* @param path - The path to derive the key from. This is used to derive the key from the root of trust.
|
|
25
|
+
* @param subject - The subject to derive the key from. This is used for the certificate chain.
|
|
26
|
+
* @returns The derived key.
|
|
27
|
+
*/
|
|
22
28
|
rawDeriveKey(path: string, subject: string): Promise<DeriveKeyResponse>;
|
|
29
|
+
/**
|
|
30
|
+
* Derives an Ed25519 keypair from the given path and subject.
|
|
31
|
+
* @param path - The path to derive the key from. This is used to derive the key from the root of trust.
|
|
32
|
+
* @param subject - The subject to derive the key from. This is used for the certificate chain.
|
|
33
|
+
* @param agentId - The agent ID to generate an attestation for.
|
|
34
|
+
* @returns An object containing the derived keypair and attestation.
|
|
35
|
+
*/
|
|
23
36
|
deriveEd25519Keypair(path: string, subject: string, agentId: string): Promise<{
|
|
24
37
|
keypair: Keypair;
|
|
25
38
|
attestation: RemoteAttestationQuote;
|
|
26
39
|
}>;
|
|
40
|
+
/**
|
|
41
|
+
* Derives an ECDSA keypair from the given path and subject.
|
|
42
|
+
* @param path - The path to derive the key from. This is used to derive the key from the root of trust.
|
|
43
|
+
* @param subject - The subject to derive the key from. This is used for the certificate chain.
|
|
44
|
+
* @param agentId - The agent ID to generate an attestation for. This is used for the certificate chain.
|
|
45
|
+
* @returns An object containing the derived keypair and attestation.
|
|
46
|
+
*/
|
|
27
47
|
deriveEcdsaKeypair(path: string, subject: string, agentId: string): Promise<{
|
|
28
48
|
keypair: PrivateKeyAccount;
|
|
29
49
|
attestation: RemoteAttestationQuote;
|
package/dist/index.js
CHANGED
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
toHex,
|
|
42
42
|
trim,
|
|
43
43
|
wrapConstructor
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-NTU6R7BC.js";
|
|
45
45
|
import "./chunk-PR4QN5HX.js";
|
|
46
46
|
|
|
47
47
|
// src/providers/remoteAttestationProvider.ts
|
|
@@ -116,13 +116,22 @@ rtmr3: ${rtmrs[3]}f`
|
|
|
116
116
|
}
|
|
117
117
|
};
|
|
118
118
|
var remoteAttestationProvider = {
|
|
119
|
-
get: async (runtime,
|
|
119
|
+
get: async (runtime, message, _state) => {
|
|
120
120
|
const teeMode = runtime.getSetting("TEE_MODE");
|
|
121
121
|
const provider = new RemoteAttestationProvider(teeMode);
|
|
122
122
|
const agentId = runtime.agentId;
|
|
123
123
|
try {
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
const attestationMessage = {
|
|
125
|
+
agentId,
|
|
126
|
+
timestamp: Date.now(),
|
|
127
|
+
message: {
|
|
128
|
+
userId: message.userId,
|
|
129
|
+
roomId: message.roomId,
|
|
130
|
+
content: message.content.text
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
elizaLogger.log("Generating attestation for: ", JSON.stringify(attestationMessage));
|
|
134
|
+
const attestation = await provider.generateAttestation(JSON.stringify(attestationMessage));
|
|
126
135
|
return `Your Agent's remote attestation is: ${JSON.stringify(attestation)}`;
|
|
127
136
|
} catch (error) {
|
|
128
137
|
console.error("Error in remote attestation provider:", error);
|
|
@@ -1379,10 +1388,11 @@ var DeriveKeyProvider = class {
|
|
|
1379
1388
|
this.client = endpoint ? new TappdClient2(endpoint) : new TappdClient2();
|
|
1380
1389
|
this.raProvider = new RemoteAttestationProvider(teeMode);
|
|
1381
1390
|
}
|
|
1382
|
-
async generateDeriveKeyAttestation(agentId, publicKey) {
|
|
1391
|
+
async generateDeriveKeyAttestation(agentId, publicKey, subject) {
|
|
1383
1392
|
const deriveKeyData = {
|
|
1384
1393
|
agentId,
|
|
1385
|
-
publicKey
|
|
1394
|
+
publicKey,
|
|
1395
|
+
subject
|
|
1386
1396
|
};
|
|
1387
1397
|
const reportdata = JSON.stringify(deriveKeyData);
|
|
1388
1398
|
elizaLogger2.log(
|
|
@@ -1392,6 +1402,12 @@ var DeriveKeyProvider = class {
|
|
|
1392
1402
|
elizaLogger2.log("Remote Attestation Quote generated successfully!");
|
|
1393
1403
|
return quote;
|
|
1394
1404
|
}
|
|
1405
|
+
/**
|
|
1406
|
+
* Derives a raw key from the given path and subject.
|
|
1407
|
+
* @param path - The path to derive the key from. This is used to derive the key from the root of trust.
|
|
1408
|
+
* @param subject - The subject to derive the key from. This is used for the certificate chain.
|
|
1409
|
+
* @returns The derived key.
|
|
1410
|
+
*/
|
|
1395
1411
|
async rawDeriveKey(path, subject) {
|
|
1396
1412
|
try {
|
|
1397
1413
|
if (!path || !subject) {
|
|
@@ -1408,6 +1424,13 @@ var DeriveKeyProvider = class {
|
|
|
1408
1424
|
throw error;
|
|
1409
1425
|
}
|
|
1410
1426
|
}
|
|
1427
|
+
/**
|
|
1428
|
+
* Derives an Ed25519 keypair from the given path and subject.
|
|
1429
|
+
* @param path - The path to derive the key from. This is used to derive the key from the root of trust.
|
|
1430
|
+
* @param subject - The subject to derive the key from. This is used for the certificate chain.
|
|
1431
|
+
* @param agentId - The agent ID to generate an attestation for.
|
|
1432
|
+
* @returns An object containing the derived keypair and attestation.
|
|
1433
|
+
*/
|
|
1411
1434
|
async deriveEd25519Keypair(path, subject, agentId) {
|
|
1412
1435
|
try {
|
|
1413
1436
|
if (!path || !subject) {
|
|
@@ -1434,6 +1457,13 @@ var DeriveKeyProvider = class {
|
|
|
1434
1457
|
throw error;
|
|
1435
1458
|
}
|
|
1436
1459
|
}
|
|
1460
|
+
/**
|
|
1461
|
+
* Derives an ECDSA keypair from the given path and subject.
|
|
1462
|
+
* @param path - The path to derive the key from. This is used to derive the key from the root of trust.
|
|
1463
|
+
* @param subject - The subject to derive the key from. This is used for the certificate chain.
|
|
1464
|
+
* @param agentId - The agent ID to generate an attestation for. This is used for the certificate chain.
|
|
1465
|
+
* @returns An object containing the derived keypair and attestation.
|
|
1466
|
+
*/
|
|
1437
1467
|
async deriveEcdsaKeypair(path, subject, agentId) {
|
|
1438
1468
|
try {
|
|
1439
1469
|
if (!path || !subject) {
|
|
@@ -1472,13 +1502,13 @@ var deriveKeyProvider = {
|
|
|
1472
1502
|
try {
|
|
1473
1503
|
const secretSalt = runtime.getSetting("WALLET_SECRET_SALT") || "secret_salt";
|
|
1474
1504
|
const solanaKeypair = await provider.deriveEd25519Keypair(
|
|
1475
|
-
"/",
|
|
1476
1505
|
secretSalt,
|
|
1506
|
+
"solana",
|
|
1477
1507
|
agentId
|
|
1478
1508
|
);
|
|
1479
1509
|
const evmKeypair = await provider.deriveEcdsaKeypair(
|
|
1480
|
-
"/",
|
|
1481
1510
|
secretSalt,
|
|
1511
|
+
"evm",
|
|
1482
1512
|
agentId
|
|
1483
1513
|
);
|
|
1484
1514
|
return JSON.stringify({
|
|
@@ -1511,7 +1541,7 @@ function hexToUint8Array(hex) {
|
|
|
1511
1541
|
}
|
|
1512
1542
|
const array = new Uint8Array(hex.length / 2);
|
|
1513
1543
|
for (let i = 0; i < hex.length; i += 2) {
|
|
1514
|
-
const byte = parseInt(hex.slice(i, i + 2), 16);
|
|
1544
|
+
const byte = Number.parseInt(hex.slice(i, i + 2), 16);
|
|
1515
1545
|
if (isNaN(byte)) {
|
|
1516
1546
|
throw new Error("Invalid hex string");
|
|
1517
1547
|
}
|
|
@@ -1532,18 +1562,26 @@ var remoteAttestationAction = {
|
|
|
1532
1562
|
name: "REMOTE_ATTESTATION",
|
|
1533
1563
|
similes: ["REMOTE_ATTESTATION", "TEE_REMOTE_ATTESTATION", "TEE_ATTESTATION"],
|
|
1534
1564
|
description: "Generate a remote attestation to prove that the agent is running in a TEE",
|
|
1535
|
-
handler: async (runtime,
|
|
1565
|
+
handler: async (runtime, message, _state, _options, callback) => {
|
|
1536
1566
|
try {
|
|
1537
|
-
const
|
|
1567
|
+
const attestationMessage = {
|
|
1568
|
+
agentId: runtime.agentId,
|
|
1569
|
+
timestamp: Date.now(),
|
|
1570
|
+
message: {
|
|
1571
|
+
userId: message.userId,
|
|
1572
|
+
roomId: message.roomId,
|
|
1573
|
+
content: message.content.text
|
|
1574
|
+
}
|
|
1575
|
+
};
|
|
1538
1576
|
const teeMode = runtime.getSetting("TEE_MODE");
|
|
1539
1577
|
const provider = new RemoteAttestationProvider(teeMode);
|
|
1540
|
-
const attestation = await provider.generateAttestation(
|
|
1578
|
+
const attestation = await provider.generateAttestation(JSON.stringify(attestationMessage));
|
|
1541
1579
|
const attestationData = hexToUint8Array(attestation.quote);
|
|
1542
1580
|
const response = await uploadUint8Array(attestationData);
|
|
1543
1581
|
const data = await response.json();
|
|
1544
1582
|
callback({
|
|
1545
1583
|
text: `Here's my \u{1F9FE} RA Quote \u{1FAE1}
|
|
1546
|
-
|
|
1584
|
+
https://proof.t16z.com/reports/${data.checksum}`,
|
|
1547
1585
|
action: "NONE"
|
|
1548
1586
|
});
|
|
1549
1587
|
return true;
|
|
@@ -1560,14 +1598,14 @@ var remoteAttestationAction = {
|
|
|
1560
1598
|
{
|
|
1561
1599
|
user: "{{user1}}",
|
|
1562
1600
|
content: {
|
|
1563
|
-
text: "If you are running in a TEE, generate a remote attestation"
|
|
1601
|
+
text: "If you are running in a TEE, generate a remote attestation",
|
|
1602
|
+
action: "REMOTE_ATTESTATION"
|
|
1564
1603
|
}
|
|
1565
1604
|
},
|
|
1566
1605
|
{
|
|
1567
1606
|
user: "{{user2}}",
|
|
1568
1607
|
content: {
|
|
1569
|
-
text: "Of course, one second..."
|
|
1570
|
-
action: "REMOTE_ATTESTATION"
|
|
1608
|
+
text: "Of course, one second..."
|
|
1571
1609
|
}
|
|
1572
1610
|
}
|
|
1573
1611
|
]
|