iancoleman / bip39

A web tool for converting BIP39 mnemonic codes
https://iancoleman.io/bip39/
MIT License
3.42k stars 1.42k forks source link

new entropy modifications not working ? #457

Closed jpph closed 3 years ago

jpph commented 3 years ago

I have tested 0.5.0 and 0.4.3, with same dice roll, they produce different raw binary entropy but same 24 words bip39 mnemonic. For example : dice roll : 12345612341234561234123456123412345612341234561234 (123456 1234 five times) new version binary : 01101101000 11011001101 10100011011 00110110100 01101100110 11010001101 10011011010 00110110 old version binary :
01001000111 01100010011 10000010011 10111110011 11101110011 10001010111 00100001110 11011110011 11111011011 11010001000 00101100010 10010110

But 24 words bip39 is the same for both : reduce prefer put marriage reform genuine carbon diagram lounge night grace put brown loud cover chuckle plug open very oval cupboard scene album receive

iancoleman commented 3 years ago

Any selection of entropy into a fixed number of words will hash the entropy string as entered (ie not hash the binary conversion). This happens on L1702 of index.js. The hash result is then used as the binary (and truncated if needed).

D6 generates log2(6) ~2.58 bits of entropy per roll. It's most sensible to simply take the exact entropy as entered (which may overall represent some non-integer number of bits of entropy) rather than the conversion into binary entropy.

jpph commented 3 years ago

Ok, thank you for the clarification. Closing....