pub trait Fancy {
type Item: Clone + HasModulus;
// Required methods
fn encode_many(
&mut self,
values: &[u16],
moduli: &[u16],
channel: &mut Channel<'_>,
) -> Result<Vec<Self::Item>>;
fn receive_many(
&mut self,
moduli: &[u16],
channel: &mut Channel<'_>,
) -> Result<Vec<Self::Item>>;
fn constant(
&mut self,
x: u16,
q: u16,
channel: &mut Channel<'_>,
) -> Result<Self::Item>;
fn output(
&mut self,
x: &Self::Item,
channel: &mut Channel<'_>,
) -> Result<Option<u16>>;
// Provided methods
fn outputs(
&mut self,
xs: &[Self::Item],
channel: &mut Channel<'_>,
) -> Result<Option<Vec<u16>>> { ... }
fn encode(
&mut self,
value: u16,
modulus: u16,
channel: &mut Channel<'_>,
) -> Result<Self::Item> { ... }
fn receive(
&mut self,
modulus: u16,
channel: &mut Channel<'_>,
) -> Result<Self::Item> { ... }
}Expand description
The Fancy trait provides the basic set of operations possible in a garbled
circuit.
The trait contains an associated type, Fancy::Item, which defines the
underlying wirelabel representation. The trait then defines several methods
for:
- Encoding a value into a wirelabel (
Fancy::encodeandFancy::encode_many). - Receiving a wirelabel for an unknown value (
Fancy::receiveandFancy::receive_many). - Creating a wirelabel for a fixed (public) constant value
(
Fancy::constant). - Outputting a wirelabel as its underlying value (
Fancy::outputandFancy::outputs).
This trait can be further extended to support binary, arithmetic, and/or
projections by using the FancyBinary, FancyArithmetic, or
FancyProj extension traits, respectively.
Required Associated Types§
Sourcetype Item: Clone + HasModulus
type Item: Clone + HasModulus
The underlying wirelabel representation of this Fancy object.
Required Methods§
Sourcefn encode_many(
&mut self,
values: &[u16],
moduli: &[u16],
channel: &mut Channel<'_>,
) -> Result<Vec<Self::Item>>
fn encode_many( &mut self, values: &[u16], moduli: &[u16], channel: &mut Channel<'_>, ) -> Result<Vec<Self::Item>>
Encode many wirelabels for known values.
When writing a garbler, the return value must correspond to the zero wire label.
Sourcefn receive_many(
&mut self,
moduli: &[u16],
channel: &mut Channel<'_>,
) -> Result<Vec<Self::Item>>
fn receive_many( &mut self, moduli: &[u16], channel: &mut Channel<'_>, ) -> Result<Vec<Self::Item>>
Receive many wirelabels for unknown values.
Provided Methods§
Sourcefn outputs(
&mut self,
xs: &[Self::Item],
channel: &mut Channel<'_>,
) -> Result<Option<Vec<u16>>>
fn outputs( &mut self, xs: &[Self::Item], channel: &mut Channel<'_>, ) -> Result<Option<Vec<u16>>>
Output the values associated with a slice of wirelabels.
Some Fancy implementers don’t actually return output, but they
need to be involved in the process, so they can return None.