diff --git a/Cargo.toml b/Cargo.toml index 8b747ce..8848c2c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hbbft" -version = "0.1.1" +version = "0.2.0" authors = [ "Vladimir Komendantskiy ", "Andreas Fackler ", @@ -29,11 +29,12 @@ failure = "0.1.6" hex_fmt = "0.3" init_with = "1.1.0" log = "0.4.8" -rand = "0.6.5" +rand = "0.7.3" rand_derive = "0.5.0" reed-solomon-erasure = "4.0.1" serde = { version = "1.0.102", features = ["derive", "rc"] } -threshold_crypto = { rev = "624eeee", git = "https://github.com/poanetwork/threshold_crypto" } +# TODO: Version 0.4.0 +threshold_crypto = { rev = "d4a500ce75002fca761c88adc7f4f9b28fded987", git = "https://github.com/poanetwork/threshold_crypto" } tiny-keccak = { version = "2.0.1", features = ["sha3"]} [dev-dependencies] @@ -44,7 +45,8 @@ docopt = "1.1.0" hbbft_testing = { path = "hbbft_testing", features = ["use-insecure-test-only-mock-crypto"] } itertools = "0.9.0" number_prefix = "0.3.0" -proptest = "0.9.4" +# TODO: Update once there is a release that uses rand 0.7. +proptest = { rev = "2f5062a", git = "https://github.com/AltSysrq/proptest" } [[example]] name = "consensus-node" diff --git a/examples/network/node.rs b/examples/network/node.rs index 0c4dffc..2a895c0 100644 --- a/examples/network/node.rs +++ b/examples/network/node.rs @@ -89,7 +89,7 @@ impl + PartialEq + Send + Sync + From> + let tx_from_algo = messaging.tx_from_algo(); let stop_tx = messaging.stop_tx(); - let mut rng = rand::rngs::OsRng::new().unwrap(); + let mut rng = rand::rngs::OsRng; // All spawned threads will have exited by the end of the scope. crossbeam::scope(|scope| { diff --git a/examples/simulation.rs b/examples/simulation.rs index 2438131..5df3b34 100644 --- a/examples/simulation.rs +++ b/examples/simulation.rs @@ -399,7 +399,7 @@ fn parse_args() -> Result { fn main() { env_logger::init(); - let mut rng = OsRng::new().expect("Could not initialize OS random number generator."); + let mut rng = OsRng; let args = parse_args().unwrap_or_else(|e| e.exit()); if args.flag_n <= 3 * args.flag_f { diff --git a/hbbft_testing/Cargo.toml b/hbbft_testing/Cargo.toml index de51d6d..edb5a11 100644 --- a/hbbft_testing/Cargo.toml +++ b/hbbft_testing/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hbbft_testing" -version = "0.1.0" +version = "0.2.0" authors = [ "Vladimir Komendantskiy ", "Andreas Fackler ", @@ -25,10 +25,12 @@ travis-ci = { repository = "poanetwork/hbbft" } failure = "0.1.6" hbbft = { path = ".." } integer-sqrt = "0.1.2" -proptest = "0.9.4" -rand = "0.6.5" -rand_xorshift = "0.1.1" -threshold_crypto = { rev = "624eeee", git = "https://github.com/poanetwork/threshold_crypto" } +# TODO: Update once there is a release that uses rand 0.7. +proptest = { rev = "2f5062a", git = "https://github.com/AltSysrq/proptest" } +rand = "0.7.3" +rand_xorshift = "0.2.0" +# TODO: Version 0.4.0 +threshold_crypto = { rev = "d4a500ce75002fca761c88adc7f4f9b28fded987", git = "https://github.com/poanetwork/threshold_crypto" } [features] use-insecure-test-only-mock-crypto = ["hbbft/use-insecure-test-only-mock-crypto"] diff --git a/src/broadcast/mod.rs b/src/broadcast/mod.rs index 191c75c..83980e0 100644 --- a/src/broadcast/mod.rs +++ b/src/broadcast/mod.rs @@ -150,8 +150,6 @@ //! const NUM_NODES: u64 = 7; //! const PROPOSER_ID: u64 = 3; //! -//! let mut rng = OsRng::new().expect("Could not initialize OS random number generator."); -//! //! let validators = Arc::new(ValidatorSet::from(0..NUM_NODES)); //! //! // Create initial nodes by instantiating a `Broadcast` for each. @@ -163,7 +161,7 @@ //! //! // First we generate a random payload. //! let mut payload: Vec<_> = vec![0; 128]; -//! rng.fill_bytes(&mut payload[..]); +//! OsRng.fill_bytes(&mut payload[..]); //! //! // Define a function for handling one step of a `Broadcast` instance. This function appends //! // new messages onto the message queue and checks whether each node outputs at most once diff --git a/src/dynamic_honey_badger/votes.rs b/src/dynamic_honey_badger/votes.rs index e40d114..bb3607a 100644 --- a/src/dynamic_honey_badger/votes.rs +++ b/src/dynamic_honey_badger/votes.rs @@ -209,7 +209,7 @@ mod tests { /// the vote by node `i` for making `j` the only validator. Each node signed this for nodes /// `0`, `1`, ... in order. fn setup(node_num: usize, era: u64) -> (Vec>, Vec>>) { - let mut rng = rngs::OsRng::new().expect("could not initialize OsRng"); + let mut rng = rngs::OsRng; // Generate keys for signing and encrypting messages. let sec_keys: BTreeMap<_, SecretKey> = (0..node_num).map(|id| (id, rng.gen())).collect(); diff --git a/src/lib.rs b/src/lib.rs index a4bacf8..3220cdb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -139,7 +139,7 @@ pub mod threshold_sign; pub mod transaction_queue; pub mod util; -pub use crate::crypto::pairing; +pub use crate::crypto::{group, pairing}; pub use crate::fault_log::{Fault, FaultLog}; pub use crate::messaging::{SourcedMessage, Target, TargetedMessage}; pub use crate::network_info::{NetworkInfo, ValidatorSet}; diff --git a/src/sync_key_gen.rs b/src/sync_key_gen.rs index 9b45810..7f7b92d 100644 --- a/src/sync_key_gen.rs +++ b/src/sync_key_gen.rs @@ -63,7 +63,7 @@ //! use hbbft::sync_key_gen::{to_pub_keys, AckOutcome, PartOutcome, PubKeyMap, SyncKeyGen}; //! //! // Use the OS random number generator for any randomness: -//! let mut rng = rand::rngs::OsRng::new().expect("Could not open OS random number generator."); +//! let mut rng = rand::rngs::OsRng; //! //! // Two out of four shares will suffice to sign or encrypt something. //! let (threshold, node_num) = (1, 4); @@ -189,8 +189,9 @@ use crate::crypto::{ serde_impl::FieldWrap, Fr, G1Affine, PublicKeySet, SecretKeyShare, }; -use crate::pairing::{CurveAffine, Field}; use crate::NodeIdT; +use crypto::ff::Field; +use crypto::group::CurveAffine; /// A cryptographic key that allows decrypting messages that were encrypted to the key's owner. pub trait SecretKey {