0

Hello fellow cryptographers.

I have spent last few days trying to understand and find a way to generate secp256k1 private and public keys from scratch, but i failed.

I have seen tons of videos and read tons of pdfs about it but I still can't understand how to implement it even in pseudocode.

r = Random
k = PrivateKey (64bit hex string that should safely be generated from r and hashed)
K = PublicKey
G =
0479BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798483ADA7726A3C4655DA4FBF0E1108A8FD17B448A68554199C47D08FFB10D4B8

K = k * G

Now i know G has x,y and that 04 at the beginning means that its in uncompressed form. But i am confused with the way I should multiply k and G, since whenever I tried turning them into decimal values multiplying them and then encoding them into hex afterwards I would get wrong results.

Now lets say I have K(public key).

How would I go about encrypting an message, and then proving that I can decrypt it?

I really look forward to hearing your answers :D

1 Answers1

1

G is a point on the curve, but multiplication on elliptic curves is not the same as just multiplying the x and y value by the number. Have a look here https://en.m.wikipedia.org/wiki/Elliptic_curve_point_multiplication to see how you multiply a Point (G) with a natural number. Because the elliptic curve, you are talking about, is not over the real numbers, but over a residual field (natural numbers mod N), the division is just another way to write the multiplication by the inverse (mod N) https://en.m.wikipedia.org/wiki/Modular_multiplicative_inverse

jjj
  • 469
  • 3
  • 8