@@ -295,7 +295,7 @@ where
295
295
// Even a single zero value will fail inversion for the entire batch.
296
296
// Put a dummy value (above `FieldElement::ONE`) so inversion succeeds
297
297
// and treat that case specially later-on.
298
- zs. as_mut ( ) [ i] . conditional_assign ( & points[ i] . z , !points[ i] . z . ct_eq ( & FieldElement :: ZERO ) ) ;
298
+ zs. as_mut ( ) [ i] . conditional_assign ( & points[ i] . z , !points[ i] . z . normalizes_to_zero ( ) ) ;
299
299
}
300
300
301
301
// This is safe to unwrap since we assured that all elements are non-zero
@@ -307,7 +307,7 @@ where
307
307
out[ i] = AffinePoint :: conditional_select (
308
308
& points[ i] . to_affine_internal ( zs_inverses. as_ref ( ) [ i] ) ,
309
309
& AffinePoint :: IDENTITY ,
310
- points[ i] . z . ct_eq ( & FieldElement :: ZERO ) ,
310
+ points[ i] . z . normalizes_to_zero ( ) ,
311
311
) ;
312
312
}
313
313
}
@@ -721,17 +721,20 @@ mod tests {
721
721
<ProjectivePoint as group:: Curve >:: batch_normalize ( & [ g, h] , & mut res) ;
722
722
assert_eq ! ( res, expected) ;
723
723
724
- let expected = [ g. to_affine ( ) , AffinePoint :: IDENTITY ] ;
724
+ let mut res = [ AffinePoint :: IDENTITY ; 3 ] ;
725
+ let non_normalized_identity = ProjectivePoint :: IDENTITY * Scalar :: random ( & mut OsRng ) ;
726
+ let expected = [ g. to_affine ( ) , AffinePoint :: IDENTITY , AffinePoint :: IDENTITY ] ;
725
727
assert_eq ! (
726
728
<ProjectivePoint as BatchNormalize <_>>:: batch_normalize( & [
727
729
g,
728
- ProjectivePoint :: IDENTITY
730
+ ProjectivePoint :: IDENTITY ,
731
+ non_normalized_identity,
729
732
] ) ,
730
733
expected
731
734
) ;
732
735
733
736
<ProjectivePoint as group:: Curve >:: batch_normalize (
734
- & [ g, ProjectivePoint :: IDENTITY ] ,
737
+ & [ g, ProjectivePoint :: IDENTITY , non_normalized_identity ] ,
735
738
& mut res,
736
739
) ;
737
740
assert_eq ! ( res, expected) ;
0 commit comments