Skip to content

Commit 9ca2984

Browse files
authored
elliptic-curve: bump crypto-bigint to v0.7.0-rc.1 (#1967)
This isn't ideal but gets the crate upgraded. I would like to experiment with changing `Curve::ORDER` to `NonZero` or `Odd` as a better solution
1 parent 373e153 commit 9ca2984

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

Cargo.lock

Lines changed: 2 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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ and public/secret keys composed thereof.
1818

1919
[dependencies]
2020
base16ct = "0.2"
21-
crypto-bigint = { version = "0.7.0-rc.0", default-features = false, features = ["rand_core", "hybrid-array", "zeroize"] }
21+
crypto-bigint = { version = "0.7.0-rc.1", default-features = false, features = ["rand_core", "hybrid-array", "zeroize"] }
2222
hybrid-array = { version = "0.3", default-features = false, features = ["zeroize"] }
2323
rand_core = { version = "0.9.0", default-features = false }
2424
subtle = { version = "2.6", default-features = false }

elliptic-curve/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ pub trait Curve: 'static + Copy + Clone + Debug + Default + Eq + Ord + Send + Sy
179179

180180
/// Order of this elliptic curve, i.e. number of elements in the scalar
181181
/// field.
182+
// TODO(tarcieri): make `NonZero` or `Odd`?
182183
const ORDER: Self::Uint;
183184
}
184185

elliptic-curve/src/scalar/primitive.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ where
6262
};
6363

6464
/// Scalar modulus.
65+
// TODO(tarcieri): make `NonZero` or `Odd`?
6566
pub const MODULUS: C::Uint = C::ORDER;
6667

6768
/// Generate a random [`ScalarPrimitive`].
@@ -254,7 +255,9 @@ where
254255

255256
fn add(self, other: &Self) -> Self {
256257
Self {
257-
inner: self.inner.add_mod(&other.inner, &Self::MODULUS),
258+
inner: self
259+
.inner
260+
.add_mod(&other.inner, &NonZero::new(Self::MODULUS).unwrap()),
258261
}
259262
}
260263
}
@@ -296,7 +299,9 @@ where
296299

297300
fn sub(self, other: &Self) -> Self {
298301
Self {
299-
inner: self.inner.sub_mod(&other.inner, &Self::MODULUS),
302+
inner: self
303+
.inner
304+
.sub_mod(&other.inner, &NonZero::new(Self::MODULUS).unwrap()),
300305
}
301306
}
302307
}
@@ -327,7 +332,7 @@ where
327332

328333
fn neg(self) -> Self {
329334
Self {
330-
inner: self.inner.neg_mod(&Self::MODULUS),
335+
inner: self.inner.neg_mod(&NonZero::new(Self::MODULUS).unwrap()),
331336
}
332337
}
333338
}

0 commit comments

Comments
 (0)