<p>Bitcoin uses point multiplication on the Elliptic Curve <a href="https://en.bitcoin.it/wiki/Secp256k1" rel="nofollow noreferrer">secp256k1</a> to generate a public key from a private key. Basically, this curve has a defined Generator point G, and a method for 'adding' two points together in a way to get a new point (<a href="https://en.m.wikipedia.org/wiki/Elliptic_curve_point_multiplication" rel="nofollow noreferrer">EC Point Addition</a>). </p>

<p>Your private key is just a number, aka a Scalar, so to get your public key you just add the generator point to itself privkey number of times - basically scalar multiplication on the Elliptic curve. At the end, you'll end up with a point on the curve, with an X and Y coordinate, and this point is your public key. Those two coordinates of your point are what is referred to by the document you quoted, using 32 bytes for each coordinate plus a prefix.</p>

<p>The 0x04 prefix used is to denote the fact this is an uncompressed private key. You can also form a compressed version, by just using the X coordinate with either 0x02 or 0x03 prefix, because the Elliptic curve has only 2 values for Y coordinate for each X coordinate (one positive and one negative), so it's trivial to recover the Y coordinate if you know the X coordinate and the sign (based on your choice of prefix).</p>

CC BY-SA 3.0
2017-08-05T00:57:22.020Z
2017-08-05T01:03:43.607Z
2017-08-05T01:03:43.607Z
meshcollider
<pre><code>your priv = 18E14A7B6A307F426A94F8114701E7C8E774E7F9A47E2C2035DB29A206321725
X = priv x 79BE667E F9DCBBAC 55A06295 CE870B07 029BFCDB 2DCE28D9 59F2815B 16F81798
Y = priv x 483ADA77 26A3C465 5DA4FBFC 0E1108A8 FD17B448 A6855419 9C47D08F FB10D4B8
</code></pre>

<p><a href="https://en.bitcoin.it/wiki/Secp256k1" rel="nofollow">https://en.bitcoin.it/wiki/Secp256k1</a></p>

CC BY-SA 3.0
2016-06-13T11:23:43.343Z
Downvoted. You make it sound like you need to multiply the individual X and Y coordates of the generator with the private key as numbers. This is not correct; you need to perform an elliptic curve multiplication, which requires a repeated geometric construction.
Pieter Wuille
CC BY-SA 3.0
2016-04-14T08:35:57.760Z
2016-04-14T08:35:57.760Z
amaclin
<p>= 18E14A7B6A307F426A94F8114701E7C8E774E7F9A47E2C2035DB29A206321725
X = priv x 79BE667E F9DCBBAC 55A06295 CE870B07 029BFCDB 2DCE28D9 59F2815B 16F81798
Y = priv x 483ADA77 26A3C465 5DA4FBFC 0E1108A8 FD17B448 A6855419 9C47D08F FB10D4B8</p>

CC BY-SA 4.0
2022-01-28T23:07:36.933Z
2022-01-28T23:07:36.933Z
judy gant
<p>I managed to write the below code which will create public and private keys</p>

<p><strong>Private Key</strong></p>

<pre><code>$input = "satoshinakamoto";
$sha256 = hash("sha256", ($input));
echo "&lt;strong&gt;Private Key: &lt;/strong&gt;".$sha256."&lt;br/&gt;";
</code></pre>

<p><strong>Public Key</strong></p>

