Skip to content

Commit

Permalink
this commit updates the protocol parameters for the mithril protocol …
Browse files Browse the repository at this point in the history
…demonstration. the parameters modified are the security parameter `m`, the quorum parameter `k`, `phi_f`, the number of parties `nparties`, and the number of messages to be signed `nmessages`. these parameters are now set to the default values of 200, 5, 0.2, 5, and 1 respectively.

the changes can be seen in the diff, with lines 9-63 in `main.rs` being updated to adjust the parameters. the new parameters are set with the `clap` macro, and are assigned to the `config` struct. the `config` struct is then used to initialize the `demonstrator` object in `main()` and can be seen in the updated code.
  • Loading branch information
falcucci committed Nov 7, 2023
1 parent 724c39f commit 2b1575c
Showing 1 changed file with 43 additions and 43 deletions.
86 changes: 43 additions & 43 deletions demo/protocol-demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,63 +9,63 @@ use rand_core::SeedableRng;
/// Simple demonstration of the Mithril protocol
#[derive(Parser, Debug, PartialEq, Clone, Copy)]
pub struct Config {
/// Security parameter, upper bound on indices
#[clap(short, long, default_value_t = 200)]
m: u64,
/// Security parameter, upper bound on indices
#[clap(short, long, default_value_t = 200)]
m: u64,

/// Quorum parameter
#[clap(short, long, default_value_t = 5)]
k: u64,
/// Quorum parameter
#[clap(short, long, default_value_t = 5)]
k: u64,

/// f in phi(w) = 1 - (1 - f)^w, where w is the stake of a participant.
#[clap(long, default_value_t = 0.2)]
phi_f: f64,
/// f in phi(w) = 1 - (1 - f)^w, where w is the stake of a participant.
#[clap(long, default_value_t = 0.2)]
phi_f: f64,

/// Number of parties
#[clap(long, default_value_t = 5)]
nparties: usize,
/// Number of parties
#[clap(long, default_value_t = 5)]
nparties: usize,

/// Number of messages to sign
#[clap(long, default_value_t = 1)]
nmessages: usize,
/// Number of messages to sign
#[clap(long, default_value_t = 1)]
nmessages: usize,
}

fn main() {
let config = Config::parse();
let config = Config::parse();

println!(">> Launch Mithril protocol demonstrator with configuration: \n{config:#?}");
println!(">> Launch Mithril protocol demonstrator with configuration: \n{config:#?}");

//////////////////////
// establish phase //
/////////////////////
//////////////////////
// establish phase //
/////////////////////

println!("\n>> Protocol establish phase");
let seed = [0u8; 32];
let mut rng = ChaCha20Rng::from_seed(seed);
let mut mithril_protocol = Demonstrator::new(&config, &mut rng);
mithril_protocol.establish();
println!("\n>> Protocol establish phase");
let seed = [0u8; 32];
let mut rng = ChaCha20Rng::from_seed(seed);
let mut mithril_protocol = Demonstrator::new(&config, &mut rng);
mithril_protocol.establish();

//////////////////////////
// initialization phase //
/////////////////////////
//////////////////////////
// initialization phase //
/////////////////////////

println!("\n>> Protocol initialize phase:");
mithril_protocol.initialize(&mut rng);
println!("\n>> Protocol initialize phase:");
mithril_protocol.initialize(&mut rng);

//////////////////////
// operations phase //
//////////////////////
//////////////////////
// operations phase //
//////////////////////

println!("\n>> Protocol issue certificates phase:");
mithril_protocol.issue_certificates();
println!("\n>> Protocol issue certificates phase:");
mithril_protocol.issue_certificates();

println!("\n>> Protocol verify certificates phase:");
match mithril_protocol.verify_certificates() {
Ok(_) => {
println!("\n>> Congrats, protocol terminated with success!\n")
}
Err(err) => {
println!("\n>> Certificate verification failed: {err}\n")
}
println!("\n>> Protocol verify certificates phase:");
match mithril_protocol.verify_certificates() {
Ok(_) => {
println!("\n>> Congrats, protocol terminated with success!\n")
}
Err(err) => {
println!("\n>> Certificate verification failed: {err}\n")
}
}
}

0 comments on commit 2b1575c

Please sign in to comment.