Trait round_based::party::Mpc

source ·
pub trait Mpc: Sealed {
    type ProtocolMessage;
    type Delivery: Delivery<Self::ProtocolMessage, SendError = Self::SendError, ReceiveError = Self::ReceiveError>;
    type Runtime: AsyncRuntime;
    type SendError: StdError + Send + Sync + 'static;
    type ReceiveError: StdError + Send + Sync + 'static;

    // Required method
    fn into_party(
        self
    ) -> MpcParty<Self::ProtocolMessage, Self::Delivery, Self::Runtime>;
}
Expand description

Party of MPC protocol (trait)

MpcParty is the only struct that implement this trait. Motivation to have this trait is to fewer amount of generic bounds that are needed to be specified.

Typical usage of this trait when implementing MPC protocol:

use round_based::{Mpc, MpcParty, PartyIndex};

async fn keygen<M>(party: M, i: PartyIndex, n: u16)
where
    M: Mpc<ProtocolMessage = Msg>
{
    let MpcParty{ delivery, .. } = party.into_party();
    // ...
}

If we didn’t have this trait, generics would be less readable:

use round_based::{MpcParty, Delivery, runtime::AsyncRuntime, PartyIndex};

async fn keygen<D, R>(party: MpcParty<Msg, D, R>, i: PartyIndex, n: u16)
where
    D: Delivery<Msg>,
    R: AsyncRuntime
{
    // ...
}

Required Associated Types§

source

type ProtocolMessage

MPC message

source

type Delivery: Delivery<Self::ProtocolMessage, SendError = Self::SendError, ReceiveError = Self::ReceiveError>

Transport layer implementation

source

type Runtime: AsyncRuntime

Async runtime

source

type SendError: StdError + Send + Sync + 'static

Sending message error

source

type ReceiveError: StdError + Send + Sync + 'static

Receiving message error

Required Methods§

source

fn into_party( self ) -> MpcParty<Self::ProtocolMessage, Self::Delivery, Self::Runtime>

Converts into MpcParty

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<M, D, R> Mpc for MpcParty<M, D, R>
where D: Delivery<M>, D::SendError: StdError + Send + Sync + 'static, D::ReceiveError: StdError + Send + Sync + 'static, R: AsyncRuntime,

§

type ProtocolMessage = M

§

type Delivery = D

§

type Runtime = R

§

type SendError = <D as Delivery<M>>::SendError

§

type ReceiveError = <D as Delivery<M>>::ReceiveError