Private Key Export from Mobile Crypto Wallet
Private key export — maximum threat level operation. Key appears on screen in plaintext and vulnerable to screenshots, screen recording, shoulder surfing until "hide" pressed. Task — minimize exposure time and paths through which key passes.
Protection Before Display
Biometric auth or PIN-code mandatory before showing key. Insufficient to just check "user logged in" — need challenge-at-point-of-action authentication.
iOS — LAContext.evaluatePolicy(.deviceOwnerAuthentication). Android — BiometricPrompt with BIOMETRIC_STRONG. Key from Keychain/Keystore requested only after successful auth, not before.
Flag preventScreenCapture / FLAG_SECURE:
// iOS — in viewWillAppear
UIScreen.main.value(forKey: "disableScreenCapture") // deprecated
// correctly:
func screenCaptureBlocking() {
let field = UITextField()
field.isSecureTextEntry = true
if let layer = field.layer.sublayers?.first {
view.layer.addSublayer(layer)
layer.frame = view.bounds
}
}
iOS has no public API blocking screenshots, but UITextField.isSecureTextEntry trick works on iOS 13–17. Android WindowManager.LayoutParams.FLAG_SECURE blocks both screenshots and screen recording.
Display and Format
Key shown in monospace font, split into 4-character groups for readability. QR code — convenient transmission method, but QR renders in memory only, never saved to photo library.
Auto-hide timer — 60 seconds. After expiration key replaced with ••••••••••••. Re-display — biometry again.
Clipboard — Carefully
"Copy" button convenient, but Android clipboard before version 10 accessible to any app in background without permissions. Either don't provide private key copying, or — copy and auto-clear after 30 seconds with user notification.
What We Test
Export → import same key in different wallet (MetaMask, Trust Wallet) checking address match. Behavior when biometry rejected. Key absence in logs — NSLog, print, Android Log.d in production build shouldn't capture sensitive data. Verified via grep in CI for patterns privateKey, mnemonic, secret.
Timeline — 1–3 days. If supporting multiple formats (hex, WIF, Base58) and QR — closer to three.







