<p>Take a (random) integer from the permitted range, between 1 and the integer order of the elliptic curve base point <em>G</em> on secp256k1, i.e. between 1 and 115792089237316195423570985008687907852837564279074904382605163141518161494336 inclusive, and call it your private key <em>d<sub>A</sub></em>.</p>
<p>Perform an <a href="https://en.wikipedia.org/wiki/Elliptic_curve_point_multiplication" rel="nofollow noreferrer">elliptic curve point multiplication</a> of the private key <em>d<sub>A</sub></em> with the Generator <em>G</em> to calculate another point on the curve, the public key: <em>Q<sub>A</sub> = d<sub>A</sub> × G</em>.</p>
<p>Use the public key <em>Q<sub>A</sub></em> with the coordinates <em>(x<sub>Q<sub>A</sub></sub>, y<sub>Q<sub>A</sub></sub>)</em> to generate an output script, then derive an address as described in (1) or (2).</p>

CC BY-SA 4.0
2023-07-07T17:46:31.840Z
2023-07-08T04:00:51.227Z
2023-07-08T04:00:51.227Z
Murch
<p>Maybe that's the documentation that answers your question:</p>
<ul>
<li><a href="https://learnmeabitcoin.com/beginners/keys_addresses" rel="nofollow noreferrer">https://learnmeabitcoin.com/beginners/keys_addresses</a></li>
<li><a href="https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch04.asciidoc" rel="nofollow noreferrer">https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch04.asciidoc</a></li>
<li><a href="https://learn.saylor.org/mod/book/view.php?id=36353&amp;chapterid=18935" rel="nofollow noreferrer">https://learn.saylor.org/mod/book/view.php?id=36353&amp;chapterid=18935</a></li>
</ul>
<p>And there is a tool that may assist learning: <a href="https://bitcoiner.guide/seed/" rel="nofollow noreferrer">https://bitcoiner.guide/seed/</a></p>
<p>Supplementary catalog:</p>
<ul>
<li><a href="https://www.lopp.net/bitcoin-information.html" rel="nofollow noreferrer">https://www.lopp.net/bitcoin-information.html</a></li>
</ul>

CC BY-SA 4.0
2023-07-07T21:32:27.963Z
2023-07-12T13:35:06.950Z
2023-07-12T13:35:06.950Z
Greg Tonoski
<p>I found a diagram, which explains in an excellent way how to convert a public key to a P2PKH address <a href="https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses" rel="nofollow noreferrer">here</a>(1). Also, I found a good map of types of addresses/keys <a href="https://en.bitcoin.it/wiki/Invoice_address" rel="nofollow noreferrer">here</a>(2) and a list of all possible address prefixes <a href="https://en.bitcoin.it/wiki/List_of_address_prefixes" rel="nofollow noreferrer">here</a>(3).</p>
<p>I'd like to understand how exactly private keys are converted into pub keys and addresses - like in (1) but for all elements (except testnet), starting from the private key.</p>
<p>Is there any documentation on that, ideally - as clear as (1)?
Thank you.</p>

CC BY-SA 4.0
2023-07-05T14:51:18.433Z
Do you want an explanation of all the elliptic curve cryptography that goes into the computation of a public key from a private key? There are tutorials out there, but I think it's a bit much for a stackexchange answer.
Pieter Wuille
CC BY-SA 4.0
2023-07-06T05:14:20.893Z
@PieterWuille no, explanation like function_name(...) is enough, just like doc(1) does not explain what `ripemd160` or `Base58` is.
Putnik
CC BY-SA 4.0
2023-07-07T13:06:18.283Z
@Putnik, function names will depend on what programming language you use and which library. I would only use libraries that have documentation for function calls.
RedGrittyBrick
CC BY-SA 4.0
2023-07-07T14:13:20.580Z
@RedGrittyBrick ripemd160 or Base58  are not functions names only, it's the name of transformation, what should be done to get dataB from dataA. It's programming language agnostic, the same as in the doc (1). My apologies for not being clear.
Putnik
CC BY-SA 4.0
2023-07-07T14:42:09.847Z
@Putnik It's still unclear what you're asking for. Based on what you're saying, I think `pubkey = secp256k1_pubkey(privkey)` would be a correct answer, but I assume you want something more detailed than that.
Pieter Wuille
CC BY-SA 4.0
2023-07-07T15:35:07.140Z
@PieterWuille Thank you for your patience. I want doc which describes all way from random 256bit to public key in the form of this document: https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses 
In fact, the schema from that doc is the best element.
Putnik
CC BY-SA 4.0
2023-07-07T15:49:23.483Z
@Putnik There is nothing to be said, I've already given you the answer if that is your question. That document describes the process from public key to address using "cryptographic primitives" as the level of detail. The conversion from private key to public key is just a single cryptographic primitive "compute the secp256k1 public key for that private key". If you want more detail than that, we need to dig into the elliptic curve cryptography that is involved in that process.
Pieter Wuille
<private-key><public-key><wallet-import-format>
Bitcoin keys explained?
Putnik
# Bitcoin keys explained?

