記録用なので英語のまま。
気が向いたら日本語にしようと思っていますが、たぶんしません。
Note: this post is rather specific to a 12*-word phrase.
Note: be aware that terminology in cryptography and BIP can be messy - so always ask questions.
- Generate the entropy
- An entropy, a Greek term not specific to cryptography, is simply a randomly generated number that is unlikely to be re-generated
- Often 128-256 bits in length.
Ex:11011010010000101100101111001001110010000111111000010010100000001100001101001100101001011110011111001000010001010110000101111111
- First conversion using BIP0039
-
W/o going into detail on what a BIP39 is, there exists a pre-determined BIP39 wordlist consisting of 2048 words. Each word is represented by the number in which the words are alphabetically ordered starting with 1..2048 ("abandon".."zoo")
-
In binary, a set of 11 bits represent any number between 0 and 2047 (in relative terms, think array index)
2 ^ 11 = 2048 -
Therefore, 128 / 11 = 11R7, and 11 words can be derived from the wordlist.
-
- Checksum for the 12th word
- As an extension of the remainder 7, we see that it only needs 4 more bits to complete the typical 12 word phrase that a mnemonic is often recognized as. These last 4 bits are what is referred to as the checksum. (3 bits for a 256 bit entropy)
- The entropy, as a parameter of type binary, is handed to a hash function such as SHA-256, which converts it into a hexadecimal (a sequence of characters consisting of 0-9 and A-F)
Ex:ced25fa131e86640ffc9517b590f84877e40ad20f7f1ae88707ec79945d0d454
Each character in the hexadecimal can be represented as a binary of length 4 (i.e. 0000-1111 because 2 ^ 4 = 16 and len([0..9]) + len([A..F]) = 16) - The first character of the hexadecimal, after being converted back to a binary, is then added to the entropy and its remainder of 7 bits to complete the 12th word in the mnemonic phrase
- There seem to be several ways to construct the 4 bits, but the important thing to know for now is that the hexadecimal, which is essentially the SHA-256 version of an entropy, is always used to generate the checksum
Also good to look up: brain wallet