Skip to main content
The leo account command provides tools for managing Aleo accounts, including generating keys, importing accounts, signing messages, and verifying signatures.

Syntax

Subcommands

new

Generate a new Aleo account with a random private key.

import

Import an Aleo account from a private key.

sign

Sign a message using your Aleo private key.

verify

Verify a signature from an Aleo address.

decrypt

Decrypt a record ciphertext using your private or view key.

New Options

number
Seed the RNG with a numeric value for reproducible key generation.
Only use --seed for testing. Production keys should use secure randomness.
boolean
default:false
Write the private key to the .env file in the current directory.
boolean
default:false
Print sensitive information (private key) to an alternate screen for privacy.
string
default:"testnet"
Network type: mainnet, testnet, or canary.
string
default:"https://api.explorer.provable.com/v1"
Network endpoint URL.

Import Options

string
Private key to import. If not provided, will prompt interactively.
boolean
default:false
Write the private key to the .env file.
boolean
default:false
Print sensitive information discreetly.
string
default:"testnet"
Network type.
string
default:"https://api.explorer.provable.com/v1"
Network endpoint URL.

Sign Options

string
Private key to use for signing.
string
Path to file containing the private key.
string
required
Message (Aleo value) to sign.
boolean
default:false
Parse the message as bytes instead of Aleo literals.
string
default:"testnet"
Network type.

Verify Options

string
required
Address to use for verification.
string
required
Signature to verify.
string
required
Message (Aleo value) to verify against.
boolean
default:false
Parse the message as bytes instead of Aleo literals.
string
default:"testnet"
Network type.

Decrypt Options

string
Private key or view key to use for decryption.
string
Path to file containing the private key or view key.
string
required
Record ciphertext to decrypt (starts with record1).
string
default:"testnet"
Network type.

Examples

Generate New Account

Output:
Store your private key securely. Anyone with your private key can access your account.

Generate and Write to .env

Creates or updates .env:

Generate with Seed (Testing)

Generates the same key each time for testing:

Generate Discreetly

Displays sensitive info on an alternate screen that clears after viewing.

Import Account

Output:

Import Interactively

Prompts for private key:

Import and Write to .env

Sign a Message

Sign Aleo Literal

Output:

Sign from File

Sign Raw Bytes

Verify a Signature

Output:
Or if invalid:

Verify Raw Message

Decrypt Record with Private Key

Output:

Decrypt Record with View Key

View keys can decrypt records but cannot spend them.

Decrypt from File

Key Formats

Private Key

Format: APrivateKey1zkp... A private key allows:
  • Signing transactions
  • Decrypting records
  • Deriving view key and address
  • Full account control

View Key

Format: AViewKey1... A view key allows:
  • Decrypting records
  • Viewing transaction details
  • Cannot spend funds
Derived from private key:

Address

Format: aleo1... A public address for:
  • Receiving funds
  • Identifying accounts
  • Public visibility
Derived from private key:

Key Derivation

The relationship between keys:
  • Private Key: Full control, keep secret
  • View Key: Read-only access, can share selectively
  • Address: Public identifier, safe to share

Security Best Practices

1. Generate Securely

2. Store Safely

3. Never Share Private Keys

4. Use View Keys for Read-Only Access

5. Backup Securely

6. Test with Small Amounts

Message Signing Use Cases

Authentication

Prove account ownership without revealing private key:

Data Integrity

Sign data to prove authenticity:

Timestamping

Create unforgeable timestamps:

Record Decryption

Records are encrypted on-chain. Decrypt them with your key:
Common record types:
  • Credits records (from credits.aleo)
  • Custom program records
  • Fee records

Environment Variables

Store account info in .env:
Leo commands automatically use these values:
Add .env to .gitignore to prevent committing private keys to version control.

Troubleshooting

Invalid Private Key Format

Ensure:
  1. Private key starts with APrivateKey1
  2. Full key is provided (not truncated)
  3. No extra whitespace

Signature Verification Failed

Check:
  1. Address matches the signing private key
  2. Message exactly matches signed message
  3. Signature is complete and correct

Decryption Failed

Verify:
  1. Ciphertext starts with record1
  2. Key corresponds to the record owner
  3. Record ciphertext is complete

Next Steps