Documentation Index
Fetch the complete documentation index at: https://mintlify.com/satsigner/satsigner/llms.txt
Use this file to discover all available pages before exploring further.
Overview
SatSigner implements multiple layers of cryptographic protection to secure your Bitcoin wallet data. This document provides technical details of the encryption systems protecting your funds.Encryption Architecture
Multi-Layer Security Model
SatSigner employs a defense-in-depth strategy: Layer 1: Platform Security- iOS Keychain (hardware-backed when available)
- Android KeyStore (hardware-backed on supported devices)
- Secure Enclave / TEE integration
- AES-256-CBC for sensitive data
- PBKDF2 for key derivation
- Per-account initialization vectors
- Sensitive data in secure storage
- Non-sensitive data in MMKV
- Clear separation of plaintext and ciphertext
Symmetric Encryption (AES-256-CBC)
Algorithm Details
Advanced Encryption Standard (AES):- Key Size: 256 bits
- Block Size: 128 bits (16 bytes)
- Mode: CBC (Cipher Block Chaining)
- Padding: PKCS#7
react-native-aes-crypto
- Native implementation (not JavaScript)
- Platform-optimized cryptographic operations
- Hardware acceleration where available
Why AES-256-CBC?
Advantages:- ✓ Industry standard, widely audited
- ✓ NIST approved for TOP SECRET data
- ✓ Hardware acceleration available
- ✓ Well-understood security properties
- ✓ Compatible with most platforms
- Each block depends on previous block
- Requires initialization vector (IV)
- Parallel decryption possible
- No built-in authentication (relies on key verification)
- GCM: Authenticated encryption, but more complex implementation
- CTR: Streaming mode, but requires careful nonce handling
- ECB: Never considered (vulnerable to pattern analysis)
Initialization Vectors (IV)
Purpose:- Ensures same plaintext produces different ciphertext each time
- Prevents pattern recognition in encrypted data
- Must be unique per encryption operation
- 32-character hexadecimal string (128 bits)
- Cryptographically random
- Unique per account
- Stored alongside encrypted data (not secret)
Key Derivation (PBKDF2)
Algorithm Details
Password-Based Key Derivation Function 2 (PBKDF2): Implementation (apps/mobile/utils/crypto.ts:39-41):- Input: User’s 4-digit PIN
- Salt: 16-byte random value
- Iterations: 10,000
- Output Length: 256 bits
- Hash Function: SHA-256
Security Properties
Iteration Count (10,000): Purpose:- Slow down brute-force attacks
- Each PIN attempt takes measurable time
- Negligible delay for legitimate user
- Significant delay for attacker trying many PINs
- 10,000 PINs possible (0000-9999)
- At ~1ms per iteration on mobile device
- Brute force all PINs: ~100 seconds
- With rate limiting: effectively impossible
- Balance between security and UX
- Mobile devices have limited power
- Higher iterations would cause noticeable delay
- Supplemented by attempt limiting (5 max attempts)
Salt Generation
Purpose:- Prevents pre-computed rainbow table attacks
- Ensures identical PINs produce different keys
- Unique per installation
- 128-bit random value
- Generated at PIN setup
- Stored in secure storage
- Never changes unless PIN reset
Secure Storage Implementation
Expo Secure Store
Implementation (apps/mobile/storage/encrypted.ts):- Automatic versioning (supports migration)
- Platform-specific secure storage
- Encrypted at rest
- Protected by device unlock
Platform-Specific Storage
iOS: Keychain
Security Features:- Hardware-backed encryption (Secure Enclave)
- Tied to device unlock state
- iCloud Keychain sync (disabled by default)
- Access control lists
- Default:
kSecAttrAccessibleWhenUnlocked - Data accessible only when device unlocked
- Encrypted using key protected by device passcode
- AES-256 encryption in hardware
- Key material never leaves Secure Enclave
- Protection against physical attacks
- Available on iPhone 5s and newer
Android: SharedPreferences + EncryptedSharedPreferences
Security Features:- Master key in Android KeyStore
- Hardware-backed when available (TEE/Strongbox)
- AES-256-GCM encryption
- Key attestation support
- Keys generated in hardware (supported devices)
- Protected by device lock screen
- Cannot be extracted from device
- Deleted on factory reset
- Strongbox: Dedicated security chip (Pixel 3+)
- TEE: Trusted Execution Environment
- Software: Fallback for older devices
MMKV Storage
Implementation (apps/mobile/storage/mmkv.ts):- High-performance key-value storage
- Application state and preferences
- Non-sensitive data only
- Account metadata (names, IDs)
- Public keys and addresses
- Transaction history (no signing keys)
- Application settings
- UI preferences
- NOT encrypted by default
- Relies on device-level encryption
- Protected by OS sandboxing
- Never stores sensitive key material
Data Classification
Highly Sensitive (Secure Storage + AES)
Encrypted with PIN-derived key:- AES-256-CBC encryption
- Key derived from PIN via PBKDF2
- Unique IV per account
- Stored in Keychain/KeyStore
Sensitive (Secure Storage Only)
Stored in platform secure storage without additional encryption:- Platform secure storage
- Hardware-backed encryption
- Device unlock required
Non-Sensitive (MMKV)
Plaintext storage (relies on device encryption):- Public keys (xpub, ypub, zpub)
- Addresses
- Transaction history
- UTXOs (no spending ability)
- Account names and labels
- Application settings
- Public data by design
- No risk if exposed
- Performance critical
- Large data volumes
Encryption Operations
Account Creation Flow
-
Generate Seed
-
Create Secret Object
-
Serialize Secret
-
Generate IV
-
Encrypt with PIN
-
Store Encrypted Data
Transaction Signing Flow
-
Retrieve Encrypted Secret
-
Get PIN for Decryption
-
Decrypt Secret
-
Use Mnemonic
-
Sign Transaction
-
Zero Sensitive Data
PIN Change Flow
Re-encryption Required (apps/mobile/hooks/useReEncryptAccounts.ts):-
Validate Old PIN
-
Decrypt All Secrets with Old PIN
-
Set New PIN
-
Re-encrypt All Secrets with New PIN
-
Update Account Storage
- Brief moment where both old and new keys exist
- Operation is atomic (all or nothing)
- No intermediate state persisted
- Failure requires retry with old PIN
Duress PIN Implementation
Architecture
Dual PIN System:- Use same PBKDF2 derivation
- Share same salt
- Produce different hashes
- Stored separately in secure storage
Duress PIN Behavior
Unlock Flow (apps/mobile/app/unlock.tsx:63-78):- Plausible deniability
- No indication duress PIN exists
- Irreversible data deletion
- Appears as normal unlock
Cryptographic Primitives
Random Number Generation
Implementation (apps/mobile/utils/crypto.ts:21-24):react-native-get-random-values
- Polyfill for Web Crypto API
- Platform-specific CSPRNG:
- iOS:
SecRandomCopyBytes - Android:
SecureRandom
- iOS:
- Cryptographically Secure Pseudo-Random Number Generator (CSPRNG)
- Hardware-backed when available
- Suitable for key generation
- Passes statistical randomness tests
Hashing (SHA-256)
Implementation (apps/mobile/utils/crypto.ts:26-28):- Key fingerprint calculation
- Cryptographic commitments
- Data integrity verification
- Bitcoin address generation
- 256-bit output
- Collision resistant
- Pre-image resistant
- Avalanche effect
Security Considerations
Memory Protection
Limitations:- JavaScript doesn’t guarantee memory clearing
- Sensitive data may persist in memory
- Garbage collection timing unpredictable
- No explicit memory zeroing
- Minimize time secrets in memory
- Avoid string concatenation of secrets
- Rely on device-level protection
- Process isolation (OS sandboxing)
Side-Channel Attacks
Timing Attacks:- PBKDF2 uses constant iterations
- AES implementation uses constant-time operations (native)
- PIN comparison uses hashed values
- Rely on hardware countermeasures
- TEE/Secure Enclave protection
- Application-level mitigation limited
Cryptanalysis Resistance
AES-256:- No practical attacks on full AES-256
- Best known attack: Related-key attack (irrelevant to this use)
- Quantum resistance: ~128-bit security (post-quantum)
- Resistant to rainbow tables (salt)
- Resistant to parallel attacks (independent iterations)
- Vulnerable to ASICs/GPUs (not used here due to rate limiting)
- Vulnerable to padding oracle attacks (mitigated by no padding verification)
- Requires unique IV per encryption (enforced)
- No authentication (acceptable for this use case)
Compliance & Standards
Standards Compliance
NIST:- AES-256: FIPS 197
- SHA-256: FIPS 180-4
- PBKDF2: NIST SP 800-132
- AES-CBC: RFC 3602
- PBKDF2: RFC 8018
- BIP39: Bitcoin Improvement Proposal 39
- BIP32: Hierarchical Deterministic Wallets
Audit Recommendations
Third-Party Review:- Cryptographic implementation audit
- Key management review
- Secure storage verification
- Side-channel testing
- All crypto code auditable
- Dependency on well-audited libraries
- No proprietary cryptography
Related Topics
- PIN Protection - User-facing PIN security
- Seed Management - Protecting seed phrases
- Backup & Recovery - Ensuring recoverability
- Duress PIN - Emergency data deletion