purplesquirrelnetworks commited on
Commit
f4be4fd
·
verified ·
1 Parent(s): 0170afc

Upload documentation/WALLET_GENERATION_UPDATE.md with huggingface_hub

Browse files
documentation/WALLET_GENERATION_UPDATE.md ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Wallet Generation Update - Step 7
2
+
3
+ ## Overview
4
+ 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.
5
+
6
+ ## What Changed
7
+
8
+ ### Previous Behavior (6 Steps)
9
+ 1. Download Alpine Linux minirootfs
10
+ 2. Extract filesystem
11
+ 3. Configure offline OS
12
+ 4. Configure Python environment
13
+ 5. Create bootable image
14
+ 6. Flash to USB drive
15
+
16
+ **The wallet was NOT generated** - users had to:
17
+ - Boot from the USB on an air-gapped device
18
+ - Run the wallet generation script manually
19
+ - Or create the wallet separately after mounting
20
+
21
+ ### New Behavior (7 Steps)
22
+ 1. Download Alpine Linux minirootfs
23
+ 2. Extract filesystem
24
+ 3. Configure offline OS
25
+ 4. Configure Python environment
26
+ 5. Create bootable image
27
+ 6. Flash to USB drive
28
+ 7. **Generate keypair and wallet on USB** ✨ NEW!
29
+
30
+ **The wallet IS NOW generated automatically** - when the drive is mounted, it's ready to:
31
+ - Receive SOL immediately (public key is available)
32
+ - Sign transactions (private key is encrypted and stored on USB)
33
+ - No additional setup required
34
+
35
+ ## Features of Step 7
36
+
37
+ ### Automatic Wallet Generation
38
+ - Generates a new Solana keypair using `solders`
39
+ - Creates both `keypair.json` (encrypted) and `pubkey.txt` files
40
+ - Stores them in the `/wallet` directory on the USB
41
+
42
+ ### Security Features
43
+ - **Password Protection**: Prompts for a password during the flash process
44
+ - **Encryption**: Uses `SecureWalletHandler` to encrypt the private key
45
+ - **Memory Safety**: Clears keypair from memory immediately after saving
46
+ - **Secure Permissions**: Sets appropriate file permissions (0o600 for keypair)
47
+
48
+ ### User Experience
49
+ - Displays the public key (wallet address) at the end of the flash process
50
+ - Shows a clear visual panel with the wallet address
51
+ - Provides instructions for next steps
52
+ - Warns users to write down/photograph the address
53
+
54
+ ### Overwrite Protection
55
+ - Checks if a wallet already exists on the USB
56
+ - Prompts for confirmation before overwriting
57
+ - Allows users to keep existing wallets
58
+
59
+ ## Technical Implementation
60
+
61
+ ### Key Files Modified
62
+
63
+ #### [src/iso_builder.py](src/iso_builder.py)
64
+ - Added `_generate_wallet_on_usb()` method
65
+ - Updated `_flash_to_usb_windows()` to call Step 7
66
+ - Updated `_flash_to_usb_linux()` to call Step 7
67
+ - Updated all step counts from 6 to 7
68
+ - Added `self.generated_pubkey` to store the generated address
69
+
70
+ #### [main.py](main.py)
71
+ - Updated flash process description to mention wallet generation
72
+ - Added display of generated public key after successful flash
73
+ - Updated step counter from 6 to 7
74
+ - Enhanced success messaging with wallet information
75
+
76
+ ### Code Flow
77
+
78
+ ```python
79
+ # Step 7: Generate wallet on USB
80
+ def _generate_wallet_on_usb(self, mount_point: str) -> bool:
81
+ 1. Check if wallet already exists
82
+ 2. Generate new Solana keypair
83
+ 3. Prompt for encryption password
84
+ 4. Encrypt keypair using SecureWalletHandler
85
+ 5. Save encrypted keypair.json
86
+ 6. Save public key to pubkey.txt
87
+ 7. Set secure file permissions
88
+ 8. Clear keypair from memory
89
+ 9. Display public key to user
90
+ 10. Store pubkey for later display
91
+ ```
92
+
93
+ ### Dependencies
94
+ - `solders`: Solana SDK for keypair generation
95
+ - `src.secure_memory`: SecureWalletHandler for encryption
96
+ - `src.ui`: get_password_input and UI functions
97
+
98
+ ## User Workflow
99
+
100
+ ### Before (Manual Wallet Creation)
101
+ ```bash
102
+ 1. Flash USB drive (6 steps)
103
+ 2. Mount USB on computer
104
+ 3. Navigate to wallet directory
105
+ 4. Run wallet generation script manually
106
+ 5. Set password and generate keys
107
+ 6. Now ready for transactions
108
+ ```
109
+
110
+ ### After (Automatic Wallet Creation)
111
+ ```bash
112
+ 1. Flash USB drive (7 steps, includes wallet generation)
113
+ 2. Mount USB on computer
114
+ 3. ✅ Ready for transactions immediately!
115
+ ```
116
+
117
+ ## Benefits
118
+
119
+ 1. **Convenience**: No manual wallet generation required
120
+ 2. **Time Savings**: One-step setup process
121
+ 3. **User-Friendly**: Less technical knowledge required
122
+ 4. **Immediate Use**: Can receive SOL right away
123
+ 5. **Secure**: Same encryption and security as manual generation
124
+ 6. **Flexible**: Can still overwrite or use existing wallets
125
+
126
+ ## Security Considerations
127
+
128
+ ### ✅ Maintains Security
129
+ - Password-protected encryption still required
130
+ - Private key never exposed to memory longer than necessary
131
+ - Secure file permissions automatically set
132
+ - Works with existing SecureWalletHandler module
133
+
134
+ ### ⚠️ Important Notes
135
+ - **Password must be remembered** - cannot recover funds without it
136
+ - **Write down public key** - needed to receive SOL
137
+ - **Keep USB secure** - contains encrypted private key
138
+ - **Use offline for signing** - never sign on internet-connected machines
139
+
140
+ ## Testing Recommendations
141
+
142
+ 1. **Flash a test USB** and verify wallet files are created
143
+ 2. **Check encryption** - ensure keypair.json is encrypted
144
+ 3. **Verify public key** - confirm it's saved correctly in pubkey.txt
145
+ 4. **Test transactions** - try receiving and sending SOL
146
+ 5. **Password protection** - verify password prompts work correctly
147
+ 6. **Overwrite protection** - test with existing wallet on USB
148
+
149
+ ## Compatibility
150
+
151
+ - ✅ Windows: Full support (uses PowerShell for drive detection)
152
+ - ✅ Linux: Full support (uses mount points)
153
+ - ✅ macOS: Should work (uses Unix-like mount points)
154
+
155
+ ## Future Enhancements
156
+
157
+ Potential improvements for future versions:
158
+ - [ ] Option to skip wallet generation (keep it manual)
159
+ - [ ] Support for generating multiple wallets
160
+ - [ ] Backup wallet to secondary location during flash
161
+ - [ ] QR code generation for easy public key sharing
162
+ - [ ] Mnemonic phrase generation for recovery
163
+
164
+ ## Troubleshooting
165
+
166
+ ### Wallet generation fails during flash
167
+ - Check that `solders` is installed: `pip install solders`
168
+ - Verify `src.secure_memory` module is available
169
+ - Ensure sufficient permissions on USB drive
170
+
171
+ ### Password prompt doesn't appear
172
+ - Check terminal supports interactive input
173
+ - Verify `src.ui.get_password_input` is working
174
+
175
+ ### Public key not displayed
176
+ - Check `self.generated_pubkey` is being set
177
+ - Verify the flash process completed successfully
178
+
179
+ ## Summary
180
+
181
+ 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.
182
+
183
+ **B - Love U 3000** 💙