-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add wallet creation with secure key generation #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Implements the ability to create new wallets with cryptographically secure randomly generated private keys, complementing the existing import and Ledger functionality. Features: - Secure key generation using Node.js crypto.randomBytes() (CSPRNG) - Multi-step security flow with explicit user warnings - Private key display with one-time visibility - Backup verification requiring last 8 characters re-entry - Encrypted storage using existing AES-256-GCM infrastructure - 27 comprehensive unit tests covering security aspects - Integration tests for CLI command - Full documentation in README Command: safe wallet create 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds the ability to create new wallets with randomly generated private keys, eliminating the need for users to provide their own keys. The implementation includes secure key generation using Node.js crypto, comprehensive backup verification flow, and extensive documentation.
- Introduces
generatePrivateKey(),deriveWalletFromPrivateKey(), andgenerateWalletId()utility functions using cryptographically secure random number generation - Implements
safe wallet createcommand with security warnings, password setup, key display, and backup verification - Updates documentation with detailed wallet creation guide and security best practices
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/key-generation.ts | New utility module for secure private key generation, wallet derivation, and ID generation |
| src/commands/wallet/create.ts | New command implementation for interactive wallet creation workflow with security checks |
| src/cli.ts | Registers the new wallet create command |
| src/ui/screens/WalletListScreen.tsx | Improves UI to always show "Last used" field with "Never" fallback |
| src/tests/unit/utils/key-generation.test.ts | Comprehensive unit tests covering key generation, validation, entropy, and security |
| src/tests/integration/e2e-wallet-commands.test.ts | E2E test verifying the create command is available |
| README.md | Extensive documentation on wallet creation workflow, security practices, and usage examples |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export function generateWalletId(): string { | ||
| return randomBytes(16).toString('hex') |
Copilot
AI
Oct 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The generateWalletId() function duplicates the wallet ID generation logic already present in wallet-store.ts line 121. Consider importing and using this function in WalletStorageService.importWallet() instead of using inline randomBytes(16).toString('hex') to maintain a single source of truth for ID generation.
| spinner.start('Storing wallet...') | ||
|
|
||
| try { | ||
| const wallet = await walletStorage.importWallet(name as string, privateKey, password as string) |
Copilot
AI
Oct 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type assertions name as string and password as string are unnecessary since the control flow guarantees these variables are strings (early returns prevent null/undefined). Remove the type assertions for cleaner code.
| const wallet = await walletStorage.importWallet(name as string, privateKey, password as string) | |
| const wallet = await walletStorage.importWallet(name, privateKey, password) |
Replaces inline randomBytes(16).toString('hex') calls in wallet-store.ts
with the centralized generateWalletId() utility function to eliminate
code duplication and maintain consistency.
Changes:
- Import generateWalletId from key-generation.ts
- Replace wallet ID generation in importWallet() (line 122)
- Replace wallet ID generation in importLedgerWallet() (line 165)
This ensures all wallet IDs are generated using the same method
across the codebase.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Refactoring UpdateAdded a follow-up commit to eliminate code duplication: Changes
Testing✅ All tests pass This ensures consistency and makes the ID generation logic easier to maintain and test. |
Summary
Implements the ability to create new wallets with cryptographically secure randomly generated private keys, complementing the existing import and Ledger functionality.
Features
crypto.randomBytes()(CSPRNG)Usage
User Flow
Files Changed
New Files
src/utils/key-generation.ts- Core key generation utilitiessrc/commands/wallet/create.ts- Wallet creation commandsrc/tests/unit/utils/key-generation.test.ts- 27 comprehensive unit testsModified Files
src/cli.ts- Register create commandsrc/tests/integration/e2e-wallet-commands.test.ts- Add create command testssrc/ui/screens/WalletListScreen.tsx- Show "Never" for unused walletsREADME.md- Comprehensive documentation updateTesting
All tests passing:
Security
Documentation
Updated README with:
🤖 Generated with Claude Code