Skip to main content

Fancy

Trait Fancy 

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

  1. Encoding a value into a wirelabel (Fancy::encode and Fancy::encode_many).
  2. Receiving a wirelabel for an unknown value (Fancy::receive and Fancy::receive_many).
  3. Creating a wirelabel for a fixed (public) constant value (Fancy::constant).
  4. Outputting a wirelabel as its underlying value (Fancy::output and Fancy::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§

Source

type Item: Clone + HasModulus

The underlying wirelabel representation of this Fancy object.

Required Methods§

Source

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.

Source

fn receive_many( &mut self, moduli: &[u16], channel: &mut Channel<'_>, ) -> Result<Vec<Self::Item>>

Receive many wirelabels for unknown values.

Source

fn constant( &mut self, x: u16, q: u16, channel: &mut Channel<'_>, ) -> Result<Self::Item>

Encode a constant x with modulus q.

Source

fn output( &mut self, x: &Self::Item, channel: &mut Channel<'_>, ) -> Result<Option<u16>>

Output the value associated with wirelabel x.

Some Fancy implementers don’t actually return output, but they need to be involved in the process, so they can return None.

Provided Methods§

Source

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.

Source

fn encode( &mut self, value: u16, modulus: u16, channel: &mut Channel<'_>, ) -> Result<Self::Item>

Encode a wirelabel for a known value.

When writing a garbler, the return value must correspond to the zero wire label.

Source

fn receive( &mut self, modulus: u16, channel: &mut Channel<'_>, ) -> Result<Self::Item>

Receive a wirelabel for an unknown value.

Implementors§

Source§

impl Fancy for CircuitAnalyzer

Source§

impl Fancy for Dummy

Source§

impl<F: Fancy> Fancy for Informer<F>

Source§

type Item = <F as Fancy>::Item

Source§

impl<RNG: RngCore + CryptoRng, Wire: WireLabel> Fancy for Garbler<RNG, Wire>

Source§

type Item = Wire

Source§

impl<Wire: WireLabel> Fancy for Evaluator<Wire>

Source§

type Item = Wire