(Asked by: username_0 on 2023-07-05)

I found a diagram, which explains in an excellent way how to convert a public key to a P2PKH address [here](https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses)(1). Also, I found a good map of types of addresses/keys [here](https://en.bitcoin.it/wiki/Invoice_address)(2) and a list of all possible address prefixes [here](https://en.bitcoin.it/wiki/List_of_address_prefixes)(3).

I'd like to understand how exactly private keys are converted into pub keys and addresses - like in (1) but for all elements (except testnet), starting from the private key.

Is there any documentation on that, ideally - as clear as (1)?
Thank you.

**Tags:** private-key, public-key, wallet-import-format

> **Comments:**
> **username_1**: Do you want an explanation of all the elliptic curve cryptography that goes into the computation of a public key from a private key? There are tutorials out there, but I think it's a bit much for a stackexchange answer.  
> **username_0**: @PieterWuille no, explanation like function_name(...) is enough, just like doc(1) does not explain what `ripemd160` or `Base58` is.  
> **username_2**: @username_0, function names will depend on what programming language you use and which library. I would only use libraries that have documentation for function calls.  
> **username_0**: @username_2 ripemd160 or Base58  are not functions names only, it's the name of transformation, what should be done to get dataB from dataA. It's programming language agnostic, the same as in the doc (1). My apologies for not being clear.  
> **username_1**: @username_0 It's still unclear what you're asking for. Based on what you're saying, I think `pubkey = secp256k1_pubkey(privkey)` would be a correct answer, but I assume you want something more detailed than that.  
> **username_0**: @PieterWuille Thank you for your patience. I want doc which describes all way from random 256bit to public key in the form of this document: https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses  In fact, the schema from that doc is the best element.  
> **username_1**: @username_0 There is nothing to be said, I've already given you the answer if that is your question. That document describes the process from public key to address using "cryptographic primitives" as the level of detail. The conversion from private key to public key is just a single cryptographic primitive "compute the secp256k1 public key for that private key". If you want more detail than that, we need to dig into the elliptic curve cryptography that is involved in that process.  

---

## 2 answers

### Answer by username_3 on 2023-07-07. Score: 4

Take a (random) integer from the permitted range, between 1 and the integer order of the elliptic curve base point *G* on secp256k1, i.e. between 1 and 115792089237316195423570985008687907852837564279074904382605163141518161494336 inclusive, and call it your private key *dA*.

Perform an [elliptic curve point multiplication](https://en.wikipedia.org/wiki/Elliptic_curve_point_multiplication) of the private key *dA* with the Generator *G* to calculate another point on the curve, the public key: *QA = dA × G*.

Use the public key *QA* with the coordinates *(xQA, yQA)* to generate an output script, then derive an address as described in (1) or (2).


---

### Answer by username_4 on 2023-07-07. Score: 2

Maybe that's the documentation that answers your question:

* <https://learnmeabitcoin.com/beginners/keys_addresses>
* <https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch04.asciidoc>
* <https://learn.saylor.org/mod/book/view.php?id=36353&chapterid=18935>

And there is a tool that may assist learning: <https://bitcoiner.guide/seed/>

Supplementary catalog:

* <https://www.lopp.net/bitcoin-information.html>


---

