<p>Also look at <a href="http://www.commandlinefu.com/commands/view/13183/bitcoin-brainwallet-private-key-calculator" rel="nofollow noreferrer">this fairly simple brain wallet generator</a> - it shows the steps needed to create the standard base58 private key from a passphrase.</p>

<p>Below is a partial screen capture of the above URL from the site commandlinefu.com:</p>

<p><a href="https://i.sstatic.net/xCWJd.gif" rel="nofollow noreferrer"><img src="https://i.sstatic.net/xCWJd.gif" alt="Screen capture of URL"></a></p>

<p>Also useful - you can use <a href="https://brainwallet.io/" rel="nofollow noreferrer">brainwallet.io</a> to cross-check the above results.</p>

CC BY-SA 3.0
2017-03-09T01:18:42.977Z
2017-03-09T02:28:02.947Z
2017-03-09T02:28:02.947Z
neonzeon
<p><code>F29E9187</code> are indeed the first four bytes of the double sha256 of the bytes:</p>

<pre><code>802CF24DBA5FB0A30E26E83B2AC5B9E29E1B161E5C1FA7425E73043362938B982401
</code></pre>

<p>In order to check this, you need to compute the double sha256 of this array of bytes. However, as already discussed, passing the string <code>802CF2...</code> to the hash function will not yield the right answer, as this string is not the array of bytes itself (it is a hexadecimal encoding of the array). So let us create a binary file which corresponds to the hex encoding above:</p>

<pre><code>$ echo -n 802CF24DBA5FB0A30E26E83B2AC5B9E29E1B161E5C1FA7425E73043362938B982401 \
   | xxd -r -p &gt; temp
</code></pre>

<p>Let us check our binary file <code>temp</code> has the correct bytes:</p>

<pre><code>$ hexdump -C temp

00000000  80 2c f2 4d ba 5f b0 a3  0e 26 e8 3b 2a c5 b9 e2  |.,.M._...&amp;.;*...|
00000010  9e 1b 16 1e 5c 1f a7 42  5e 73 04 33 62 93 8b 98  |....\..B^s.3b...|
00000020  24 01                                             |$.|
00000022
</code></pre>

<p>So far so good. We can now compute the first sha256 hash of these bytes:</p>

<pre><code>$ sha256sum temp
08a9d3e1296633b2a4071316eaf597f1c93a0ec2f4b68b24c6e0ad2e7c06540c  temp
</code></pre>

<p>Again, we are faced with a hex encoding which we need to convert to actual bytes:</p>

<pre><code>$ echo -n 08a9d3e1296633b2a4071316eaf597f1c93a0ec2f4b68b24c6e0ad2e7c06540c \
  | xxd -r -p &gt; temp
</code></pre>

<p>Checking once more:</p>

<pre><code>$ hexdump -C temp

00000000  08 a9 d3 e1 29 66 33 b2  a4 07 13 16 ea f5 97 f1  |....)f3.........|
00000010  c9 3a 0e c2 f4 b6 8b 24  c6 e0 ad 2e 7c 06 54 0c  |.:.....$....|.T.|
00000020
</code></pre>

<p>So let's compute the sha256 hash of these bytes:</p>

<pre><code>$ sha256sum temp
f29e9187a566a24502d7cd2eae948e74bc4dfafc7deff44cce80e1256ef12a3e  temp
</code></pre>

<p><strong>you can see that the first 4 bytes are indeed <code>F29E9187</code></strong>.</p>

CC BY-SA 3.0
2017-03-08T19:30:36.257Z
2017-03-08T19:30:36.257Z
Sven Williamson
<p>I want to understand how a bitcoin private key is made up.</p>

<p>Looking at this graphical generator 
<a href="https://royalforkblog.github.io/2014/08/11/graphical-address-generator/#hello" rel="nofollow noreferrer">https://royalforkblog.github.io/2014/08/11/graphical-address-generator/#hello</a></p>

<p>I understand step 1, how the private key is generated: 
<code>2CF24DBA5FB0A30E26E83B2AC5B9E29E1B161E5C1FA7425E73043362938B9824</code></p>

<p>I can see the prepended version number <code>80</code>, and that I should append the compression flag  <code>01</code></p>

<p>My question is around step 4, which is simply detailed as "Append checksum. Checksum is the first 4 bytes of double sha256 hash of whatever is being checkedsum'ed." </p>

