Bitcoin Forum
May 04, 2024, 06:51:36 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to generate public key from private key  (Read 306 times)
TAnalyzer (OP)
Newbie
*
Offline Offline

Activity: 8
Merit: 0


View Profile
December 16, 2017, 08:40:29 PM
 #1

i went through loads of articles include ECDSA ones but i couldn't find a detailed scheme on how to generate the public key out of the private one.
anyone has any idea?
1714805496
Hero Member
*
Offline Offline

Posts: 1714805496

View Profile Personal Message (Offline)

Ignore
1714805496
Reply with quote  #2

1714805496
Report to moderator
No Gods or Kings. Only Bitcoin
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
mda
Member
**
Offline Offline

Activity: 144
Merit: 13


View Profile
December 16, 2017, 09:04:22 PM
 #2

https://coinb.in/#verify is good enough for this? Do it off-line of course.
TAnalyzer (OP)
Newbie
*
Offline Offline

Activity: 8
Merit: 0


View Profile
December 16, 2017, 09:19:27 PM
 #3

https://coinb.in/#verify is good enough for this? Do it off-line of course.

i'm not interested of any website to do it for me, i want to understand the algorithm behind it.
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3388
Merit: 6578


Just writing some code


View Profile WWW
December 17, 2017, 01:11:56 AM
Merited by Welsh (2), ABCbits (2)
 #4

The public key is calculated by taking the generator point G and performing elliptic curve point multiplication on it with the private key. Given private key d and generator G, you do d * G. The process for elliptic curve point multiplication is detailed on wikipedia. The curve parameters are the ones for the secp256k1 curve which are defined here (section 2.4.1): http://www.secg.org/sec2-v2.pdf

TAnalyzer (OP)
Newbie
*
Offline Offline

Activity: 8
Merit: 0


View Profile
December 17, 2017, 02:48:32 PM
 #5

The public key is calculated by taking the generator point G and performing elliptic curve point multiplication on it with the private key. Given private key d and generator G, you do d * G. The process for elliptic curve point multiplication is detailed on wikipedia. The curve parameters are the ones for the secp256k1 curve which are defined here (section 2.4.1): http://www.secg.org/sec2-v2.pdf

thank you very much.

i have only one missing part to understand the complete picture.
G is a point on the curve with two coordinates(X,Y), how can you multiply the with a number and end up with a single number(public key) and not with a new point?
aplistir
Full Member
***
Offline Offline

Activity: 378
Merit: 197



View Profile
December 17, 2017, 03:13:47 PM
 #6

i have only one missing part to understand the complete picture.
G is a point on the curve with two coordinates(X,Y), how can you multiply the with a number and end up with a single number(public key) and not with a new point?

What you get is a new point, which is your public key.
There are two possible ways to represent your public key. Either the long one with
04 + x_coordinate + y_coordinate
or (the compressed way) if y is even
02 + x_coordinate
and for odd y
03 + x_coordinate

Your public key is a point in the field. It is just represented in the way I described above. And you can always calculate the x and y coordinates from the compressed format too.

from the public key you can calculate your address, and for that you have to take SHA256 and Ripemod160 hashes. And add a few check bytes to the end...

My Address: 121f7zb2U4g9iM4MiJTDhEzqeZGHzq5wLh
TAnalyzer (OP)
Newbie
*
Offline Offline

Activity: 8
Merit: 0


View Profile
December 17, 2017, 07:23:59 PM
 #7

i have only one missing part to understand the complete picture.
G is a point on the curve with two coordinates(X,Y), how can you multiply the with a number and end up with a single number(public key) and not with a new point?

What you get is a new point, which is your public key.
There are two possible ways to represent your public key. Either the long one with
04 + x_coordinate + y_coordinate
or (the compressed way) if y is even
02 + x_coordinate
and for odd y
03 + x_coordinate

Your public key is a point in the field. It is just represented in the way I described above. And you can always calculate the x and y coordinates from the compressed format too.

from the public key you can calculate your address, and for that you have to take SHA256 and Ripemod160 hashes. And add a few check bytes to the end...


Thanks for the explenation

when i multiply G with my secret key i get astronomical number, which is not the public key, what am i doing wrong consider those params?

var Gx = 79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798
var Gy = 483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8

var private key = 845ADD761F80CD7BA8AD296B262939D6191370D286D29D4F06A4F1C9A8DE4E4B

i get this public key which is not the right one

C532FC9C12D71842216394CD94771F9B72302CABD0C5D4CCCF1585131548378D1B9F08218A4E3A0 F5E06D981D74720B8F59235385F25AECE75E6FFA787AF3988DD1D215B39C94994D0600D31C1971E 88CF8623AC07DCB72279CD66038AD281049F0E028D31C40417FDD97364A8D6664AEB3437740CE41 D37928CF956E64E61E8
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3388
Merit: 6578


Just writing some code


View Profile WWW
December 17, 2017, 10:36:03 PM
 #8

Thanks for the explenation

when i multiply G with my secret key i get astronomical number, which is not the public key, what am i doing wrong consider those params?

var Gx = 79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798
var Gy = 483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8

var private key = 845ADD761F80CD7BA8AD296B262939D6191370D286D29D4F06A4F1C9A8DE4E4B

i get this public key which is not the right one

C532FC9C12D71842216394CD94771F9B72302CABD0C5D4CCCF1585131548378D1B9F08218A4E3A0 F5E06D981D74720B8F59235385F25AECE75E6FFA787AF3988DD1D215B39C94994D0600D31C1971E 88CF8623AC07DCB72279CD66038AD281049F0E028D31C40417FDD97364A8D6664AEB3437740CE41 D37928CF956E64E61E8
Since this is finite field arithmetic, everything needs to be done modulo n (n is defined in the secp256k1 spec). Doing all operations mod n (or doing all operations and then performing mod n) should fix this problem.

hopeAo
Jr. Member
*
Offline Offline

Activity: 42
Merit: 2


View Profile
December 25, 2017, 08:01:38 AM
 #9

i went through loads of articles include ECDSA ones but i couldn't find a detailed scheme on how to generate the public key out of the private one.
anyone has any idea?

I think this link should help

https://askubuntu.com/questions/53553/how-do-i-retrieve-the-public-key-from-a-ssh-private-key

https://opengear.zendesk.com/entries/23216142-Generating-and-uploading-SSH-keys-under-Windows

http://www.beginninglinux.com/home/server-administration/openssh-keys-certificates-authentication-pem-pub-crt
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!