@@ -3,42 +3,6 @@ use fp2::traits::Fp2 as FqTrait;
3
3
use super :: { curve:: Curve , point:: PointX } ;
4
4
5
5
impl < Fq : FqTrait > Curve < Fq > {
6
- /// Compute a curve from the projective coordinates of (A + 2) / 4 = (A24 : C24)
7
- #[ inline]
8
- fn curve_from_A24_proj ( A24 : & Fq , C24 : & Fq ) -> Curve < Fq > {
9
- // Compute A from (A24 : C24)
10
- let mut A = ( * A24 ) + ( * A24 ) ;
11
- A -= * C24 ;
12
- A += A ;
13
- A /= * C24 ;
14
-
15
- Curve :: new ( & A )
16
- }
17
-
18
- /// Compute [2]P in place using projective (A + 2) / 4 = (A24 : C24)
19
- /// Cost: 2S + 4M
20
- #[ inline( always) ]
21
- fn xdbl_proj ( A24 : & Fq , C24 : & Fq , P : & mut PointX < Fq > ) {
22
- let mut t0 = P . X + P . Z ;
23
- t0. set_square ( ) ;
24
- let mut t1 = P . X - P . Z ;
25
- t1. set_square ( ) ;
26
- let t2 = t0 - t1;
27
- t1 *= * C24 ;
28
- P . X = t0 * t1;
29
- t0 = t2 * ( * A24 ) ;
30
- t0 += t1;
31
- P . Z = t0 * t2;
32
- }
33
-
34
- /// Compute \[2^n\]P in place using projective (A + 2) / 4 = (A24 : C24).
35
- /// Cost: n * (2S + 4M)
36
- fn xdbl_proj_iter ( A24 : & Fq , C24 : & Fq , P : & mut PointX < Fq > , n : usize ) {
37
- for _ in 0 ..n {
38
- Self :: xdbl_proj ( A24 , C24 , P ) ;
39
- }
40
- }
41
-
42
6
/// Compute the codomain of the 2-isogeny E -> E/<ker> for ker != (0 : 1)
43
7
fn two_isogeny_codomain ( ker : & PointX < Fq > ) -> ( Fq , Fq ) {
44
8
let mut A24 = ker. X . square ( ) ;
@@ -144,7 +108,7 @@ impl<Fq: FqTrait> Curve<Fq> {
144
108
n : usize ,
145
109
images : & mut [ PointX < Fq > ] ,
146
110
allow_singular : bool ,
147
- ) -> ( Curve < Fq > , u32 ) {
111
+ ) -> ( Self , u32 ) {
148
112
let mut A24 = self . A24 ;
149
113
let mut C24 = Fq :: ONE ;
150
114
@@ -162,7 +126,7 @@ impl<Fq: FqTrait> Curve<Fq> {
162
126
if i == 0 {
163
127
// First check if the kernel has the correct order.
164
128
let mut inf = ker_step;
165
- Self :: xdbl_proj ( & A24 , & C24 , & mut inf) ;
129
+ Self :: xdbl_proj ( & A24 , & C24 , & mut inf. X , & mut inf . Z ) ;
166
130
if ( !ker_step. Z . is_zero ( ) & inf. Z . is_zero ( ) ) != u32:: MAX {
167
131
return ( * self , 0 ) ;
168
132
}
@@ -212,7 +176,7 @@ impl<Fq: FqTrait> Curve<Fq> {
212
176
kernel : & PointX < Fq > ,
213
177
n : usize ,
214
178
images : & mut [ PointX < Fq > ] ,
215
- ) -> ( Curve < Fq > , u32 ) {
179
+ ) -> ( Self , u32 ) {
216
180
// For 2-isogenies we represent (A + 2) / 4 projectively as (A24 : C24)
217
181
let mut A24 = self . A24 ;
218
182
let mut C24 = Fq :: ONE ;
@@ -257,13 +221,13 @@ impl<Fq: FqTrait> Curve<Fq> {
257
221
let mut tmp = ker_step;
258
222
259
223
// Ensure that the [2]ker is not (0 : 1)
260
- Self :: xdbl_proj ( & A24 , & C24 , & mut tmp) ;
224
+ Self :: xdbl_proj ( & A24 , & C24 , & mut tmp. X , & mut tmp . Z ) ;
261
225
ok &= !tmp. X . is_zero ( ) ;
262
226
263
227
// Ensure that the kernel has exact order
264
228
// [2]ker != 0 and [4]ker = 0
265
229
ok &= !tmp. Z . is_zero ( ) ;
266
- Self :: xdbl_proj ( & A24 , & C24 , & mut tmp) ;
230
+ Self :: xdbl_proj ( & A24 , & C24 , & mut tmp. X , & mut tmp . Z ) ;
267
231
ok &= tmp. Z . is_zero ( ) ;
268
232
}
269
233
@@ -294,7 +258,7 @@ impl<Fq: FqTrait> Curve<Fq> {
294
258
295
259
// Ensure the point has order exactly 2
296
260
let mut tmp = ker_step;
297
- Self :: xdbl_proj ( & A24 , & C24 , & mut tmp) ;
261
+ Self :: xdbl_proj ( & A24 , & C24 , & mut tmp. X , & mut tmp . Z ) ;
298
262
ok &= tmp. Z . is_zero ( ) ;
299
263
300
264
// Compute the codomain from ker_step
0 commit comments