# Projective Coordinates in Elliptic Curves

By: Cailyn Yong and Bryan Wee

Previously, we were introduced to elliptic curves and point operations. So far, the elliptic curves we have seen are represented in the affine space, where points can be represented as $\left(x,y\right)$ coordinates. Affine group operations, as we will soon see, are costly as they require field divisions. In this article, we will see how projective coordinates can be used to sidestep these costs and achieve greater efficiency.

Since we are concerned with computational efficiency, we will only be studying curves that are restricted to prime fields. Hence, for all equations below, all field arithmetic is modulo arithmetic.

## Cost of Affine Coordinates

Let us consider 2 affine coordinates, $P=\left({x}_{1},{y}_{1}\right),Q=\left({x}_{2},{y}_{2}\right)$, where $P\ne Q$, and recall how point addition is computed.

1. If either point is $O$, then $P+Q$ is given by the other point.

2. Else if ${x}_{1}={x}_{2}$, then $P+Q=O$.

3. Else:
• Let $m=\left({y}_{1}-{y}_{2}\right)/\left({x}_{1}-{x}_{2}\right)$
• Then, ${x}_{3}={m}^{2}-{x}_{1}-{x}_{2}$ and ${y}_{3}=m\left({x}_{1}-{x}_{3}\right)-{y}_{1}$

Notice that in its worst case, point addition requires 2 multiplications, 6 additions/subtractions, and 1 division.

Let us recall how point doubling can be performed as well. To compute $2P=\left({x}_{2},{y}_{2}\right)$, where $P=\left({x}_{1},{y}_{1}\right)$:

1. If $P=O$ or ${y}_{1}=0$, then $2P=O$

2. Else:
• Let $m=\left({3{x}_{1}}^{2}+a\right)/\left(2{y}_{1}\right)$
• Then, ${x}_{2}={m}^{2}-2{x}_{1}$ and ${y}_{2}=m\left({x}_{1}-{x}_{2}\right)-{y}_{1}$

Point doubling involves 7 multiplications, 4 additions/subtractions, and 1 division.

Both point addition and doubling require 1 field division, which for prime fields, means modular division. This form of division requires the non-trivial act of finding a modular inverse, making it very expensive.

## Projective Coordinates

Costs can be reduced by adopting a new coordinate system that avoids field division entirely. Given an affine coordinate $\left(x,y\right)$, we can transform it into a projective coordinate $\left(X,Y,Z\right)$ by taking an arbitrary non-zero value $Z$ and assigning $\left(X,Y,Z\right)=\left(xZ,yZ,Z\right)$.

For instance, $\left(2,3\right)$ can be mapped to $\left(4,6,2\right)$ or $\left(8,12,4\right)$, with $Z=2$ or $Z=4$ respectively. Usually, $z$ is chosen to be $1$ for convenience; affine coordinates $\left(x,y\right)$ would be transformed to $\left(x,y,1\right)$.

Projecting an entire elliptic curve yields the following curve equation.

${Y}^{2}Z={X}^{3}+aX{Z}^{2}+b{Z}^{3}$

The diagram below visualizes how a projected curve might look like.  To convert projective coordinates $\left(X,Y,Z\right)$ back to affine coordinates $\left(x,y\right)$, all we have to do is divide the projective coordinate by $Z$.

$\left(x,y\right)=\left(X/Z,Y/Z\right)$

With projective coordinates, the formulae for point addition and point doubling require no field division. Take $P=\left({X}_{1},{Y}_{1},{Z}_{1}\right)$, $Q=\left({X}_{2},{Y}_{2},{Z}_{2}\right)$, and $P\ne Q$. Let us see how we can compute $P+Q=\left({X}_{3},{Y}_{3},{Z}_{3}\right)$.

1. If either point is $O$, then $P+Q$ is given by the other point.

2. Else, let:
$u={Y}_{2}{Z}_{1}-{Y}_{1}{Z}_{2}$
$v={X}_{2}{Z}_{1}-{X}_{1}{Z}_{2}$
$A={u}^{2}{Z}_{1}{Z}_{2}-{v}^{3}-2{v}^{2}{X}_{1}{Z}_{2}$

${X}_{3}=vA$
${Y}_{3}=u\left({v}^{2}{X}_{1}{Z}_{2}-A\right)-{v}^{3}{Y}_{1}{Z}_{2}$
${Z}_{3}={v}^{3}{Z}_{1}{Z}_{2}$

