Merge remote-tracking branch 'newpavlov/rand_core' into develop

This commit is contained in:
Isis Lovecruft 2019-03-12 22:04:19 +00:00
commit 1bec256418
No known key found for this signature in database
GPG key ID: AB41313533E8E812
4 changed files with 29 additions and 25 deletions

View file

@ -19,10 +19,15 @@ travis-ci = { repository = "dalek-cryptography/ed25519-dalek", branch = "master"
version = "1"
default-features = false
[dependencies.rand_core]
version = "0.3"
default-features = false
[dependencies.rand]
version = "0.6"
features = ["i128_support"]
default-features = false
optional = true
[dependencies.serde]
version = "^1.0"
@ -43,6 +48,8 @@ version = "0.2"
hex = "^0.3"
bincode = "^0.9"
criterion = "0.2"
rand_os = "0.1.0"
rand_chacha = "0.1.0"
[[bench]]
name = "ed25519_benchmarks"
@ -50,9 +57,9 @@ harness = false
[features]
default = ["std", "u64_backend"]
std = ["curve25519-dalek/std", "rand/std", "sha2/std"]
std = ["curve25519-dalek/std", "rand", "sha2/std"]
alloc = ["curve25519-dalek/alloc"]
nightly = ["curve25519-dalek/nightly", "rand/nightly", "clear_on_drop/nightly"]
nightly = ["curve25519-dalek/nightly", "clear_on_drop/nightly"]
asm = ["sha2/asm"]
yolocrypto = ["curve25519-dalek/yolocrypto"]
u64_backend = ["curve25519-dalek/u64_backend"]

View file

@ -12,8 +12,7 @@
#[allow(unused_imports)]
use core::default::Default;
use rand::CryptoRng;
use rand::Rng;
use rand_core::{CryptoRng, RngCore};
#[cfg(feature = "serde")]
use serde::de::Error as SerdeError;
@ -49,8 +48,7 @@ pub use crate::signature::*;
/// * `messages` is a slice of byte slices, one per signed message.
/// * `signatures` is a slice of `Signature`s.
/// * `public_keys` is a slice of `PublicKey`s.
/// * `csprng` is an implementation of `Rng + CryptoRng`, such as
/// `rand::rngs::ThreadRng`.
/// * `csprng` is an implementation of `Rng + CryptoRng`, such as `rand::rngs::ThreadRng`.
///
/// # Panics
///
@ -107,7 +105,7 @@ pub fn verify_batch(
use std::vec::Vec;
use core::iter::once;
use rand::thread_rng;
use rand::{Rng, thread_rng};
use curve25519_dalek::traits::IsIdentity;
use curve25519_dalek::traits::VartimeMultiscalarMul;
@ -219,14 +217,13 @@ impl Keypair {
/// # Example
///
/// ```
/// extern crate rand;
/// extern crate rand_os;
/// extern crate ed25519_dalek;
///
/// # #[cfg(feature = "std")]
/// # fn main() {
///
/// use rand::Rng;
/// use rand::rngs::OsRng;
/// use rand_os::OsRng;
/// use ed25519_dalek::Keypair;
/// use ed25519_dalek::Signature;
///
@ -250,7 +247,7 @@ impl Keypair {
/// Other suitable hash functions include Keccak-512 and Blake2b-512.
pub fn generate<R>(csprng: &mut R) -> Keypair
where
R: CryptoRng + Rng,
R: CryptoRng + RngCore,
{
let sk: SecretKey = SecretKey::generate(csprng);
let pk: PublicKey = (&sk).into();
@ -417,7 +414,7 @@ impl Keypair {
/// let keypair: Keypair = Keypair::generate(&mut csprng);
/// let message: &[u8] = b"All I want is to pet all of the dogs.";
///
/// let mut prehashed: Sha512 = Sha512::default();
/// let mut prehashed: Sha512 = Sha512::new();
/// prehashed.input(message);
///
/// let context: &[u8] = b"Ed25519DalekSignPrehashedDoctest";

View file

@ -19,13 +19,13 @@
//! the operating system's builtin PRNG:
//!
//! ```
//! extern crate rand;
//! extern crate rand_os;
//! extern crate ed25519_dalek;
//!
//! # #[cfg(feature = "std")]
//! # fn main() {
//! use rand::Rng;
//! use rand::rngs::OsRng;
//! use rand_os::OsRng;
//! use ed25519_dalek::Keypair;
//! use ed25519_dalek::Signature;
//!
@ -250,7 +250,11 @@ extern crate std;
extern crate clear_on_drop;
extern crate curve25519_dalek;
extern crate failure;
#[cfg(any(feature = "std", test))]
extern crate rand;
#[cfg(test)]
extern crate rand_chacha;
extern crate rand_core;
#[cfg(feature = "serde")]
extern crate serde;
extern crate sha2;

View file

@ -19,8 +19,7 @@ use curve25519_dalek::digest::Digest;
use curve25519_dalek::edwards::CompressedEdwardsY;
use curve25519_dalek::scalar::Scalar;
use rand::CryptoRng;
use rand::Rng;
use rand_core::{CryptoRng, RngCore};
use sha2::Sha512;
@ -126,15 +125,14 @@ impl SecretKey {
/// # Example
///
/// ```
/// extern crate rand;
/// extern crate rand_os;
/// extern crate sha2;
/// extern crate ed25519_dalek;
///
/// # #[cfg(feature = "std")]
/// # fn main() {
/// #
/// use rand::Rng;
/// use rand::rngs::OsRng;
/// use rand_os::OsRng;
/// use sha2::Sha512;
/// use ed25519_dalek::PublicKey;
/// use ed25519_dalek::SecretKey;
@ -323,15 +321,14 @@ impl ExpandedSecretKey {
/// # Examples
///
/// ```
/// # extern crate rand;
/// # extern crate rand_os;
/// # extern crate sha2;
/// # extern crate ed25519_dalek;
/// #
/// # #[cfg(all(feature = "sha2", feature = "std"))]
/// # fn main() {
/// #
/// use rand::Rng;
/// use rand::rngs::OsRng;
/// use rand_os::OsRng;
/// use sha2::Sha512;
/// use ed25519_dalek::{SecretKey, ExpandedSecretKey};
///
@ -365,7 +362,7 @@ impl ExpandedSecretKey {
/// # Examples
///
/// ```
/// # extern crate rand;
/// # extern crate rand_os;
/// # extern crate sha2;
/// # extern crate ed25519_dalek;
/// #
@ -374,8 +371,7 @@ impl ExpandedSecretKey {
/// # #[cfg(all(feature = "sha2", feature = "std"))]
/// # fn do_test() -> Result<ExpandedSecretKey, SignatureError> {
/// #
/// use rand::Rng;
/// use rand::rngs::OsRng;
/// use rand_os::OsRng;
/// use ed25519_dalek::{SecretKey, ExpandedSecretKey};
/// use ed25519_dalek::SignatureError;
///