10.12.2012 Views

Prime Numbers

Prime Numbers

Prime Numbers

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

7.2 Elliptic arithmetic 327<br />

Algorithm 7.2.3 (Elliptic addition: Modified projective coordinates).<br />

We assume an elliptic curve E(F ) over a field F with characteristic = 2, 3<br />

(but see the note preceding Algorithm 7.2.2), given by the affine equation<br />

y 2 = x 3 +ax+b. For modified projective points of the general form P = 〈X, Y, Z〉,<br />

with 〈0, 1, 0〉, 〈0, −1, 0〉 both denoting the point at infinity P = O, this algorithm<br />

provides functions for point negation, doubling, addition, and subtraction.<br />

1. [Elliptic negate function]<br />

neg(P ) return 〈X, −Y,Z〉;<br />

2. [Elliptic double function]<br />

double(P ) {<br />

if(Y == 0 or Z == 0) return 〈0, 1, 0〉;<br />

M =(3X 2 + aZ 4 ); S =4XY 2 ;<br />

X ′ = M 2 − 2S; Y ′ = M(S − X2) − 8Y 4 ; Z ′ =2YZ;<br />

return 〈X ′ ,Y ′ ,Z ′ 〉;<br />

}<br />

3. [Elliptic add function]<br />

add(P1,P2) {<br />

if(Z1 == 0) return P2; // Point P1 = O.<br />

if(Z2 == 0) return P1; // Point P2 = O.<br />

U1 = X2Z 2 1; U2 = X1Z 2 2;<br />

S1 = Y2Z 3 1; S2 = Y1Z 3 2;<br />

W = U1 − U2; R = S1 − S2;<br />

if(W == 0) { // x-coordinates match.<br />

if(R == 0) return double(P1);<br />

return 〈0, 1, 0〉;<br />

}<br />

T = U1 + U2; M = S1 + S2;<br />

X3 = R 2 − TW 2 ;<br />

Y3 = 1<br />

2 ((TW2 − 2X3)R − MW 3 );<br />

Z3 = Z1Z2W ;<br />

return 〈X3,Y3,Z3〉;<br />

}<br />

4. [Elliptic subtract function]<br />

sub(P1,P2) {<br />

return add(P1,neg(P2));<br />

}<br />

It should be stressed that in all of our elliptic addition algorithms, if<br />

arithmetic is in Zn, modular reductions are taken whenever intermediate<br />

numbers exceed the modulus. This option (3) algorithm (modified projective<br />

coordinates) obviously has more field multiplications than does option (1)<br />

(affine coordinates), but as we have said, the idea is to avoid inversions (see<br />

Exercise 7.9). It is to be understood that in implementing Algorithm 7.2.3<br />

one should save some of the intermediate calculations for further use; not all<br />

of these are explicitly described in our algorithm display above. In particular,

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!