Skip to main content

MpcScheme

Trait MpcScheme 

Source
pub trait MpcScheme
where Self: Debug + Clone + Serialize + for<'de> Deserialize<'de>,
{ 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§

Source

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.

Source

type NetworkElement: Debug + Serialize + for<'de> Deserialize<'de>

The type that represents the element that travels across the network.

Source

type Wire: Debug

The type that represents the wire value.

Source

type Input: Debug

The type that represents the input from the party.

Source

type Operation: Debug + Serialize + for<'de> Deserialize<'de> + Operation

The type that represents the operation.

Source

type Pending<'a>: Debug

The type that represents the pending operation returned from MpcScheme::do_network_phase and consumed by MpcScheme::do_finalize_phase.

Source

type EstablishContextError: Error + Send + Sync + 'static

The error type returned by MpcScheme::establish_context.

Source

type NetworkPhaseError: Error + Send + Sync + 'static

The error type returned by MpcScheme::do_network_phase.

Source

type FinalizePhaseError: Error + Send + Sync + 'static

The error type returned by MpcScheme::do_finalize_phase.

Required Methods§

Source

fn is_circuit_sound<'a, I>(&self, circuit: I) -> bool
where Self::Operation: 'a, I: IntoIterator<Item = &'a Self::Operation>,

Returns true if the circuit “makes sense”. MpcCircuit::new will fail if this returns false.

  • circuit: an iterator of operations
Source

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.
Source

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.

Source

fn prepare_user_input<I>(&self, context: &mut Self::Context, inputs: I)
where I: IntoIterator<Item = (WireId, Self::Input)>,

The caller should ensure that the inputs are valid.

Source

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>,

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.

Source

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.

Implementors§