1

I found a diagram, which explains in an excellent way how to convert a public key to a P2PKH address here(1). Also, I found a good map of types of addresses/keys here(2) and a list of all possible address prefixes here(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.

7
  • 2
    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. Jul 5, 2023 at 14:51
  • @PieterWuille no, explanation like function_name(...) is enough, just like doc(1) does not explain what ripemd160 or Base58 is.
    – Putnik
    Jul 6, 2023 at 5:14
  • @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. Jul 7, 2023 at 13:06
  • 1
    @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. Jul 7, 2023 at 14:42
  • 1
    @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. Jul 7, 2023 at 15:49

2 Answers 2

4
+50

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 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).

2

Maybe that's the documentation that answers your question:

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

Supplementary catalog:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.