Merge remote-tracking branch 'mikelodder7/master' into develop

This commit is contained in:
Isis Lovecruft 2019-10-25 21:50:57 +00:00
commit fe782cd896
No known key found for this signature in database
GPG key ID: AB41313533E8E812
5 changed files with 70 additions and 102 deletions

View file

@ -20,20 +20,11 @@ travis-ci = { repository = "dalek-cryptography/ed25519-dalek", branch = "master"
version = "1" version = "1"
default-features = false default-features = false
[dependencies.rand_core]
version = "0.3"
default-features = false
[dependencies.rand] [dependencies.rand]
version = "0.6" version = "0.7"
features = ["i128_support"]
default-features = false default-features = false
optional = true optional = true
[dependencies.rand_os]
version = "0.1"
optional = true
[dependencies.serde] [dependencies.serde]
version = "^1.0" version = "^1.0"
optional = true optional = true
@ -50,11 +41,10 @@ default-features = false
version = "0.2" version = "0.2"
[dev-dependencies] [dev-dependencies]
hex = "^0.3" hex = "^0.4"
bincode = "^0.9" bincode = "^0.9"
criterion = "0.2" criterion = "0.3"
rand = "0.6" rand = "0.7"
rand_os = "0.1"
[[bench]] [[bench]]
name = "ed25519_benchmarks" name = "ed25519_benchmarks"
@ -65,9 +55,9 @@ harness = false
[features] [features]
default = ["std", "u64_backend"] default = ["std", "u64_backend"]
std = ["curve25519-dalek/std", "rand_os", "sha2/std"] std = ["curve25519-dalek/std", "sha2/std", "rand/std"]
alloc = ["curve25519-dalek/alloc"] alloc = ["curve25519-dalek/alloc", "rand/alloc"]
nightly = ["curve25519-dalek/nightly", "clear_on_drop/nightly"] nightly = ["curve25519-dalek/nightly", "clear_on_drop/nightly", "rand/nightly"]
batch = ["rand"] batch = ["rand"]
asm = ["sha2/asm"] asm = ["sha2/asm"]
# This features turns off stricter checking for scalar malleability in signatures # This features turns off stricter checking for scalar malleability in signatures

View file

@ -12,7 +12,7 @@
#[allow(unused_imports)] #[allow(unused_imports)]
use core::default::Default; use core::default::Default;
use rand_core::{CryptoRng, RngCore}; use rand::{CryptoRng, RngCore};
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
use serde::de::Error as SerdeError; use serde::de::Error as SerdeError;
@ -65,16 +65,16 @@ pub use crate::signature::*;
/// ///
/// ``` /// ```
/// extern crate ed25519_dalek; /// extern crate ed25519_dalek;
/// extern crate rand_os; /// extern crate rand;
/// ///
/// use ed25519_dalek::verify_batch; /// use ed25519_dalek::verify_batch;
/// use ed25519_dalek::Keypair; /// use ed25519_dalek::Keypair;
/// use ed25519_dalek::PublicKey; /// use ed25519_dalek::PublicKey;
/// use ed25519_dalek::Signature; /// use ed25519_dalek::Signature;
/// use rand_os::OsRng; /// use rand::rngs::OsRng;
/// ///
/// # fn main() { /// # fn main() {
/// let mut csprng: OsRng = OsRng::new().unwrap(); /// let mut csprng = OsRng{};
/// let keypairs: Vec<Keypair> = (0..64).map(|_| Keypair::generate(&mut csprng)).collect(); /// let keypairs: Vec<Keypair> = (0..64).map(|_| Keypair::generate(&mut csprng)).collect();
/// let msg: &[u8] = b"They're good dogs Brant"; /// let msg: &[u8] = b"They're good dogs Brant";
/// let messages: Vec<&[u8]> = (0..64).map(|_| msg).collect(); /// let messages: Vec<&[u8]> = (0..64).map(|_| msg).collect();
@ -216,19 +216,17 @@ impl Keypair {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// extern crate rand_core; /// extern crate rand;
/// extern crate rand_os;
/// extern crate ed25519_dalek; /// extern crate ed25519_dalek;
/// ///
/// # #[cfg(feature = "std")] /// # #[cfg(feature = "std")]
/// # fn main() { /// # fn main() {
/// ///
/// use rand_core::{CryptoRng, RngCore}; /// use rand::rngs::OsRng;
/// use rand_os::OsRng;
/// use ed25519_dalek::Keypair; /// use ed25519_dalek::Keypair;
/// use ed25519_dalek::Signature; /// use ed25519_dalek::Signature;
/// ///
/// let mut csprng: OsRng = OsRng::new().unwrap(); /// let mut csprng = OsRng{};
/// let keypair: Keypair = Keypair::generate(&mut csprng); /// let keypair: Keypair = Keypair::generate(&mut csprng);
/// ///
/// # } /// # }
@ -283,17 +281,17 @@ impl Keypair {
/// ///
/// ``` /// ```
/// extern crate ed25519_dalek; /// extern crate ed25519_dalek;
/// extern crate rand_os; /// extern crate rand;
/// ///
/// use ed25519_dalek::Digest; /// use ed25519_dalek::Digest;
/// use ed25519_dalek::Keypair; /// use ed25519_dalek::Keypair;
/// use ed25519_dalek::Sha512; /// use ed25519_dalek::Sha512;
/// use ed25519_dalek::Signature; /// use ed25519_dalek::Signature;
/// use rand_os::OsRng; /// use rand::rngs::OsRng;
/// ///
/// # #[cfg(feature = "std")] /// # #[cfg(feature = "std")]
/// # fn main() { /// # fn main() {
/// let mut csprng = OsRng::new().unwrap(); /// let mut csprng = OsRng{};
/// let keypair: Keypair = Keypair::generate(&mut csprng); /// let keypair: Keypair = Keypair::generate(&mut csprng);
/// let message: &[u8] = b"All I want is to pet all of the dogs."; /// let message: &[u8] = b"All I want is to pet all of the dogs.";
/// ///
@ -330,17 +328,17 @@ impl Keypair {
/// ///
/// ``` /// ```
/// # extern crate ed25519_dalek; /// # extern crate ed25519_dalek;
/// # extern crate rand_os; /// # extern crate rand;
/// # /// #
/// # use ed25519_dalek::Digest; /// # use ed25519_dalek::Digest;
/// # use ed25519_dalek::Keypair; /// # use ed25519_dalek::Keypair;
/// # use ed25519_dalek::Signature; /// # use ed25519_dalek::Signature;
/// # use ed25519_dalek::Sha512; /// # use ed25519_dalek::Sha512;
/// # use rand_os::OsRng; /// # use rand::rngs::OsRng;
/// # /// #
/// # #[cfg(feature = "std")] /// # #[cfg(feature = "std")]
/// # fn main() { /// # fn main() {
/// # let mut csprng: OsRng = OsRng::new().unwrap(); /// # let mut csprng = OsRng{};
/// # let keypair: Keypair = Keypair::generate(&mut csprng); /// # let keypair: Keypair = Keypair::generate(&mut csprng);
/// # let message: &[u8] = b"All I want is to pet all of the dogs."; /// # let message: &[u8] = b"All I want is to pet all of the dogs.";
/// # let mut prehashed: Sha512 = Sha512::new(); /// # let mut prehashed: Sha512 = Sha512::new();
@ -401,17 +399,17 @@ impl Keypair {
/// ///
/// ``` /// ```
/// extern crate ed25519_dalek; /// extern crate ed25519_dalek;
/// extern crate rand_os; /// extern crate rand;
/// ///
/// use ed25519_dalek::Digest; /// use ed25519_dalek::Digest;
/// use ed25519_dalek::Keypair; /// use ed25519_dalek::Keypair;
/// use ed25519_dalek::Signature; /// use ed25519_dalek::Signature;
/// use ed25519_dalek::Sha512; /// use ed25519_dalek::Sha512;
/// use rand_os::OsRng; /// use rand::rngs::OsRng;
/// ///
/// # #[cfg(feature = "std")] /// # #[cfg(feature = "std")]
/// # fn main() { /// # fn main() {
/// let mut csprng: OsRng = OsRng::new().unwrap(); /// let mut csprng = OsRng{};
/// let keypair: Keypair = Keypair::generate(&mut csprng); /// let keypair: Keypair = Keypair::generate(&mut csprng);
/// let message: &[u8] = b"All I want is to pet all of the dogs."; /// let message: &[u8] = b"All I want is to pet all of the dogs.";
/// ///

View file

@ -19,18 +19,16 @@
//! the operating system's builtin PRNG: //! the operating system's builtin PRNG:
//! //!
//! ``` //! ```
//! extern crate rand_core; //! extern crate rand;
//! extern crate rand_os;
//! extern crate ed25519_dalek; //! extern crate ed25519_dalek;
//! //!
//! # #[cfg(feature = "std")] //! # #[cfg(feature = "std")]
//! # fn main() { //! # fn main() {
//! use rand_core::RngCore; //! use rand::rngs::OsRng;
//! use rand_os::OsRng;
//! use ed25519_dalek::Keypair; //! use ed25519_dalek::Keypair;
//! use ed25519_dalek::Signature; //! use ed25519_dalek::Signature;
//! //!
//! let mut csprng: OsRng = OsRng::new().unwrap(); //! let mut csprng = OsRng{};
//! let keypair: Keypair = Keypair::generate(&mut csprng); //! let keypair: Keypair = Keypair::generate(&mut csprng);
//! # } //! # }
//! # //! #
@ -41,15 +39,13 @@
//! We can now use this `keypair` to sign a message: //! We can now use this `keypair` to sign a message:
//! //!
//! ``` //! ```
//! # extern crate rand_core; //! # extern crate rand;
//! # extern crate rand_os;
//! # extern crate ed25519_dalek; //! # extern crate ed25519_dalek;
//! # fn main() { //! # fn main() {
//! # use rand_core::RngCore; //! # use rand::rngs::OsRng;
//! # use rand_os::OsRng;
//! # use ed25519_dalek::Keypair; //! # use ed25519_dalek::Keypair;
//! # use ed25519_dalek::Signature; //! # use ed25519_dalek::Signature;
//! # let mut csprng = OsRng::new().unwrap(); //! # let mut csprng = OsRng{};
//! # let keypair: Keypair = Keypair::generate(&mut csprng); //! # let keypair: Keypair = Keypair::generate(&mut csprng);
//! let message: &[u8] = b"This is a test of the tsunami alert system."; //! let message: &[u8] = b"This is a test of the tsunami alert system.";
//! let signature: Signature = keypair.sign(message); //! let signature: Signature = keypair.sign(message);
@ -60,15 +56,13 @@
//! that `message`: //! that `message`:
//! //!
//! ``` //! ```
//! # extern crate rand_core; //! # extern crate rand;
//! # extern crate rand_os;
//! # extern crate ed25519_dalek; //! # extern crate ed25519_dalek;
//! # fn main() { //! # fn main() {
//! # use rand_core::RngCore; //! # use rand::rngs::OsRng;
//! # use rand_os::OsRng;
//! # use ed25519_dalek::Keypair; //! # use ed25519_dalek::Keypair;
//! # use ed25519_dalek::Signature; //! # use ed25519_dalek::Signature;
//! # let mut csprng = OsRng::new().unwrap(); //! # let mut csprng = OsRng{};
//! # let keypair: Keypair = Keypair::generate(&mut csprng); //! # let keypair: Keypair = Keypair::generate(&mut csprng);
//! # let message: &[u8] = b"This is a test of the tsunami alert system."; //! # let message: &[u8] = b"This is a test of the tsunami alert system.";
//! # let signature: Signature = keypair.sign(message); //! # let signature: Signature = keypair.sign(message);
@ -80,16 +74,14 @@
//! verify this signature: //! verify this signature:
//! //!
//! ``` //! ```
//! # extern crate rand_core; //! # extern crate rand;
//! # extern crate rand_os;
//! # extern crate ed25519_dalek; //! # extern crate ed25519_dalek;
//! # fn main() { //! # fn main() {
//! # use rand_core::RngCore; //! # use rand::rngs::OsRng;
//! # use rand_os::OsRng;
//! # use ed25519_dalek::Keypair; //! # use ed25519_dalek::Keypair;
//! # use ed25519_dalek::Signature; //! # use ed25519_dalek::Signature;
//! use ed25519_dalek::PublicKey; //! use ed25519_dalek::PublicKey;
//! # let mut csprng = OsRng::new().unwrap(); //! # let mut csprng = OsRng{};
//! # let keypair: Keypair = Keypair::generate(&mut csprng); //! # let keypair: Keypair = Keypair::generate(&mut csprng);
//! # let message: &[u8] = b"This is a test of the tsunami alert system."; //! # let message: &[u8] = b"This is a test of the tsunami alert system.";
//! # let signature: Signature = keypair.sign(message); //! # let signature: Signature = keypair.sign(message);
@ -108,15 +100,13 @@
//! verify your signatures!) //! verify your signatures!)
//! //!
//! ``` //! ```
//! # extern crate rand_core; //! # extern crate rand;
//! # extern crate rand_os;
//! # extern crate ed25519_dalek; //! # extern crate ed25519_dalek;
//! # fn main() { //! # fn main() {
//! # use rand_core::RngCore; //! # use rand::rngs::OsRng;
//! # use rand_os::OsRng;
//! # use ed25519_dalek::{Keypair, Signature, PublicKey}; //! # use ed25519_dalek::{Keypair, Signature, PublicKey};
//! use ed25519_dalek::{PUBLIC_KEY_LENGTH, SECRET_KEY_LENGTH, KEYPAIR_LENGTH, SIGNATURE_LENGTH}; //! use ed25519_dalek::{PUBLIC_KEY_LENGTH, SECRET_KEY_LENGTH, KEYPAIR_LENGTH, SIGNATURE_LENGTH};
//! # let mut csprng = OsRng::new().unwrap(); //! # let mut csprng = OsRng{};
//! # let keypair: Keypair = Keypair::generate(&mut csprng); //! # let keypair: Keypair = Keypair::generate(&mut csprng);
//! # let message: &[u8] = b"This is a test of the tsunami alert system."; //! # let message: &[u8] = b"This is a test of the tsunami alert system.";
//! # let signature: Signature = keypair.sign(message); //! # let signature: Signature = keypair.sign(message);
@ -132,15 +122,13 @@
//! And similarly, decoded from bytes with `::from_bytes()`: //! And similarly, decoded from bytes with `::from_bytes()`:
//! //!
//! ``` //! ```
//! # extern crate rand_core; //! # extern crate rand;
//! # extern crate rand_os;
//! # extern crate ed25519_dalek; //! # extern crate ed25519_dalek;
//! # use rand_core::RngCore; //! # use rand::rngs::OsRng;
//! # use rand_os::OsRng;
//! # use ed25519_dalek::{Keypair, Signature, PublicKey, SecretKey, SignatureError}; //! # use ed25519_dalek::{Keypair, Signature, PublicKey, SecretKey, SignatureError};
//! # use ed25519_dalek::{PUBLIC_KEY_LENGTH, SECRET_KEY_LENGTH, KEYPAIR_LENGTH, SIGNATURE_LENGTH}; //! # use ed25519_dalek::{PUBLIC_KEY_LENGTH, SECRET_KEY_LENGTH, KEYPAIR_LENGTH, SIGNATURE_LENGTH};
//! # fn do_test() -> Result<(SecretKey, PublicKey, Keypair, Signature), SignatureError> { //! # fn do_test() -> Result<(SecretKey, PublicKey, Keypair, Signature), SignatureError> {
//! # let mut csprng = OsRng::new().unwrap(); //! # let mut csprng = OsRng{};
//! # let keypair_orig: Keypair = Keypair::generate(&mut csprng); //! # let keypair_orig: Keypair = Keypair::generate(&mut csprng);
//! # let message: &[u8] = b"This is a test of the tsunami alert system."; //! # let message: &[u8] = b"This is a test of the tsunami alert system.";
//! # let signature_orig: Signature = keypair_orig.sign(message); //! # let signature_orig: Signature = keypair_orig.sign(message);
@ -175,8 +163,7 @@
//! For example, using [bincode](https://github.com/TyOverby/bincode): //! For example, using [bincode](https://github.com/TyOverby/bincode):
//! //!
//! ``` //! ```
//! # extern crate rand_core; //! # extern crate rand;
//! # extern crate rand_os;
//! # extern crate ed25519_dalek; //! # extern crate ed25519_dalek;
//! # #[cfg(feature = "serde")] //! # #[cfg(feature = "serde")]
//! extern crate serde; //! extern crate serde;
@ -185,11 +172,10 @@
//! //!
//! # #[cfg(feature = "serde")] //! # #[cfg(feature = "serde")]
//! # fn main() { //! # fn main() {
//! # use rand_core::RngCore; //! # use rand::rngs::OsRng;
//! # use rand_os::OsRng;
//! # use ed25519_dalek::{Keypair, Signature, PublicKey}; //! # use ed25519_dalek::{Keypair, Signature, PublicKey};
//! use bincode::{serialize, Infinite}; //! use bincode::{serialize, Infinite};
//! # let mut csprng = OsRng::new().unwrap(); //! # let mut csprng = OsRng{};
//! # let keypair: Keypair = Keypair::generate(&mut csprng); //! # let keypair: Keypair = Keypair::generate(&mut csprng);
//! # let message: &[u8] = b"This is a test of the tsunami alert system."; //! # let message: &[u8] = b"This is a test of the tsunami alert system.";
//! # let signature: Signature = keypair.sign(message); //! # let signature: Signature = keypair.sign(message);
@ -207,8 +193,7 @@
//! recipient may deserialise them and verify: //! recipient may deserialise them and verify:
//! //!
//! ``` //! ```
//! # extern crate rand_core; //! # extern crate rand;
//! # extern crate rand_os;
//! # extern crate ed25519_dalek; //! # extern crate ed25519_dalek;
//! # #[cfg(feature = "serde")] //! # #[cfg(feature = "serde")]
//! # extern crate serde; //! # extern crate serde;
@ -217,13 +202,12 @@
//! # //! #
//! # #[cfg(feature = "serde")] //! # #[cfg(feature = "serde")]
//! # fn main() { //! # fn main() {
//! # use rand_core::RngCore; //! # use rand::rngs::OsRng;
//! # use rand_os::OsRng;
//! # use ed25519_dalek::{Keypair, Signature, PublicKey}; //! # use ed25519_dalek::{Keypair, Signature, PublicKey};
//! # use bincode::{serialize, Infinite}; //! # use bincode::{serialize, Infinite};
//! use bincode::{deserialize}; //! use bincode::{deserialize};
//! //!
//! # let mut csprng = OsRng::new().unwrap(); //! # let mut csprng = OsRng{};
//! # let keypair: Keypair = Keypair::generate(&mut csprng); //! # let keypair: Keypair = Keypair::generate(&mut csprng);
//! let message: &[u8] = b"This is a test of the tsunami alert system."; //! let message: &[u8] = b"This is a test of the tsunami alert system.";
//! # let signature: Signature = keypair.sign(message); //! # let signature: Signature = keypair.sign(message);
@ -258,9 +242,8 @@ extern crate alloc;
extern crate clear_on_drop; extern crate clear_on_drop;
extern crate curve25519_dalek; extern crate curve25519_dalek;
extern crate failure; extern crate failure;
#[cfg(all(feature = "batch", any(feature = "std", feature = "alloc", test)))] #[cfg(any(feature = "batch", feature = "std", feature = "alloc", test))]
extern crate rand; extern crate rand;
extern crate rand_core;
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
extern crate serde; extern crate serde;
extern crate sha2; extern crate sha2;

View file

@ -19,7 +19,7 @@ use curve25519_dalek::digest::Digest;
use curve25519_dalek::edwards::CompressedEdwardsY; use curve25519_dalek::edwards::CompressedEdwardsY;
use curve25519_dalek::scalar::Scalar; use curve25519_dalek::scalar::Scalar;
use rand_core::{CryptoRng, RngCore}; use rand::{CryptoRng, RngCore};
use sha2::Sha512; use sha2::Sha512;
@ -125,18 +125,18 @@ impl SecretKey {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// extern crate rand_os; /// extern crate rand;
/// extern crate ed25519_dalek; /// extern crate ed25519_dalek;
/// ///
/// # #[cfg(feature = "std")] /// # #[cfg(feature = "std")]
/// # fn main() { /// # fn main() {
/// # /// #
/// use rand_os::OsRng; /// use rand::rngs::OsRng;
/// use ed25519_dalek::PublicKey; /// use ed25519_dalek::PublicKey;
/// use ed25519_dalek::SecretKey; /// use ed25519_dalek::SecretKey;
/// use ed25519_dalek::Signature; /// use ed25519_dalek::Signature;
/// ///
/// let mut csprng: OsRng = OsRng::new().unwrap(); /// let mut csprng = OsRng{};
/// let secret_key: SecretKey = SecretKey::generate(&mut csprng); /// let secret_key: SecretKey = SecretKey::generate(&mut csprng);
/// # } /// # }
/// # /// #
@ -147,17 +147,17 @@ impl SecretKey {
/// Afterwards, you can generate the corresponding public: /// Afterwards, you can generate the corresponding public:
/// ///
/// ``` /// ```
/// # extern crate rand_os; /// # extern crate rand;
/// # extern crate ed25519_dalek; /// # extern crate ed25519_dalek;
/// # /// #
/// # fn main() { /// # fn main() {
/// # /// #
/// # use rand_os::OsRng; /// # use rand::rngs::OsRng;
/// # use ed25519_dalek::PublicKey; /// # use ed25519_dalek::PublicKey;
/// # use ed25519_dalek::SecretKey; /// # use ed25519_dalek::SecretKey;
/// # use ed25519_dalek::Signature; /// # use ed25519_dalek::Signature;
/// # /// #
/// # let mut csprng = OsRng::new().unwrap(); /// # let mut csprng = OsRng{};
/// # let secret_key: SecretKey = SecretKey::generate(&mut csprng); /// # let secret_key: SecretKey = SecretKey::generate(&mut csprng);
/// ///
/// let public_key: PublicKey = (&secret_key).into(); /// let public_key: PublicKey = (&secret_key).into();
@ -270,18 +270,16 @@ impl<'a> From<&'a SecretKey> for ExpandedSecretKey {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # extern crate rand_core; /// # extern crate rand;
/// # extern crate rand_os;
/// # extern crate sha2; /// # extern crate sha2;
/// # extern crate ed25519_dalek; /// # extern crate ed25519_dalek;
/// # /// #
/// # fn main() { /// # fn main() {
/// # /// #
/// use rand_core::RngCore; /// use rand::rngs::OsRng;
/// use rand_os::OsRng;
/// use ed25519_dalek::{SecretKey, ExpandedSecretKey}; /// use ed25519_dalek::{SecretKey, ExpandedSecretKey};
/// ///
/// let mut csprng = OsRng::new().unwrap(); /// let mut csprng = OsRng{};
/// let secret_key: SecretKey = SecretKey::generate(&mut csprng); /// let secret_key: SecretKey = SecretKey::generate(&mut csprng);
/// let expanded_secret_key: ExpandedSecretKey = ExpandedSecretKey::from(&secret_key); /// let expanded_secret_key: ExpandedSecretKey = ExpandedSecretKey::from(&secret_key);
/// # } /// # }
@ -318,17 +316,17 @@ impl ExpandedSecretKey {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # extern crate rand_os; /// # extern crate rand;
/// # extern crate sha2; /// # extern crate sha2;
/// # extern crate ed25519_dalek; /// # extern crate ed25519_dalek;
/// # /// #
/// # #[cfg(feature = "std")] /// # #[cfg(feature = "std")]
/// # fn main() { /// # fn main() {
/// # /// #
/// use rand_os::OsRng; /// use rand::rngs::OsRng;
/// use ed25519_dalek::{SecretKey, ExpandedSecretKey}; /// use ed25519_dalek::{SecretKey, ExpandedSecretKey};
/// ///
/// let mut csprng: OsRng = OsRng::new().unwrap(); /// let mut csprng = OsRng{};
/// let secret_key: SecretKey = SecretKey::generate(&mut csprng); /// let secret_key: SecretKey = SecretKey::generate(&mut csprng);
/// let expanded_secret_key: ExpandedSecretKey = ExpandedSecretKey::from(&secret_key); /// let expanded_secret_key: ExpandedSecretKey = ExpandedSecretKey::from(&secret_key);
/// let expanded_secret_key_bytes: [u8; 64] = expanded_secret_key.to_bytes(); /// let expanded_secret_key_bytes: [u8; 64] = expanded_secret_key.to_bytes();
@ -358,7 +356,7 @@ impl ExpandedSecretKey {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// # extern crate rand_os; /// # extern crate rand;
/// # extern crate sha2; /// # extern crate sha2;
/// # extern crate ed25519_dalek; /// # extern crate ed25519_dalek;
/// # /// #
@ -367,11 +365,11 @@ impl ExpandedSecretKey {
/// # #[cfg(feature = "std")] /// # #[cfg(feature = "std")]
/// # fn do_test() -> Result<ExpandedSecretKey, SignatureError> { /// # fn do_test() -> Result<ExpandedSecretKey, SignatureError> {
/// # /// #
/// use rand_os::OsRng; /// use rand::rngs::OsRng;
/// use ed25519_dalek::{SecretKey, ExpandedSecretKey}; /// use ed25519_dalek::{SecretKey, ExpandedSecretKey};
/// use ed25519_dalek::SignatureError; /// use ed25519_dalek::SignatureError;
/// ///
/// let mut csprng: OsRng = OsRng::new().unwrap(); /// let mut csprng = OsRng{};
/// let secret_key: SecretKey = SecretKey::generate(&mut csprng); /// let secret_key: SecretKey = SecretKey::generate(&mut csprng);
/// let expanded_secret_key: ExpandedSecretKey = ExpandedSecretKey::from(&secret_key); /// let expanded_secret_key: ExpandedSecretKey = ExpandedSecretKey::from(&secret_key);
/// let bytes: [u8; 64] = expanded_secret_key.to_bytes(); /// let bytes: [u8; 64] = expanded_secret_key.to_bytes();

View file

@ -13,15 +13,13 @@
extern crate bincode; extern crate bincode;
extern crate ed25519_dalek; extern crate ed25519_dalek;
extern crate hex; extern crate hex;
extern crate rand_os;
extern crate sha2; extern crate sha2;
extern crate rand;
use ed25519_dalek::*; use ed25519_dalek::*;
use hex::FromHex; use hex::FromHex;
use rand_os::OsRng;
use sha2::Sha512; use sha2::Sha512;
#[cfg(test)] #[cfg(test)]
@ -113,6 +111,7 @@ mod vectors {
#[cfg(test)] #[cfg(test)]
mod integrations { mod integrations {
use super::*; use super::*;
use rand::rngs::OsRng;
#[test] #[test]
fn sign_verify() { // TestSignVerify fn sign_verify() { // TestSignVerify
@ -123,7 +122,7 @@ mod integrations {
let good: &[u8] = "test message".as_bytes(); let good: &[u8] = "test message".as_bytes();
let bad: &[u8] = "wrong message".as_bytes(); let bad: &[u8] = "wrong message".as_bytes();
let mut csprng: OsRng = OsRng::new().unwrap(); let mut csprng = OsRng{};
keypair = Keypair::generate(&mut csprng); keypair = Keypair::generate(&mut csprng);
good_sig = keypair.sign(&good); good_sig = keypair.sign(&good);
@ -146,7 +145,7 @@ mod integrations {
let good: &[u8] = b"test message"; let good: &[u8] = b"test message";
let bad: &[u8] = b"wrong message"; let bad: &[u8] = b"wrong message";
let mut csprng: OsRng = OsRng::new().unwrap(); let mut csprng = OsRng{};
// ugh… there's no `impl Copy for Sha512`… i hope we can all agree these are the same hashes // ugh… there's no `impl Copy for Sha512`… i hope we can all agree these are the same hashes
let mut prehashed_good1: Sha512 = Sha512::default(); let mut prehashed_good1: Sha512 = Sha512::default();
@ -186,7 +185,7 @@ mod integrations {
b"Fuck dumbin' it down, spit ice, skip jewellery: Molotov cocktails on me like accessories.", b"Fuck dumbin' it down, spit ice, skip jewellery: Molotov cocktails on me like accessories.",
b"Hey, I never cared about your bucks, so if I run up with a mask on, probably got a gas can too.", b"Hey, I never cared about your bucks, so if I run up with a mask on, probably got a gas can too.",
b"And I'm not here to fill 'er up. Nope, we came to riot, here to incite, we don't want any of your stuff.", ]; b"And I'm not here to fill 'er up. Nope, we came to riot, here to incite, we don't want any of your stuff.", ];
let mut csprng: OsRng = OsRng::new().unwrap(); let mut csprng = OsRng{};
let mut keypairs: Vec<Keypair> = Vec::new(); let mut keypairs: Vec<Keypair> = Vec::new();
let mut signatures: Vec<Signature> = Vec::new(); let mut signatures: Vec<Signature> = Vec::new();
@ -204,7 +203,7 @@ mod integrations {
#[test] #[test]
fn pubkey_from_secret_and_expanded_secret() { fn pubkey_from_secret_and_expanded_secret() {
let mut csprng = OsRng::new().unwrap(); let mut csprng = OsRng{};
let secret: SecretKey = SecretKey::generate(&mut csprng); let secret: SecretKey = SecretKey::generate(&mut csprng);
let expanded_secret: ExpandedSecretKey = (&secret).into(); let expanded_secret: ExpandedSecretKey = (&secret).into();
let public_from_secret: PublicKey = (&secret).into(); // XXX eww let public_from_secret: PublicKey = (&secret).into(); // XXX eww