File tree Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -104,6 +104,18 @@ impl ops::AddAssign<&AffinePoint> for AffinePoint {
104
104
}
105
105
}
106
106
107
+ impl ops:: Neg for & AffinePoint {
108
+ type Output = AffinePoint ;
109
+
110
+ fn neg ( self ) -> AffinePoint {
111
+ AffinePoint {
112
+ x : self . x ,
113
+ y : -self . y ,
114
+ infinity : self . infinity ,
115
+ }
116
+ }
117
+ }
118
+
107
119
impl ops:: Sub < & AffinePoint > for & AffinePoint {
108
120
type Output = AffinePoint ;
109
121
@@ -116,11 +128,7 @@ impl ops::Sub<&AffinePoint> for &AffinePoint {
116
128
117
129
impl ops:: SubAssign < & AffinePoint > for AffinePoint {
118
130
fn sub_assign ( & mut self , rhs : & AffinePoint ) {
119
- * self += & AffinePoint {
120
- x : rhs. x ,
121
- y : -rhs. y ,
122
- infinity : rhs. infinity ,
123
- } ;
131
+ * self += & -rhs;
124
132
}
125
133
}
126
134
@@ -195,10 +203,7 @@ impl ops::AddAssign<&AffinePoint> for ProjectivePoint {
195
203
return ;
196
204
}
197
205
if self . infinity {
198
- self . x = rhs. x ;
199
- self . y = rhs. y ;
200
- self . z = FieldElement :: ONE ;
201
- self . infinity = rhs. infinity ;
206
+ * self = Self :: from_affine_point ( rhs) ;
202
207
return ;
203
208
}
204
209
let u0 = self . x ;
@@ -208,11 +213,10 @@ impl ops::AddAssign<&AffinePoint> for ProjectivePoint {
208
213
if u0 == u1 {
209
214
if t0 != t1 {
210
215
self . infinity = true ;
211
- return ;
212
216
} else {
213
217
self . double_assign ( ) ;
214
- return ;
215
218
}
219
+ return ;
216
220
}
217
221
218
222
let t = t0 - t1;
You can’t perform that action at this time.
0 commit comments