I am currently implementing Elliptic Curve (EC) point multiplication over a Weierstrass curve using projective coordinates. Specifically, I am trying to add a point $P$ to the identity element (represented as $(0:1:0)$) according to the formulas provided in the answer to this question.
Based on my understanding, adding any point $P$ to the identity element should return the same point $P$. However, when I perform this operation, I end up with the result $(0:0:0)$, which seems incorrect.
Here’s a brief outline of what I’ve done:
- I’ve implemented the formulas for point addition as described in the referenced answer.
- The identity element is represented in projective coordinates as $(0:1:0)$.
Issue: When I add a point $P$ to the identity element, instead of getting back $P$, I am getting $(0:0:0)$.
Questions:
- Is my understanding correct that adding any point $P$ to the identity element $(0:1:0)$ should return $P$ in projective coordinates?
- Could there be a mistake in my implementation of the point addition formula, or is there something I might be missing in handling projective coordinates?
Let's walk through an example to illustrate the problem of adding a point on the Weierstrass elliptic curve to the identity element in projective coordinates.
Given:
- The Weierstrass equation: $y^2 = x^3 + ax + b$
- The identity element $O$ in projective coordinates: $O = (0 : 1 : 0)$
Let's choose a point $P = (x_1 : y_1 : z_1)$ on the elliptic curve.
For simplicity, let's assume:
- $x_1 = 1$
- $y_1 = 2$
- $z_1 = 1$
So, $P = (1 : 2 : 1)$.
The identity element in projective coordinates:
- $O = (0 : 1 : 0)$
Adding $P$ and $O$ in projective coordinates:
Given the formulas:
- $u = y_2 z_1 - y_1 z_2$
- $v = x_2 z_1 - x_1 z_2$
- $w = u^2 z_1 z_2 - v^3 - 2 v^2 x_1 z_2$
- $x_3 = v w$
- $y_3 = u (v^2 x_1 z_2 - w) - v^3 y_1 z_2$
- $z_3 = v^3 z_1 z_2$
Substituting $P = (1 : 2 : 1)$ and $O = (0 : 1 : 0)$:
- $u = y_2 z_1 - y_1 z_2 = 1 \times 1 - 2 \times 0 = 1$
- $v = x_2 z_1 - x_1 z_2 = 0 \times 1 - 1 \times 0 = 0$
- $w = u^2 z_1 z_2 - v^3 - 2 v^2 x_1 z_2 = 1^2 \times 1 \times 0 - 0^3 - 2 \times 0^2 \times 1 \times 0 = 0$
- $x_3 = v \times w = 0 \times 0 = 0$
- $y_3 = u \times (v^2 \times x_1 \times z_2 - w) - v^3 \times y_1 \times z_2 = 1 \times (0^2 \times 1 \times 0 - 0) - 0^3 \times 2 \times 0 = 0$
- $z_3 = v^3 \times z_1 \times z_2 = 0^3 \times 1 \times 0 = 0$
As shown, the point that I am getting is $(0:0:0)$ and not the same point $P = (1:2:1)$. Any insights or advice on what might be going wrong would be greatly appreciated!