<pre><code>    $step1 = hexStringToByteString("0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6");
    echo "&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; ".$step1."&lt;/p&gt;";
    $step2 = hash("sha256", $step1);
    echo "&lt;p&gt;&lt;strong&gt;Step 2: &lt;/strong&gt;".$step2."&lt;/p&gt;";
    $step3 = hash('ripemd160', hexStringToByteString($step2));
    echo "&lt;p&gt;&lt;strong&gt;Step 3: &lt;/strong&gt;".$step3."&lt;/p&gt;";
    $step4 = '00'.$step3;
    echo "&lt;p&gt;&lt;strong&gt;Step 4: &lt;/strong&gt;".$step4."&lt;/p&gt;";
    $step5 = hash("sha256", hexStringToByteString($step4));
    echo "&lt;p&gt;&lt;strong&gt;Step 5: &lt;/strong&gt;".$step5."&lt;/p&gt;";
    $step6 = hash("sha256",hexStringToByteString($step5));
    echo "&lt;p&gt;&lt;strong&gt;Step 6: &lt;/strong&gt;".$step6."&lt;/p&gt;";
    $step7 = substr($step6,0,8);
    echo "&lt;p&gt;&lt;strong&gt;Step 7: &lt;/strong&gt;".$step7."&lt;/p&gt;";
    $step8 = $step4.$step7;
    echo "&lt;p&gt;&lt;strong&gt;Step 8: &lt;/strong&gt;".$step8."&lt;/p&gt;";
    $step9 = bc_hexdec($step8);
    echo "&lt;p&gt;&lt;strong&gt;Step 9: &lt;/strong&gt;".$step9."&lt;/p&gt;";
    $step10 = bc_base58_encode($step9);
    echo "&lt;p&gt;&lt;strong&gt;Step 10: &lt;/strong&gt;1".$step10."&lt;/p&gt;";
    return $step10;
</code></pre>

<p>To generate public key I took reference from <a href="https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses</a></p>

<p>In that link they provided Step by Step process and I followed the same and if 
I input from <code>Step 1 in the link</code> then I am able to convert the code to public key but I am not sure how to convert <code>Step 0 to Step 1</code></p>

<p>i.e.</p>

<p><strong>From:</strong></p>

<pre><code>18E14A7B6A307F426A94F8114701E7C8E774E7F9A47E2C2035DB29A206321725
</code></pre>

<p><strong>To</strong></p>

<pre><code>0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6
</code></pre>

<p>Document says</p>

<p><strong>Take the corresponding public key generated with it (65 bytes, 1 byte 0x04, 32 bytes corresponding to X coordinate, 32 bytes corresponding to Y coordinate)</strong></p>

<p>What does that mean? How can I generate this value from Private Key.</p>

<p><strong>Edit 1</strong></p>

<p>This question says <a href="https://stackoverflow.com/questions/17672696/generating-bitcoin-address-from-ecdsa-public-key">https://stackoverflow.com/questions/17672696/generating-bitcoin-address-from-ecdsa-public-key</a> </p>

<p>Joining the <code>Elliptic Public Key</code> and I still don't understand what are they.</p>

CC BY-SA 3.0
2016-02-24T06:43:47.620Z
@duskwuff - I know that, I am just using a string as example but I am looking for algorithm how the wallets are generated. I know about the vulnerabilities of brainwallet. I just need to know the formula for how that X and Y Coordinates are generated.
Karthik Malla
<php><hash><wallet>
Generating Bitcoin Public and Private Keys
Karthik Malla
# Generating Bitcoin Public and Private Keys

(Asked by: username_0 on 2016-02-24)

I managed to write the below code which will create public and private keys

**Private Key**

```
$input = "satoshinakamoto";
$sha256 = hash("sha256", ($input));
echo "<strong>Private Key: </strong>".$sha256."<br/>";

```

**Public Key**

```
    $step1 = hexStringToByteString("0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6");
    echo "<p><strong>Step 1:</strong> ".$step1."</p>";
    $step2 = hash("sha256", $step1);
    echo "<p><strong>Step 2: </strong>".$step2."</p>";
    $step3 = hash('ripemd160', hexStringToByteString($step2));
    echo "<p><strong>Step 3: </strong>".$step3."</p>";
    $step4 = '00'.$step3;
    echo "<p><strong>Step 4: </strong>".$step4."</p>";
    $step5 = hash("sha256", hexStringToByteString($step4));
    echo "<p><strong>Step 5: </strong>".$step5."</p>";
    $step6 = hash("sha256",hexStringToByteString($step5));
    echo "<p><strong>Step 6: </strong>".$step6."</p>";
    $step7 = substr($step6,0,8);
    echo "<p><strong>Step 7: </strong>".$step7."</p>";
    $step8 = $step4.$step7;
    echo "<p><strong>Step 8: </strong>".$step8."</p>";
    $step9 = bc_hexdec($step8);
    echo "<p><strong>Step 9: </strong>".$step9."</p>";
    $step10 = bc_base58_encode($step9);
    echo "<p><strong>Step 10: </strong>1".$step10."</p>";
    return $step10;

```

