Toporin / Seedkeeper-Android

Android app to use Seedkeeper on a smartphone. Backup and recover your most precious secrets with a tap on your phone!
GNU General Public License v3.0
3 stars 0 forks source link

Check BIP39 seed format before import #26

Open Toporin opened 2 months ago

Toporin commented 2 months ago

Currently, the BIP39 format is only checked during secret import into the card. If the format is not correct, the error message is generic ("Error during scan") and not specific enough.

The stack trace:

importSecret exception: org.bitcoinj.crypto.MnemonicException$MnemonicWordException
Surface::disconnect(this=0x748daf4000,api=1)
[ImageReader-1x1f1m1-32081-9](this:0x748d41a800,id:9,api:1,p:32081,c:32081) disconnect(P): api 1
org.bitcoinj.crypto.MnemonicException$MnemonicWordException
    at org.bitcoinj.crypto.MnemonicCode.toEntropy(MnemonicCode.java:163)
    at org.satochip.seedkeeper.data.GeneratePasswordData.getSecretBytes(GeneratePasswordData.kt:31)
    at org.satochip.seedkeeper.services.NFCCardService.importSecret(NFCCardService.kt:592)
    at org.satochip.seedkeeper.services.NFCCardService.initialize(NFCCardService.kt:106)
    at org.satochip.seedkeeper.services.SatochipCardListenerForAction.onConnected(SeedkeeperCardListener.kt:20)
    at org.satochip.android.NFCCardManager.onCardConnected(NFCCardManager.java:101)
    at org.satochip.android.NFCCardManager.run(NFCCardManager.java:84)

The BIP39 format should be checked before initiating NFC scan (before the NFC toast is displayed) and a meaningful message displayed to user