<pre><code>It was my fault.
</code></pre>

<p><code>G</code> is a point on the Elliptic curve. It means <code>G</code> has a number for <code>X</code> and another one for <code>Y</code>. so uncompressed G in <code>Secp256k1</code> is <code>G(x,y)</code>:</p>

<pre><code>- Uncompressed form (prefix 04)
04 79BE667E F9DCBBAC 55A06295 CE870B07 029BFCDB 2DCE28D9 59F2815B 16F81798
483ADA77 26A3C465 5DA4FBFC 0E1108A8 FD17B448 A6855419 9C47D08F FB10D4B8 

X = 79BE667E F9DCBBAC 55A06295 CE870B07 029BFCDB 2DCE28D9 59F2815B 16F81798

Y = 483ADA77 26A3C465 5DA4FBFC 0E1108A8 FD17B448 A6855419 9C47D08F FB10D4B8 
</code></pre>

<p>And <code>04</code> to show this is an uncompressed form of <code>G</code>.</p>

<p>This point is <code>Base point</code> or <code>Generator point</code> that it used in <code>k=K*G.</code></p>

<p><code>*</code> is not like <code>*</code> in math like <code>2*2 = 4</code>. It is <code>a sign</code> to show one of operators on curve.</p>

<p>we have 3 operators on a curve :</p>

<pre><code>-Addition
-Negation
-Doubling
</code></pre>

<p>Addition is for add two points. According to we have a point like <code>P1(x1,x2)</code>, and another point like <code>Q1(x2,y2)</code>, so we can't use <code>2+2 = 4</code>, we need some other calculation for <code>P+Q.</code>
The result of <code>P+Q</code> is another point on the curve that we can call it <code>R</code>.</p>

<p><code>Doubling</code> is double a point on the curve, and the result of this is a point on the curve too.
so <code>P+P=R.</code></p>

<p>When we say <code>k*G</code>, we want to <code>multiple</code> our <code>private key</code> to <code>a point on the curve</code>. </p>

<p>We need to do these :
Convert our <code>private key</code> to <code>binary base</code>.</p>

<p>With a for on all bits we start to check:
For each of this bits we do some <code>doublePoint</code> and <code>addPoints</code>.
This is a predefined role and we have to follow it. </p>

<p>But how we can calculate a <code>addition</code> of two points?</p>

<pre><code>λ = ( yq – yp ) / ( xq – xp)
xR = λ2 – xp – xq
yR = λ(xp – xR) – yP
</code></pre>

<p>With this. first we need to calculate <code>λ</code>, it is our <code>slope</code>.</p>

<p>Then we can calculate our x and y for new point. and the result is our </p>

<pre><code>p+q = R
</code></pre>

<p>and what about <code>doubling</code>?:</p>

<pre><code>λ = (3x2) +a / (2y) 
xR = λ2 - 2x 
yR = λ(x - xR) – y
</code></pre>

<p>with these, now we can calculate <code>K=k * G</code>.</p>

<p>There are many other tips to calculate <code>Public key</code> from <code>Private key</code>. </p>

<p>This one is a good implementation in <code>PHP</code>:
<a href="https://github.com/BitcoinPHP/BitcoinECDSA.php/blob/master/src/BitcoinPHP/BitcoinECDSA/BitcoinECDSA.php#L350" rel="nofollow noreferrer">https://github.com/BitcoinPHP/BitcoinECDSA.php/blob/master/src/BitcoinPHP/BitcoinECDSA/BitcoinECDSA.php#L350</a></p>

CC BY-SA 4.0
2020-04-07T07:39:49.820Z
2020-04-07T07:39:49.820Z
Hamid Naghipour
<p>When talking about math using a curve, when we use terms like addition and multiplication, we don't mean normal additional and multiplication. We are referring to operations on the curve that have properties similar to addition and multiplication. To get the correct results, you have to use the actual operations on the curve, not normal addition and multiplication.</p>

