Skip to content

Commit

Permalink
Bump elliptic-curve to v0.14.0-pre.5
Browse files Browse the repository at this point in the history
Also bumps `ecdsa` to v0.17.0-pre.5

This includes upgrades to the new `LinearCombination` trait
  • Loading branch information
tarcieri committed Feb 2, 2024
1 parent ea9c6ee commit 1aad201
Show file tree
Hide file tree
Showing 18 changed files with 99 additions and 103 deletions.
57 changes: 29 additions & 28 deletions Cargo.lock

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

3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,3 @@ members = [

[profile.dev]
opt-level = 2

[patch.crates-io.sha2]
git = "https://github.com/RustCrypto/hashes.git"
8 changes: 4 additions & 4 deletions bign256/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ edition = "2021"
rust-version = "1.73"

[dependencies]
elliptic-curve = { version = "=0.14.0-pre.3", features = ["hazmat", "sec1"] }
elliptic-curve = { version = "=0.14.0-pre.5", features = ["hazmat", "sec1"] }

# optional dependencies
primeorder = { version = "=0.14.0-pre.0", optional = true, path = "../primeorder" }
signature = { version = "=2.3.0-pre.2", optional = true }
belt-hash = { version = "=0.2.0-pre.2", optional = true, default-features = false }
rfc6979 = { version = "=0.5.0-pre.2", optional = true }
signature = { version = "=2.3.0-pre.3", optional = true }
belt-hash = { version = "=0.2.0-pre.3", optional = true, default-features = false }
rfc6979 = { version = "=0.5.0-pre.3", optional = true }

[dev-dependencies]
criterion = "0.5"
Expand Down
10 changes: 4 additions & 6 deletions bign256/src/dsa/verifying.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,10 @@ impl PrehashVerifier<Signature> for VerifyingKey {
let right = s0.add(&Scalar::from_u64(2).pow([128, 0, 0, 0]));

// 5. Set 𝑅 ← (︀(𝑆1 + 𝐻) mod 𝑞)︀𝐺 + (𝑆0 + 2𝑙)𝑄.
let r = ProjectivePoint::lincomb(
&ProjectivePoint::generator(),
&left,
&self.public_key.to_projective(),
&right,
);
let r = ProjectivePoint::lincomb(&[
(ProjectivePoint::generator(), left),
(self.public_key.to_projective(), right),
]);

// 6. If 𝑅 = 𝑂, return NO.
if r.is_identity().into() {
Expand Down
6 changes: 3 additions & 3 deletions bp256/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ edition = "2021"
rust-version = "1.73"

[dependencies]
elliptic-curve = { version = "=0.14.0-pre.3", default-features = false, features = ["hazmat", "sec1"] }
elliptic-curve = { version = "=0.14.0-pre.5", default-features = false, features = ["hazmat", "sec1"] }

# optional dependencies
ecdsa = { version = "=0.17.0-pre.4", optional = true, default-features = false, features = ["der"] }
ecdsa = { version = "=0.17.0-pre.5", optional = true, default-features = false, features = ["der"] }
primeorder = { version = "=0.14.0-pre.0", optional = true, path = "../primeorder" }
sha2 = { version = "=0.11.0-pre.2", optional = true, default-features = false }
sha2 = { version = "=0.11.0-pre.3", optional = true, default-features = false }

[features]
default = ["pkcs8", "std"]
Expand Down
6 changes: 3 additions & 3 deletions bp384/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ edition = "2021"
rust-version = "1.73"

[dependencies]
elliptic-curve = { version = "=0.14.0-pre.3", default-features = false, features = ["hazmat", "sec1"] }
elliptic-curve = { version = "=0.14.0-pre.5", default-features = false, features = ["hazmat", "sec1"] }

# optional dependencies
ecdsa = { version = "=0.17.0-pre.4", optional = true, default-features = false, features = ["der"] }
ecdsa = { version = "=0.17.0-pre.5", optional = true, default-features = false, features = ["der"] }
primeorder = { version = "=0.14.0-pre.0", optional = true, path = "../primeorder" }
sha2 = { version = "=0.11.0-pre.2", optional = true, default-features = false }
sha2 = { version = "=0.11.0-pre.3", optional = true, default-features = false }

[features]
default = ["pkcs8", "std"]
Expand Down
12 changes: 6 additions & 6 deletions k256/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,26 @@ rust-version = "1.73"

[dependencies]
cfg-if = "1.0"
elliptic-curve = { version = "=0.14.0-pre.3", default-features = false, features = ["hazmat", "sec1"] }
elliptic-curve = { version = "=0.14.0-pre.5", default-features = false, features = ["hazmat", "sec1"] }

# optional dependencies
once_cell = { version = "1.19", optional = true, default-features = false }
ecdsa-core = { version = "=0.17.0-pre.4", package = "ecdsa", optional = true, default-features = false, features = ["der"] }
ecdsa-core = { version = "=0.17.0-pre.5", package = "ecdsa", optional = true, default-features = false, features = ["der"] }
hex-literal = { version = "0.4", optional = true }
serdect = { version = "0.2", optional = true, default-features = false }
sha2 = { version = "=0.11.0-pre.2", optional = true, default-features = false }
signature = { version = "=2.3.0-pre.2", optional = true }
sha2 = { version = "=0.11.0-pre.3", optional = true, default-features = false }
signature = { version = "=2.3.0-pre.3", optional = true }

[dev-dependencies]
blobby = "0.3"
criterion = "0.5"
ecdsa-core = { version = "=0.17.0-pre.4", package = "ecdsa", default-features = false, features = ["dev"] }
ecdsa-core = { version = "=0.17.0-pre.5", package = "ecdsa", default-features = false, features = ["dev"] }
hex-literal = "0.4"
num-bigint = "0.4"
num-traits = "0.2"
proptest = "1.4"
rand_core = { version = "0.6", features = ["getrandom"] }
sha3 = { version = "=0.11.0-pre.2", default-features = false }
sha3 = { version = "=0.11.0-pre.3", default-features = false }

[features]
default = ["arithmetic", "ecdsa", "pkcs8", "precomputed-tables", "schnorr", "std"]
Expand Down
21 changes: 8 additions & 13 deletions k256/src/arithmetic/mul.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ use crate::arithmetic::{
};

use core::ops::{Mul, MulAssign};
use elliptic_curve::ops::LinearCombinationExt as LinearCombination;
use elliptic_curve::{
ops::MulByGenerator,
ops::{LinearCombination, MulByGenerator},
scalar::IsHigh,
subtle::{Choice, ConditionallySelectable, ConstantTimeEq},
};
Expand Down Expand Up @@ -281,7 +280,7 @@ impl<const D: usize> Default for Radix16Decomposition<D> {
}

impl<const N: usize> LinearCombination<[(ProjectivePoint, Scalar); N]> for ProjectivePoint {
fn lincomb_ext(points_and_scalars: &[(ProjectivePoint, Scalar); N]) -> Self {
fn lincomb(points_and_scalars: &[(ProjectivePoint, Scalar); N]) -> Self {
let mut tables = [(LookupTable::default(), LookupTable::default()); N];
let mut digits = [(
Radix16Decomposition::<33>::default(),
Expand All @@ -292,9 +291,9 @@ impl<const N: usize> LinearCombination<[(ProjectivePoint, Scalar); N]> for Proje
}
}

#[cfg(feature = "alloc")]
impl LinearCombination<[(ProjectivePoint, Scalar)]> for ProjectivePoint {
fn lincomb_ext(points_and_scalars: &[(ProjectivePoint, Scalar)]) -> Self {
#[cfg(feature = "alloc")]
fn lincomb(points_and_scalars: &[(ProjectivePoint, Scalar)]) -> Self {
let mut tables =
vec![(LookupTable::default(), LookupTable::default()); points_and_scalars.len()];
let mut digits = vec![
Expand Down Expand Up @@ -411,7 +410,7 @@ impl MulByGenerator for ProjectivePoint {

#[inline(always)]
fn mul(x: &ProjectivePoint, k: &Scalar) -> ProjectivePoint {
ProjectivePoint::lincomb_ext(&[(*x, *k)])
ProjectivePoint::lincomb(&[(*x, *k)])
}

impl Mul<Scalar> for ProjectivePoint {
Expand Down Expand Up @@ -454,11 +453,7 @@ impl MulAssign<&Scalar> for ProjectivePoint {
mod tests {
use super::*;
use crate::arithmetic::{ProjectivePoint, Scalar};
use elliptic_curve::{
ops::{LinearCombination as _, MulByGenerator},
rand_core::OsRng,
Field, Group,
};
use elliptic_curve::{ops::MulByGenerator, rand_core::OsRng, Field, Group};

#[test]
fn test_lincomb() {
Expand All @@ -468,7 +463,7 @@ mod tests {
let l = Scalar::random(&mut OsRng);

let reference = &x * &k + &y * &l;
let test = ProjectivePoint::lincomb(&x, &k, &y, &l);
let test = ProjectivePoint::lincomb(&[(x, k), (y, l)]);
assert_eq!(reference, test);
}

Expand All @@ -491,7 +486,7 @@ mod tests {
let reference = &x * &k + &y * &l;
let points_and_scalars = vec![(x, k), (y, l)];

let test = ProjectivePoint::lincomb_ext(points_and_scalars.as_slice());
let test = ProjectivePoint::lincomb(points_and_scalars.as_slice());
assert_eq!(reference, test);
}
}
10 changes: 4 additions & 6 deletions k256/src/schnorr/verifying.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,10 @@ impl PrehashVerifier<Signature> for VerifyingKey {
.finalize(),
);

let R = ProjectivePoint::lincomb(
&ProjectivePoint::GENERATOR,
s,
&self.inner.to_projective(),
&-e,
)
let R = ProjectivePoint::lincomb(&[
(ProjectivePoint::GENERATOR, **s),
(self.inner.to_projective(), -e),
])
.to_affine();

if R.is_identity().into() || R.y.normalize().is_odd().into() || R.x.normalize() != *r {
Expand Down
6 changes: 3 additions & 3 deletions p192/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ edition = "2021"
rust-version = "1.73"

[dependencies]
elliptic-curve = { version = "=0.14.0-pre.3", default-features = false, features = ["hazmat", "sec1"] }
elliptic-curve = { version = "=0.14.0-pre.5", default-features = false, features = ["hazmat", "sec1"] }
sec1 = { version = "=0.8.0-pre.1", default-features = false }

# optional dependencies
ecdsa-core = { version = "=0.17.0-pre.4", package = "ecdsa", optional = true, default-features = false, features = ["der"] }
ecdsa-core = { version = "=0.17.0-pre.5", package = "ecdsa", optional = true, default-features = false, features = ["der"] }
hex-literal = { version = "0.4", optional = true }
primeorder = { version = "=0.14.0-pre.0", optional = true, path = "../primeorder" }
serdect = { version = "0.2", optional = true, default-features = false }

[dev-dependencies]
ecdsa-core = { version = "=0.17.0-pre.4", package = "ecdsa", default-features = false, features = ["dev"] }
ecdsa-core = { version = "=0.17.0-pre.5", package = "ecdsa", default-features = false, features = ["dev"] }
hex-literal = "0.4"
primeorder = { version = "=0.14.0-pre.0", features = ["dev"], path = "../primeorder" }

Expand Down
Loading

0 comments on commit 1aad201

Please sign in to comment.