Skip to main content
This guide covers account management in snarkVM, including key generation, derivation, and secure storage practices.

Account Components

An Aleo account consists of three cryptographic components:
  • Private Key: The secret key that controls the account
  • View Key: Derived from the private key, used to decrypt records
  • Address: The public identifier derived from the view key

Generating a New Account

Key Formats

Each key type has a specific string format:

Parsing Keys from Strings

Parse keys with proper error handling:

Account Derivation Chain

Understand the full derivation chain:

Signing Messages

Use the private key to sign messages:

Verifying Signatures

Verify signatures using the address:

Secure Key Storage

Critical Security PracticesPrivate keys must be stored securely:
  • Never log private keys to console in production
  • Never commit private keys to version control
  • Always encrypt private keys at rest
  • Always use secure random number generators
  • Consider hardware security modules for production

Environment Variables

Store keys in environment variables:

Encrypted Storage

Encrypt private keys before storing:

Working with Multiple Accounts

Manage multiple accounts:

Deriving Graph Keys

Graph keys are used for efficient record detection:

Account Serialization

Serialize and deserialize keys:

Zeroizing Sensitive Data

snarkVM uses the zeroize crate to clear sensitive data:

Testing Accounts

For testing, use deterministic keys:

Common Patterns

Loading Account from File

Deriving Child Accounts

For deterministic wallet generation:

Error Handling

Handle account-related errors properly:

Next Steps