pub struct Simulation<'a, O, M> { /* private fields */ }sim only.Expand description
Simulates MPC protocol with parties defined as state machines
Implementations§
Source§impl<'a, O, M> Simulation<'a, O, M>where
M: Clone + 'static,
impl<'a, O, M> Simulation<'a, O, M>where
M: Clone + 'static,
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Creates empty simulation containing no parties
New parties can be added via .add_party()
Sourcepub fn with_capacity(n: u16) -> Self
pub fn with_capacity(n: u16) -> Self
Constructs empty simulation containing no parties, with allocated memory that can fit up to n parties without re-allocations
Sourcepub fn from_async_fn<F>(n: u16, init: impl FnMut(u16, MpcParty<M>) -> F) -> Selfwhere
F: Future<Output = O> + 'a,
pub fn from_async_fn<F>(n: u16, init: impl FnMut(u16, MpcParty<M>) -> F) -> Selfwhere
F: Future<Output = O> + 'a,
Constructs a simulation with n parties from async function that defines the protocol
Each party has index 0 <= i < n and instantiated via provided init function
Async function will be converted into a state machine. Because of that,
it cannot await on any futures that aren’t provided by MpcParty (that is given as an argument
to this function).
Sourcepub fn from_fn<S>(n: u16, init: impl FnMut(u16) -> S) -> Selfwhere
S: StateMachine<Output = O, Msg = M> + 'a,
pub fn from_fn<S>(n: u16, init: impl FnMut(u16) -> S) -> Selfwhere
S: StateMachine<Output = O, Msg = M> + 'a,
Construct a simulation with n parties from init function that constructs state machine for each party
Each party has index 0 <= i < n and instantiated via provided init function
Sourcepub fn add_party(&mut self, party: impl StateMachine<Output = O, Msg = M> + 'a)
pub fn add_party(&mut self, party: impl StateMachine<Output = O, Msg = M> + 'a)
Adds new party into the protocol
New party will be assigned index i = n - 1 where n is amount of parties in the
simulation after this party was added.
Sourcepub fn add_async_party<F>(&mut self, party: impl FnOnce(MpcParty<M>) -> F)where
F: Future<Output = O> + 'a,
pub fn add_async_party<F>(&mut self, party: impl FnOnce(MpcParty<M>) -> F)where
F: Future<Output = O> + 'a,
Adds new party, defined as an async function, into the protocol
New party will be assigned index i = n - 1 where n is amount of parties in the
simulation after this party was added.
Async function will be converted into a state machine. Because of that,
it cannot await on any futures that aren’t provided by MpcParty (that is given as an argument
to this function).
Sourcepub fn parties_amount(&self) -> usize
pub fn parties_amount(&self) -> usize
Returns amount of parties in the simulation