I'm trying to find the Y coordinate for an elliptic point. I understand the formula is y^2≡x^3+ax+b mod p
.
However I'm unsure of how I would actually program this in Go.
xCubed.Exp(X, 3, nil)
AX.Mul(A,X)
N.Add(XPow3, AX) // x^3 + ax
N.Mod(N, P) // mod p
N.Add(N, B) // (x^3 + ax) + b
N.Mod(N, P) // mod p
return N
Where xCubed,X,N,P,B are *big.Int
and N represents y^2
I'm a noob to modular arithmetic, so my assumption mod P is applied to each operation; Is this the correct way to to calculate x^3 + ax + b mod p
?
edit: should I have added AX.Mod(p) ?