maciejhirsz/tiny-bip39

[bug] Invalid checksum errors on valid phrases

Closed this issue · 3 comments

Hello!
I generated the following mnemonic:
boost then machine pluck main scorpion garden law gift obscure beauty mother
then tried to use Mnemonic::from_phrase to get the mnemonic type, but 4/5 times I get a bad checksum error.

@Morgandri1 may I ask how did you generate that mnemonic? It seems to be rejected not just by this crate but by other tools I can quickly check.

I've run it in a loop 100000 times and the checksum always fails, can you provide code example on how you get it to pass?

I downloaded the wordlist from bip39 and used some logic to pick 12 words randomly and pass them to the mnemonic constructor. I'd be happy to provide code if you'd like.

pick 12 words randomly

Ah, here is your problem, that is not how BIP39 phrases are constructed. You first need to generate random entropy, then calculate checksum for it, and only then convert entropy to phrase, see https://bips.dev/39/ for details.