Bump edition to 2024 and crate versions to prereleases (#775)

This represents the first breaking change in a new release series,
bumping all crates to the 2024 edition of Rust.

As such, the version numbers of all crates have been incremented to
represent a new prerelease series:

- `curve25519-dalek`: v5.0.0-pre
- `ed25519-dalek`: v3.0.0-pre
- `x25519-dalek`: v3.0.0-pre

Note that this commit isn't intended to cut associated crate releases of
these on crates.io, but is merely bumping the version numbers to denote
there are pending breaking changes.

This commit also includes rustfmt changes which were made as part of the
2024 edition.

Also includes clippy fixes.
This commit is contained in:
Tony Arcieri 2025-07-07 09:52:25 -06:00 committed by GitHub
parent 37d3ae99d3
commit 53df025bb3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
29 changed files with 84 additions and 73 deletions

View file

@ -130,7 +130,7 @@ jobs:
run: cargo test --no-default-features --features alloc,precomputed-tables,zeroize,group-bits --target x86_64-unknown-linux-gnu
msrv:
name: Current MSRV is 1.60.0
name: Current MSRV is 1.85.0
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
@ -139,7 +139,7 @@ jobs:
- run: cargo update -Z minimal-versions
# Now check that `cargo build` works with respect to the oldest possible
# deps and the stated MSRV
- uses: dtolnay/rust-toolchain@1.60.0
- uses: dtolnay/rust-toolchain@1.85.0
- run: cargo build --no-default-features --features serde
# Also make sure the AVX2 build works
- run: cargo build --target x86_64-unknown-linux-gnu

View file

@ -20,7 +20,7 @@ env:
jobs:
msrv:
name: Current MSRV is 1.81.0
name: Current MSRV is 1.85.0
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
@ -29,5 +29,5 @@ jobs:
- run: cargo update -Z minimal-versions
# Now check that `cargo build` works with respect to the oldest possible
# deps and the stated MSRV
- uses: dtolnay/rust-toolchain@1.81.0
- uses: dtolnay/rust-toolchain@1.85.0
- run: cargo build

View file

@ -20,7 +20,7 @@ env:
jobs:
msrv:
name: Current MSRV is 1.60.0
name: Current MSRV is 1.85.0
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
@ -29,5 +29,5 @@ jobs:
- run: cargo update -Z minimal-versions
# Now check that `cargo build` works with respect to the oldest possible
# deps and the stated MSRV
- uses: dtolnay/rust-toolchain@1.60.0
- uses: dtolnay/rust-toolchain@1.85.0
- run: cargo build

View file

@ -4,9 +4,9 @@ name = "curve25519-dalek"
# - update CHANGELOG
# - update README if required by semver
# - if README was updated, also update module documentation in src/lib.rs
version = "4.1.3"
edition = "2021"
rust-version = "1.60.0"
version = "5.0.0-pre"
edition = "2024"
rust-version = "1.85.0"
authors = ["Isis Lovecruft <isis@patternsinthevoid.net>",
"Henry de Valence <hdevalence@hdevalence.ca>"]
readme = "README.md"

View file

@ -1,9 +1,9 @@
#![allow(non_snake_case)]
use rand::{rngs::OsRng, thread_rng, RngCore};
use rand::{RngCore, rngs::OsRng, thread_rng};
use criterion::{
criterion_main, measurement::Measurement, BatchSize, BenchmarkGroup, BenchmarkId, Criterion,
BatchSize, BenchmarkGroup, BenchmarkId, Criterion, criterion_main, measurement::Measurement,
};
#[cfg(feature = "digest")]
use sha2::Sha512;

View file

@ -84,7 +84,9 @@ fn main() {
}
}
Ok("unstable_avx512") if !nightly => {
panic!("Could not override curve25519_dalek_backend to unstable_avx512, as this is nightly only");
panic!(
"Could not override curve25519_dalek_backend to unstable_avx512, as this is nightly only"
);
}
// default between serial / simd (if potentially capable)
_ => match is_capable_simd(&target_arch, curve25519_dalek_bits) {

View file

@ -558,7 +558,10 @@ impl Debug for AffineNielsPoint {
impl Debug for ProjectiveNielsPoint {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "ProjectiveNielsPoint{{\n\tY_plus_X: {:?},\n\tY_minus_X: {:?},\n\tZ: {:?},\n\tT2d: {:?}\n}}",
&self.Y_plus_X, &self.Y_minus_X, &self.Z, &self.T2d)
write!(
f,
"ProjectiveNielsPoint{{\n\tY_plus_X: {:?},\n\tY_minus_X: {:?},\n\tZ: {:?},\n\tT2d: {:?}\n}}",
&self.Y_plus_X, &self.Y_minus_X, &self.Z, &self.T2d
)
}
}

