BIP-39: Mnemonic Seed Phrases
BIP-39 defines mnemonic sentence generation for deterministic keys.Implementation
Library:@scure/bip39
Mnemonic Generation (helper/secureStorage.ts:80-95):
- 12-word phrases: 128 bits of entropy
- English wordlist: BIP-39 standard English words
- Cryptographically secure: Uses
crypto.getRandomValues() - Checksum validation: Built-in error detection
Secure Storage
Platform:expo-secure-store with iOS keychain integration
Storage (helper/secureStorage.ts:36-57):
helper/secureStorage.ts:63-74):
- iOS Keychain integration
- Biometric authentication support (optional)
- Platform-specific encryption
- Secure deletion support
Mnemonic Initialization
Provider Integration (providers/NostrKeysProvider.tsx:250-292):
The NostrKeysProvider ensures a mnemonic exists or generates one:
- Checks SecureStore first
- Falls back to Redux for legacy wallets
- Migrates Redux mnemonic to SecureStore automatically
- Generates new mnemonic if none exists
BIP-32: Hierarchical Deterministic Wallets
BIP-32 enables deriving multiple keys from a single seed.Implementation
Library:@scure/bip32
Derivation Paths
Sovran uses separate derivation paths for Nostr and Cashu:Nostr Keys (NIP-06)
Path:m/44'/1237'/<accountIndex>'/0/0
Implementation (helper/keyDerivation.ts:14-31):
Cashu Mnemonic (NUT-13)
Path:m/44'/129372'/0'/<accountIndex>'/0/0
Implementation (helper/keyDerivation.ts:36-47):
- Derive child private key from BIP-32 path
- Re-encode 32-byte private key as 24-word BIP-39 mnemonic
- Use derived mnemonic for Cashu wallet operations
Wallet Seed Derivation
From Cashu Mnemonic (helper/keyDerivation.ts:52-54):
helper/keyDerivation.ts:60-65):
Key Caching
Derived keys are cached to avoid expensive re-derivation. Cache Structure (helper/secureStorage.ts:16-22):
helper/secureStorage.ts:178-185):
providers/NostrKeysProvider.tsx:302-322):
- Fast app startup (skip expensive derivation)
- Cache invalidation on mnemonic change
- Per-account caching
- Background cache updates
Multi-Account Support
Sovran supports multiple accounts from a single seed. Account Management (providers/NostrKeysProvider.tsx:185-210):
stores/profileStore.ts):
Wallet Recovery
Sovran provides comprehensive wallet recovery from seed phrases. Recovery Screen (app/settings-pages/recovery.tsx):
- Input 12-word seed phrase
- Restore tokens from all known mints
- Progress tracking per mint
hooks/coco/useMintManagement.ts):
Security Best Practices
Storage Security
Implementation (helper/secureStorage.ts:24-29):
Secure Deletion
Clear All Data (helper/secureStorage.ts:134-163):
- Main mnemonic
- Derived keys cache (all accounts)
- Cashu mnemonics cache (all accounts)
- Migration flags
Passcode Protection
Additional app-level security layer. Implementation (app/settings-pages/passcode.tsx):
- 4-digit PIN code
- Custom numeric keyboard
- Passcode gate on app launch
- Separate from mnemonic encryption
PasscodeScreen.tsx: PIN entry interfaceNumericKeyboard.tsx: Custom keyboardPasscodeGate.tsx: Authentication gate
Dependencies
Sovran uses
@scure libraries for BIP implementation instead of older libraries. These are audited, TypeScript-native, and maintained by the noble-crypto team.Reference Implementation
- Key Derivation:
helper/keyDerivation.ts - Secure Storage:
helper/secureStorage.ts - Nostr Keys Provider:
providers/NostrKeysProvider.tsx - Secure Store Hook:
hooks/useSecureStore.ts - Recovery Flow:
app/settings-pages/recovery.tsx - Passcode Lock:
app/settings-pages/passcode.tsx
Derivation Path Summary
Learn More
Nostr NIPs
NIP-06 key derivation implementation
Cashu NUTs
NUT-13 deterministic wallet derivation
BIP-39 Spec
Official BIP-39 specification
BIP-32 Spec
Official BIP-32 specification