Search code examples
public-keysecp256k1

How can this section of Discrete logarithm problem in ECDSA be sorted out/implemented


In the discrete logarithm problem of the secp256k1 curve, I'm actually curious as to how the generator point and the public key would be implemented (on the grounds that there are two versions of the parameters).

I was wondering if the Public key and the Generator point should be applied “compressed with the “02” or “03” or uncompressed with the “04”.

I couldn't find any answer to this anywhere.


Solution

  • The prefix "02","03","04" denote the compression type of the point.

    "04" means that the point is uncompressed, that is, both x and y coordinates are specified in this form. "02" and "03" means that the point is compressed. Only x coordinate is present in this representation. The y coordinate can be computed from the x coordinate(by solving y^2 = x^3 + ax + b (mod n)). Because there are 2 possible values of y, "02" denotes the positive one and "03" denotes the negative one. (The negative one is not actually negative, because we are using modulo operation).

    For example for secp256k1, we have -

    Gx = 79BE667E F9DCBBAC 55A06295 CE870B07 029BFCDB 2DCE28D9 59F2815B 16F81798
    Gy = 483ADA77 26A3C465 5DA4FBFC 0E1108A8 FD17B448 A6855419 9C47D08F FB10D4B8
    
    // Which can be written as
    G_compressed = 02 79BE667E F9DCBBAC 55A06295 CE870B07 029BFCDB 2DCE28D9 59F2815B 16F81798
    G_uncompressed = 04 79BE667E F9DCBBAC 55A06295 CE870B07 029BFCDB 2DCE28D9 59F2815B 16F81798 483ADA77 26A3C465 5DA4FBFC 0E1108A8 FD17B448 A6855419 9C47D08F FB10D4B8
    

    Internally, both these forms represent the same point, that is,

    x = 55066263022277343669578718895168534326250603453777594175500187360389116729240
    y = 32670510020758816978083085130507043184471273380659243275938904335757337482424
    

    On a a side note, this has nothing to do with Discrete log problem.