pub struct MpcFabric<C: CurveGroup> { /* private fields */ }
Expand description
A fabric for the MPC protocol, defines a dependency injection layer that dynamically schedules circuit gate evaluations onto the network to be executed
The fabric does not block on gate evaluations, but instead returns a handle to a future result that may be polled to obtain the materialized result. This allows the application layer to continue using the fabric, scheduling more gates to be evaluated and maximally exploiting gate-level parallelism within the circuit
Implementations§
source§impl<C: CurveGroup> MpcFabric<C>
impl<C: CurveGroup> MpcFabric<C>
sourcepub fn new<N: 'static + MpcNetwork<C>, S: 'static + SharedValueSource<C>>(
network: N,
beaver_source: S
) -> Self
pub fn new<N: 'static + MpcNetwork<C>, S: 'static + SharedValueSource<C>>( network: N, beaver_source: S ) -> Self
Constructor
sourcepub fn new_with_size_hint<N: 'static + MpcNetwork<C>, S: 'static + SharedValueSource<C>>(
size_hint: usize,
network: N,
beaver_source: S
) -> Self
pub fn new_with_size_hint<N: 'static + MpcNetwork<C>, S: 'static + SharedValueSource<C>>( size_hint: usize, network: N, beaver_source: S ) -> Self
Constructor that takes an additional size hint, indicating how much buffer space the fabric should allocate for results. The size is given in number of gates
sourcepub fn register_waiter(&self, waiter: ResultWaiter<C>)
pub fn register_waiter(&self, waiter: ResultWaiter<C>)
Register a waiter on a result
sourcepub fn zero(&self) -> ScalarResult<C>
pub fn zero(&self) -> ScalarResult<C>
Get the hardcoded zero wire as a raw ScalarResult
sourcepub fn zero_authenticated(&self) -> AuthenticatedScalarResult<C>
pub fn zero_authenticated(&self) -> AuthenticatedScalarResult<C>
Get the hardcoded zero wire as an AuthenticatedScalarResult
Both parties hold the share 0 directly in this case
sourcepub fn zeros_authenticated(&self, n: usize) -> Vec<AuthenticatedScalarResult<C>>
pub fn zeros_authenticated(&self, n: usize) -> Vec<AuthenticatedScalarResult<C>>
Get a batch of references to the zero wire as an
AuthenticatedScalarResult
sourcepub fn one(&self) -> ScalarResult<C>
pub fn one(&self) -> ScalarResult<C>
Get the hardcoded one wire as a raw ScalarResult
sourcepub fn one_authenticated(&self) -> AuthenticatedScalarResult<C>
pub fn one_authenticated(&self) -> AuthenticatedScalarResult<C>
Get the hardcoded one wire as an AuthenticatedScalarResult
Party 0 holds the value zero and party 1 holds the value one
sourcepub fn ones_authenticated(&self, n: usize) -> Vec<AuthenticatedScalarResult<C>>
pub fn ones_authenticated(&self, n: usize) -> Vec<AuthenticatedScalarResult<C>>
Get a batch of references to the one wire as an
AuthenticatedScalarResult
sourcepub fn curve_identity(&self) -> CurvePointResult<C>
pub fn curve_identity(&self) -> CurvePointResult<C>
Get the hardcoded curve identity wire as a raw CurvePointResult
sourcepub fn curve_identity_authenticated(&self) -> AuthenticatedPointResult<C>
pub fn curve_identity_authenticated(&self) -> AuthenticatedPointResult<C>
Get the hardcoded curve identity wire as an AuthenticatedPointResult
Both parties hold the identity point directly in this case
Share a Scalar
value with the counterparty
Share a batch of Scalar
values with the counterparty
Share a CurvePoint
value with the counterparty
Share a batch of CurvePoint
s with the counterparty
sourcepub fn allocate_scalar<T: Into<Scalar<C>>>(&self, value: T) -> ScalarResult<C>
pub fn allocate_scalar<T: Into<Scalar<C>>>(&self, value: T) -> ScalarResult<C>
Allocate a public value in the fabric
sourcepub fn allocate_scalars<T: Into<Scalar<C>>>(
&self,
values: Vec<T>
) -> Vec<ScalarResult<C>>
pub fn allocate_scalars<T: Into<Scalar<C>>>( &self, values: Vec<T> ) -> Vec<ScalarResult<C>>
Allocate a batch of scalars in the fabric
Allocate a scalar as a secret share of an already shared value
Allocate a batch of scalars as secret shares of already shared values
sourcepub fn allocate_point(&self, value: CurvePoint<C>) -> CurvePointResult<C>
pub fn allocate_point(&self, value: CurvePoint<C>) -> CurvePointResult<C>
Allocate a public curve point in the fabric
sourcepub fn allocate_points(
&self,
values: Vec<CurvePoint<C>>
) -> Vec<CurvePointResult<C>>
pub fn allocate_points( &self, values: Vec<CurvePoint<C>> ) -> Vec<CurvePointResult<C>>
Allocate a batch of points in the fabric
sourcepub fn send_value<T: From<ResultValue<C>> + Into<NetworkPayload<C>>>(
&self,
value: ResultHandle<C, T>
) -> ResultHandle<C, T> ⓘ
pub fn send_value<T: From<ResultValue<C>> + Into<NetworkPayload<C>>>( &self, value: ResultHandle<C, T> ) -> ResultHandle<C, T> ⓘ
Send a value to the peer, placing the identity in the local result buffer at the send ID
sourcepub fn send_values<T>(
&self,
values: &[ResultHandle<C, T>]
) -> ResultHandle<C, Vec<T>> ⓘwhere
T: From<ResultValue<C>>,
Vec<T>: Into<NetworkPayload<C>> + From<ResultValue<C>>,
pub fn send_values<T>( &self, values: &[ResultHandle<C, T>] ) -> ResultHandle<C, Vec<T>> ⓘwhere T: From<ResultValue<C>>, Vec<T>: Into<NetworkPayload<C>> + From<ResultValue<C>>,
Send a batch of values to the counterparty
sourcepub fn receive_value<T: From<ResultValue<C>>>(&self) -> ResultHandle<C, T> ⓘ
pub fn receive_value<T: From<ResultValue<C>>>(&self) -> ResultHandle<C, T> ⓘ
Receive a value from the peer
sourcepub fn exchange_value<T: From<ResultValue<C>> + Into<NetworkPayload<C>>>(
&self,
value: ResultHandle<C, T>
) -> ResultHandle<C, T> ⓘ
pub fn exchange_value<T: From<ResultValue<C>> + Into<NetworkPayload<C>>>( &self, value: ResultHandle<C, T> ) -> ResultHandle<C, T> ⓘ
Exchange a value with the peer, i.e. send then receive or receive then send based on the party ID
Returns a handle to the received value, which will be different for different parties
sourcepub fn exchange_values<T>(
&self,
values: &[ResultHandle<C, T>]
) -> ResultHandle<C, Vec<T>> ⓘwhere
T: From<ResultValue<C>>,
Vec<T>: From<ResultValue<C>> + Into<NetworkPayload<C>>,
pub fn exchange_values<T>( &self, values: &[ResultHandle<C, T>] ) -> ResultHandle<C, Vec<T>> ⓘwhere T: From<ResultValue<C>>, Vec<T>: From<ResultValue<C>> + Into<NetworkPayload<C>>,
Exchange a batch of values with the peer, i.e. send then receive or receive then send based on party ID
Share a public value with the counterparty
Share a batch of public values with the counterparty
sourcepub fn new_gate_op<F, T>(
&self,
args: Vec<ResultId>,
function: F
) -> ResultHandle<C, T> ⓘwhere
F: 'static + FnOnce(Vec<ResultValue<C>>) -> ResultValue<C> + Send + Sync,
T: From<ResultValue<C>>,
pub fn new_gate_op<F, T>( &self, args: Vec<ResultId>, function: F ) -> ResultHandle<C, T> ⓘwhere F: 'static + FnOnce(Vec<ResultValue<C>>) -> ResultValue<C> + Send + Sync, T: From<ResultValue<C>>,
Construct a new gate operation in the fabric, i.e. one that can be evaluated immediate given its inputs
sourcepub fn new_batch_gate_op<F, T>(
&self,
args: Vec<ResultId>,
output_arity: usize,
function: F
) -> Vec<ResultHandle<C, T>>where
F: 'static + FnOnce(Vec<ResultValue<C>>) -> Vec<ResultValue<C>> + Send + Sync,
T: From<ResultValue<C>>,
pub fn new_batch_gate_op<F, T>( &self, args: Vec<ResultId>, output_arity: usize, function: F ) -> Vec<ResultHandle<C, T>>where F: 'static + FnOnce(Vec<ResultValue<C>>) -> Vec<ResultValue<C>> + Send + Sync, T: From<ResultValue<C>>,
Construct a new batch gate operation in the fabric, i.e. one that can be evaluated to return an array of results
The array must be sized so that the fabric knows how many results to allocate buffer space for ahead of execution
sourcepub fn new_network_op<F, T>(
&self,
args: Vec<ResultId>,
function: F
) -> ResultHandle<C, T> ⓘwhere
F: 'static + FnOnce(Vec<ResultValue<C>>) -> NetworkPayload<C> + Send + Sync,
T: From<ResultValue<C>>,
pub fn new_network_op<F, T>( &self, args: Vec<ResultId>, function: F ) -> ResultHandle<C, T> ⓘwhere F: 'static + FnOnce(Vec<ResultValue<C>>) -> NetworkPayload<C> + Send + Sync, T: From<ResultValue<C>>,
Construct a new network operation in the fabric, i.e. one that requires a value to be sent over the channel
sourcepub fn next_beaver_triple(
&self
) -> (MpcScalarResult<C>, MpcScalarResult<C>, MpcScalarResult<C>)
pub fn next_beaver_triple( &self ) -> (MpcScalarResult<C>, MpcScalarResult<C>, MpcScalarResult<C>)
Sample the next beaver triplet from the beaver source
sourcepub fn next_beaver_triple_batch(
&self,
n: usize
) -> (Vec<MpcScalarResult<C>>, Vec<MpcScalarResult<C>>, Vec<MpcScalarResult<C>>)
pub fn next_beaver_triple_batch( &self, n: usize ) -> (Vec<MpcScalarResult<C>>, Vec<MpcScalarResult<C>>, Vec<MpcScalarResult<C>>)
Sample a batch of beaver triples
sourcepub fn next_authenticated_triple(
&self
) -> (AuthenticatedScalarResult<C>, AuthenticatedScalarResult<C>, AuthenticatedScalarResult<C>)
pub fn next_authenticated_triple( &self ) -> (AuthenticatedScalarResult<C>, AuthenticatedScalarResult<C>, AuthenticatedScalarResult<C>)
Sample the next beaver triplet with MACs from the beaver source
TODO: Authenticate these values either here or in the pre-processing phase as per the SPDZ paper
sourcepub fn next_authenticated_triple_batch(
&self,
n: usize
) -> (Vec<AuthenticatedScalarResult<C>>, Vec<AuthenticatedScalarResult<C>>, Vec<AuthenticatedScalarResult<C>>)
pub fn next_authenticated_triple_batch( &self, n: usize ) -> (Vec<AuthenticatedScalarResult<C>>, Vec<AuthenticatedScalarResult<C>>, Vec<AuthenticatedScalarResult<C>>)
Sample the next batch of beaver triples as AuthenticatedScalar
s
Sample a batch of random shared values from the beaver source
Sample a batch of random shared values from the beaver source and
allocate them as AuthenticatedScalars
sourcepub fn random_inverse_pair(
&self
) -> (AuthenticatedScalarResult<C>, AuthenticatedScalarResult<C>)
pub fn random_inverse_pair( &self ) -> (AuthenticatedScalarResult<C>, AuthenticatedScalarResult<C>)
Sample a pair of values that are multiplicative inverses of one another
sourcepub fn random_inverse_pairs(
&self,
n: usize
) -> (Vec<AuthenticatedScalarResult<C>>, Vec<AuthenticatedScalarResult<C>>)
pub fn random_inverse_pairs( &self, n: usize ) -> (Vec<AuthenticatedScalarResult<C>>, Vec<AuthenticatedScalarResult<C>>)
Sample a batch of values that are multiplicative inverses of one another
Sample a random shared bit from the beaver source
Sample a batch of random shared bits from the beaver source