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

Revert "fix: Update Key Derive in TEE" #2049

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading