Private Key Architecture
Agentic Wallet implements strict key isolation to ensure that private keys never leave the wallet-engine boundary. This architecture protects against key exfiltration by agents, protocol adapters, or external services.Key Isolation Principles
Exclusive Signing Authority
Only wallet-engine can access private keys
No Key Transmission
Keys never sent over network or to agents
Provider Abstraction
Pluggable backends for different custody models
Encrypted at Rest
All key material encrypted when stored
Key Provider Interface
All signer backends implement a commonKeyProvider interface:
save(): Persist a new wallet keypair securelyload(): Retrieve keypair for signing operationsprovenance(): Report backend type and custody model for audit trails
Wallet-Engine Exclusive Signing
The transaction-engine requests signatures via the wallet-engine API, never directly accessing keys:1
Sign Request
Transaction-engine sends unsigned transaction to wallet-engine:
2
Key Retrieval
Wallet-engine loads keypair from the configured key provider:
3
Signing
Wallet-engine signs the transaction using Solana’s built-in signing:
4
Return Signature
Signed transaction returned to transaction-engine (keys never leave wallet-engine)
Key Lifecycle
Wallet Creation
New wallets are generated with cryptographically secure random keys:- Keypairs generated using Solana’s
Keypair.generate()(ed25519) - Each wallet assigned a unique UUID identifier
- Public key derived from keypair and stored in metadata
- Private key immediately encrypted and stored via key provider
Key Storage
Key material is never stored in plaintext. All backends encrypt keys at rest:Key Loading
Keys are loaded into memory only when needed for signing:- Keys decrypted on-demand per signing request
- Keypair object exists in memory only during signing operation
- No persistent in-memory key cache (reduces memory dump risk)
Key Rotation
Key rotation is currently manual but supported:1
Generate New Wallet
Create a new wallet with
POST /api/v1/wallets2
Transfer Assets
Move SOL and SPL tokens from old wallet to new wallet
3
Update Agent Configuration
Point agents to the new
walletId4
Archive Old Wallet
Optionally delete old wallet key file or mark inactive
Automated key rotation is a planned feature. For production environments using KMS/HSM backends, implement rotation policies at the KMS/HSM layer.
Key Storage Locations
Key files are stored in the wallet-engine data directory:services/wallet-engine/data/keys/
File Naming Conventions
Encryption Details
Encrypted-File Backend
Uses AES-256-GCM authenticated encryption:- Key derivation: SHA-256 hash of
WALLET_KEY_ENCRYPTION_SECRET - Initialization vector (IV): 16 random bytes per encryption
- Authentication tag: GCM tag for integrity verification
- Format: JSON envelope with IV, ciphertext, and auth tag
KMS Backend
Uses envelope encryption with a data key wrapped by the master secret:- Data key: Random 32-byte key generated per wallet
- Master secret: Configured via
WALLET_KMS_MASTER_SECRET - Key ID: Optional identifier for key rotation scenarios
HSM Backend
Wraps keys using HSM slot, PIN, and module secret:- Slot ID: HSM slot identifier (default:
slot-0) - PIN: HSM access PIN from
WALLET_HSM_PIN - Module secret: Shared secret from
WALLET_HSM_MODULE_SECRET
The current HSM implementation is a software simulation. For production, integrate with real HSM hardware (e.g., AWS CloudHSM, Thales Luna, YubiHSM).
MPC Backend
Splits keys into 3 shares using Shamir-like secret sharing over GF(256):- 3-of-3 split: Secret divided into 3 shares
- 2-of-3 reconstruction: Any 2 shares can reconstruct the key
- Node secrets: Each share encrypted with a different
WALLET_MPC_NODE{1,2,3}_SECRET - GF(256) arithmetic: Galois field operations for share generation/reconstruction
Production Security Recommendations
1
Choose Appropriate Backend
Use
kms, hsm, or mpc for production (see Signer Backends)2
Strong Secrets
Generate secrets with
openssl rand -base64 32 or equivalent3
Secret Management
Store secrets in external secret managers (AWS Secrets Manager, Vault, etc.)
4
Network Isolation
Run wallet-engine in an isolated network segment, not exposed to public internet
5
File System Permissions
Set restrictive permissions on key storage directory:
6
Backup Strategy
Implement secure encrypted backups of key files
7
Audit Logging
Enable audit logging for all key load/sign operations
8
Key Rotation Policy
Establish periodic key rotation schedule (e.g., quarterly)
Key Provenance Tracking
Each key provider reports its provenance for audit purposes:- backend: Identifies the key storage mechanism
- custody:
localmeans keys stored on disk,externalmeans KMS/HSM/MPC - deterministicAddressing: Reserved for future HD wallet support
Auto-Funding (Devnet Only)
For devnet development, wallets can be auto-funded on creation:Related Pages
Security Overview
Trust boundaries and protection layers
Signer Backends
Detailed guide for each backend option
Policy Enforcement
Policy evaluation before signing