element-x-ada/docs/build-logs/emulator-wallet-test-result.md

3.6 KiB

Emulator Wallet Test Results

Date: 2026-03-28 Tester: Kayos (subagent) Branch: phase1-dev Final Commit: 9e9192dd3b

Summary

WALLET CREATION WORKS END-TO-END ON EMULATOR

The Problem

The original design had setUserAuthenticationRequired(true) on the keystore key that encrypts the mnemonic. This was fundamentally wrong because:

  1. It broke wallet creation for anyone without biometrics
  2. It broke emulator testing entirely
  3. Even with a PIN set, Android requires the user to actively authenticate (BiometricPrompt) before the key can be used

The Fix

Removed all biometric requirements from the mnemonic storage key.

The mnemonic encryption key should just be device-protected (unlocked when device is unlocked via PIN/pattern/biometric — whatever the user has set). The key should NOT require biometric at the time of use.

Changes Made

  1. Removed setUserAuthenticationRequired(true) from KeyGenParameterSpec.Builder
  2. Removed setUserAuthenticationValidityDurationSeconds()
  3. Removed setInvalidatedByBiometricEnrollment()
  4. Removed the hacky isEmulator() and canUseBiometricAuth() functions
  5. Removed unused android.os.Build and androidx.biometric.BiometricManager imports
  6. Added documentation explaining the security model

Security Model

  • Mnemonic is encrypted with AES-256-GCM using an Android Keystore key
  • The keystore key is device-bound (cannot be extracted)
  • The key is accessible when the device is unlocked
  • Transaction signing should use BiometricPrompt separately for user confirmation (future enhancement)

Test Results

Test Environment

  • Emulator: Android 14 (sdk_gphone64_x86_64)
  • Container: android-emulator on Lucy (192.168.0.5)
  • Test Account: @testbot-elementx:sulkta.com

Wallet Created Successfully

Address: addr_test1qz57gfnua79ajquraf9v86h4kc8zugeszpmnujd7ktqqkk7nupfaelycr785nh2jnh87jv6ehcfnnve78tfrmxxrm5gseddjqc

Logs

19:49:00.883 D: Created new keystore key for wallet: cardano_wallet_testbot-elementx_sulkta_com
19:49:02.041 I: Generated new Cardano wallet for session: @testbot-elementx:sulkta.com

No authentication errors. No emulator detection hacks. Clean device-protected keys.

Git Commits

Final Fix (Proper)

commit 9e9192dd3b
Author: Kayos
Date: 2026-03-28

Fix wallet keystore auth: remove biometric requirement from mnemonic key

The mnemonic encryption key should be device-protected (unlocked when device
is unlocked), not require biometric/PIN at time of use. This was breaking:
- Wallet creation on devices without biometrics
- Emulator testing entirely

Changes:
- Remove setUserAuthenticationRequired(true) from keystore key spec
- Remove setUserAuthenticationValidityDurationSeconds()
- Remove setInvalidatedByBiometricEnrollment()
- Remove emulator detection hacks (isEmulator, canUseBiometricAuth)
- Remove unused Build and BiometricManager imports
- Add documentation explaining security model

Previous Hacky Fix (Superseded)

commit 02ecbfda83 (superseded)
Fix emulator detection for keystore authentication

Future Enhancements

For transaction signing, consider adding optional BiometricPrompt confirmation:

  • Use BiometricManager.canAuthenticate(BIOMETRIC_WEAK or DEVICE_CREDENTIAL)
  • Set authenticators to BIOMETRIC_WEAK or DEVICE_CREDENTIAL in PromptInfo
  • If user cancels → cancel the transaction (don't crash)

This would provide an extra layer of security for high-value transactions while still allowing users without biometrics to use the wallet.

Files Changed

  • features/wallet/impl/src/main/kotlin/io/element/android/features/wallet/impl/storage/CardanoKeyStorageImpl.kt (+26/-54 lines)