Skip to content

Commit f6ac254

Browse files
committed
Move normalize() into is_odd()
1 parent 8a44a3f commit f6ac254

File tree

4 files changed

+4
-5
lines changed

4 files changed

+4
-5
lines changed

k256/src/arithmetic/affine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl DecompressPoint<Secp256k1> for AffinePoint {
154154
let y = FieldElement::conditional_select(
155155
&beta.negate(1),
156156
&beta,
157-
beta.normalize().is_odd().ct_eq(&y_is_odd),
157+
beta.is_odd().ct_eq(&y_is_odd),
158158
);
159159

160160
Self {

k256/src/arithmetic/field/field_impl.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ impl FieldElementImpl {
8989
}
9090

9191
pub fn is_odd(&self) -> Choice {
92-
debug_assert!(self.normalized);
93-
self.value.is_odd()
92+
self.normalize().value.is_odd()
9493
}
9594

9695
pub fn negate(&self, magnitude: u32) -> Self {

k256/src/arithmetic/hash2curve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl OsswuMap for FieldElement {
126126
// if e2, y = y1, else y = y2
127127
let mut y = Self::conditional_select(&y2, &y1, e2);
128128

129-
y.conditional_assign(&-y, self.normalize().sgn0() ^ y.normalize().sgn0());
129+
y.conditional_assign(&-y, self.sgn0() ^ y.sgn0());
130130
(x, y)
131131
}
132132
}

k256/src/ecdsa/sign.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl SignPrimitive<Secp256k1> for Scalar {
183183
}
184184

185185
let signature = Signature::from_scalars(r, s)?;
186-
let is_r_odd: bool = R.y.normalize().is_odd().into();
186+
let is_r_odd: bool = R.y.is_odd().into();
187187
let is_s_high: bool = signature.s().is_high().into();
188188
let signature_low = signature.normalize_s().unwrap_or(signature);
189189
let recovery_id = ecdsa_core::RecoveryId::new(is_r_odd ^ is_s_high, false);

0 commit comments

Comments
 (0)