<p>This may be of help, assuming you're fine with PHP code.</p>

<p><a href="https://github.com/peterscott78/synala/blob/master/data/lib/bip32.php#L348" rel="nofollow">https://github.com/peterscott78/synala/blob/master/data/lib/bip32.php#L348</a></p>

CC BY-SA 3.0
2016-07-25T18:18:35.977Z
2016-07-25T18:18:35.977Z
Envrin Group
<p>From a privatekey (ECC, 32Byte) to an P2PKH address:</p>

<ol>
<li>Ensure the private key is a valid ECC privat key (<a href="https://github.com/bitcoin-core/secp256k1/blob/master/include/secp256k1.h#L475" rel="nofollow">libsecp256k1 function</a>)</li>
<li>Calculate the public key from the private key (complex math. function, use a library)</li>
<li>Calculate the RIPEMD160 hash (aka Hash160) from the public key</li>
<li>Do a base58check encoding of the hash160 with a prefix byte 0x00 (for mainnet) or 0x6f for testnet</li>
</ol>

<p>C code to explore:
<a href="https://github.com/libbtc/libbtc/blob/3331ec47ca4ad33e8f2e46e6f01dfbeae090c53d/src/toolfunc.c#L22" rel="nofollow">https://github.com/libbtc/libbtc/blob/3331ec47ca4ad33e8f2e46e6f01dfbeae090c53d/src/toolfunc.c#L22</a></p>

CC BY-SA 3.0
2016-07-25T09:59:22.137Z
2016-07-25T09:59:22.137Z
Jonas Schnelli
<p><a href="https://bitcoin.stackexchange.com/questions/36634/how-do-i-get-to-the-value-in-the-scriptpubkey-part-of-the-transaction">How do I get to the value in the &#39;scriptPubKey&#39; part of the transaction ?</a> shows a great example of going from address to scriptPubKey.</p>

<p>I'd like to do something similar: go from private key (ECDSA) to address.  How do I do that? References to libs or code, as in the above question, would be appreciated.</p>

<address><development><private-key><public-key>
Transforming private key into address
Manilla
# Transforming private key into address

(Asked by: username_0 on 2016-07-25)

[How do I get to the value in the 'scriptPubKey' part of the transaction ?](https://bitcoin.stackexchange.com/questions/36634/how-do-i-get-to-the-value-in-the-scriptpubkey-part-of-the-transaction) shows a great example of going from address to scriptPubKey.

I'd like to do something similar: go from private key (ECDSA) to address. How do I do that? References to libs or code, as in the above question, would be appreciated.

**Tags:** address, development, private-key, public-key


---

## 2 answers

### Answer by username_1 on 2016-07-25. Score: 0

This may be of help, assuming you're fine with PHP code.

<https://github.com/peterscott78/synala/blob/master/data/lib/bip32.php#L348>


---

### Answer by username_2 on 2016-07-25. Score: 0

From a privatekey (ECC, 32Byte) to an P2PKH address:

1. Ensure the private key is a valid ECC privat key ([libsecp256k1 function](https://github.com/bitcoin-core/secp256k1/blob/master/include/secp256k1.h#L475))
2. Calculate the public key from the private key (complex math. function, use a library)
3. Calculate the RIPEMD160 hash (aka Hash160) from the public key
4. Do a base58check encoding of the hash160 with a prefix byte 0x00 (for mainnet) or 0x6f for testnet

C code to explore:
<https://github.com/libbtc/libbtc/blob/3331ec47ca4ad33e8f2e46e6f01dfbeae090c53d/src/toolfunc.c#L22>


---

