Skip to content

Commit

Permalink
Merge pull request #2049 from elizaOS/revert-2039-fix/tee-derive-key
Browse files Browse the repository at this point in the history
Revert "fix: Update Key Derive in TEE"
  • Loading branch information
shakkernerd authored Jan 9, 2025
2 parents 941b8d1 + e6b5bbe commit 4cefcba
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 354 deletions.
10 changes: 2 additions & 8 deletions docs/docs/advanced/eliza-in-tee.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,16 @@ Example usage:
const provider = new DeriveKeyProvider(teeMode);
// For Solana
const { keypair, attestation } = await provider.deriveEd25519Keypair(
"/",
secretSalt,
"solana",
agentId,
);
// For EVM
const { keypair, attestation } = await provider.deriveEcdsaKeypair(
"/",
secretSalt,
"evm",
agentId,
);

// For raw key derivation
const rawKey = await provider.deriveRawKey(
secretSalt,
"raw",
);
```

---
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-evm/src/providers/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ export const initWalletProvider = async (runtime: IAgentRuntime) => {

const deriveKeyProvider = new DeriveKeyProvider(teeMode);
const deriveKeyResult = await deriveKeyProvider.deriveEcdsaKeypair(
"/",
walletSecretSalt,
"evm",
runtime.agentId
);
return new WalletProvider(
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-solana/src/keypairUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export async function getWalletKey(

const deriveKeyProvider = new DeriveKeyProvider(teeMode);
const deriveKeyResult = await deriveKeyProvider.deriveEd25519Keypair(
"/",
walletSecretSalt,
"solana",
runtime.agentId
);

Expand Down
3 changes: 1 addition & 2 deletions packages/plugin-tee/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
"scripts": {
"build": "tsup --format esm --dts",
"dev": "tsup --format esm --dts --watch",
"lint": "eslint --fix --cache .",
"test": "vitest run"
"lint": "eslint --fix --cache ."
},
"peerDependencies": {
"whatwg-url": "7.1.0"
Expand Down
24 changes: 2 additions & 22 deletions packages/plugin-tee/src/providers/deriveKeyProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ class DeriveKeyProvider {
return quote;
}

/**
* Derives a raw key from the given path and subject.
* @param path - The path to derive the key from. This is used to derive the key from the root of trust.
* @param subject - The subject to derive the key from. This is used for the certificate chain.
* @returns The derived key.
*/
async rawDeriveKey(
path: string,
subject: string
Expand All @@ -100,13 +94,6 @@ class DeriveKeyProvider {
}
}

/**
* Derives an Ed25519 keypair from the given path and subject.
* @param path - The path to derive the key from. This is used to derive the key from the root of trust.
* @param subject - The subject to derive the key from. This is used for the certificate chain.
* @param agentId - The agent ID to generate an attestation for.
* @returns An object containing the derived keypair and attestation.
*/
async deriveEd25519Keypair(
path: string,
subject: string,
Expand Down Expand Up @@ -143,13 +130,6 @@ class DeriveKeyProvider {
}
}

/**
* Derives an ECDSA keypair from the given path and subject.
* @param path - The path to derive the key from. This is used to derive the key from the root of trust.
* @param subject - The subject to derive the key from. This is used for the certificate chain.
* @param agentId - The agent ID to generate an attestation for. This is used for the certificate chain.
* @returns An object containing the derived keypair and attestation.
*/
async deriveEcdsaKeypair(
path: string,
subject: string,
Expand Down Expand Up @@ -204,13 +184,13 @@ const deriveKeyProvider: Provider = {
const secretSalt =
runtime.getSetting("WALLET_SECRET_SALT") || "secret_salt";
const solanaKeypair = await provider.deriveEd25519Keypair(
"/",
secretSalt,
"solana",
agentId
);
const evmKeypair = await provider.deriveEcdsaKeypair(
"/",
secretSalt,
"evm",
agentId
);
return JSON.stringify({
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-tee/src/providers/walletProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ const walletProvider: Provider = {
keypair: Keypair;
attestation: RemoteAttestationQuote;
} = await deriveKeyProvider.deriveEd25519Keypair(
"/",
runtime.getSetting("WALLET_SECRET_SALT"),
"solana",
agentId
);
publicKey = derivedKeyPair.keypair.publicKey;
Expand Down
135 changes: 0 additions & 135 deletions packages/plugin-tee/src/tests/deriveKey.test.ts

This file was deleted.

81 changes: 0 additions & 81 deletions packages/plugin-tee/src/tests/remoteAttestation.test.ts

This file was deleted.

Loading

0 comments on commit 4cefcba

Please sign in to comment.