According to http://www.secg.org/sec1-v2.pdf#page=13 ,
Rule to add two points with the same x-coordinates when the points are either distinct or have y-coordinate 0:
(x, y) + (x, −y) = O for all (x, y) ∈ E(Fp)
— i.e. the negative of the point (x, y) is −(x, y) = (x, −y).
The fact that it says "when the points are distinct" makes it sound like it applies when the x
coordinates of both points match but the y
coordinates do not.But if that's the case then it seems to me that that'd make the "or have y-coordinate 0" bit redundant? y is not equal to -y so it seems to me that that's redundant? I mean, I guess y is equal to -y over mod p but in ECC is it even worthwhile to handle the use case where x or y are greater than p?
And what about adding (x, 0) to itself? At that point do we do point doubling, since the points are the same or do we just return 0 because of the "or have y-coordinate 0" bit?
If y was 0 I guess you'd be doing $\frac{\mathbb{3x}_{1}^2 + a}{2y_1}$ or $\frac{\mathbb{3x}_{1}^2 + a}{0}$ so it seems like it might be good to avoid it all together by returning $\mathcal O$ but idk.
And plus, using that rationale then what is supposed to be done for when the two coordinates are different? At that point $\lambda$ is $\frac{y_2 - y_1}{x_2 - x_1}$ so what if both x coordinates match whilst the y coordinates didn't? At that point you'd have another division by zero error..