Skip to content

Commit 06bcf26

Browse files
authored
k256: use ORDER constant instead of reconstructing from ORDER_HEX (#1599)
1 parent e4f7778 commit 06bcf26

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

k256/src/arithmetic/scalar.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use core::{
1414
iter::{Product, Sum},
1515
ops::{Add, AddAssign, Mul, MulAssign, Neg, Shr, ShrAssign, Sub, SubAssign},
1616
};
17-
use elliptic_curve::bigint::Odd;
1817
use elliptic_curve::{
1918
Curve, Error, Generate, ScalarValue,
2019
bigint::{ArrayEncoding, Integer, Limb, U256, U512, Word, modular::Retrieve},
@@ -136,18 +135,14 @@ impl Scalar {
136135

137136
/// Returns the multiplicative inverse of self, if self is non-zero.
138137
pub fn invert(&self) -> CtOption<Self> {
139-
let inv = self
140-
.retrieve()
141-
.invert_odd_mod(const { &Odd::from_be_hex(ORDER_HEX) });
138+
let inv = self.retrieve().invert_odd_mod(&ORDER);
142139

143140
CtOption::from(inv).map(Self::from_uint_unchecked)
144141
}
145142

146143
/// Returns the multiplicative inverse of self in variable-time, if self is non-zero.
147144
pub fn invert_vartime(&self) -> CtOption<Self> {
148-
let inv = self
149-
.retrieve()
150-
.invert_odd_mod_vartime(const { &Odd::from_be_hex(ORDER_HEX) });
145+
let inv = self.retrieve().invert_odd_mod_vartime(&ORDER);
151146

152147
CtOption::from(inv).map(Self::from_uint_unchecked)
153148
}

0 commit comments

Comments
 (0)