I'm trying to implement an authentication protocol based on elliptic curve over prime field in Matlab. I have already done the point addition and point multiplication successfully, but I'm facing a problem while computing the following steps: (Capital letters are points on the curve, small letters are integer scalars)
((y^-1)T4-T2)(rs^-1) = x1P
((y^-1)T5-x1T3)(rs^-1) = X2
Should I compute
y^-1
as
ModInverse(y , prime)? % the multiplicative inverse of y mod prime
Also, is that how I'm supposed to do the subtraction?
nT2 = T2;
nT2{2} = mod(-nT2{2}, prime);
(Negate the y-coordinate of a point) mod prime, and then do the addition on nT2
and another point