Skip to main content

Evaluator

Struct Evaluator 

Source
pub struct Evaluator<Wire> { /* private fields */ }
Expand description

Streaming evaluator using a callback to receive ciphertexts as needed.

Evaluates a garbled circuit on the fly, using messages containing ciphertexts and wires. Parallelizable.

Implementations§

Source§

impl<Wire: WireLabel> Evaluator<Wire>

Source

pub fn new(channel: &mut Channel<'_>) -> Result<Self>

Create a new Evaluator.

Trait Implementations§

Source§

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

Source§

type Item = Wire

The underlying wire representation of this Fancy object.
Source§

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

Encode a constant x with modulus q.
Source§

impl<Wire: WireLabel + ArithmeticWire> FancyArithmetic for Evaluator<Wire>

Source§

fn add(&mut self, x: &Wire, y: &Wire) -> Wire

Add x and y. Read more
Source§

fn sub(&mut self, x: &Wire, y: &Wire) -> Wire

Subtract x and y. Read more
Source§

fn cmul(&mut self, x: &Wire, c: u16) -> Wire

Multiply x with the constant c.
Source§

fn mul(&mut self, A: &Wire, B: &Wire, channel: &mut Channel<'_>) -> Result<Wire>

Multiply x and y.
Source§

impl FancyBinary for Evaluator<AllWire>

Source§

fn negate(&mut self, x: &Self::Item) -> Self::Item

Overriding negate to be a noop: entirely handled on garbler’s end

Source§

fn xor(&mut self, x: &Self::Item, y: &Self::Item) -> Self::Item

Binary XOR.
Source§

fn and( &mut self, x: &Self::Item, y: &Self::Item, channel: &mut Channel<'_>, ) -> Result<Self::Item>

Binary AND.
Source§

fn or( &mut self, x: &Self::Item, y: &Self::Item, channel: &mut Channel<'_>, ) -> Result<Self::Item>

Binary OR.
Source§

impl<W: BinaryWireLabel> FancyBinary for Evaluator<W>

Source§

fn negate(&mut self, x: &Self::Item) -> Self::Item

Negate is a noop for the evaluator

Source§

fn xor(&mut self, x: &Self::Item, y: &Self::Item) -> Self::Item

Binary XOR.
Source§

fn and( &mut self, A: &Self::Item, B: &Self::Item, channel: &mut Channel<'_>, ) -> Result<Self::Item>

Binary AND.
Source§

fn or( &mut self, x: &Self::Item, y: &Self::Item, channel: &mut Channel<'_>, ) -> Result<Self::Item>

Binary OR.
Source§

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

Source§

fn encode_many( &mut self, _values: &[u16], _moduli: &[u16], _: &mut Channel<'_>, ) -> Result<Vec<Self::Item>>

Encode many wires for known values.
Source§

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

Receive many wires for unknown values.
Source§

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

Encode a wire for a known value.
Source§

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

Receive a wire for an unknown value.
Source§

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

Source§

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

Output the value associated with wire x. Read more
Source§

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

Output the values associated with a slice of wires. Read more
Source§

impl<Wire: WireLabel + ArithmeticWire> FancyProj for Evaluator<Wire>

Source§

fn proj( &mut self, x: &Wire, q: u16, _: Option<Vec<u16>>, channel: &mut Channel<'_>, ) -> Result<Wire>

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

Auto Trait Implementations§

§

impl<Wire> Freeze for Evaluator<Wire>
where Wire: Freeze,

§

impl<Wire> RefUnwindSafe for Evaluator<Wire>
where Wire: RefUnwindSafe,

§

impl<Wire> Send for Evaluator<Wire>
where Wire: Send,

§

impl<Wire> Sync for Evaluator<Wire>
where Wire: Sync,

§

impl<Wire> Unpin for Evaluator<Wire>
where Wire: Unpin,

§

impl<Wire> UnsafeUnpin for Evaluator<Wire>
where Wire: UnsafeUnpin,

§

impl<Wire> UnwindSafe for Evaluator<Wire>
where Wire: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<F> BinaryGadgets for F

Source§

fn bin_encode( &mut self, value: u128, nbits: usize, channel: &mut Channel<'_>, ) -> Result<BinaryBundle<Self::Item>>

Encode a binary input bundle.
Source§

fn bin_receive( &mut self, nbits: usize, channel: &mut Channel<'_>, ) -> Result<BinaryBundle<Self::Item>>

Receive an binary input bundle.
Source§

fn bin_encode_many( &mut self, values: &[u128], nbits: usize, channel: &mut Channel<'_>, ) -> Result<Vec<BinaryBundle<Self::Item>>>

Encode many binary input bundles.
Source§

fn bin_receive_many( &mut self, ninputs: usize, nbits: usize, channel: &mut Channel<'_>, ) -> Result<Vec<BinaryBundle<Self::Item>>>

Receive many binary input bundles.
Source§

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

Output a binary bundle and interpret the result as a u128.
Source§

fn bin_outputs( &mut self, xs: &[BinaryBundle<Self::Item>], channel: &mut Channel<'_>, ) -> Result<Option<Vec<u128>>>

Output a slice of binary bundles and interpret the results as a u128.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<F> CrtGadgets for F

Source§

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

Encode a CRT input bundle.
Source§

fn crt_receive( &mut self, modulus: u128, channel: &mut Channel<'_>, ) -> Result<CrtBundle<Self::Item>>

Receive an CRT input bundle.
Source§

fn crt_encode_many( &mut self, values: &[u128], modulus: u128, channel: &mut Channel<'_>, ) -> Result<Vec<CrtBundle<Self::Item>>>

Encode many CRT input bundles.
Source§

fn crt_receive_many( &mut self, n: usize, modulus: u128, channel: &mut Channel<'_>, ) -> Result<Vec<CrtBundle<Self::Item>>>

Receive many CRT input bundles.
Source§

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

Output a CRT bundle and interpret it mod Q.
Source§

fn crt_outputs( &mut self, xs: &[CrtBundle<Self::Item>], channel: &mut Channel<'_>, ) -> Result<Option<Vec<u128>>>

Output a slice of CRT bundles and interpret the outputs mod Q.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> IsSameType<T> for T

§

const WITNESS: Witness<<T as IsSameType<T>>::EqualityProposition> = Witness::EQUAL_TYPES

A [Witness] that Self == T Read more
§

type EqualityProposition = TrueEqualityProposition

The [EqualityProposition] that Self == T
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,