mirror of
https://github.com/saymrwulf/risc0-curve25519-dalek-source.git
synced 2026-09-04 20:03:40 +00:00
Make rand_core optional (#262)
* Make rand_core optional * Bench requires features rand_core
This commit is contained in:
parent
b5dc40bedf
commit
8c455f58ae
4 changed files with 10 additions and 8 deletions
1
.github/workflows/rust.yml
vendored
1
.github/workflows/rust.yml
vendored
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
@ -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"]
|
||||
|
||||
|
|
@ -60,6 +61,7 @@ batch = ["alloc", "merlin", "rand_core"]
|
|||
legacy_compatibility = []
|
||||
pkcs8 = ["ed25519/pkcs8"]
|
||||
pem = ["alloc", "ed25519/pem", "pkcs8"]
|
||||
rand_core = ["dep:rand_core"]
|
||||
serde = ["dep:serde", "serde_bytes", "ed25519/serde"]
|
||||
zeroize = ["dep:zeroize", "curve25519-dalek/zeroize"]
|
||||
|
||||
|
|
|
|||
|
|
@ -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")]
|
||||
|
|
@ -183,7 +183,7 @@ 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")]
|
||||
#[cfg(any(test, feature = "rand_core"))]
|
||||
pub fn generate<R: CryptoRngCore + ?Sized>(csprng: &mut R) -> SigningKey {
|
||||
let mut secret = SecretKey::default();
|
||||
csprng.fill_bytes(&mut secret);
|
||||
|
|
@ -208,7 +208,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;
|
||||
|
|
|
|||
|
|
@ -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::*;
|
||||
|
|
@ -285,6 +282,7 @@ mod vectors {
|
|||
mod integrations {
|
||||
use super::*;
|
||||
use rand::rngs::OsRng;
|
||||
use sha2::Sha512;
|
||||
|
||||
#[test]
|
||||
fn sign_verify() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue