Post
Topic
Board Development & Technical Discussion
Re: Private key to public key (TUTORIAL)
by
ricardosuperx
on 03/05/2020, 00:43:48 UTC
It does not work in this way.

Keep in mind main thing: private key is a number (just integer), but public key is a point with x and y coordinates.
So you in your example public key was not correct for private key 1.

For private key 1 the public key is:
0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8

where 04 is a prefix for uncompressed key, green part is X-coordinate and blue part is Y-coordinate.

The compressed key contains only X coordinate with the prefix 02/03 (02 for Y even, and 03 for Y odd), because Y could be received from the formula y^2 = x^3 + 7, so no need to keep Y.
The compressed key so will be:
0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798

In your example you wrote only X coordinate for public key, it was not correct. Prefix 02 should also be there in order to know both coordinates.

Also, you should know that there is a basis point which was determined for elliptic curve selected for bitcoin. Basis point is usually written as G, and has coordinates:
Thanks for the answer. I will correct my question!
Gx = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
Gy = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8

Now the public key for every pk is pk*G, so for 1 public key 1*G - actually the G basis point itself.

For pk=2 the public key is 2*G = G + G, so you should perform scalar addition for basis point with itself (you hsould use poin doubling).
For pk=3 you just add the publik key for pk=2 with basis point G
And so on

For more details have a look at parrt 4 of this reading:
https://pdfslide.net/documents/introduction-to-bitcoin-and-ecdsa.html
Thanks for the answer. I will correct my question.
I just wanted to understand the G + G2 point duplication part ... The public key of 2, X =
0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798. But for me: X = 02f37cccfdf3b97758ab40c52b9d0e160e0537f9b65b9c51b2b3e502b62df02f30