<p>So I take <code>802CF24DBA5FB0A30E26E83B2AC5B9E29E1B161E5C1FA7425E73043362938B982401</code> and double SHA-256, and I don't get anything like the expected checksum of <code>F29E9187</code></p>

<p>Can anyone help me understand how <code>F29E9187</code> is derived?</p>

<cryptography><sha256>
How to generate a Bitcoin Private Key Checksum
Will-In-China
# How to generate a Bitcoin Private Key Checksum

(Asked by: username_0 on 2017-03-08)

I want to understand how a bitcoin private key is made up.

Looking at this graphical generator
<https://royalforkblog.github.io/2014/08/11/graphical-address-generator/#hello>

I understand step 1, how the private key is generated:
`2CF24DBA5FB0A30E26E83B2AC5B9E29E1B161E5C1FA7425E73043362938B9824`

I can see the prepended version number `80`, and that I should append the compression flag `01`

My question is around step 4, which is simply detailed as "Append checksum. Checksum is the first 4 bytes of double sha256 hash of whatever is being checkedsum'ed."

So I take `802CF24DBA5FB0A30E26E83B2AC5B9E29E1B161E5C1FA7425E73043362938B982401` and double SHA-256, and I don't get anything like the expected checksum of `F29E9187`

Can anyone help me understand how `F29E9187` is derived?

**Tags:** cryptography, sha256


---

## 2 answers

### Answer by username_2 on 2017-03-08. Score: 9 | Accepted answer

`F29E9187` are indeed the first four bytes of the double sha256 of the bytes:

```
802CF24DBA5FB0A30E26E83B2AC5B9E29E1B161E5C1FA7425E73043362938B982401

```

In order to check this, you need to compute the double sha256 of this array of bytes. However, as already discussed, passing the string `802CF2...` to the hash function will not yield the right answer, as this string is not the array of bytes itself (it is a hexadecimal encoding of the array). So let us create a binary file which corresponds to the hex encoding above:

```
$ echo -n 802CF24DBA5FB0A30E26E83B2AC5B9E29E1B161E5C1FA7425E73043362938B982401 \
   | xxd -r -p > temp

```

Let us check our binary file `temp` has the correct bytes:

```
$ hexdump -C temp

00000000  80 2c f2 4d ba 5f b0 a3  0e 26 e8 3b 2a c5 b9 e2  |.,.M._...&.;*...|
00000010  9e 1b 16 1e 5c 1f a7 42  5e 73 04 33 62 93 8b 98  |....\..B^s.3b...|
00000020  24 01                                             |$.|
00000022

```

So far so good. We can now compute the first sha256 hash of these bytes:

```
$ sha256sum temp
08a9d3e1296633b2a4071316eaf597f1c93a0ec2f4b68b24c6e0ad2e7c06540c  temp

```

Again, we are faced with a hex encoding which we need to convert to actual bytes:

```
$ echo -n 08a9d3e1296633b2a4071316eaf597f1c93a0ec2f4b68b24c6e0ad2e7c06540c \
  | xxd -r -p > temp

```

Checking once more:

```
$ hexdump -C temp

00000000  08 a9 d3 e1 29 66 33 b2  a4 07 13 16 ea f5 97 f1  |....)f3.........|
00000010  c9 3a 0e c2 f4 b6 8b 24  c6 e0 ad 2e 7c 06 54 0c  |.:.....$....|.T.|
00000020

```

So let's compute the sha256 hash of these bytes:

```
$ sha256sum temp
f29e9187a566a24502d7cd2eae948e74bc4dfafc7deff44cce80e1256ef12a3e  temp

```

**you can see that the first 4 bytes are indeed `F29E9187`**.


---

### Answer by username_1 on 2017-03-09. Score: -1

Also look at [this fairly simple brain wallet generator](http://www.commandlinefu.com/commands/view/13183/bitcoin-brainwallet-private-key-calculator) - it shows the steps needed to create the standard base58 private key from a passphrase.

Below is a partial screen capture of the above URL from the site commandlinefu.com:

[![Screen capture of URL](https://i.sstatic.net/xCWJd.gif)](https://i.sstatic.net/xCWJd.gif)

Also useful - you can use [brainwallet.io](https://brainwallet.io/) to cross-check the above results.


---

