pub trait MpcScheme{
type Context: Debug;
type NetworkElement: Debug + Serialize + for<'de> Deserialize<'de>;
type Wire: Debug;
type Input: Debug;
type Operation: Debug + Serialize + for<'de> Deserialize<'de> + Operation;
type Pending<'a>: Debug;
type EstablishContextError: Error + Send + Sync + 'static;
type NetworkPhaseError: Error + Send + Sync + 'static;
type FinalizePhaseError: Error + Send + Sync + 'static;
// Required methods
fn is_circuit_sound<'a, I>(&self, circuit: I) -> bool
where Self::Operation: 'a,
I: IntoIterator<Item = &'a Self::Operation>;
fn is_operation_local(&self, op: &Self::Operation) -> bool;
fn establish_context<N: Network>(
&self,
network: &mut N,
circuit: &MpcCircuit<Self>,
) -> Result<Self::Context, Self::EstablishContextError>;
fn prepare_user_input<I>(&self, context: &mut Self::Context, inputs: I)
where I: IntoIterator<Item = (WireId, Self::Input)>;
fn do_network_phase<'a, I>(
&self,
context: &mut Self::Context,
op: &Self::Operation,
inputs: I,
) -> Result<NetworkPhaseOutput<'a, Self>, Self::NetworkPhaseError>
where Self::Wire: 'a,
I: IntoIterator<Item = &'a Self::Wire>;
fn do_finalize_phase<'a, I>(
&self,
context: &mut Self::Context,
pending: Self::Pending<'a>,
network_data: I,
) -> Result<FinalizePhaseOutput<Self>, Self::FinalizePhaseError>
where I: IntoIterator<Item = Self::NetworkElement>;
}Expand description
A type that represents an MPC scheme.
Required Associated Types§
Sourcetype Context: Debug
type Context: Debug
The context type that contains the necessary information that should be remembered during
the entire execution. See MpcScheme::establish_context,
MpcScheme::do_network_phase, and MpcScheme::do_finalize_phase.
Sourcetype NetworkElement: Debug + Serialize + for<'de> Deserialize<'de>
type NetworkElement: Debug + Serialize + for<'de> Deserialize<'de>
The type that represents the element that travels across the network.
Sourcetype Operation: Debug + Serialize + for<'de> Deserialize<'de> + Operation
type Operation: Debug + Serialize + for<'de> Deserialize<'de> + Operation
The type that represents the operation.
Sourcetype Pending<'a>: Debug
type Pending<'a>: Debug
The type that represents the pending operation returned from MpcScheme::do_network_phase
and consumed by MpcScheme::do_finalize_phase.
Sourcetype EstablishContextError: Error + Send + Sync + 'static
type EstablishContextError: Error + Send + Sync + 'static
The error type returned by MpcScheme::establish_context.
Sourcetype NetworkPhaseError: Error + Send + Sync + 'static
type NetworkPhaseError: Error + Send + Sync + 'static
The error type returned by MpcScheme::do_network_phase.
Sourcetype FinalizePhaseError: Error + Send + Sync + 'static
type FinalizePhaseError: Error + Send + Sync + 'static
The error type returned by MpcScheme::do_finalize_phase.
Required Methods§
Sourcefn is_circuit_sound<'a, I>(&self, circuit: I) -> bool
fn is_circuit_sound<'a, I>(&self, circuit: I) -> bool
Returns true if the circuit “makes sense”. MpcCircuit::new will fail if this returns
false.
circuit: an iterator of operations
Sourcefn is_operation_local(&self, op: &Self::Operation) -> bool
fn is_operation_local(&self, op: &Self::Operation) -> bool
Returns true if op can be done without communication whenever the inputs are ready.
// The "input" operation of this scheme must not be local.
assert!(!op.is_input() || !scheme.is_operation_local(op));op: The operation.
Sourcefn establish_context<N: Network>(
&self,
network: &mut N,
circuit: &MpcCircuit<Self>,
) -> Result<Self::Context, Self::EstablishContextError>
fn establish_context<N: Network>( &self, network: &mut N, circuit: &MpcCircuit<Self>, ) -> Result<Self::Context, Self::EstablishContextError>
Specify how the context should be established given a network and the circuit.
Sourcefn prepare_user_input<I>(&self, context: &mut Self::Context, inputs: I)
fn prepare_user_input<I>(&self, context: &mut Self::Context, inputs: I)
The caller should ensure that the inputs are valid.
Sourcefn do_network_phase<'a, I>(
&self,
context: &mut Self::Context,
op: &Self::Operation,
inputs: I,
) -> Result<NetworkPhaseOutput<'a, Self>, Self::NetworkPhaseError>
fn do_network_phase<'a, I>( &self, context: &mut Self::Context, op: &Self::Operation, inputs: I, ) -> Result<NetworkPhaseOutput<'a, Self>, Self::NetworkPhaseError>
Given a context, an operation, and the inputs, return the send/receive requests that should
be processed before calling the corresponding MpcScheme::do_network_phase. This
function must sanitize inputs.
Sourcefn do_finalize_phase<'a, I>(
&self,
context: &mut Self::Context,
pending: Self::Pending<'a>,
network_data: I,
) -> Result<FinalizePhaseOutput<Self>, Self::FinalizePhaseError>where
I: IntoIterator<Item = Self::NetworkElement>,
fn do_finalize_phase<'a, I>(
&self,
context: &mut Self::Context,
pending: Self::Pending<'a>,
network_data: I,
) -> Result<FinalizePhaseOutput<Self>, Self::FinalizePhaseError>where
I: IntoIterator<Item = Self::NetworkElement>,
Given a context, a pending operation, and the (possible) network data, finalize the
operation and return the corresponding outputs. The return value must be consistent with
Operation::outputs (i.e. the number of output wires must match).
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.