Skip to content

Commit

Permalink
This commit fixes the bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
ycscaly committed Feb 7, 2024
1 parent 754fbe2 commit 0668e01
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions k256/src/arithmetic/projective.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ where
// Even a single zero value will fail inversion for the entire batch.
// Put a dummy value (above `FieldElement::ONE`) so inversion succeeds
// and treat that case specially later-on.
zs.as_mut()[i].conditional_assign(&points[i].z, !points[i].z.ct_eq(&FieldElement::ZERO));
zs.as_mut()[i].conditional_assign(&points[i].z, !points[i].z.normalizes_to_zero());
}

// This is safe to unwrap since we assured that all elements are non-zero
Expand All @@ -307,7 +307,7 @@ where
out[i] = AffinePoint::conditional_select(
&points[i].to_affine_internal(zs_inverses.as_ref()[i]),
&AffinePoint::IDENTITY,
points[i].z.ct_eq(&FieldElement::ZERO),
points[i].z.normalizes_to_zero(),
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions primeorder/src/projective.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ where
// Even a single zero value will fail inversion for the entire batch.
// Put a dummy value (above `FieldElement::ONE`) so inversion succeeds
// and treat that case specially later-on.
zs.as_mut()[i].conditional_assign(&points[i].z, !points[i].z.ct_eq(&C::FieldElement::ZERO));
zs.as_mut()[i].conditional_assign(&points[i].z, !points[i].z.normalizes_to_zero());
}

// This is safe to unwrap since we assured that all elements are non-zero
Expand All @@ -405,7 +405,7 @@ where
out[i] = C::AffinePoint::conditional_select(
&points[i].to_affine_internal(zs_inverses.as_ref()[i]),
&C::AffinePoint::IDENTITY,
points[i].z.ct_eq(&C::FieldElement::ZERO),
points[i].z.normalizes_to_zero(),
);
}
}
Expand Down

0 comments on commit 0668e01

Please sign in to comment.