Next, given $P=\left({X}_{1},{Y}_{1},{Z}_{1}\right)$, how can compute $2P=\left({X}_{2},{Y}_{2},{Z}_{2}\right)$?

1. Let:
$w=a{{Z}_{1}}^{2}+3{{X}_{1}}^{2}$
$s={Y}_{1}{Z}_{1}$
$B={X}_{1}{Y}_{1}s$
$h={w}^{2}-8B$

2. To perform point doubling:
${X}_{2}=2hs$
${Y}_{2}=w\left(4B-h\right)-8{s}^{2}{{Y}_{1}}^{2}$
${Z}_{2}=8{s}^{3}f$

Both operations require more addition and multiplication than before, but demand zero divisions! Knowing this, we can much more efficiently manipulate elliptic curve points by:

1. Converting affine coordinates to projective coordinates.

2. Perform the required computation.

3. Converting the results back to affine coordinates. (Only this step requires division)

Now, only two field divisions are required for any amount of consecutive point addition and doubling. This, in turn, saves a drastic amount of computation for elliptic curves over finite fields.

## Jacobian Coordinates

A modified form of projective coordinates is Jacobian coordinates. For Jacobian coordinates, instead of multiplying $x$ and $y$ with $Z$ like we did in the standard form of projective coordinates, we map affine coordinates $\left(x,y\right)$ to $\left(X,Y,Z\right)=\left(x\ast {Z}^{2},y\ast {Z}^{3},Z\right)$.

Using Jacobian coordinates, elliptic curves adopt the following equation.

${Y}^{2}={X}^{3}+aX{Z}^{4}+b{Z}^{6}$

Here is the formula for point addition, assuming $P\ne Q$:

1. If either point is $O$, then $P+Q$ is given by the other point.

2. Else, let:
${U}_{1}={X}_{1}{{Z}_{2}}^{2}$ and ${U}_{2}={X}_{2}{{Z}_{1}}^{2}$
$s={S}_{1}={Y}_{1}{{Z}_{2}}^{3}$ and ${S}_{2}={Y}_{2}{{Z}_{1}}^{3}$
$H={U}_{2}-{U}_{1}$
$r={S}_{2}-{S}_{1}$

${X}_{3}={r}^{2}-{H}^{3}-2{U}_{1}{H}^{2}$
${Y}_{3}=r\left({U}_{1}{H}^{2}-{X}_{3}\right)-{S}_{1}{H}^{3}$
${Z}^{3}=H{Z}_{1}{Z}_{2}$

...and the formula for point doubling.

1. If ${Y}_{1}=0,$ then $2P=O$.

2. Else, let:
$S=4{X}_{1}{{Y}_{1}}^{2}$
$M=3{{X}_{1}}^{2}+a{{Z}_{1}}^{4}$
$T={M}^{2}-2S$

3. To perform point doubling:
$S={X}_{2}=T$
${Y}_{2}=M\left(S-T\right)-8{{Y}_{1}}^{4}$
${Z}_{2}=2{Y}_{1}{Z}_{1}$

Like before, these operations do not require field division. Jacobian coordinates offer a slight edge compared to standard projective coordinates because they trade multiplication for more addition/subtraction which tends to be cheaper.

### Jacobian Coordinates ⇌ Affine Coordinates

Each instance of affine point addition/doubling requires one field division. This becomes extremely expensive once we consider consecutive curve operations (e.g., scalar multiplication). On the other hand, Jacobian coordinates demand no field divisions. We can exploit this fact to support affine point manipulation by:

1. Converting affine points to Jacobian points, with $z=1$.

$\left(x,y\right)\to \left(x,y,1\right)$

2. Performing all necessary operations in Jacobian space.

3. Converting Jacobian points back to affine space. Let ${z}^{-1}$ be the modular inverse of $z$.

$\left(x,y,z\right)\to \left(x\ast \left({z}^{-1}{\right)}^{2},y\ast \left({z}^{-1}{\right)}^{3}\right)$

This way, we only require one modular inversion for an arbitrary number of elliptic curve operations, saving a significant amount of computation!

## Conclusion

In the previous article, we learned about the elliptic curve and the discrete logarithm problem. We then restricted the curve such that it can be computed by a computer with finite memory.

In this article, we transformed the curve onto a projective space and saw how it optimizes point arithmetic. After much math, we have arrived at a version of elliptic curves that is optimal for computers, and now have the necessary impetus to learn about elliptic curve cryptography.

## Theoretical Quest

### Part : Projective Coordinates in Elliptic Curves If only I could read these glyphs a little faster...