Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
1 change: 1 addition & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
- 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 rand_core
- run: cargo test --target ${{ matrix.target }} --features serde
- run: cargo test --target ${{ matrix.target }} --features pem

Expand Down
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ sha2 = { version = "0.10", default-features = false }
zeroize = { version = "1.5", default-features = false, optional = true }

[dev-dependencies]
curve25519-dalek = { version = "=4.0.0-pre.5", default-features = false, features = ["digest", "rand_core"] }
hex = "0.4"
bincode = "1.0"
serde_json = "1.0"
Expand All @@ -43,14 +44,14 @@ rand = "0.8"
rand_core = { version = "0.6.4", default-features = false }
serde = { version = "1.0", features = ["derive"] }
toml = { version = "0.5" }
curve25519-dalek = { version = "=4.0.0-pre.5", default-features = false, features = ["digest", "rand_core"] }

[[bench]]
name = "ed25519_benchmarks"
harness = false
required-features = ["rand_core"]

[features]
default = ["std", "rand_core", "zeroize"]
default = ["std", "zeroize"]
alloc = ["curve25519-dalek/alloc", "ed25519/alloc", "serde?/alloc", "zeroize/alloc"]
std = ["alloc", "ed25519/std", "serde?/std", "sha2/std"]

Expand All @@ -60,6 +61,7 @@ batch = ["alloc", "merlin", "rand_core"]
legacy_compatibility = []
pkcs8 = ["ed25519/pkcs8"]
pem = ["alloc", "ed25519/pem", "pkcs8"]
rand_core = ["dep:rand_core"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is best to keep iterating explicitly all the features in Cargo.toml as it's easier to understand for downstream

serde = ["dep:serde", "serde_bytes", "ed25519/serde"]
zeroize = ["dep:zeroize", "curve25519-dalek/zeroize"]

Expand Down
11 changes: 8 additions & 3 deletions src/signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#[cfg(feature = "pkcs8")]
use ed25519::pkcs8::{self, DecodePrivateKey};

#[cfg(feature = "rand_core")]
#[cfg(any(test, feature = "rand_core"))]
use rand_core::CryptoRngCore;

#[cfg(feature = "serde")]
Expand Down Expand Up @@ -153,6 +153,7 @@ impl SigningKey {
self.verifying_key
}

#[cfg(any(test, feature = "rand_core"))]
/// Generate an ed25519 signing key.
///
/// # Example
Expand Down Expand Up @@ -183,7 +184,10 @@ impl SigningKey {
/// The standard hash function used for most ed25519 libraries is SHA-512,
/// which is available with `use sha2::Sha512` as in the example above.
/// Other suitable hash functions include Keccak-512 and Blake2b-512.
#[cfg(feature = "rand_core")]
///
/// # Features
///
/// Requires optional feature `rand_core` activated
pub fn generate<R: CryptoRngCore + ?Sized>(csprng: &mut R) -> SigningKey {
let mut secret = SecretKey::default();
csprng.fill_bytes(&mut secret);
Expand All @@ -208,7 +212,8 @@ impl SigningKey {
///
/// # Examples
///
/// ```
#[cfg_attr(feature = "rand_core", doc = "```")]
#[cfg_attr(not(feature = "rand_core"), doc = "```ignore")]
/// use ed25519_dalek::Digest;
/// use ed25519_dalek::SigningKey;
/// use ed25519_dalek::Sha512;
Expand Down
4 changes: 1 addition & 3 deletions tests/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ use ed25519_dalek::*;
use hex::FromHex;
use hex_literal::hex;

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

#[cfg(test)]
mod vectors {
use super::*;
Expand Down Expand Up @@ -285,6 +282,7 @@ mod vectors {
mod integrations {
use super::*;
use rand::rngs::OsRng;
use sha2::Sha512;

#[test]
fn sign_verify() {
Expand Down