Skip to content

Commit

Permalink
Use namespaced/weak features; MSRV 1.60
Browse files Browse the repository at this point in the history
This enables activating the `alloc` and `std` features without
unnecessarily pulling in optional dependencies like `rand` and `serde`.

It also fixes tests for `--no-default-features` (w\ `--lib` only)
  • Loading branch information
tarcieri committed Dec 10, 2022
1 parent cfcdf53 commit ba54a9d
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 16 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ jobs:
- uses: dtolnay/rust-toolchain@stable
- run: rustup target add ${{ matrix.target }}
- run: ${{ matrix.deps }}
- run: cargo test --target ${{ matrix.target }} --no-default-features --features alloc
- run: cargo test --target ${{ matrix.target }} --no-default-features --lib
- run: cargo test --target ${{ matrix.target }} --no-default-features --features alloc --lib
- run: cargo test --target ${{ matrix.target }}
- run: cargo test --target ${{ matrix.target }} --features batch
- run: cargo test --target ${{ matrix.target }} --features batch_deterministic
Expand All @@ -46,7 +47,7 @@ jobs:
run: cargo build --target x86_64-unknown-linux-gnu

msrv:
name: Current MSRV is 1.56.1
name: Current MSRV is 1.60.0
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -56,7 +57,7 @@ jobs:
- run: cargo -Z minimal-versions check --no-default-features --features serde
# Now check that `cargo build` works with respect to the oldest possible
# deps and the stated MSRV
- uses: dtolnay/rust-toolchain@1.56.1
- uses: dtolnay/rust-toolchain@1.60.0
- run: cargo build

bench:
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased

### Changes
* Bumped MSRV from 1.41 to 1.56.1
* Bumped MSRV from 1.41 to 1.60.0
* Removed `ExpandedSecretKey` API ((#205)[https://github.com/dalek-cryptography/ed25519-dalek/pull/205])
11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,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", "res/*" ]
rust-version = "1.60"

[badges]
travis-ci = { repository = "dalek-cryptography/ed25519-dalek", branch = "master"}
Expand All @@ -27,7 +28,7 @@ ed25519 = { version = "=2.0.0-pre.0", default-features = false }
merlin = { version = "3", default-features = false, optional = true }
rand = { version = "0.8", default-features = false, optional = true }
rand_core = { version = "0.6", default-features = false, optional = true }
serde_crate = { package = "serde", version = "1.0", default-features = false, optional = true }
serde = { version = "1.0", default-features = false, optional = true }
serde_bytes = { version = "0.11", optional = true }
sha2 = { version = "0.10", default-features = false }
zeroize = { version = "1", default-features = false }
Expand All @@ -38,7 +39,7 @@ bincode = "1.0"
serde_json = "1.0"
criterion = "0.3"
rand = "0.8"
serde_crate = { package = "serde", version = "1.0", features = ["derive"] }
serde = { version = "1.0", features = ["derive"] }
toml = { version = "0.5" }

[[bench]]
Expand All @@ -48,9 +49,9 @@ required-features = ["batch"]

[features]
default = ["std", "rand"]
std = ["alloc", "ed25519/std", "serde_crate/std", "sha2/std", "rand/std"]
alloc = ["curve25519-dalek/alloc", "rand/alloc", "zeroize/alloc"]
serde = ["serde_crate", "serde_bytes", "ed25519/serde"]
std = ["alloc", "ed25519/std", "rand?/std", "serde?/std", "sha2/std"]
alloc = ["curve25519-dalek/alloc", "rand?/alloc", "serde?/alloc", "zeroize/alloc"]
serde = ["dep:serde", "serde_bytes", "ed25519/serde"]
batch = ["alloc", "merlin", "rand/std"]
# This feature enables deterministic batch verification.
batch_deterministic = ["alloc", "merlin", "rand", "rand_core"]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ version = "1"

# Minimum Supported Rust Version

This crate requires Rust 1.56.1 at a minimum. 1.x releases of this crate supported an MSRV of 1.41.
This crate requires Rust 1.60.0 at a minimum. Older 1.x releases of this crate supported an MSRV of 1.41.

In the future, MSRV changes will be accompanied by a minor version bump.

Expand Down
3 changes: 3 additions & 0 deletions src/batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

//! Batch signature verification.
#[cfg(all(feature = "batch", feature = "batch_deterministic"))]
compile_error!("`batch` and `batch_deterministic` features are mutually exclusive");

use alloc::vec::Vec;

use core::convert::TryFrom;
Expand Down
3 changes: 0 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,6 @@ extern crate alloc;
#[macro_use]
extern crate std;

#[cfg(feature = "serde")]
extern crate serde_crate as serde;

pub use ed25519;

#[cfg(any(feature = "batch", feature = "batch_deterministic"))]
Expand Down
1 change: 1 addition & 0 deletions src/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ mod test {
assert!(!memory.contains(&0x15));
}

#[cfg(feature = "rand")]
#[test]
fn pubkey_from_secret_and_expanded_secret() {
let mut csprng = rand::rngs::OsRng {};
Expand Down
7 changes: 4 additions & 3 deletions tests/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use ed25519_dalek::*;

use hex::FromHex;

#[cfg(feature = "rand")]
use sha2::Sha512;

#[cfg(test)]
Expand Down Expand Up @@ -196,7 +197,7 @@ mod vectors {
}
}

#[cfg(test)]
#[cfg(feature = "rand")]
mod integrations {
use super::*;
use rand::rngs::OsRng;
Expand Down Expand Up @@ -314,8 +315,8 @@ mod integrations {
}

#[cfg(all(test, feature = "serde"))]
#[derive(Debug, serde_crate::Serialize, serde_crate::Deserialize)]
#[serde(crate = "serde_crate")]
#[derive(Debug, serde::Serialize, serde::Deserialize)]
#[serde(crate = "serde")]
struct Demo {
keypair: Keypair,
}
Expand Down

0 comments on commit ba54a9d

Please sign in to comment.