@@ -80,11 +80,11 @@ impl ExtendedPoint {
8080 /// Returns an extensible point
8181 /// (3.1) https://iacr.org/archive/asiacrypt2008/53500329/53500329.pdf
8282 pub fn add_extended ( & self , other : & ExtendedPoint ) -> ExtensiblePoint {
83- let A = self . X * other. X ;
84- let B = self . Y * other. Y ;
85- let C = self . T * other. T * FieldElement :: TWISTED_D ;
86- let D = self . Z * other. Z ;
87- let E = ( self . X + self . Y ) * ( other . X + other . Y ) - A - B ;
83+ let A = ( self . Y - self . X ) * ( other. Y - other . X ) ;
84+ let B = ( self . Y + self . X ) * ( other. Y + other . X ) ;
85+ let C = FieldElement :: TWO_TIMES_TWISTED_D * self . T * other. T ;
86+ let D = ( self . Z * other. Z ) . double ( ) ;
87+ let E = B - A ;
8888 let F = D - C ;
8989 let G = D + C ;
9090 let H = B + A ;
@@ -97,27 +97,6 @@ impl ExtendedPoint {
9797 }
9898 }
9999
100- /// Subtracts an extensible point from an extended point
101- /// Returns an extensible point
102- /// This is a direct modification of the addition formula to the negation of `other`
103- pub fn sub_extended ( & self , other : & ExtendedPoint ) -> ExtensiblePoint {
104- let A = self . X * other. X ;
105- let B = self . Y * other. Y ;
106- let C = self . T * other. T * FieldElement :: TWISTED_D ;
107- let D = self . Z * other. Z ;
108- let E = ( self . X + self . Y ) * ( other. Y - other. X ) + A - B ;
109- let F = D + C ;
110- let G = D - C ;
111- let H = B - A ;
112- ExtensiblePoint {
113- X : E * F ,
114- Y : G * H ,
115- T1 : E ,
116- T2 : H ,
117- Z : F * G ,
118- }
119- }
120-
121100 /// Adds an extensible point to an AffineNiels point
122101 /// Returns an Extensible point
123102 pub fn add_affine_niels ( & self , other : AffineNielsPoint ) -> ExtensiblePoint {
@@ -297,19 +276,6 @@ mod tests {
297276 assert ! ( c == c_1) ;
298277 }
299278
300- #[ test]
301- fn test_point_sub ( ) {
302- let a = TWISTED_EDWARDS_BASE_POINT ;
303- let b = a. to_extensible ( ) . double ( ) . to_extended ( ) ;
304-
305- // A - B = C
306- let c_1 = a. sub_extended ( & b) . to_extended ( ) ;
307-
308- // -B + A = C
309- let c_2 = b. negate ( ) . add_extended ( & a) . to_extended ( ) ;
310- assert ! ( c_1 == c_2) ;
311- }
312-
313279 #[ test]
314280 fn test_negate ( ) {
315281 let a = TWISTED_EDWARDS_BASE_POINT ;
0 commit comments