Skip to content

Commit 28bb5d4

Browse files
authored
elliptic-curve: bump crypto-bigint to v0.7.0-rc.11 (#2153)
This includes a mostly-backwards-compatible migration from `subtle` to `ctutils`.
1 parent 7db7413 commit 28bb5d4

3 files changed

Lines changed: 34 additions & 13 deletions

File tree

Cargo.lock

Lines changed: 19 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

elliptic-curve/Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ and traits for representing various elliptic curve forms, scalars, points,
1616
and public/secret keys composed thereof.
1717
"""
1818

19+
[dependencies.crypto-bigint]
20+
version = "0.7.0-rc.11"
21+
default-features = false
22+
features = ["hybrid-array", "rand_core", "subtle", "zeroize"]
23+
1924
[dependencies]
2025
base16ct = "0.3"
21-
crypto-bigint = { version = "0.7.0-rc.10", default-features = false, features = ["rand_core", "hybrid-array", "zeroize"] }
2226
hybrid-array = { version = "0.4", default-features = false, features = ["zeroize"] }
2327
rand_core = { version = "0.10.0-rc-3", default-features = false }
2428
subtle = { version = "2.6", default-features = false }

elliptic-curve/src/scalar/value.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ where
6666
/// Generate a random [`ScalarValue`].
6767
pub fn random<R: CryptoRng + ?Sized>(rng: &mut R) -> Self {
6868
Self {
69-
inner: C::Uint::random_mod(rng, Self::MODULUS.as_nz_ref()),
69+
inner: C::Uint::random_mod_vartime(rng, Self::MODULUS.as_nz_ref()),
7070
}
7171
}
7272

7373
/// Create a new scalar from [`Curve::Uint`].
7474
pub fn new(uint: C::Uint) -> CtOption<Self> {
75-
CtOption::new(Self { inner: uint }, uint.ct_lt(&Self::MODULUS))
75+
CtOption::new(Self { inner: uint }, uint.ct_lt(&Self::MODULUS).into())
7676
}
7777

7878
/// Decode [`ScalarValue`] from a serialized field element
@@ -98,17 +98,17 @@ where
9898

9999
/// Is this [`ScalarValue`] value equal to zero?
100100
pub fn is_zero(&self) -> Choice {
101-
self.inner.is_zero()
101+
self.inner.is_zero().into()
102102
}
103103

104104
/// Is this [`ScalarValue`] value even?
105105
pub fn is_even(&self) -> Choice {
106-
self.inner.is_even()
106+
self.inner.is_even().into()
107107
}
108108

109109
/// Is this [`ScalarValue`] value odd?
110110
pub fn is_odd(&self) -> Choice {
111-
self.inner.is_odd()
111+
self.inner.is_odd().into()
112112
}
113113

114114
/// Encode [`ScalarValue`] as a serialized field element.
@@ -160,7 +160,7 @@ where
160160
{
161161
fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self {
162162
Self {
163-
inner: C::Uint::conditional_select(&a.inner, &b.inner, choice),
163+
inner: C::Uint::ct_select(&a.inner, &b.inner, choice.into()),
164164
}
165165
}
166166
}
@@ -170,7 +170,7 @@ where
170170
C: Curve,
171171
{
172172
fn ct_eq(&self, other: &Self) -> Choice {
173-
self.inner.ct_eq(&other.inner)
173+
self.inner.ct_eq(&other.inner).into()
174174
}
175175
}
176176

@@ -179,7 +179,7 @@ where
179179
C: Curve,
180180
{
181181
fn ct_lt(&self, other: &Self) -> Choice {
182-
self.inner.ct_lt(&other.inner)
182+
self.inner.ct_lt(&other.inner).into()
183183
}
184184
}
185185

@@ -188,7 +188,7 @@ where
188188
C: Curve,
189189
{
190190
fn ct_gt(&self, other: &Self) -> Choice {
191-
self.inner.ct_gt(&other.inner)
191+
self.inner.ct_gt(&other.inner).into()
192192
}
193193
}
194194

@@ -357,7 +357,7 @@ where
357357
{
358358
fn is_high(&self) -> Choice {
359359
let n_2 = Self::MODULUS.get() >> 1u32;
360-
self.inner.ct_gt(&n_2)
360+
self.inner.ct_gt(&n_2).into()
361361
}
362362
}
363363

0 commit comments

Comments
 (0)