Calculate mnemonic code from terminal

2

I want to replicate mnemonic code with terminal. the steps are:

  1. Create a random sequence (entropy) of 128 to 256 bits.
  2. Create a checksum of the random sequence by taking the first (entropy- length/32) bits of its SHA256 hash.
  3. Add the checksum to the end of the random sequence.
  4. Divide the sequence into sections of 11 bits.
  5. Map each 11-bit value to a word from the predefined dictionary of 2048 words.
  6. The mnemonic code is the sequence of words.

I can see this image

enter image description here

And I take this entropy

0c1e24e5917779d297e14d45f14e1a1a

If I follow the image, I create the checksum

printf 0c1e24e5917779d297e14d45f14e1a1a | xxd -r -p | sha256sum -b

result

76e57a90f93135e97ce700a9e79196ba46315d65e696d0a4518270a8de3e80e4 

Then take 4 bits (0,5 byte => 1 char ) and append to my entropy with this result:

0c1e24e5917779d297e14d45f14e1a1a7

Now I have 132 bits And I have to split in 12 segments of 11 bits each

I try to convert in base 2

 echo "ibase=16; obase=2; 0C1E24E5917779D297E14D45F14E1A1A7" | bc

11000001111000100100111001011001000101110111011110011101001010010111111000010100110101000101111100010100111000011010000110100111

But the result is not correct, If I put that entropy in https://iancoleman.io/bip39/#entropy-notes I can see that result

00001100000 11110001001 00111001011 00100010111 01110111100 11101001010 01011111100 00101001101 01000101111 10001010011 10000110100 0011010

But I don't understand How can I obtain that

00001100000 = 96 = army

monkeyUser

Posted 2019-01-29T11:40:35.483

Reputation: 245

See the dictionary: https://github.com/bitcoin/bips/blob/master/bip-0039/english.txt 00001100000=96=army, 11110001001=1929=van, etc. Checksum of 0111 (7) seems to be correct as well. Do you get a different binary?

James C. 2019-01-29T13:41:26.130

@JamesC. Yes update my questionmonkeyUser 2019-01-29T13:48:14.013

1

Take a look at one of the answers under https://bitcoin.stackexchange.com/questions/83883/manually-generating-seed-for-trezor-t/83923#83923.

skaht 2019-01-31T01:10:07.273

Answers

1

Your binary (which includes the 4 checksum bits 0111, or 7) has the leading null's removed.

(0000)1100000 11110001001 00111001011 00100010111 01110111100 11101001010 01011111100 00101001101 01000101111 10001010011 10000110100 00110100111

Which is identical to the binary (without checksum bits 0111) from the web tool:

00001100000 11110001001 00111001011 00100010111 01110111100 11101001010 01011111100 00101001101 01000101111 10001010011 10000110100 0011010....

(Note the missing checksum bits .... at the end)

James C.

Posted 2019-01-29T11:40:35.483

Reputation: 2 183

I don't understand sorry. My checksum is 7. 7 in binary is 111 echo "ibase=16; obase=2; 7" | bc.monkeyUser 2019-01-29T14:05:05.543

If I do echo "ibase=16; obase=2; 0C1E24E5917779D297E14D45F14E1A1A" | bcwithout seven I have 1100000111100010010011100101100100010111011101111001110100101001011111100001010011010100010111110001010011100001101000011010 Why I have to add 0000 to the beginning?monkeyUser 2019-01-29T14:06:36.057

Yes, 111 = 0111, the leading zeros are always clipped by your command line tool. But you need to maintain all leading bits, even if they are nulls, because we need exact multiples of 11 for the mnemonic key word.James C. 2019-01-29T14:07:30.117

The 0 in 0C1E24E5917779D297E14D45F14E1A1A is 0000 bits, but these are clipped by the encoding tool. The tool preserves the value of the hex, because the leading null's do not contribute to the value, but we need a fixed-width binary encoding so we always have multiples of 11 bits for the words.James C. 2019-01-29T14:09:26.250

If your entropy were 000E24E5917779D297E14D45F14E1A1A, it would clip the 12 leading 0 bits.James C. 2019-01-29T14:10:03.620

I'm stupid, 7 in base 2 is 0111 you are right ! But I don't understand why 0 is 0000 bits and I ave to add before my binary sorrymonkeyUser 2019-01-29T14:17:24.480

Let us continue this discussion in chat.

monkeyUser 2019-01-29T14:20:05.227

I have to add padding maybe https://pastebin.com/jUCLmsX8

monkeyUser 2019-01-29T14:58:09.607

1hex is 0001bits. The 3 null bits are clipped by your tool.James C. 2019-01-29T15:03:46.197

2hex is 0010bits. The 2 null bits are clipped ...James C. 2019-01-29T15:04:19.850

How many leading nulls are clipped depends on the first hex character.James C. 2019-01-29T15:05:21.100