<p>You accidentally converted to binary the original public key hash, not the result of prepending <code>00</code> (you can tell because it should start with <code>00000000</code>). You also might not need to convert to binary at all, many hashing tools will be perfectly happy to accept a hexadecimal input.</p>
<p>The hash you should get after this step is:</p>
<pre><code>296b64c7d7e8cf61a327d3e351b9e92e4451af50dff18227550167fe7a13bee2
</code></pre>

CC BY-SA 4.0
2024-02-03T08:05:05.243Z
You are correct I don't need to convert to binary first but I was doomed from the start regardless. I was using an online SHA256 hashing tool and didn't realise it defaulted to treating the input as text not hex. Once I changed it to hex it worked.
user2334659
CC BY-SA 4.0
2024-02-03T05:56:21.837Z
2024-02-03T05:56:21.837Z
Vojtěch Strnad
<p>I have been learning about how P2PKH addresses are generated so I thought I would try and work through one myself manually. I start with the following public key hash:</p>
<p><code>e049ccc9e524a9302c2187bf02c4d78741d9b039</code></p>
<p>Which I know should come out to address:</p>
<p><code>1MSvmgVJvYkdtCsopFqsT2g3FNNhpcoeBG</code></p>
<p>I append the <code>00</code> prefix to my hash getting:</p>
<p><code>00e049ccc9e524a9302c2187bf02c4d78741d9b039</code></p>
<p>I then go to calculate the checksum by converting this to binary:</p>
<p><code>1110000001001001110011001100100111100101001001001010100100110000001011000010000110000111101111110000001011000100110101111000011101000001110110011011000000111001</code></p>
<p>And then running this through SHA256 twice which gets me:</p>
<p><code>a66d4caa10c1b665d6bca3f06788db9fbea6e9912a9fcf8101eb5992f9e8ab78</code></p>
<p>I take the first 4 bytes <code>a66d4caa</code> and put them onto the end of my prefix+hash:</p>
<p><code>00e049ccc9e524a9302c2187bf02c4d78741d9b039a66d4caa</code></p>
<p>And I wind up with:</p>
<p><code>1MSvmgVJvYkdtCsopFqsT2g3FNNhsp8jXo</code></p>
<p>Can someone help me out with where I am going wrong?</p>
<p>EDIT: Forgot to convert it to binary first. But it still doesn't work.</p>

<address-generation><p2pkh><base58><base58check>
Creating a P2PKH address
user2334659
# Creating a P2PKH address

(Asked by: username_0 on 2024-02-03)

I have been learning about how P2PKH addresses are generated so I thought I would try and work through one myself manually. I start with the following public key hash:

`e049ccc9e524a9302c2187bf02c4d78741d9b039`

Which I know should come out to address:

`1MSvmgVJvYkdtCsopFqsT2g3FNNhpcoeBG`

I append the `00` prefix to my hash getting:

`00e049ccc9e524a9302c2187bf02c4d78741d9b039`

I then go to calculate the checksum by converting this to binary:

`1110000001001001110011001100100111100101001001001010100100110000001011000010000110000111101111110000001011000100110101111000011101000001110110011011000000111001`

And then running this through SHA256 twice which gets me:

`a66d4caa10c1b665d6bca3f06788db9fbea6e9912a9fcf8101eb5992f9e8ab78`

I take the first 4 bytes `a66d4caa` and put them onto the end of my prefix+hash:

`00e049ccc9e524a9302c2187bf02c4d78741d9b039a66d4caa`

And I wind up with:

`1MSvmgVJvYkdtCsopFqsT2g3FNNhsp8jXo`

Can someone help me out with where I am going wrong?

EDIT: Forgot to convert it to binary first. But it still doesn't work.

**Tags:** address-generation, p2pkh, base58, base58check


---

## 1 answers

### Answer by username_1 on 2024-02-03. Score: 1

You accidentally converted to binary the original public key hash, not the result of prepending 00 (you can tell because it should start with 00000000). You also might not need to convert to binary at all, many hashing tools will be perfectly happy to accept a hexadecimal input.
The hash you should get after this step is:
296b64c7d7e8cf61a327d3e351b9e92e4451af50dff18227550167fe7a13bee2

> **Comments:**
> **username_0**: You are correct I don't need to convert to binary first but I was doomed from the start regardless. I was using an online SHA256 hashing tool and didn't realise it defaulted to treating the input as text not hex. Once I changed it to hex it worked.  

---

