Post
Topic
Board Development & Technical Discussion
Re: How to generate public key from private key
by
achow101
on 17/12/2017, 22:36:03 UTC
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.