Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion elliptic-curve/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ and traits for representing various elliptic curve forms, scalars, points,
and public/secret keys composed thereof.
"""

[dependencies.crypto-bigint]
version = "0.7.0-rc.11"
default-features = false
features = ["hybrid-array", "rand_core", "subtle", "zeroize"]

[dependencies]
base16ct = "0.3"
crypto-bigint = { version = "0.7.0-rc.10", default-features = false, features = ["rand_core", "hybrid-array", "zeroize"] }
hybrid-array = { version = "0.4", default-features = false, features = ["zeroize"] }
rand_core = { version = "0.10.0-rc-3", default-features = false }
subtle = { version = "2.6", default-features = false }
Expand Down
20 changes: 10 additions & 10 deletions elliptic-curve/src/scalar/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ where
/// Generate a random [`ScalarValue`].
pub fn random<R: CryptoRng + ?Sized>(rng: &mut R) -> Self {
Self {
inner: C::Uint::random_mod(rng, Self::MODULUS.as_nz_ref()),
inner: C::Uint::random_mod_vartime(rng, Self::MODULUS.as_nz_ref()),
}
}

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

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

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

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

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

/// Encode [`ScalarValue`] as a serialized field element.
Expand Down Expand Up @@ -160,7 +160,7 @@ where
{
fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self {
Self {
inner: C::Uint::conditional_select(&a.inner, &b.inner, choice),
inner: C::Uint::ct_select(&a.inner, &b.inner, choice.into()),
}
}
}
Expand All @@ -170,7 +170,7 @@ where
C: Curve,
{
fn ct_eq(&self, other: &Self) -> Choice {
self.inner.ct_eq(&other.inner)
self.inner.ct_eq(&other.inner).into()
}
}

Expand All @@ -179,7 +179,7 @@ where
C: Curve,
{
fn ct_lt(&self, other: &Self) -> Choice {
self.inner.ct_lt(&other.inner)
self.inner.ct_lt(&other.inner).into()
}
}

Expand All @@ -188,7 +188,7 @@ where
C: Curve,
{
fn ct_gt(&self, other: &Self) -> Choice {
self.inner.ct_gt(&other.inner)
self.inner.ct_gt(&other.inner).into()
}
}

Expand Down Expand Up @@ -357,7 +357,7 @@ where
{
fn is_high(&self) -> Choice {
let n_2 = Self::MODULUS.get() >> 1u32;
self.inner.ct_gt(&n_2)
self.inner.ct_gt(&n_2).into()
}
}

Expand Down