View file

@ -50,7 +50,7 @@ use core::ops::{Add, Mul, Neg};
use crate::backend::serial::u64::field::FieldElement51;
use crate::backend::vector::avx2::constants::{
P_TIMES_16_HI, P_TIMES_16_LO, P_TIMES_2_HI, P_TIMES_2_LO,
P_TIMES_2_HI, P_TIMES_2_LO, P_TIMES_16_HI, P_TIMES_16_LO,
};
use curve25519_dalek_derive::unsafe_target_feature;

View file

@ -106,13 +106,13 @@ use core::ops::{Mul, MulAssign};
#[cfg(feature = "digest")]
use digest::{
consts::True, crypto_common::BlockSizeUser, generic_array::typenum::U64, typenum::IsGreater,
Digest, FixedOutput, HashMarker,
Digest, FixedOutput, HashMarker, consts::True, crypto_common::BlockSizeUser,
generic_array::typenum::U64, typenum::IsGreater,
};
#[cfg(feature = "group")]
use {
group::{cofactor::CofactorGroup, prime::PrimeGroup, GroupEncoding},
group::{GroupEncoding, cofactor::CofactorGroup, prime::PrimeGroup},
subtle::CtOption,
};
@ -130,7 +130,7 @@ use zeroize::Zeroize;
use crate::constants;
use crate::field::FieldElement;
use crate::scalar::{clamp_integer, Scalar};
use crate::scalar::{Scalar, clamp_integer};
use crate::montgomery::MontgomeryPoint;
@ -141,8 +141,8 @@ use crate::backend::serial::curve_models::ProjectivePoint;
#[cfg(feature = "precomputed-tables")]
use crate::window::{
LookupTableRadix128, LookupTableRadix16, LookupTableRadix256, LookupTableRadix32,
LookupTableRadix64,
LookupTableRadix16, LookupTableRadix32, LookupTableRadix64, LookupTableRadix128,
LookupTableRadix256,
};
#[cfg(feature = "precomputed-tables")]

View file

@ -1,6 +1,6 @@
use super::{CompressedEdwardsY, EdwardsPoint};
use crate::traits::Identity;
use crate::{field::FieldElement, Scalar};
use crate::{Scalar, field::FieldElement};
use core::ops::Mul;
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq};

View file

