pub fn run<M, F>(
n: u16,
party_start: impl FnMut(u16, MpcParty<M>) -> F,
) -> Result<SimResult<F::Output>, SimError>Available on crate feature
sim only.Expand description
Simulates execution of the protocol
Takes amount of participants, and a function that carries out the protocol for
one party. The function takes as input: index of the party, and MpcParty
that can be used to communicate with others.
ยงExample
use round_based::{Mpc, PartyIndex};
// Any MPC protocol you want to test
pub async fn protocol_of_random_generation<M>(
party: M,
i: PartyIndex,
n: u16
) -> Result<Randomness>
where
M: Mpc<ProtocolMessage = Msg>
{
// ...
}
let n = 3;
let output = round_based::sim::run(
n,
|i, party| protocol_of_random_generation(party, i, n),
)
.unwrap()
// unwrap `Result`s
.expect_ok()
// check that all parties produced the same response
.expect_eq();
println!("Output randomness: {}", hex::encode(output));