Need some help understanding the math regarding why multiple checksums work for mnemonic phrase generation (BIP39).
Let's assume a 12 word passphrase. If we divide the 2048 wordlist into groups of 16 ... exactly 1 word out of 16 word "block" will be a valid checksum for the 11 words selected.
With a 24 word passphrase, 1 word out of every 256 would be a correct checksum.
When generating a phrase by hand... I know that the ENT / 32 bits of the sha-256 hash are appended to the entropy to generate the checksum word.. but this generates one specific word.
So I guess my long-winded question is ... what is the math behind other checksum values being valid? I guess my real question is how is the ENT + CS validated as legitimate?
See this example:
Entropy (128 bits): 11010011 01100100 00000010 01011110 01010011 11101100 01010011 01101110 01101010 01111000 11010010 11011000 10111010 00100011 11101100 11110010
SHA-256 Hash of entropy = 14 c5 8b c9 05 11 5e 08 27 49 61 1e 48 d6 04 c0 2a 70 8c 39 ad 6c dc 0c 91 2f 70 62 c3 24 71 23
First 4 bits of SHA-256 Hash = 1 (hex) Binary = 0001
Generated Recovery Phrase: square cactus nurse pond share rescue prepare bottom suffer speed will tomorrow
another valid phrase (with same entropy but different checksum): square cactus nurse pond share rescue prepare bottom suffer speed will account
Account = 13 (on the BIPS39 wordlist) Subtract 1 since word index starts at 0 = 12 12 to binary = 1100 Hex = C
C (hex) != 1 (hex)
another valid phrase (with same entropy but different checksum): square cactus nurse pond share rescue prepare bottom suffer speed will acoustic
Acoustic = 17 (on the BIPS39 wordlist) Subtract 1 since word index starts at 0 = 16 16 to Binary: 10000 Hex = 10
10 (hex) != 1 (hex)
I guess I'm also confused how these checksums are valid when their values do not equal the first 4 bits of the SHA-256 Hash of ENT? I'm guessing it has to do with how the checksum is validated (and pointing back to my original question)?
b = b'11010011011001000000001001011110010100111110110001010011011011100110101001111000110100101101100010111010001000111110110011110010' hashlib.sha256(b).hexdigest()
# I get 3f0d468d18072538bedc4d5d47eb789795f1e01782de20de795027ca4ff1790bb= b"11010011011001000000001001011110010100111110110001010011011011100110101001111000110100101101100010111010001000111110110011110010" b = int(b,2) b = b.to_bytes(16, byteorder="big") hashlib.sha256(b).hexdigest()