odudex / krux_binaries

compiled krux
17 stars 2 forks source link

SeedQR error. Each word's digit is minus one #2

Closed 2oh1 closed 1 year ago

2oh1 commented 1 year ago

I'm testing your current firmware binary on a Sipeed Amigo and I found an odd error where clicking on "Plaintext QR" shows a QR for the correct words, and "Compact SeedQR" appears to be correct as well (I think) but "SeedQR" gives incorrect data, where each number is off by one digit.

For example, here's a mnemonic:

moon follow home river all wolf car robust account echo clean window skate appear outdoor sniff near mother lamp pipe curious favorite cram buddy

That mnemonic produces this SeedQR:

1148 0725 0872 1494 0051 2022 0274 1498 0012 0559 0338 2011 1616 0084 1257 1643 1180 1153 0998 1322 0431 0672 0401 0235

That's incorrect. Each number is off by -1. Moon should be 1149, not 1148. Follow should be 0726, not 0725. Home should be 0873, not 0872. Etc. Each number is one lower than it should be.

I realize this is beta software, but most of what I'm seeing looks like it'll be a fantastic update.

odudex commented 1 year ago

There's always a lot of confusion on BIP39 numbers, as some use them ranging from 1 to 2048, others from 0 to 2047. For the manual input methods, as most metal backup methods, we use the Bitcoin BIP39 Standard, with numbers ranging from 1 to 2048. But for SeedQR, for the sake of interoperability, we follow the SeedQR standard, created by SeedSigner, that uses numbers ranging from 0 to 2047. From the SeedSigner specs I quote:

"Each word comes from a list of 2048 words. The words themselves are meaningless; all that matters is the word's position number (aka index) in the word list.

For example, "tomato" is the 1,825th word in the list.

But code always starts counting list items with zero. So the index of "tomato" is actually 1824 (if you're looking at the github wordlist line numbers, just remember to always subtract one)."

2oh1 commented 1 year ago

Thanks for the info. I feel silly now, not having realized the obvious. Feel free to delete this "issue." Cheers!