Prime Numbers
Prime Numbers Prime Numbers
7.2 Elliptic arithmetic 325 with ECM, in which case inversion (mod n) for the composite n can be avoided altogether. As for explicit elliptic-curve arithmetic, we shall start for completeness with option (1), though the operations for this option are easy to infer directly from Definition 7.1.2. An important note: The operations are given here and in subsequent algorithms for underlying field F , although further work with “pseudocurves” as in factorization of composite n involves using the ring Zn with operations mod n instead of mod p, while extension to fields F p k involves straightforward polynomial or equivalent arithmetic, and so on. Algorithm 7.2.2 (Elliptic addition: Affine coordinates). We assume an elliptic curve E(F ) (see note preceding this algorithm), given by the affine equation Y 2 = X 3 + aX + b, where a, b ∈ F and the characteristic of the field F is not equal to 2 or 3. We represent points P as triples (x, y, z), where for an affine point, z =1and (x, y) lies on the affine curve, and for O, the point at infinity, z =0 (the triples (0, 1, 0), (0, −1, 0), both standing for the same point). This algorithm provides functions for point negation, doubling, addition, and subtraction. 1. [Elliptic negate function] neg(P ) return (x, −y, z); 2. [Elliptic double function] double(P ) return add(P, P); 3. [Elliptic add function] add(P1,P2){ if(z1 == 0) return P2; // Point P1 = O. if(z2 == 0) return P1; // Point P2 = O. if(x1 == x2) { if(y1 + y2 == 0) return (0, 1, 0); // i.e., return O. m =(3x 2 1 + a)(2y1) −1 ; // Inversion in the field F . } else { m =(y2 − y1)(x2 − x1) −1 ; // Inversion in the field F . } x3 = m 2 − x1 − x2; return (x3,m(x1 − x3) − y1, 1); } 4. [Elliptic subtract function] sub(P1,P2) return add(P1,neg(P2)); In the case of option (2) using ordinary projective coordinates, consider the curve Y 2 Z = X 3 + aXZ 2 + bZ 3 and points Pi =[Xi,Yi,Zi] fori =1, 2. Rule (5) of Definition 7.1.2, for P1 + P2 when P1 = ±P2 and neither P1,P2 is O, becomes P3 = P1 + P2 =[X3,Y3,Z3], where X3 = α γ 2 ζ − α 2 β ,
326 Chapter 7 ELLIPTIC CURVE ARITHMETIC and Y3 = 1 2 2 3 γ 3α β − γ ζ − α δ , 2 Z3 = α 3 ζ, α = X2Z1 − X1Z2, β = X2Z1 + X1Z2, γ = Y2Z1 − Y1Z2, δ = Y2Z1 + Y1Z2, ζ = Z1Z2. By holding on to the intermediate calculations of α 2 ,α 3 ,α 2 β,γ 2 ζ, the coordinates of P1 +P2 may be computed in 14 field multiplications and 8 field additions (multiplication by 1/2 can generally be accomplished by a shift or an add and a shift). In the case of doubling a point by rule (5), if [2]P = O, the projective equations for are where [2]P = [2][X, Y, Z] =[X ′ ,Y ′ ,Z ′ ] X ′ = ν(µ 2 − 2λν), Y ′ = µ 3λν − µ 2 − 2Y 2 1 ν 2 , Z ′ = ν 3 , λ =2XY, µ =3X 2 + aZ 2 , ν =2YZ. So doubling can be accomplished in 13 field multiplications and 4 field additions. In both adding and doubling, no field inversions of variables are necessary. When using projective coordinates and starting from a given affine point (u, v), one easily creates projective coordinates by tacking on a 1 at the end, namely, creating the projective point [u, v, 1]. If one wishes to recover an affine point from [X, Y, Z] at the end of a long calculation, and if this is not the point at infinity, one computes Z −1 in the field, and has the affine point (XZ −1 ,YZ −1 ). We shall see that option (3) also avoids field inversions. In comparison with option (2), the addition for option (3) is more expensive, but the doubling for option (3) is cheaper. Since in a typical elliptic multiplication [n]P we would expect about twice as many doublings as additions, one can see that option (3) could well be preferable to option (2). Recalling the notation, we understand 〈X, Y, Z〉 to be the affine point (X/Z 2 ,Y/Z 3 )ony 2 = x 3 + ax + b if Z = 0, and we understand 〈0, 1, 0〉 to be the point at infinity. Again, if we start with an affine point (u, v) on the curve and wish to convert to modified projective coordinates, we just tack on a 1 at the end, creating the point 〈u, v, 1〉. Andif one has a modified projective point 〈X, Y, Z〉 that is not the point at infinity, and one wishes to find the affine point corresponding to it, one computes Z −1 ,Z −2 ,Z −3 and the affine point (XZ −2 ,YZ −3 ). The following algorithm performs the algebra for modified projective coordinates, option (3).
- Page 284 and 285: 274 Chapter 6 SUBEXPONENTIAL FACTOR
- Page 286 and 287: 276 Chapter 6 SUBEXPONENTIAL FACTOR
- Page 288 and 289: 278 Chapter 6 SUBEXPONENTIAL FACTOR
- Page 290 and 291: 280 Chapter 6 SUBEXPONENTIAL FACTOR
- Page 292 and 293: 282 Chapter 6 SUBEXPONENTIAL FACTOR
- Page 294 and 295: 284 Chapter 6 SUBEXPONENTIAL FACTOR
- Page 296 and 297: 286 Chapter 6 SUBEXPONENTIAL FACTOR
- Page 298 and 299: 288 Chapter 6 SUBEXPONENTIAL FACTOR
- Page 300 and 301: 290 Chapter 6 SUBEXPONENTIAL FACTOR
- Page 302 and 303: 292 Chapter 6 SUBEXPONENTIAL FACTOR
- Page 304 and 305: 294 Chapter 6 SUBEXPONENTIAL FACTOR
- Page 306 and 307: 296 Chapter 6 SUBEXPONENTIAL FACTOR
- Page 308 and 309: 298 Chapter 6 SUBEXPONENTIAL FACTOR
- Page 310 and 311: 300 Chapter 6 SUBEXPONENTIAL FACTOR
- Page 312 and 313: 302 Chapter 6 SUBEXPONENTIAL FACTOR
- Page 314 and 315: 304 Chapter 6 SUBEXPONENTIAL FACTOR
- Page 316 and 317: 306 Chapter 6 SUBEXPONENTIAL FACTOR
- Page 318 and 319: 308 Chapter 6 SUBEXPONENTIAL FACTOR
- Page 320 and 321: 310 Chapter 6 SUBEXPONENTIAL FACTOR
- Page 322 and 323: 312 Chapter 6 SUBEXPONENTIAL FACTOR
- Page 324 and 325: 314 Chapter 6 SUBEXPONENTIAL FACTOR
- Page 326 and 327: 316 Chapter 6 SUBEXPONENTIAL FACTOR
- Page 328 and 329: Chapter 7 ELLIPTIC CURVE ARITHMETIC
- Page 330 and 331: 7.1 Elliptic curve fundamentals 321
- Page 332 and 333: 7.2 Elliptic arithmetic 323 the poi
- Page 336 and 337: 7.2 Elliptic arithmetic 327 Algorit
- Page 338 and 339: 7.2 Elliptic arithmetic 329 Before
- Page 340 and 341: 7.2 Elliptic arithmetic 331 the “
- Page 342 and 343: 7.3 The theorems of Hasse, Deuring,
- Page 344 and 345: 7.4 Elliptic curve method 335 a ran
- Page 346 and 347: 7.4 Elliptic curve method 337 B1 =
- Page 348 and 349: 7.4 Elliptic curve method 339 facto
- Page 350 and 351: 7.4 Elliptic curve method 341 propa
- Page 352 and 353: 7.4 Elliptic curve method 343 As fo
- Page 354 and 355: 7.4 Elliptic curve method 345 if(1
- Page 356 and 357: 7.5 Counting points on elliptic cur
- Page 358 and 359: 7.5 Counting points on elliptic cur
- Page 360 and 361: 7.5 Counting points on elliptic cur
- Page 362 and 363: 7.5 Counting points on elliptic cur
- Page 364 and 365: 7.5 Counting points on elliptic cur
- Page 366 and 367: 7.5 Counting points on elliptic cur
- Page 368 and 369: 7.5 Counting points on elliptic cur
- Page 370 and 371: 7.5 Counting points on elliptic cur
- Page 372 and 373: 7.5 Counting points on elliptic cur
- Page 374 and 375: 7.5 Counting points on elliptic cur
- Page 376 and 377: 7.5 Counting points on elliptic cur
- Page 378 and 379: 7.6 Elliptic curve primality provin
- Page 380 and 381: 7.6 Elliptic curve primality provin
- Page 382 and 383: 7.6 Elliptic curve primality provin
326 Chapter 7 ELLIPTIC CURVE ARITHMETIC<br />
and<br />
Y3 = 1 2 2 3<br />
γ 3α β − γ ζ − α δ ,<br />
2<br />
Z3 = α 3 ζ,<br />
α = X2Z1 − X1Z2, β = X2Z1 + X1Z2,<br />
γ = Y2Z1 − Y1Z2, δ = Y2Z1 + Y1Z2, ζ = Z1Z2.<br />
By holding on to the intermediate calculations of α 2 ,α 3 ,α 2 β,γ 2 ζ, the<br />
coordinates of P1 +P2 may be computed in 14 field multiplications and 8 field<br />
additions (multiplication by 1/2 can generally be accomplished by a shift or<br />
an add and a shift). In the case of doubling a point by rule (5), if [2]P = O,<br />
the projective equations for<br />
are<br />
where<br />
[2]P = [2][X, Y, Z] =[X ′ ,Y ′ ,Z ′ ]<br />
X ′ = ν(µ 2 − 2λν),<br />
Y ′ = µ 3λν − µ 2 − 2Y 2<br />
1 ν 2 ,<br />
Z ′ = ν 3 ,<br />
λ =2XY, µ =3X 2 + aZ 2 , ν =2YZ.<br />
So doubling can be accomplished in 13 field multiplications and 4 field<br />
additions. In both adding and doubling, no field inversions of variables are<br />
necessary.<br />
When using projective coordinates and starting from a given affine point<br />
(u, v), one easily creates projective coordinates by tacking on a 1 at the end,<br />
namely, creating the projective point [u, v, 1]. If one wishes to recover an<br />
affine point from [X, Y, Z] at the end of a long calculation, and if this is not<br />
the point at infinity, one computes Z −1 in the field, and has the affine point<br />
(XZ −1 ,YZ −1 ).<br />
We shall see that option (3) also avoids field inversions. In comparison with<br />
option (2), the addition for option (3) is more expensive, but the doubling for<br />
option (3) is cheaper. Since in a typical elliptic multiplication [n]P we would<br />
expect about twice as many doublings as additions, one can see that option (3)<br />
could well be preferable to option (2). Recalling the notation, we understand<br />
〈X, Y, Z〉 to be the affine point (X/Z 2 ,Y/Z 3 )ony 2 = x 3 + ax + b if Z = 0,<br />
and we understand 〈0, 1, 0〉 to be the point at infinity. Again, if we start with<br />
an affine point (u, v) on the curve and wish to convert to modified projective<br />
coordinates, we just tack on a 1 at the end, creating the point 〈u, v, 1〉. Andif<br />
one has a modified projective point 〈X, Y, Z〉 that is not the point at infinity,<br />
and one wishes to find the affine point corresponding to it, one computes<br />
Z −1 ,Z −2 ,Z −3 and the affine point (XZ −2 ,YZ −3 ). The following algorithm<br />
performs the algebra for modified projective coordinates, option (3).