<p>To read a string of bits with <code>shasum</code> you need to use <code>-0</code>, not <code>-b</code>:</p>
<pre><code>echo &quot;11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111&quot; | shasum -a 256 -0
</code></pre>
<p>The hash comes out as <code>5ac6a5945f16500911219129984ba8b387a06f24fe383ce4e81a73294065461b</code> which indeed makes the last word &quot;wrong&quot;.</p>

CC BY-SA 4.0
2022-01-09T23:47:16.463Z
Thanks!  So this means that chytrik (answering https://bitcoin.stackexchange.com/questions/99765/pseudo-code-to-find-bip39-checksum?rq=1), was using the wrong command line flags for shasum but got the correct first four bits, he got 3043b02ceb37bb00ab48c91f76bb23d487e1ec822c90e1575967e8838a655f7c when he should have gotten 3beeaf4009651c2fdcf083ddc2ae8f224e74f1adc40bbc1783ebf4bac56e20b7 (funny how it has beeaf in it).
ssocolow
CC BY-SA 4.0
2022-01-08T02:17:11.247Z
2022-01-08T02:17:11.247Z
Vojtěch Strnad
<p>I read <a href="https://bitcoin.stackexchange.com/questions/99765/pseudo-code-to-find-bip39-checksum?rq=1">Pseudo code to find Bip39 checksum?</a> and followed the steps outlined by the answer and arrived at the correct checksum.</p>
<p>But when I went to try it on a 128 bit entropy that were all 1s: 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111</p>
<p>I got the wrong checksum (checking with <a href="https://iancoleman.io/bip39/" rel="nofollow noreferrer">https://iancoleman.io/bip39/</a> and <a href="https://learnmeabitcoin.com/technical/mnemonic" rel="nofollow noreferrer">https://learnmeabitcoin.com/technical/mnemonic</a>).</p>
<p>On ubuntu 20.04, I ran:</p>
<pre><code>echo &quot;11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111&quot; | shasum -a 256 -b
</code></pre>
<p>and my hash was
<code>951354377d60faddeaf27bbc864565a2fef8db8da4b4bdf5c21a2c6f6ac9a06f</code></p>
<p>so, reading from the Bip39 spec (<a href="https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki#Generating_the_mnemonic" rel="nofollow noreferrer">https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki#Generating_the_mnemonic</a>), it says &quot;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.&quot;</p>
<p>So I took the first four bits of the hash, 9 in hex is 1001, and appended it to the 128 1s so now the checksum word should be 11111111001, and checking it on <a href="https://github.com/hatgit/BIP39-wordlist-printable-en/blob/master/BIP39-en-printable.txt" rel="nofollow noreferrer">https://github.com/hatgit/BIP39-wordlist-printable-en/blob/master/BIP39-en-printable.txt</a> tells me that my checksum word should be &quot;you&quot;.</p>
<p>Therefore, shouldn't my 12 word mnemonic now be:
<code>zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo you</code>
?</p>
<p>But importing the 128 1s as entropy into <a href="https://iancoleman.io/bip39/" rel="nofollow noreferrer">https://iancoleman.io/bip39/</a> (checking the box for &quot;Show entropy details&quot;), tells me my last word should be &quot;wrong&quot;, so &quot;you&quot; is incorrect.</p>
<p>Can someone please point out what I'm doing wrong?  This is driving me a little crazy.  Thanks!</p>

<hash><mnemonic-seed><checksum>
Stumped on finding checksum for 12 word Bip39 mnemonic
ssocolow
# Stumped on finding checksum for 12 word Bip39 mnemonic

(Asked by: username_0 on 2022-01-08)

I read [Pseudo code to find Bip39 checksum?](https://bitcoin.stackexchange.com/questions/99765/pseudo-code-to-find-bip39-checksum?rq=1) and followed the steps outlined by the answer and arrived at the correct checksum.

But when I went to try it on a 128 bit entropy that were all 1s: 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

I got the wrong checksum (checking with <https://iancoleman.io/bip39/> and <https://learnmeabitcoin.com/technical/mnemonic>).

On ubuntu 20.04, I ran:

```
echo "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" | shasum -a 256 -b

```

and my hash was
`951354377d60faddeaf27bbc864565a2fef8db8da4b4bdf5c21a2c6f6ac9a06f`

so, reading from the Bip39 spec (<https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki#Generating_the_mnemonic>), it says "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."

So I took the first four bits of the hash, 9 in hex is 1001, and appended it to the 128 1s so now the checksum word should be 11111111001, and checking it on <https://github.com/hatgit/BIP39-wordlist-printable-en/blob/master/BIP39-en-printable.txt> tells me that my checksum word should be "you".

Therefore, shouldn't my 12 word mnemonic now be:
`zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo you`
?

But importing the 128 1s as entropy into <https://iancoleman.io/bip39/> (checking the box for "Show entropy details"), tells me my last word should be "wrong", so "you" is incorrect.

Can someone please point out what I'm doing wrong? This is driving me a little crazy. Thanks!

**Tags:** hash, mnemonic-seed, checksum


---

## 1 answers

### Answer by username_1 on 2022-01-08. Score: 4

To read a string of bits with `shasum` you need to use `-0`, not `-b`:

```
echo "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" | shasum -a 256 -0

```

The hash comes out as `5ac6a5945f16500911219129984ba8b387a06f24fe383ce4e81a73294065461b` which indeed makes the last word "wrong".

> **Comments:**
> **username_0**: Thanks!  So this means that chytrik (answering https://bitcoin.stackexchange.com/questions/99765/pseudo-code-to-find-bip39-checksum?rq=1), was using the wrong command line flags for shasum but got the correct first four bits, he got 3043b02ceb37bb00ab48c91f76bb23d487e1ec822c90e1575967e8838a655f7c when he should have gotten 3beeaf4009651c2fdcf083ddc2ae8f224e74f1adc40bbc1783ebf4bac56e20b7 (funny how it has beeaf in it).  

---

