updated the examples with the keys

This commit is contained in:
Vladimir Komendantskiy 2018-06-13 10:47:33 +01:00
parent 4dbef3968d
commit 04b7365ed9
3 changed files with 27 additions and 2 deletions

View File

@ -8,7 +8,9 @@ extern crate env_logger;
extern crate hbbft;
#[macro_use]
extern crate log;
extern crate pairing;
extern crate protobuf;
extern crate rand;
mod network;

View File

@ -42,7 +42,11 @@ use std::net::SocketAddr;
use std::rc::Rc;
use std::{io, iter, process, thread, time};
use pairing::bls12_381::Bls12;
use rand;
use hbbft::broadcast::{Broadcast, BroadcastMessage};
use hbbft::crypto::SecretKeySet;
use hbbft::messaging::{DistAlgorithm, NetworkInfo, SourcedMessage};
use hbbft::proto::message::BroadcastProto;
use network::commst;
@ -124,7 +128,16 @@ impl<T: Clone + Debug + AsRef<[u8]> + PartialEq + Send + Sync + From<Vec<u8>> +
// corresponding to this instance, and no dedicated comms task. The
// node index is 0.
let broadcast_handle = scope.spawn(move || {
let netinfo = Rc::new(NetworkInfo::new(our_id, (0..num_nodes).collect()));
let all_ids = (0..num_nodes).collect();
let sk_set =
SecretKeySet::<Bls12>::new((num_nodes - 1) / 3, &mut rand::thread_rng());
let pk_set = sk_set.public_keys();
let netinfo = Rc::new(NetworkInfo::new(
our_id,
all_ids,
sk_set.secret_key_share(our_id as u64),
pk_set.clone(),
));
let mut broadcast =
Broadcast::new(netinfo, proposer_id).expect("failed to instantiate broadcast");

View File

@ -4,6 +4,7 @@ extern crate docopt;
extern crate env_logger;
extern crate hbbft;
extern crate itertools;
extern crate pairing;
extern crate rand;
extern crate serde;
#[macro_use(Deserialize, Serialize)]
@ -18,11 +19,13 @@ use std::{cmp, u64};
use colored::*;
use docopt::Docopt;
use itertools::Itertools;
use pairing::bls12_381::Bls12;
use rand::Rng;
use serde::de::DeserializeOwned;
use serde::Serialize;
use signifix::{metric, TryFrom};
use hbbft::crypto::SecretKeySet;
use hbbft::honey_badger::{Batch, HoneyBadger};
use hbbft::messaging::{DistAlgorithm, NetworkInfo, Target};
@ -425,8 +428,15 @@ fn main() {
println!();
let num_good_nodes = args.flag_n - args.flag_f;
let txs = (0..args.flag_txs).map(|_| Transaction::new(args.flag_tx_size));
let sk_set = SecretKeySet::<Bls12>::new(args.flag_f, &mut rand::thread_rng());
let pk_set = sk_set.public_keys();
let new_honey_badger = |id: NodeUid, all_ids: BTreeSet<NodeUid>| {
let netinfo = Rc::new(NetworkInfo::new(id, all_ids));
let netinfo = Rc::new(NetworkInfo::new(
id,
all_ids,
sk_set.secret_key_share(id.0 as u64),
pk_set.clone(),
));
HoneyBadger::new(netinfo, args.flag_b, txs.clone()).expect("Instantiate honey_badger")
};
let hw_quality = HwQuality {