Before considering the projective plane over (\Z/n\Z)/\sim, first consider a 'normal'
projective space over \mathbb{R}: Instead of points, lines through the origin are studied. A line may be represented as a non-zero point (x,y,z), under an equivalence relation ~ given by: (x,y,z)\sim(x',y',z') ⇔ ∃
c ≠ 0 such that ''x' =
cx
, y' =
cy
and z' =
cz''. Under this equivalence relation, the space is called
the projective plane \mathbb{P}^2; points, denoted by (x:y:z), correspond to lines in a three-dimensional space that pass through the origin. Note that the point (0:0:0) does not exist in this space since to draw a line in any possible direction requires at least one of x',y' or z' ≠ 0. Now observe that almost all lines go through any given reference plane - such as the (
X,
Y,1)-plane, whilst the lines precisely parallel to this plane, having coordinates (
X,Y,0), specify directions uniquely, as 'points at infinity' that are used in the affine (
X,Y)-plane it lies above. The corrdinate (x:y:z) corresponds to (x/z:y/z) in affine space. In the algorithm, only the group structure of an elliptic curve over the field \mathbb{R} is used. Since we do not necessarily need the field \mathbb{R}, a finite field will also provide a group structure on an elliptic curve. However, considering the same curve and operation over (\Z/n\Z)/\sim with not a prime does not give a group. The Elliptic Curve Method makes use of the failure cases of the addition law. We now state the algorithm in projective coordinates. The neutral element is then given by the point at infinity (0:1:0). Let be a (positive) integer to be factored and consider the elliptic curve (a set of points with some structure on it) E(\Z/n\Z)=\{(x:y:z) \in \mathbb{P}^2\ |\ y^2z=x^3+axz^2+bz^3\}. • Pick x_P,y_P,a \in \Z/n\Z with ≠ 0. • Calculate b = y_P^2 - x_P^3 - ax_P. The elliptic curve is then in Weierstrass form given by y^2 = x^3 + ax + b and by using projective coordinates the elliptic curve is given by the homogeneous equation ZY^2=X^3+aZ^2X+bZ^3. It has the point P=(x_P:y_P:1). • Choose an upperbound B \in \Z for this elliptic curve. • Remark: You will only find factors if the group order of the elliptic curve over \Z/p\Z (denoted by \#E(\Z/p\Z)) is
B-smooth, which means that all prime factors of n have to be less or equal to . • Calculate k={\rm lcm}(1,\dots ,B). • Calculate kP := P + P + \cdots + P (multiplication is repeated addition) in the ring E(\Z/n\Z). • If the calculation successfully returns kP = (0:1:0), it means is not -smooth or is prime. Go back to step 2 to pick another curve. • If the calculation fails at some point, it means a non-trivial divisor can be found. It can fail because addition and multiplication are not well-defined if is not prime, but this only occurs when a inversion of a particular residue is tried. In this case the factor is found as \gcd(v,n) as above. In point 5 it is said that under the right circumstances a non-trivial divisor can be found. As pointed out in Lenstra's article (Factoring Integers with Elliptic Curves) the addition needs the assumption \gcd(x_1-x_2,n)=1. If P,Q are not (0:1:0) and distinct (otherwise addition works similarly, but is a little different), then addition works as follows: • To calculate: R = P + Q; P = (x_1:y_1:1), Q = (x_2:y_2:1), • \lambda =(y_1-y_2) (x_1-x_2)^{-1}, • x_3 = \lambda^2 - x_1 - x_2, • y_3 = \lambda(x_1-x_3) - y_1, • R = P + Q = (x_3:y_3:1). If addition fails, this will be due to a failure calculating \lambda. In particular, because (x_1-x_2)^{-1} can not always be calculated if is not prime (and therefore \Z/n\Z is not a field). Without making use of \Z/n\Z being a field, one could calculate: • \lambda'=y_1-y_2, • x_3' = {\lambda'}^2 - x_1(x_1-x_2)^2 - x_2(x_1-x_2)^2, • y_3' = \lambda'(x_1(x_1-x_2)^2-x_3') - y_1(x_1-x_2)^3, • R = P + Q = (x_3'(x_1-x_2):y_3':(x_1-x_2)^3), and simplify if possible. This calculation is always legal and if the gcd of the -coordinate with ≠ (1 or ), so when simplifying fails, a non-trivial divisor of is found.
Two-stage variant Analogous to the
two-stage variant of Pollard's p − 1 algorithm, Lenstra ECM can too be done in two stages. This allows one to save a time factor of O(log
p). • For each prime , B_1 \leq p \leq B_2, • Compute a point (x_p:y_p:z_p) = pQ on . • Compute g := \operatorname{gcd}\left(n, z_p\right). If g \neq 1, output g and exit. • If all primes in range are tried without producing a factor, report failure. It is possible for stage 1 to yield a factor like previously discussed: a non-invertible denominator implies a factor. B_1 is functionally the same as B from the standard version, so it too happens when the group order is
B-smooth. In other words, one looks for a prime divisor such that sP is the neutral element of E(\mathbb{Z}/p\mathbb{Z}) in stage 1. The second stage is very similar to the second stage of p-1 and p+1. It is a continuation of the work in stage 1 and can be described using very similar mathematical terms. It relaxes the condition such that one can find a factor when is (B_1, B_2)-smooth, or in other words the largest prime factor of is at most B_2 and the second-smallest is at most B_1. To achieve stage 2, one hopes there is a prime between B_1 and B_2 such that pQ = (0:1:0) \mod p; looking for a failed inversion would produce it after a gcd. Equivalently, one is looking for a prime divisor such that sP has small prime order in E(\mathbb{Z}/q\mathbb{Z}). Checking for a small order of sP is done in stage 2 by computing (ls)P modulo for each prime . This approach was later extended to p-1 and p+1.(Montgomery and Kruppa 2008). ==Twisted Edwards curves==