Overview
Medusa Wallet employs multiple layers of security to protect your Bitcoin funds and sensitive data. From device-level biometric authentication to encrypted storage and automatic locking, Medusa ensures your wallet remains secure while maintaining ease of use.Authentication Methods
Medusa offers two complementary authentication methods:PIN Code
4-digit PIN for quick and secure wallet access
Biometric
Face ID or Touch ID for seamless authentication
PIN Code Security
Setting Up PIN
Protect your wallet with a 4-digit PIN:- Navigate to Settings → Security
- Enable “PIN Protection”
- Enter your desired 4-digit PIN
- Confirm by entering it again
- PIN is now active
PIN must be enabled before you can use biometric authentication.
PIN Requirements
- Length: Exactly 4 digits
- Unique: Choose numbers not easily guessable
- Secure Storage: PIN is hashed and stored using secure encryption
- Required for: App access, sensitive operations, settings changes
PIN Retries
Failed PIN attempts are limited:- Maximum Attempts: 5 incorrect tries
- After 5 Failures: Automatic logout and data clearing
- Counter Reset: Successful PIN entry resets retry counter
When PIN is Required
Your PIN is requested:- When opening the app after inactivity
- When accessing sensitive settings
- When the app has been in background for more than 5 minutes
- On cold start if PIN protection is enabled
Biometric Authentication
Supported Biometric Types
Medusa supports device-native biometric authentication:- Face ID: On supported iOS devices
- Touch ID: On iPhone and iPad with Touch ID
- Face Unlock: On supported Android devices
- Fingerprint: On Android devices with fingerprint sensors
Enabling Biometric Authentication
Prerequisites:- PIN protection must be enabled first
- Device must have biometric hardware
- Biometric authentication must be enrolled on your device
- Enrollment level must meet security requirements
- Ensure PIN is already set up
- Navigate to Settings → Security
- Enable “Biometric Authentication”
- Authenticate with your biometric to confirm
- Biometric access is now active
How Biometric Works
When biometric authentication is enabled:- Priority: Biometric is attempted first before PIN
- Fallback: If biometric fails, PIN entry is required
- Device Security: Uses your device’s Secure Enclave/TEE
- No Storage: No biometric data is stored by Medusa
Biometric Enrollment Level
Medusa requires a minimum enrollment level for security:- Required Level: 2 (strong biometric enrollment)
- Checks: Hardware presence, enrollment status, security level
- Validation: Performed each time app becomes active
If your device biometric enrollment doesn’t meet requirements, PIN entry will be required instead.
Biometric Authentication Flow
- App becomes active after background time
- Medusa checks if biometric is available and properly enrolled
- If yes: Biometric prompt is shown
- On success: App unlocks immediately
- On failure: User is redirected to PIN entry screen
App Locking Behavior
Automatic Locking
Medusa automatically locks when:- App enters background and remains inactive
- Lock time threshold is exceeded
- Device screen is locked
- User manually triggers lock
Lock Time Configuration
Default Lock Time: 5 minutes of inactivity After this period, authentication is required to access your wallet.Grace Period
Short Background Time:- Grace Period: 30 seconds
- Behavior: If you return within 30 seconds, no authentication required
- Applicable to: Camera, Send, and Receive screens
- Purpose: Smooth UX when quickly switching apps
The grace period prevents annoying auth prompts when briefly leaving the app to copy an address or check a message.
Privacy Overlay
Screen Privacy
When the app goes to background or becomes inactive:- Privacy Screen: Automatic overlay obscures content
- App Switcher: Prevents sensitive info from appearing in app previews
- Platform-specific: Works on both iOS and Android
- Instant: Activates immediately when app loses focus
Protection Against
- Shoulder surfing
- Screenshot previews in app switcher
- Accidental exposure when switching apps
- Screen recording of sensitive content
Secure Storage
MMKV Encrypted Storage
Medusa uses MMKV for high-performance encrypted storage: Stored Securely:- Wallet credentials (admin keys, invoice keys)
- PIN hash (not the PIN itself)
- User preferences and settings
- Transaction cache
- Wallet metadata
- Encryption: Military-grade AES encryption
- Device-bound: Data encrypted using device hardware keys
- Persistent: Survives app restarts
- Efficient: Fast read/write operations
MMKV storage is encrypted at rest and only accessible by Medusa on your device.
What’s NOT Stored Locally
- Account password (only stored server-side, hashed)
- Unencrypted sensitive data
- Payment history beyond cache (fetched from server)
- Biometric data (handled entirely by device OS)
Authentication State Management
Auth State Tracking
Medusa tracks authentication state:- Logged Out: No user credentials, no authentication required
- Logged In, Locked: User credentials present, auth required
- Logged In, Unlocked: User authenticated, full access granted
State Transitions
Auth Triggering
Authentication is triggered when:- App state changes from background to active
- Elapsed background time exceeds lock time
- Auth flag is manually set (e.g., settings change)
- Cold start with existing session
Session Management
Login Sessions
When you log in:- Access Token: Received from LNbits server
- Secure Storage: Token stored encrypted in MMKV
- Session Duration: Token remains valid until logout
- Cookie-based: Uses
cookie_access_tokenfor API requests
Logout Process
Logging out:- Clears all local wallet data
- Removes access tokens
- Resets authentication state
- Clears transaction cache
- Removes all stored credentials
Best Security Practices
Strong PIN Selection
✅ Do:- Choose a unique 4-digit PIN
- Avoid obvious patterns (1234, 0000)
- Use numbers not related to birthdays or addresses
- Remember your PIN (write it down securely if needed)
- Use default or simple PINs
- Share your PIN with others
- Use the same PIN as other apps
- Let others see you entering your PIN
Biometric Best Practices
✅ Do:- Keep device biometric enrollment updated
- Use strong device passcode as backup
- Enable biometric if available (convenience + security)
- Re-enroll if device prompts
- Share device access with untrusted people
- Disable device biometric security
- Ignore biometric enrollment warnings
General Security
✅ Do:- Keep your device OS updated
- Use device encryption
- Enable device lock screen
- Install apps only from official stores
- Back up wallet credentials securely
- Monitor wallet activity regularly
- Jailbreak or root your device
- Install from untrusted sources
- Share your device with untrusted users
- Ignore security warnings
- Store large amounts without additional backup
Recovery Options
Forgot PIN
If you forget your PIN:- After 5 failed attempts, you’ll be logged out
- Log back in using your username and password
- Set a new PIN after logging in
- All previous wallet data remains intact (server-synced)
Lost Device Access
If you lose your device:- Log in on a new device using your credentials
- Your wallets and funds are accessible (custodial)
- Set up new PIN and biometric on new device
- Previous device sessions remain active until manual logout
Since Medusa is a custodial wallet, your funds are recoverable with your login credentials even if you lose your device.
Account Credentials
Always remember:- Username: Required for login
- Password: Required for login
- Email: Used for account recovery (if supported)
Platform-Specific Security
iOS Security Features
- Secure Enclave: Biometric data never leaves secure hardware
- Keychain: Additional secure storage option
- App Transport Security: Enforced HTTPS
- Background Task Limits: Automatic app suspension
Android Security Features
- Trusted Execution Environment (TEE): Hardware-backed security
- BiometricPrompt API: Standard biometric authentication
- Scoped Storage: App data isolation
- Play Integrity API: App integrity verification
Technical Implementation
Authentication Flow
- App State Monitoring:
AppStatelistener tracks active/background states - Timestamp Tracking: Background timestamp recorded when app backgrounds
- Elapsed Time Check: On active, elapsed time calculated
- Auth Decision: If > lock time and PIN enabled, trigger auth
- Biometric First: If biometric enabled and available, try biometric
- PIN Fallback: If biometric unavailable or fails, require PIN
- Success: Auth cleared, app unlocked
- Failure: Retry counter incremented, logout after 5 failures
Security Constants
Secure Storage Keys
medusa_pin: Hashed PIN storage keymedusa-wallets: Wallet data storage namespacelast_background_timestamp: For lock time calculation- Store names: Persistent across app restarts
Next Steps
Wallet Management
Learn about managing your wallets securely
Payment Features
Understand secure payment workflows