Trait FancyArithmetic

Source
pub trait FancyArithmetic: Fancy {
    // Required methods
    fn add(
        &mut self,
        x: &Self::Item,
        y: &Self::Item,
    ) -> Result<Self::Item, Self::Error>;
    fn sub(
        &mut self,
        x: &Self::Item,
        y: &Self::Item,
    ) -> Result<Self::Item, Self::Error>;
    fn cmul(
        &mut self,
        x: &Self::Item,
        c: u16,
    ) -> Result<Self::Item, Self::Error>;
    fn mul(
        &mut self,
        x: &Self::Item,
        y: &Self::Item,
    ) -> Result<Self::Item, Self::Error>;
    fn proj(
        &mut self,
        x: &Self::Item,
        q: u16,
        tt: Option<Vec<u16>>,
    ) -> Result<Self::Item, Self::Error>;

    // Provided methods
    fn add_many(
        &mut self,
        args: &[Self::Item],
    ) -> Result<Self::Item, Self::Error> { ... }
    fn mod_change(
        &mut self,
        x: &Self::Item,
        to_modulus: u16,
    ) -> Result<Self::Item, Self::Error> { ... }
}
Expand description

DSL for arithmetic computation.

Required Methods§

Source

fn add( &mut self, x: &Self::Item, y: &Self::Item, ) -> Result<Self::Item, Self::Error>

Add x and y.

Source

fn sub( &mut self, x: &Self::Item, y: &Self::Item, ) -> Result<Self::Item, Self::Error>

Subtract x and y.

Source

fn cmul(&mut self, x: &Self::Item, c: u16) -> Result<Self::Item, Self::Error>

Multiply x times the constant c.

Source

fn mul( &mut self, x: &Self::Item, y: &Self::Item, ) -> Result<Self::Item, Self::Error>

Multiply x and y.

Source

fn proj( &mut self, x: &Self::Item, q: u16, tt: Option<Vec<u16>>, ) -> Result<Self::Item, Self::Error>

Project x according to the truth table tt. Resulting wire has modulus q.

Optional tt is useful for hiding the gate from the evaluator.

Provided Methods§

Source

fn add_many(&mut self, args: &[Self::Item]) -> Result<Self::Item, Self::Error>

Sum up a slice of wires.

Source

fn mod_change( &mut self, x: &Self::Item, to_modulus: u16, ) -> Result<Self::Item, Self::Error>

Change the modulus of x to to_modulus using a projection gate.

Implementors§

Source§

impl FancyArithmetic for CircuitBuilder<ArithmeticCircuit>

Source§

impl FancyArithmetic for DepthInformer

Source§

impl FancyArithmetic for Dummy

Source§

impl<C: AbstractChannel, RNG, OT, Wire: WireLabel + ArithmeticWire> FancyArithmetic for fancy_garbling::twopac::semihonest::Evaluator<C, RNG, OT, Wire>

Source§

impl<C: AbstractChannel, RNG: CryptoRng + Rng, OT, Wire: WireLabel + ArithmeticWire> FancyArithmetic for fancy_garbling::twopac::semihonest::Garbler<C, RNG, OT, Wire>

Source§

impl<C: AbstractChannel, RNG: RngCore + CryptoRng, Wire: WireLabel + ArithmeticWire> FancyArithmetic for fancy_garbling::Garbler<C, RNG, Wire>

Source§

impl<C: AbstractChannel, Wire: WireLabel + ArithmeticWire> FancyArithmetic for fancy_garbling::Evaluator<C, Wire>

Source§

impl<F: FancyArithmetic> FancyArithmetic for Informer<F>