pub trait MpcExecution {
type Round<R: RoundInfo>;
type Msg;
type CompleteRoundErr<E>;
type SendErr;
type SendMany: SendMany<Exec = Self, Msg = Self::Msg, SendErr = Self::SendErr>;
// Required methods
async fn complete<R>(
&mut self,
round: Self::Round<R>,
) -> Result<R::Output, Self::CompleteRoundErr<R::Error>>
where R: RoundInfo,
Self::Msg: RoundMsg<R::Msg>;
async fn send(
&mut self,
msg: Outgoing<Self::Msg>,
) -> Result<(), Self::SendErr>;
fn send_many(self) -> Self::SendMany;
async fn yield_now(&self);
// Provided methods
async fn send_p2p(
&mut self,
recipient: PartyIndex,
msg: Self::Msg,
) -> Result<(), Self::SendErr> { ... }
async fn send_to_all(&mut self, msg: Self::Msg) -> Result<(), Self::SendErr> { ... }
async fn reliably_broadcast(
&mut self,
msg: Self::Msg,
) -> Result<(), Self::SendErr> { ... }
}Expand description
Abstracts functionalities needed for MPC protocol execution
Required Associated Types§
Sourcetype Round<R: RoundInfo>
type Round<R: RoundInfo>
Witness that round was registered
It’s obtained by registering round in Mpc::add_round, which then can be used to retrieve
messages from associated round by calling MpcExecution::complete.
Sourcetype CompleteRoundErr<E>
type CompleteRoundErr<E>
Error indicating that completing a round has failed
Required Methods§
Sourceasync fn complete<R>(
&mut self,
round: Self::Round<R>,
) -> Result<R::Output, Self::CompleteRoundErr<R::Error>>
async fn complete<R>( &mut self, round: Self::Round<R>, ) -> Result<R::Output, Self::CompleteRoundErr<R::Error>>
Completes the round
Waits until we receive all the messages in the round R from other parties. Returns
received messages.
Sourceasync fn send(&mut self, msg: Outgoing<Self::Msg>) -> Result<(), Self::SendErr>
async fn send(&mut self, msg: Outgoing<Self::Msg>) -> Result<(), Self::SendErr>
Sends a message
This method awaits until the message is sent, which might be not the best method to use if you
need to send many messages at once. If it’s the case, prefer using .send_many().
Sourcefn send_many(self) -> Self::SendMany
fn send_many(self) -> Self::SendMany
Creates a buffer of outgoing messages so they can be sent all at once
When you have many messages that you want to send at once, using .send()
may be inefficient, as delivery implementation may pause the execution until the message is
received by the recipient. Use this method to send many messages in a batch.
This method takes ownership of self to create the impl SendMany object. After
enqueueing all the messages, you need to reclaim self back by calling SendMany::flush.
Provided Methods§
Sourceasync fn send_p2p(
&mut self,
recipient: PartyIndex,
msg: Self::Msg,
) -> Result<(), Self::SendErr>
async fn send_p2p( &mut self, recipient: PartyIndex, msg: Self::Msg, ) -> Result<(), Self::SendErr>
Sends a p2p message to another party
Note: when you send many messages at once (it’s most likely the case when you send a p2p message), this method
is not efficient, prefer using .send_many().
Sourceasync fn send_to_all(&mut self, msg: Self::Msg) -> Result<(), Self::SendErr>
async fn send_to_all(&mut self, msg: Self::Msg) -> Result<(), Self::SendErr>
Sends a message that will be received by all parties
Message will be broadcasted, but not reliably. If you need a reliable broadcast, use
MpcExecution::reliably_broadcast method.
Sourceasync fn reliably_broadcast(
&mut self,
msg: Self::Msg,
) -> Result<(), Self::SendErr>
async fn reliably_broadcast( &mut self, msg: Self::Msg, ) -> Result<(), Self::SendErr>
Reliably broadcasts a message
Message will be received by all participants of the protocol. Moreover, when recipient receives a message, it will be assured (cryptographically or through other trust assumptions) that all honest participants of the protocol received the same message.
It’s a responsibility of a message delivery layer to provide the reliable broadcast mechanism. If it’s not supported, this method returns an error. Note that not every MPC protocol requires the reliable broadcast, so it’s totally normal to have a message delivery implementation that does not support it.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
Source§impl<D, M, MainMsg> MpcExecution for WithEchoBroadcast<D, M, MainMsg>where
D: Digest + 'static,
M: MpcExecution<Msg = Msg<D, MainMsg>>,
MainMsg: ProtocolMsg + Digestable + Clone + 'static,
Available on crate feature echo-broadcast only.
impl<D, M, MainMsg> MpcExecution for WithEchoBroadcast<D, M, MainMsg>where
D: Digest + 'static,
M: MpcExecution<Msg = Msg<D, MainMsg>>,
MainMsg: ProtocolMsg + Digestable + Clone + 'static,
echo-broadcast only.