@ -37,10 +37,10 @@ use crate::constants;
#[cfg(feature = "digest")]
use digest::{
core_api::BlockSizeUser,
generic_array::{typenum::U64, GenericArray},
typenum::{IsGreater, True},
Digest, FixedOutput, HashMarker,
core_api::BlockSizeUser,
generic_array::{GenericArray, typenum::U64},
typenum::{IsGreater, True},
};
cfg_if! {

View file

@ -57,7 +57,7 @@ use core::{
use crate::constants::{APLUS2_OVER_FOUR, MONTGOMERY_A, MONTGOMERY_A_NEG};
use crate::edwards::{CompressedEdwardsY, EdwardsPoint};
use crate::field::FieldElement;
use crate::scalar::{clamp_integer, Scalar};
use crate::scalar::{Scalar, clamp_integer};
use crate::traits::Identity;

View file

@ -172,17 +172,17 @@ use core::ops::{Mul, MulAssign};
#[cfg(any(test, feature = "rand_core"))]
use rand_core::CryptoRngCore;
#[cfg(feature = "digest")]
use digest::generic_array::typenum::U64;
#[cfg(feature = "digest")]
use digest::Digest;
#[cfg(feature = "digest")]
use digest::generic_array::typenum::U64;
use crate::constants;
use crate::field::FieldElement;
#[cfg(feature = "group")]
use {
group::{cofactor::CofactorGroup, prime::PrimeGroup, GroupEncoding},
group::{GroupEncoding, cofactor::CofactorGroup, prime::PrimeGroup},
rand_core::RngCore,
subtle::CtOption,
};

View file

@ -133,10 +133,10 @@ use rand_core::RngCore;
#[cfg(any(test, feature = "rand_core"))]
use rand_core::CryptoRngCore;
#[cfg(feature = "digest")]
use digest::generic_array::typenum::U64;
#[cfg(feature = "digest")]
use digest::Digest;
#[cfg(feature = "digest")]
use digest::generic_array::typenum::U64;
use subtle::Choice;
use subtle::ConditionallySelectable;
@ -1024,9 +1024,9 @@ impl Scalar {
debug_assert!(w <= 8);
let digits_count = match w {
4..=7 => (256 + w - 1) / w,
4..=7 => 256_usize.div_ceil(w),
// See comment in to_radix_2w on handling the terminal carry.
8 => (256 + w - 1) / w + 1_usize,
8 => 256_usize.div_ceil(w) + 1_usize,
_ => panic!("invalid radix parameter"),
};
@ -1073,7 +1073,7 @@ impl Scalar {
let mut carry = 0u64;
let mut digits = [0i8; 64];
let digits_count = (256 + w - 1) / w;
let digits_count = 256_usize.div_ceil(w);
#[allow(clippy::needless_range_loop)]
for i in 0..digits_count {
// Construct a buffer of bits of the scalar, starting at `bit_offset`.

View file

@ -15,7 +15,7 @@
use core::borrow::Borrow;
use crate::scalar::{clamp_integer, Scalar};
use crate::scalar::{Scalar, clamp_integer};
use subtle::ConstantTimeEq;
// ------------------------------------------------------------------------

View file

@ -1,7 +1,7 @@
[package]
name = "ed25519-dalek"
version = "2.1.1"
edition = "2021"
version = "3.0.0-pre"
edition = "2024"
authors = [
"isis lovecruft <isis@patternsinthevoid.net>",
"Tony Arcieri <bascule@gmail.com>",
@ -16,7 +16,7 @@ keywords = ["cryptography", "ed25519", "curve25519", "signature", "ECC"]
categories = ["cryptography", "no-std"]
description = "Fast and efficient ed25519 EdDSA key generations, signing, and verification in pure Rust."
exclude = [ ".gitignore", "TESTVECTORS", "VALIDATIONVECTORS", "res/*" ]
rust-version = "1.81"
rust-version = "1.85"
[package.metadata.docs.rs]
rustdoc-args = [
@ -26,7 +26,7 @@ rustdoc-args = [
features = ["batch", "digest", "hazmat", "pem", "serde"]
[dependencies]
curve25519-dalek = { version = "4", path = "../curve25519-dalek", default-features = false, features = ["digest"] }
curve25519-dalek = { version = "=5.0.0-pre", path = "../curve25519-dalek", default-features = false, features = ["digest"] }
ed25519 = { version = ">=2.2, <2.3", default-features = false }
signature = { version = ">=2.0, <2.3", optional = true, default-features = false }
sha2 = { version = "0.10", default-features = false }
@ -39,8 +39,8 @@ serde = { version = "1.0", default-features = false, optional = true }
zeroize = { version = "1.5", default-features = false, optional = true }
[dev-dependencies]
curve25519-dalek = { version = "4", path = "../curve25519-dalek", default-features = false, features = ["digest", "rand_core"] }
x25519-dalek = { version = "2", path = "../x25519-dalek", default-features = false, features = ["static_secrets"] }
curve25519-dalek = { version = "=5.0.0-pre", path = "../curve25519-dalek", default-features = false, features = ["digest", "rand_core"] }
x25519-dalek = { version = "=3.0.0-pre", path = "../x25519-dalek", default-features = false, features = ["static_secrets"] }
blake2 = "0.10"
sha3 = "0.10"
hex = "0.4"

View file

@ -7,7 +7,7 @@
// Authors:
// - isis agora lovecruft <isis@patternsinthevoid.net>
use criterion::{criterion_group, Criterion};
use criterion::{Criterion, criterion_group};
mod ed25519_benches {
use super::*;

View file

@ -30,10 +30,10 @@ use rand_core::RngCore;
use sha2::Sha512;
use crate::VerifyingKey;
use crate::errors::InternalError;
use crate::errors::SignatureError;
use crate::signature::InternalSignature;
use crate::VerifyingKey;
/// Domain separation label to initialize the STROBE context.
///

View file

@ -1,5 +1,5 @@
use super::strobe::Strobe128;
use super::MERLIN_PROTOCOL_LABEL;
use super::strobe::Strobe128;
fn encode_usize_as_u32(x: usize) -> [u8; 4] {
u32::try_from(x).expect("usize too large").to_le_bytes()

View file

@ -17,7 +17,7 @@ use core::fmt::Debug;
use crate::{InternalError, SignatureError};
use curve25519_dalek::scalar::{clamp_integer, Scalar};
use curve25519_dalek::scalar::{Scalar, clamp_integer};
use subtle::{Choice, ConstantTimeEq};
#[cfg(feature = "zeroize")]
@ -25,7 +25,7 @@ use zeroize::{Zeroize, ZeroizeOnDrop};
// These are used in the functions that are made public when the hazmat feature is set
use crate::{Signature, VerifyingKey};
use curve25519_dalek::digest::{generic_array::typenum::U64, Digest};
use curve25519_dalek::digest::{Digest, generic_array::typenum::U64};
/// Contains the secret scalar and domain separator used for generating signatures.
///
@ -258,7 +258,7 @@ mod test {
use super::*;
use rand::{rngs::OsRng, CryptoRng, RngCore};
use rand::{CryptoRng, RngCore, rngs::OsRng};
// Pick distinct, non-spec 512-bit hash functions for message and sig-context hashing
type CtxDigest = blake2::Blake2b512;

View file

@ -285,10 +285,10 @@ pub use crate::signing::*;
pub use crate::verifying::*;
// Re-export the `Signer` and `Verifier` traits from the `signature` crate
pub use ed25519::Signature;
#[cfg(feature = "digest")]
pub use ed25519::signature::{DigestSigner, DigestVerifier};
pub use ed25519::signature::{Signer, Verifier};
pub use ed25519::Signature;
#[cfg(feature = "pkcs8")]
pub use ed25519::pkcs8;

View file

@ -24,7 +24,7 @@ use sha2::Sha512;
use subtle::{Choice, ConstantTimeEq};
use curve25519_dalek::{
digest::{generic_array::typenum::U64, Digest},
digest::{Digest, generic_array::typenum::U64},
edwards::{CompressedEdwardsY, EdwardsPoint},
scalar::Scalar,
};
@ -42,12 +42,12 @@ use zeroize::{Zeroize, ZeroizeOnDrop};
#[cfg(feature = "hazmat")]
use crate::verifying::StreamVerifier;
use crate::{
Signature,
constants::{KEYPAIR_LENGTH, SECRET_KEY_LENGTH},
errors::{InternalError, SignatureError},
hazmat::ExpandedSecretKey,
signature::InternalSignature,
verifying::VerifyingKey,
Signature,
};
/// ed25519 secret key as defined in [RFC8032 § 5.1.5]:

View file

@ -13,7 +13,7 @@ use core::fmt::Debug;
use core::hash::{Hash, Hasher};
use curve25519_dalek::{
digest::{generic_array::typenum::U64, Digest},
digest::{Digest, generic_array::typenum::U64},
edwards::{CompressedEdwardsY, EdwardsPoint},
montgomery::MontgomeryPoint,
scalar::Scalar,

View file

@ -2,7 +2,7 @@ use curve25519_dalek::edwards::CompressedEdwardsY;
use sha2::Sha512;
use crate::verifying::RCompute;
use crate::{signature::InternalSignature, InternalError, SignatureError, VerifyingKey};
use crate::{InternalError, SignatureError, VerifyingKey, signature::InternalSignature};
/// An IUF verifier for ed25519.
///

View file

@ -29,7 +29,7 @@ mod vectors {
};
#[cfg(not(feature = "digest"))]
use sha2::{digest::Digest, Sha512};
use sha2::{Sha512, digest::Digest};
use std::{
fs::File,
@ -104,7 +104,9 @@ mod vectors {
let sec_bytes = hex!("833fe62409237b9d62ec77587520911e9a759cec1d19755b7da901b96dca3d42");
let pub_bytes = hex!("ec172b93ad5e563bf4932c70e1245034c35467ef2efd4d64ebf819683467e2bf");
let msg_bytes = hex!("616263");
let sig_bytes = hex!("98a70222f0b8121aa9d30f813d683f809e462b469c7ff87639499bb94e6dae4131f85042463c2a355a2003d062adf5aaa10b8c61e636062aaad11c2a26083406");
let sig_bytes = hex!(
"98a70222f0b8121aa9d30f813d683f809e462b469c7ff87639499bb94e6dae4131f85042463c2a355a2003d062adf5aaa10b8c61e636062aaad11c2a26083406"
);
let signing_key = SigningKey::from_bytes(&sec_bytes);
let expected_verifying_key = VerifyingKey::from_bytes(&pub_bytes).unwrap();
@ -268,20 +270,24 @@ mod vectors {
let signature = serialize_signature(&r, &s);
let vk = VerifyingKey::from_bytes(pubkey.compress().as_bytes()).unwrap();
let sig = Signature::try_from(&signature[..]).unwrap();
assert!(vk
.verify_prehashed(message1.clone(), context_str, &sig)
.is_ok());
assert!(vk
.verify_prehashed(message2.clone(), context_str, &sig)
.is_ok());
assert!(
vk.verify_prehashed(message1.clone(), context_str, &sig)
.is_ok()
);
assert!(
vk.verify_prehashed(message2.clone(), context_str, &sig)
.is_ok()
);
// Check that verify_prehashed_strict fails on both sigs
assert!(vk
.verify_prehashed_strict(message1.clone(), context_str, &sig)
.is_err());
assert!(vk
.verify_prehashed_strict(message2.clone(), context_str, &sig)
.is_err());
assert!(
vk.verify_prehashed_strict(message1.clone(), context_str, &sig)
.is_err()
);
assert!(
vk.verify_prehashed_strict(message2.clone(), context_str, &sig)
.is_err()
);
}
}

View file

@ -1,7 +1,7 @@
use ed25519::signature::Verifier;
use ed25519_dalek::{Signature, VerifyingKey};
use serde::{de::Error as SError, Deserialize, Deserializer};
use serde::{Deserialize, Deserializer, de::Error as SError};
use std::{collections::BTreeSet as Set, fs::File};
/// The set of edge cases that [`VerifyingKey::verify()`] permits.

View file

@ -1,6 +1,6 @@
//! Tests for converting Ed25519 keys into X25519 (Montgomery form) keys.
use curve25519_dalek::scalar::{clamp_integer, Scalar};
use curve25519_dalek::scalar::{Scalar, clamp_integer};
use ed25519_dalek::SigningKey;
use hex_literal::hex;
use sha2::{Digest, Sha512};

View file

@ -1,12 +1,12 @@
[package]
name = "x25519-dalek"
edition = "2021"
edition = "2024"
# Before changing this:
# - update version in README.md
# - update html_root_url
# - update CHANGELOG
# - if any changes were made to README.md, mirror them in src/lib.rs docs
version = "2.0.1"
version = "3.0.0-pre"
authors = [
"Isis Lovecruft <isis@patternsinthevoid.net>",
"DebugSteven <debugsteven@gmail.com>",
@ -25,7 +25,7 @@ exclude = [
".travis.yml",
"CONTRIBUTING.md",
]
rust-version = "1.60"
rust-version = "1.85"
[badges]
travis-ci = { repository = "dalek-cryptography/x25519-dalek", branch = "master"}
@ -38,7 +38,7 @@ rustdoc-args = [
features = ["getrandom", "reusable_secrets", "serde", "static_secrets"]
[dependencies]
curve25519-dalek = { version = "4", path = "../curve25519-dalek", default-features = false }
curve25519-dalek = { version = "=5.0.0-pre", path = "../curve25519-dalek", default-features = false }
rand_core = { version = "0.6", default-features = false }
serde = { version = "1", default-features = false, optional = true, features = ["derive"] }
zeroize = { version = "1", default-features = false, optional = true }

View file

@ -11,7 +11,7 @@
//! Benchmark the Diffie-Hellman operation.
use criterion::{criterion_group, criterion_main, Criterion};
use criterion::{Criterion, criterion_group, criterion_main};
use rand_core::OsRng;