Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 0.2.0, using threshold_crypto 0.4.0 #434

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hbbft"
version = "0.1.1"
version = "0.2.0"
authors = [
"Vladimir Komendantskiy <[email protected]>",
"Andreas Fackler <[email protected]>",
Expand Down Expand Up @@ -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]
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion examples/network/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl<T: Clone + Debug + AsRef<[u8]> + PartialEq + Send + Sync + From<Vec<u8>> +
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| {
Expand Down
2 changes: 1 addition & 1 deletion examples/simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ fn parse_args() -> Result<Args, docopt::Error> {

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 {
Expand Down
12 changes: 7 additions & 5 deletions hbbft_testing/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hbbft_testing"
version = "0.1.0"
version = "0.2.0"
authors = [
"Vladimir Komendantskiy <[email protected]>",
"Andreas Fackler <[email protected]>",
Expand All @@ -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"]
4 changes: 1 addition & 3 deletions src/broadcast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/dynamic_honey_badger/votes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<VoteCounter<usize>>, Vec<Vec<SignedVote<usize>>>) {
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();
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
5 changes: 3 additions & 2 deletions src/sync_key_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down