CC BY-SA 4.0
2020-04-03T09:57:09.890Z
Ok thank you,I got it. but in how we calculate it in the computers view? I know about it if we have a point like A and another point like B, with add these two we will have C, and if we reverse c in X line we will have another point. Or about multiplication in the Math view. I want to know how can I write a function that get Private key as input and give us public key as output? All we have in computers like 2*2=4 and I can't find relation between these.
Hamid Naghipour
CC BY-SA 4.0
2020-04-03T17:51:36.643Z
@HamidNaghipour You need a tool that specifically does secp256k1 point addition at least. Then you can do multiplication by repeated addition. For example, you can compute 9*k by adding k to itself (giving 2*k), then adding that result to itself (giving 4*k), then adding that result to itself (giving 8*k), then adding k to that result (giving 9*k).
David Schwartz
CC BY-SA 4.0
2020-04-04T07:13:48.240Z
after many researches on this topic, I got it. Now I'm looking a way how to create a function that does point addition. Could you please edit your answer? I want to accept it with these extra information. Thanks a lot.
Hamid Naghipour
CC BY-SA 4.0
2020-04-07T08:03:04.347Z
Thank you for your help. I added the answer that I needed it.
Hamid Naghipour
CC BY-SA 4.0
2020-05-03T09:42:34.597Z
could you please answer my question:
https://bitcoin.stackexchange.com/questions/95676/how-to-getheaders-from-blockchain
Hamid Naghipour
CC BY-SA 4.0
2020-04-03T09:41:04.313Z
2020-04-03T09:41:04.313Z
David Schwartz
<p>According to this answer: <a href="https://bitcoin.stackexchange.com/a/63996/100526">https://bitcoin.stackexchange.com/a/63996/100526</a>
When he wants to generate a <code>public key</code> from the <code>private key</code>, he has used <code>K=k*G</code>. but I can't understand it's result.
If we assume our <code>private key</code> is (according to the answer) :</p>

<pre><code>0F479245FB19A38A1954C5C7C0EBAB2F9BDFD96A17563EF28A6A4B1A2A764EF4
</code></pre>

<p>and according to <code>Secp256k1</code> <code>G</code> point is:</p>

<pre><code>- Compressed form (prefix 02)
02 79BE667E F9DCBBAC 55A06295 CE870B07 029BFCDB 2DCE28D9 59F2815B 16F81798 

 - Uncompressed form (prefix 04)
04 79BE667E F9DCBBAC 55A06295 CE870B07 029BFCDB 2DCE28D9 59F2815B 16F81798
483ADA77 26A3C465 5DA4FBFC 0E1108A8 FD17B448 A6855419 9C47D08F FB10D4B8 
</code></pre>

<p>So to calculate the public key I used this site: <a href="https://www.boxentriq.com/code-breaking/big-number-calculator" rel="nofollow noreferrer">https://www.boxentriq.com/code-breaking/big-number-calculator</a> </p>

<p>I used <code>compressed form</code> and <code>private key</code>:
<code>0279BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798</code>  *  <code>0F479245FB19A38A1954C5C7C0EBAB2F9BDFD96A17563EF28A6A4B1A2A764EF4</code></p>

<p>and result is :</p>

<pre><code>25d355ebb23e6ce0fd5463bf40e6da2ccc4e2e8ce654db6a8a8e5a275f0d2266005569112cfda60d14f9b6d0c0218cc072047a3b2fcf97aee95a437b4bb6cce0
</code></pre>

<p>but in that answer the result is :</p>

<pre><code>02E8445082A72F29B75CA48748A914DF60622A609CACFCE8ED0E35804560741D29
</code></pre>

<p>what's wrong?</p>

