Summary
Secret keys are currently stored in plaintext in ~/.starforge/config.toml.
While this is acceptable for throwaway testnet wallets, it is a security risk
for any wallet holding real value. Encrypting keys at rest with a user-provided
passphrase would significantly improve security.
Task
Add opt-in passphrase-based encryption for secret keys stored in config.toml,
using AES-256-GCM. When a passphrase is set, secret keys are stored encrypted
and decrypted on-demand when needed for signing.
Acceptance Criteria
Files Likely Touched
Cargo.toml — add aes-gcm and pbkdf2 crates
src/utils/config.rs — add encrypt_key and decrypt_key functions
src/commands/wallet.rs — add --encrypt flag and passphrase prompts
Notes
Use aes-gcm crate for encryption and pbkdf2 with SHA-256 for key derivation
from the passphrase. Store the salt alongside the ciphertext in config.toml.
Never store the passphrase itself. Prompt securely using the rpassword crate.
Summary
Secret keys are currently stored in plaintext in
~/.starforge/config.toml.While this is acceptable for throwaway testnet wallets, it is a security risk
for any wallet holding real value. Encrypting keys at rest with a user-provided
passphrase would significantly improve security.
Task
Add opt-in passphrase-based encryption for secret keys stored in config.toml,
using AES-256-GCM. When a passphrase is set, secret keys are stored encrypted
and decrypted on-demand when needed for signing.
Acceptance Criteria
starforge wallet create alice --encryptprompts for a passphrase and stores the key encryptedstarforge wallet show alice --revealprompts for the passphrase to decrypt and display the keyFiles Likely Touched
Cargo.toml— addaes-gcmandpbkdf2cratessrc/utils/config.rs— addencrypt_keyanddecrypt_keyfunctionssrc/commands/wallet.rs— add--encryptflag and passphrase promptsNotes
Use
aes-gcmcrate for encryption andpbkdf2with SHA-256 for key derivationfrom the passphrase. Store the salt alongside the ciphertext in config.toml.
Never store the passphrase itself. Prompt securely using the
rpasswordcrate.