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.

332 Chapter 7 ELLIPTIC CURVE ARITHMETIC<br />

2. [Begin Montgomery adding/doubling ladder]<br />

[U : V ]=[X : Z]; // Copy coordinate.<br />

[T : W ]=doubleh([X : Z]);<br />

3. [Loop over bits of n, starting with next-to-highest]<br />

for(B − 2 ≥ j ≥ 0) {<br />

if(nj == 1) {<br />

[U : V ]=addh([T : W ], [U : V ], [X : Z]);<br />

[T : W ]=doubleh([T : W ]);<br />

} else {<br />

[T : W ]=addh([U : V ], [T : W ], [X : Z]);<br />

[U : V ]=doubleh([U : V ]);<br />

}<br />

}<br />

4. [Final calculation]<br />

if(n0 == 1) return addh([U : V ], [T : W ], [X : Y ]);<br />

return doubleh([U : V ]);<br />

Montgomery’s rules when B = 0 make for an efficient algorithm, as can<br />

be seen from the simplification of the addh() and doubleh() function forms.<br />

In particular, the addh() and doubleh() functions can each be done in 9<br />

multiplications. In the case B =0,A= 1, the operation count drops further.<br />

We have noted that to get the affine x-coordinate of [n]P , one must<br />

compute XZ −1 in the field. When n is very large, the single inversion is,<br />

of course, not expensive in comparison. But such inversion can sometimes<br />

be avoided entirely. For example, if, as in factoring studies covered later, we<br />

wish to know whether [n]P =[m]P in the elliptic-curve group, it is enough<br />

to check whether the cross product XnZm − XmZn vanishes, and this is yet<br />

another inversion-free task. Similarly, there is a very convenient fact: If the<br />

point at infinity has been attained by some multiple [n]P = O, then the Z<br />

denominator will have vanished, and any further multiples [mn]P will also<br />

have vanishing Z denominator. Because of this, one need not find the precise<br />

multiple when O is attained; the fact of Z = 0 propagates nicely through<br />

successive applications of the elliptic multiply functions.<br />

We have observed that only x-coordinates of multiples [n]P are processed<br />

in Algorithm 7.2.7, and that ignorance of y values is acceptable in certain<br />

implementations. It is not easy to add two arbitrary points with the<br />

homogeneous coordinate approach above, because of the suppression of y<br />

coordinates. But all is not lost: There is a useful result that tells very quickly<br />

whether the sum of two points can possibly be a given third point. That is,<br />

given merely the x-coordinates of two points P1,P2 the following algorithm<br />

can be used to determine the two x-coordinates for the pair P1 ± P2, although<br />

which of the coordinates goes with the + and which with − will be unknown.

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

Saved successfully!

Ooh no, something went wrong!