Decentralized Key Management: Securing the Autonomy of DeFi Agents
Decentralized key management systems can enable autonomy for agents by securing private keys through TEEs.
.png)
The agentic revolution promises autonomous machine intelligence that will multiply human productivity and transform society. But consider a more immediate example in today’s reality: an AI agent optimizing yield by managing a wallet with some ETH or USDC. If the agent runs off-chain on a centralized server, it begs the question, who controls the private keys?
The funds might be on a blockchain, and there may be automated actions, but if a person or an even small group of people can access keys, this isn't real autonomy, it's centralization in a new format. Without guardrails like decentralized key management systems, the situation is primed for mishaps or abuse. Indeed, many popular DeFAI agents don’t have full solutions to this problem.
The Spectrum of Trust
Interacting onchain includes some risk. When you hand funds off to an agent to do the interacting, this includes more risks. In the worst case scenario, the agent custodies user funds and the developer has unilateral control of the wallet.
This isn’t the case with any reputable project but even with popular agents like ARMA, Spectra, Modius, Mushy, AutoPaal, BigTonyXBT, or Axal AutoPilot, key generation and storage are often not fully specified or require digging through to the docs to understand the setup.
If the approach to key management is clearly communicated, it’s commonly based on a combination of smart accounts and session keys. That is, temporary cryptographic credentials, that enable efficient automation within user-defined rules.
With session keys, the approach is non-custodial and allows granular control over the agent’s actions without constant requests for approval. However, it also requires manual setup of the parameters and local security—keys are susceptible to malware, physical theft, and the agent itself could theoretically leak the keys or sign unauthorized transactions.
What Is Decentralized Key Management?
Another way to approach this is to leverage Sapphire, whose privacy-focused architecture enables secure and private key handling for dApps. With Sapphire, you have this onchain, decentralized, persistent data storage that can go inside a smart contract, which, in turn, can facilitate access controls.
Keys are stored as part of a smart contract's confidential state using the ConfidentialCell primitive, which ensures hardware-level encryption through trusted execution environments (TEEs). This setup allows dApps to manage private keys onchain, keeping them encrypted and secure.
When a smart contract needs to sign a transaction, it simply:
- Retrieves the key via the confidential_store() method
- Decrypts it within the TEE enclave
- Processes the operation without exposure
This ensures that no one can access the keys—not developers, not node operators, not any external party.
Extending To AI Agents: TEE Cloud
To expand decentralized key management to agents, we need Runtime Offchain Logic (ROFL). ROFL is a framework that enables complex, non-deterministic AIs to run off-chain in TEEs, ensuring privacy and verifiability through remote attestation and reproducible builds.
ROFL also provides onchain upgrade governance, a log of all enclave invocation, and, critically, onchain key management, meaning all cryptographic keys are generated and stored within the same TEEs. This ensures they remain unexposed, creating more autonomous agents.

Why Does Decentralized Key Management Matter?
The bottom line benefits of using a decentralized key management system is that instead of having one centralized server, multiple Sapphire nodes collectively manage your private keys without exposing them. If you tried to do this on a transparent blockchain like Ethereum, the keys would instantly become compromised.
For AI agents, decentralized key management means true autonomy, no single point of failure, no backdoor, and no handwaving. But ultimately, this isn’t about just one solution, it’s about awareness. It's about having more solutions, and solving the fundamental disconnect between the promise of autonomous agents and what's often delivered: agents with puppet masters.
Check out WT3, a trustless agent with decentralized key management running on Oasis! More here.