I've been learning about the elliptic curves and how they work, and their usage in cryptography, and I'm trying to figure out how to use them using Go.
- Where is the 'a' parameter from my ECC equation y^2 = x^3 + a*x + b, in this CurveParams structure? https://golang.org/pkg/crypto/elliptic/#CurveParams To verify I am understanding well please correct me if I am wrong:
- 'P' parameter represents the order of the finite field
- 'N' is the minimum prime number such that N*G result is the infinity point
- 'B' is the constant 'b' in my ECC equation
- 'Gx','Gy' represents the base point (which for example is used for calculating public keys using your chosen private key and multiplying it with G, or in the example above where N*G is used to calculate the infinity point)
- 'BitSize' this is where I'm not sure what this actually represents. I understand that in the P256 (secp256k1 BTC) curve this is equal to 256 and so it represents the length of the private key. What I do not understand is where in the math does this number actually appear from? Or is it actually just the binary length of the 'P' ?
- The biggest question here is where is 'a' parameter from the elliptic curve equation? How can elliptic curves actually be defined if I don't decide this parameter?
What happens if you use the Double() function using a point that is not on the curve, or using the infinity point? I tried to search for some point that is not found on the curve to call the function with it but didn't find any (for the P256 curve, i searched on google) https://golang.org/pkg/crypto/elliptic/#CurveParams.Double
What happens if you use the Add() function using points that are not on the curve, or using the infinity point + on curve point, or infinity point + not on curve point? https://golang.org/pkg/crypto/elliptic/#CurveParams.Add
Why are private keys returned in byte types? What's the deal with the byte type? I see it used in a lot of places. Why do we not use the big int type? I see them being used in GenerateKey(), Marshal(), MarshalCompressed(), UnmarshalCompressed(), ScalarBaseMult(), ScalarMult().
For all the questions above, I am interested also from the math and programming point of view, but especially programming. If you do not have the answers for all of them, please provide any answer to any question you have answer/s for.
- question 1 partially answered. BitSize still needs to be explained