With no server and only in the browser I'm generating an a bip39 key and giving the user the mnemonic to store some place safe for restoring, I also want the user to be able to login with a password.
1) Could I encrypt the mnemonic with a password?
2) If I do encrypt the mnemonic, which algorithm should I use?
The weakness there is that BIP39 uses only 2048 rounds during KDF. Which is easy to bruteforce. An attacker would have to take the mnemonic + append a password guess + do KDF rounds + get HD master key + derive a set of address keys + query the blockchain for balances. Is this not enough of a slowdown? I see that the salt is capped at 64-bit entropy :( One could put some balance with master keys resulting from dummy weak passwords, to detect a compromised seed and be alerted to move funds.
Here's an interesting read: https://coldbit.com/can-bip-39-passphrase-be-cracked/
– bca-0353f40e Dec 17 '22 at 10:00