# What are some restrictions when converting Montgomery Curves into Weierstrass Curves?

I want to represent a Montgomery Curve (curve25519) in Weierstrass form as a personal exercise.

After doing some math and referencing the conversion equation at http://en.wikipedia.org/wiki/Montgomery_curve, several of my terms contain decimals, which I believe is incorrect. Namely,

(3-A^2) / (3*B^2)

is a decimal, when A = 486662 and B = 1 and doing it directly.

Note that (3-A^2) is negative, so I added the modulus to it to make it positive, which then enables the division by 3 properly as shown here, b

Are there restrictions on which Montgomery curves can be converted to Weierstrass curves?

• Wouldn't you do those conversion equations within the field, and not in the reals? That is, do the addition, subtraction and multiplication modulo the prime, and division by computing the modular inverse? Feb 7, 2014 at 14:30

My comment already gave you the answer; I'm submitting an official answer to give you something to upvote :-)

An elliptic curve is defined within a field; in the case of curve25519, it is defined within the field $GF(2^{255}-19)$; this is a prime field, because $2^{255}-19$ is prime.

So, when we get to the conversion formulas such as $\frac{3 - A^2}{3\cdot B^2}$, this formula is done within the field the curve is defined in.

Because this is a prime field, addition and multiplication can be implemented by addition and multiplication modulo $2^{255}-19$. However, division is trickier; it's typically done by computing the modular inverse of the divisor.

The one glitch is converting the Curve25519 generator, which is defined as $x=9$; they omit the y-coordinate, and hence corresponds to two elliptic curve points (as there are two different solutions on the curve equation with $x=9$). This translates into two different points on the Weierstrass curve (which share the $x$ coordinate as well); you can either say that the conversion is that translated $x$ coordinate, or arbitrarily pick one of the valid $y$ coordinates.