coldstar-whitepaper / documentation /WALLET_GENERATION_UPDATE.md
purplesquirrelnetworks's picture
Upload documentation/WALLET_GENERATION_UPDATE.md with huggingface_hub
f4be4fd verified

Wallet Generation Update - Step 7

Overview

The cold wallet USB flash process now includes a 7th step that automatically generates the keypair and wallet during the flash process, making the USB drive ready for transactions immediately upon mounting.

What Changed

Previous Behavior (6 Steps)

  1. Download Alpine Linux minirootfs
  2. Extract filesystem
  3. Configure offline OS
  4. Configure Python environment
  5. Create bootable image
  6. Flash to USB drive

The wallet was NOT generated - users had to:

  • Boot from the USB on an air-gapped device
  • Run the wallet generation script manually
  • Or create the wallet separately after mounting

New Behavior (7 Steps)

  1. Download Alpine Linux minirootfs
  2. Extract filesystem
  3. Configure offline OS
  4. Configure Python environment
  5. Create bootable image
  6. Flash to USB drive
  7. Generate keypair and wallet on USB ✨ NEW!

The wallet IS NOW generated automatically - when the drive is mounted, it's ready to:

  • Receive SOL immediately (public key is available)
  • Sign transactions (private key is encrypted and stored on USB)
  • No additional setup required

Features of Step 7

Automatic Wallet Generation

  • Generates a new Solana keypair using solders
  • Creates both keypair.json (encrypted) and pubkey.txt files
  • Stores them in the /wallet directory on the USB

Security Features

  • Password Protection: Prompts for a password during the flash process
  • Encryption: Uses SecureWalletHandler to encrypt the private key
  • Memory Safety: Clears keypair from memory immediately after saving
  • Secure Permissions: Sets appropriate file permissions (0o600 for keypair)

User Experience

  • Displays the public key (wallet address) at the end of the flash process
  • Shows a clear visual panel with the wallet address
  • Provides instructions for next steps
  • Warns users to write down/photograph the address

Overwrite Protection

  • Checks if a wallet already exists on the USB
  • Prompts for confirmation before overwriting
  • Allows users to keep existing wallets

Technical Implementation

Key Files Modified

src/iso_builder.py

  • Added _generate_wallet_on_usb() method
  • Updated _flash_to_usb_windows() to call Step 7
  • Updated _flash_to_usb_linux() to call Step 7
  • Updated all step counts from 6 to 7
  • Added self.generated_pubkey to store the generated address

main.py

  • Updated flash process description to mention wallet generation
  • Added display of generated public key after successful flash
  • Updated step counter from 6 to 7
  • Enhanced success messaging with wallet information

Code Flow

# Step 7: Generate wallet on USB
def _generate_wallet_on_usb(self, mount_point: str) -> bool:
    1. Check if wallet already exists
    2. Generate new Solana keypair
    3. Prompt for encryption password
    4. Encrypt keypair using SecureWalletHandler
    5. Save encrypted keypair.json
    6. Save public key to pubkey.txt
    7. Set secure file permissions
    8. Clear keypair from memory
    9. Display public key to user
    10. Store pubkey for later display

Dependencies

  • solders: Solana SDK for keypair generation
  • src.secure_memory: SecureWalletHandler for encryption
  • src.ui: get_password_input and UI functions

User Workflow

Before (Manual Wallet Creation)

1. Flash USB drive (6 steps)
2. Mount USB on computer
3. Navigate to wallet directory
4. Run wallet generation script manually
5. Set password and generate keys
6. Now ready for transactions

After (Automatic Wallet Creation)

1. Flash USB drive (7 steps, includes wallet generation)
2. Mount USB on computer
3. ✅ Ready for transactions immediately!

Benefits

  1. Convenience: No manual wallet generation required
  2. Time Savings: One-step setup process
  3. User-Friendly: Less technical knowledge required
  4. Immediate Use: Can receive SOL right away
  5. Secure: Same encryption and security as manual generation
  6. Flexible: Can still overwrite or use existing wallets

Security Considerations

✅ Maintains Security

  • Password-protected encryption still required
  • Private key never exposed to memory longer than necessary
  • Secure file permissions automatically set
  • Works with existing SecureWalletHandler module

⚠️ Important Notes

  • Password must be remembered - cannot recover funds without it
  • Write down public key - needed to receive SOL
  • Keep USB secure - contains encrypted private key
  • Use offline for signing - never sign on internet-connected machines

Testing Recommendations

  1. Flash a test USB and verify wallet files are created
  2. Check encryption - ensure keypair.json is encrypted
  3. Verify public key - confirm it's saved correctly in pubkey.txt
  4. Test transactions - try receiving and sending SOL
  5. Password protection - verify password prompts work correctly
  6. Overwrite protection - test with existing wallet on USB

Compatibility

  • ✅ Windows: Full support (uses PowerShell for drive detection)
  • ✅ Linux: Full support (uses mount points)
  • ✅ macOS: Should work (uses Unix-like mount points)

Future Enhancements

Potential improvements for future versions:

  • Option to skip wallet generation (keep it manual)
  • Support for generating multiple wallets
  • Backup wallet to secondary location during flash
  • QR code generation for easy public key sharing
  • Mnemonic phrase generation for recovery

Troubleshooting

Wallet generation fails during flash

  • Check that solders is installed: pip install solders
  • Verify src.secure_memory module is available
  • Ensure sufficient permissions on USB drive

Password prompt doesn't appear

  • Check terminal supports interactive input
  • Verify src.ui.get_password_input is working

Public key not displayed

  • Check self.generated_pubkey is being set
  • Verify the flash process completed successfully

Summary

The addition of Step 7 transforms the cold wallet USB creation process from a multi-stage setup to a single-command solution. Users can now flash a USB drive and immediately have a fully functional, encrypted cold wallet ready to receive and send SOL - all in one seamless operation.

B - Love U 3000 💙