File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -333,12 +333,14 @@ impl EdwardsPoint {
333333
334334 let affine = self . to_affine ( ) ;
335335
336- // TODO: optimize to a single inversion.
337336 let xx = affine. x . square ( ) ;
338337 let yy = affine. y . square ( ) ;
339338
340- let u = yy * xx. invert ( ) ;
341- let v = ( FieldElement :: TWO - xx - yy) * affine. y * ( xx * affine. x ) . invert ( ) ;
339+ let v_den = xx * affine. x ;
340+ let den = ( xx * v_den) . invert ( ) ;
341+
342+ let u = yy * v_den * den;
343+ let v = ( FieldElement :: TWO - xx - yy) * affine. y * xx * den;
342344
343345 AffineMontgomeryPoint :: conditional_select (
344346 & AffineMontgomeryPoint :: new ( u, v) ,
Original file line number Diff line number Diff line change @@ -129,8 +129,11 @@ impl From<&AffineMontgomeryPoint> for AffinePoint {
129129 t4 = t1 * t2; // 2x^2y^2+2y^2
130130 let yDen = t5 - t4; // yDen = x^5-2x^3+x-2x^2y^2-2y^2
131131
132- let x = xNum * xDen. invert ( ) ;
133- let y = yNum * yDen. invert ( ) ;
132+ let commonDen = xDen * yDen;
133+ let invDen = commonDen. invert ( ) ;
134+
135+ let x = xNum * yDen * invDen;
136+ let y = yNum * xDen * invDen;
134137
135138 AffinePoint :: conditional_select (
136139 & AffinePoint { x, y } ,
You can’t perform that action at this time.
0 commit comments