2018-03-05 14:02 GMT-03:00 Stephane Ducasse <stepharo.s...@gmail.com>: > On Sun, Mar 4, 2018 at 9:43 PM, Esteban A. Maringolo > <emaring...@gmail.com> wrote: >> 2018-03-04 17:15 GMT-03:00 Sven Van Caekenberghe <s...@stfx.eu>: >>> Bits are actually numbered from right to left (seen from how they are >>> printed). >> >> I understand bit operations, used it extensively with IP address eons ago. >> >> But if a spec says: "Take the first n bits from the hash", it means >> the first significant bits. >> so in 2r100101111 the first 3 bits are "100" and not "111". > > naive question: why?
Because it says so. "A checksum is generated by taking the first ENT / 32 bits of its SHA256 hash. This checksum is appended to the end of the initial entropy. Next, these concatenated bits are split into groups of 11 bits, each encoding a number from 0-2047, serving as an index into a wordlist. Finally, we convert these numbers into words and use the joined words as a mnemonic sentence." [1]. > To me it looks like a lousy specification. It might be, I can't really tell. But such manipulation could be useful if you are knitting different parts of a binary packet whose boundaries are not at byte level, but bit instead. So you can take "these 5 bits, concatenate with this other 7, add 13 zero bits, then 1 followed by the payload". I'm assuming a non real case here though, my use case was fulfilled already. Regards! -- Esteban A. Maringolo [1] https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki#generating-the-mnemonic