Skip to main content
Sovran implements BIP-39 and BIP-32 standards for secure, deterministic wallet generation and recovery.

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):
Characteristics:
  • 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):
Retrieval (helper/secureStorage.ts:63-74):
Security Features:
  • 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:
Migration Support:
  • 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):
Coin Type: 1237 (Nostr) Account Index: Supports multiple Nostr identities

Cashu Mnemonic (NUT-13)

Path: m/44'/129372'/0'/<accountIndex>'/0/0 Implementation (helper/keyDerivation.ts:36-47):
Process:
  1. Derive child private key from BIP-32 path
  2. Re-encode 32-byte private key as 24-word BIP-39 mnemonic
  3. Use derived mnemonic for Cashu wallet operations
Coin Type: 129372 (Cashu) Output: 24-word mnemonic for NUT-13 compatibility

Wallet Seed Derivation

From Cashu Mnemonic (helper/keyDerivation.ts:52-54):
Full Chain (helper/keyDerivation.ts:60-65):
Flow:

Key Caching

Derived keys are cached to avoid expensive re-derivation. Cache Structure (helper/secureStorage.ts:16-22):
Mnemonic Hash (helper/secureStorage.ts:178-185):
Cache Validation (providers/NostrKeysProvider.tsx:302-322):
Benefits:
  • 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):
Profile Store (stores/profileStore.ts):
Each profile has a unique account index for deterministic key derivation.

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
Recovery Process (hooks/coco/useMintManagement.ts):
Flow:

Security Best Practices

Storage Security

Never commit or expose:
  • Mnemonic seed phrases
  • Private keys (nsec, hex)
  • .env files with secrets
  • credentials.json or similar
Implementation (helper/secureStorage.ts:24-29):
For production builds, enable requireAuthentication: true to enforce biometric authentication on iOS.

Secure Deletion

Clear All Data (helper/secureStorage.ts:134-163):
Clears:
  • 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
Components:
  • PasscodeScreen.tsx: PIN entry interface
  • NumericKeyboard.tsx: Custom keyboard
  • PasscodeGate.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