To generate public key I took reference from <https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses>

In that link they provided Step by Step process and I followed the same and if
I input from `Step 1 in the link` then I am able to convert the code to public key but I am not sure how to convert `Step 0 to Step 1`

i.e.

**From:**

```
18E14A7B6A307F426A94F8114701E7C8E774E7F9A47E2C2035DB29A206321725

```

**To**

```
0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6

```

Document says

**Take the corresponding public key generated with it (65 bytes, 1 byte 0x04, 32 bytes corresponding to X coordinate, 32 bytes corresponding to Y coordinate)**

What does that mean? How can I generate this value from Private Key.

**Edit 1**

This question says <https://stackoverflow.com/questions/17672696/generating-bitcoin-address-from-ecdsa-public-key>

Joining the `Elliptic Public Key` and I still don't understand what are they.

**Tags:** php, hash, wallet

> **Comments:**
> **username_0**: @duskwuff - I know that, I am just using a string as example but I am looking for algorithm how the wallets are generated. I know about the vulnerabilities of brainwallet. I just need to know the formula for how that X and Y Coordinates are generated.  

---

## 3 answers

### Answer by username_1 on 2017-08-05. Score: 2

Bitcoin uses point multiplication on the Elliptic Curve [secp256k1](https://en.bitcoin.it/wiki/Secp256k1) to generate a public key from a private key. Basically, this curve has a defined Generator point G, and a method for 'adding' two points together in a way to get a new point ([EC Point Addition](https://en.m.wikipedia.org/wiki/Elliptic_curve_point_multiplication)).

Your private key is just a number, aka a Scalar, so to get your public key you just add the generator point to itself privkey number of times - basically scalar multiplication on the Elliptic curve. At the end, you'll end up with a point on the curve, with an X and Y coordinate, and this point is your public key. Those two coordinates of your point are what is referred to by the document you quoted, using 32 bytes for each coordinate plus a prefix.

The 0x04 prefix used is to denote the fact this is an uncompressed private key. You can also form a compressed version, by just using the X coordinate with either 0x02 or 0x03 prefix, because the Elliptic curve has only 2 values for Y coordinate for each X coordinate (one positive and one negative), so it's trivial to recover the Y coordinate if you know the X coordinate and the sign (based on your choice of prefix).


---

### Answer by username_2 on 2016-04-14. Score: -1

```
your priv = 18E14A7B6A307F426A94F8114701E7C8E774E7F9A47E2C2035DB29A206321725
X = priv x 79BE667E F9DCBBAC 55A06295 CE870B07 029BFCDB 2DCE28D9 59F2815B 16F81798
Y = priv x 483ADA77 26A3C465 5DA4FBFC 0E1108A8 FD17B448 A6855419 9C47D08F FB10D4B8

```

<https://en.bitcoin.it/wiki/Secp256k1>

> **Comments:**
> **username_3**: Downvoted. You make it sound like you need to multiply the individual X and Y coordates of the generator with the private key as numbers. This is not correct; you need to perform an elliptic curve multiplication, which requires a repeated geometric construction.  

---

### Answer by username_4 on 2022-01-28. Score: -1

= 18E14A7B6A307F426A94F8114701E7C8E774E7F9A47E2C2035DB29A206321725
X = priv x 79BE667E F9DCBBAC 55A06295 CE870B07 029BFCDB 2DCE28D9 59F2815B 16F81798
Y = priv x 483ADA77 26A3C465 5DA4FBFC 0E1108A8 FD17B448 A6855419 9C47D08F FB10D4B8


---