CC BY-SA 4.0
2020-04-03T07:43:26.340Z
Read [this](https://en.wikipedia.org/wiki/Elliptic_curve_point_multiplication). You have to multiply key by the **point** G which is a special process to make it irreversible.
Coding Enthusiast
CC BY-SA 4.0
2020-04-03T07:59:06.637Z
@CodingEnthusiast : I know it. So I wrote in my question. 

private key * G. 

Is this wrong way to multiply those like  two hex numbers?
Hamid Naghipour
CC BY-SA 4.0
2020-04-03T08:11:20.003Z
@Hamid You have clearly not read it. G is not a number, and the multiplication here is nothing like big integer multiplication. It's an elliptic curve point, and you need elliptic curve multiplication.
Pieter Wuille
CC BY-SA 4.0
2020-04-03T08:19:57.350Z
@PieterWuille Thank you. Could you please give me a good resource that explaining this clearly? I was totally confused :(
Hamid Naghipour
CC BY-SA 4.0
2020-04-03T08:21:05.307Z
The entire article CodingEnthousiast linked to is about elliptic curve multiplication. It's not a simple operation.
Pieter Wuille
CC BY-SA 4.0
2020-04-03T08:27:36.853Z
@PieterWuille As a developer I wanted to create a function for this to calculate public key from private key and I thought it's like 2 * 2 = 4. As you told it's not like this. Is there any online tools that we give it private key and it calculate K=k*G ?
Hamid Naghipour
CC BY-SA 4.0
2020-04-03T08:58:00.140Z
As a developer, see https://bitcoin.stackexchange.com/questions/25024/how-do-you-get-a-bitcoin-public-key-from-a-private-key . For an online tool, google online calculator secp256k1 key -> https://paulmillr.com/ecc/ which gives the specified result for your example.
dave_thompson_085
CC BY-SA 4.0
2020-04-03T09:12:03.547Z
Does this answer your question? [How do you get a Bitcoin Public Key from a Private Key](https://bitcoin.stackexchange.com/questions/25024/how-do-you-get-a-bitcoin-public-key-from-a-private-key)
Pieter Wuille
CC BY-SA 4.0
2020-04-07T07:45:55.807Z
@PieterWuille,  Thank you for your help. I added an answer to clear about k=k*g.
Hamid Naghipour
CC BY-SA 4.0
2020-04-07T07:48:25.977Z
@dave_thompson_085 Thank you for you help. I read all your links and I added an answer to fix my fault.
Hamid Naghipour
CC BY-SA 4.0
2020-04-07T07:49:57.623Z
@CodingEnthusiast Thank you for you help, I lost this page and it was the lost ring. I added an answer to fix my fault.
Hamid Naghipour
<private-key><public-key><secp256k1>
produce a public key from private key with ecc, with clear description about k=k*g
Hamid Naghipour
# produce a public key from private key with ecc, with clear description about k=k*g

(Asked by: username_0 on 2020-04-03)

According to this answer: <https://bitcoin.stackexchange.com/a/63996/100526>
When he wants to generate a `public key` from the `private key`, he has used `K=k*G`. but I can't understand it's result.
If we assume our `private key` is (according to the answer) :

```
0F479245FB19A38A1954C5C7C0EBAB2F9BDFD96A17563EF28A6A4B1A2A764EF4

```

and according to `Secp256k1` `G` point is:

```
- Compressed form (prefix 02)
02 79BE667E F9DCBBAC 55A06295 CE870B07 029BFCDB 2DCE28D9 59F2815B 16F81798 

 - Uncompressed form (prefix 04)
04 79BE667E F9DCBBAC 55A06295 CE870B07 029BFCDB 2DCE28D9 59F2815B 16F81798
483ADA77 26A3C465 5DA4FBFC 0E1108A8 FD17B448 A6855419 9C47D08F FB10D4B8 

```

So to calculate the public key I used this site: <https://www.boxentriq.com/code-breaking/big-number-calculator>

I used `compressed form` and `private key`:
`0279BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798` \* `0F479245FB19A38A1954C5C7C0EBAB2F9BDFD96A17563EF28A6A4B1A2A764EF4`

and result is :

```
25d355ebb23e6ce0fd5463bf40e6da2ccc4e2e8ce654db6a8a8e5a275f0d2266005569112cfda60d14f9b6d0c0218cc072047a3b2fcf97aee95a437b4bb6cce0

```

but in that answer the result is :

```
02E8445082A72F29B75CA48748A914DF60622A609CACFCE8ED0E35804560741D29

```

what's wrong?

**Tags:** private-key, public-key, secp256k1

> **Comments:**
> **username_1**: Read [this](https://en.wikipedia.org/wiki/Elliptic_curve_point_multiplication). You have to multiply key by the **point** G which is a special process to make it irreversible.  
> **username_0**: @username_1 : I know it. So I wrote in my question.   private key * G.   Is this wrong way to multiply those like  two hex numbers?  
> **username_2**: @username_0 You have clearly not read it. G is not a number, and the multiplication here is nothing like big integer multiplication. It's an elliptic curve point, and you need elliptic curve multiplication.  
> **username_0**: @username_2 Thank you. Could you please give me a good resource that explaining this clearly? I was totally confused :(  
> **username_2**: The entire article CodingEnthousiast linked to is about elliptic curve multiplication. It's not a simple operation.  
> **username_0**: @username_2 As a developer I wanted to create a function for this to calculate public key from private key and I thought it's like 2 * 2 = 4. As you told it's not like this. Is there any online tools that we give it private key and it calculate K=k*G ?  
> **username_3**: As a developer, see https://bitcoin.stackexchange.com/questions/25024/how-do-you-get-a-bitcoin-public-key-from-a-private-key . For an online tool, google online calculator secp256k1 key -> https://paulmillr.com/ecc/ which gives the specified result for your example.  
> **username_2**: Does this answer your question? [How do you get a Bitcoin Public Key from a Private Key](https://bitcoin.stackexchange.com/questions/25024/how-do-you-get-a-bitcoin-public-key-from-a-private-key)  
> **username_0**: @username_2,  Thank you for your help. I added an answer to clear about k=k*g.  
> **username_0**: @username_3 Thank you for you help. I read all your links and I added an answer to fix my fault.  
> **username_0**: @username_1 Thank you for you help, I lost this page and it was the lost ring. I added an answer to fix my fault.  

---

## 2 answers

### Answer by username_0 on 2020-04-07. Score: 1 | Accepted answer

```
It was my fault.

```

`G` is a point on the Elliptic curve. It means `G` has a number for `X` and another one for `Y`. so uncompressed G in `Secp256k1` is `G(x,y)`:

```
- Uncompressed form (prefix 04)
04 79BE667E F9DCBBAC 55A06295 CE870B07 029BFCDB 2DCE28D9 59F2815B 16F81798
483ADA77 26A3C465 5DA4FBFC 0E1108A8 FD17B448 A6855419 9C47D08F FB10D4B8 

X = 79BE667E F9DCBBAC 55A06295 CE870B07 029BFCDB 2DCE28D9 59F2815B 16F81798

Y = 483ADA77 26A3C465 5DA4FBFC 0E1108A8 FD17B448 A6855419 9C47D08F FB10D4B8 

```

And `04` to show this is an uncompressed form of `G`.

This point is `Base point` or `Generator point` that it used in `k=K*G.`

`*` is not like `*` in math like `2*2 = 4`. It is `a sign` to show one of operators on curve.

we have 3 operators on a curve :

```
-Addition
-Negation
-Doubling

```

Addition is for add two points. According to we have a point like `P1(x1,x2)`, and another point like `Q1(x2,y2)`, so we can't use `2+2 = 4`, we need some other calculation for `P+Q.`
The result of `P+Q` is another point on the curve that we can call it `R`.

`Doubling` is double a point on the curve, and the result of this is a point on the curve too.
so `P+P=R.`

When we say `k*G`, we want to `multiple` our `private key` to `a point on the curve`.

We need to do these :
Convert our `private key` to `binary base`.

With a for on all bits we start to check:
For each of this bits we do some `doublePoint` and `addPoints`.
This is a predefined role and we have to follow it.

But how we can calculate a `addition` of two points?

```
λ = ( yq – yp ) / ( xq – xp)
xR = λ2 – xp – xq
yR = λ(xp – xR) – yP

```

With this. first we need to calculate `λ`, it is our `slope`.

Then we can calculate our x and y for new point. and the result is our

```
p+q = R

```

and what about `doubling`?:

```
λ = (3x2) +a / (2y) 
xR = λ2 - 2x 
yR = λ(x - xR) – y

```

with these, now we can calculate `K=k * G`.

There are many other tips to calculate `Public key` from `Private key`.

This one is a good implementation in `PHP`:
<https://github.com/BitcoinPHP/BitcoinECDSA.php/blob/master/src/BitcoinPHP/BitcoinECDSA/BitcoinECDSA.php#L350>


---

### Answer by username_4 on 2020-04-03. Score: 2

When talking about math using a curve, when we use terms like addition and multiplication, we don't mean normal additional and multiplication. We are referring to operations on the curve that have properties similar to addition and multiplication. To get the correct results, you have to use the actual operations on the curve, not normal addition and multiplication.

> **Comments:**
> **username_0**: Ok thank you,I got it. but in how we calculate it in the computers view? I know about it if we have a point like A and another point like B, with add these two we will have C, and if we reverse c in X line we will have another point. Or about multiplication in the Math view. I want to know how can I write a function that get Private key as input and give us public key as output? All we have in computers like 2*2=4 and I can't find relation between these.  
> **username_4**: @username_0 You need a tool that specifically does secp256k1 point addition at least. Then you can do multiplication by repeated addition. For example, you can compute 9*k by adding k to itself (giving 2*k), then adding that result to itself (giving 4*k), then adding that result to itself (giving 8*k), then adding k to that result (giving 9*k).  
> **username_0**: after many researches on this topic, I got it. Now I'm looking a way how to create a function that does point addition. Could you please edit your answer? I want to accept it with these extra information. Thanks a lot.  
> **username_0**: Thank you for your help. I added the answer that I needed it.  
> **username_0**: could you please answer my question: https://bitcoin.stackexchange.com/questions/95676/how-to-getheaders-from-blockchain  

---

