pub struct Garbler<RNG, Wire> { /* private fields */ }Expand description
Streams garbled circuit ciphertexts through a callback.
Implementations§
Source§impl<RNG: CryptoRng + RngCore, Wire: WireLabel> Garbler<RNG, Wire>
impl<RNG: CryptoRng + RngCore, Wire: WireLabel> Garbler<RNG, Wire>
Sourcepub fn delta(&mut self, q: u16) -> Wire
pub fn delta(&mut self, q: u16) -> Wire
Create a delta if it has not been created yet for this modulus, otherwise just return the existing one.
Sourcepub fn get_deltas(self) -> HashMap<u16, Wire>
pub fn get_deltas(self) -> HashMap<u16, Wire>
Get the deltas, consuming the Garbler.
This is useful for reusing wires in multiple garbled circuit instances.
Sourcepub fn encode_zero(&mut self, modulus: u16) -> Wire
pub fn encode_zero(&mut self, modulus: u16) -> Wire
Output a fresh zero wirelabel associated with the provided modulus.
Sourcepub fn bin_encode_zero(&mut self, nbits: usize) -> BinaryBundle<Wire>
pub fn bin_encode_zero(&mut self, nbits: usize) -> BinaryBundle<Wire>
Output fresh zero wirelabels associated with a BinaryBundle.
Trait Implementations§
Source§impl<RNG: RngCore + CryptoRng, Wire: WireLabel + ArithmeticWire> FancyArithmetic for Garbler<RNG, Wire>
impl<RNG: RngCore + CryptoRng, Wire: WireLabel + ArithmeticWire> FancyArithmetic for Garbler<RNG, Wire>
Source§impl<RNG: RngCore + CryptoRng> FancyBinary for Garbler<RNG, AllWire>
impl<RNG: RngCore + CryptoRng> FancyBinary for Garbler<RNG, AllWire>
Source§fn negate(&mut self, x: &Self::Item) -> Self::Item
fn negate(&mut self, x: &Self::Item) -> Self::Item
We can negate by having garbler xor wire with Delta
Since we treat all garbler wires as zero, xoring with delta conceptually negates the value of the wire
Source§impl<RNG: RngCore + CryptoRng, W: BinaryWireLabel> FancyBinary for Garbler<RNG, W>
impl<RNG: RngCore + CryptoRng, W: BinaryWireLabel> FancyBinary for Garbler<RNG, W>
Source§fn negate(&mut self, x: &Self::Item) -> Self::Item
fn negate(&mut self, x: &Self::Item) -> Self::Item
We can negate by having garbler xor wire with Delta
Since we treat all garbler wires as zero, xoring with delta conceptually negates the value of the wire
Source§impl<RNG: RngCore + CryptoRng, Wire: WireLabel> FancyEncode for Garbler<RNG, Wire>
impl<RNG: RngCore + CryptoRng, Wire: WireLabel> FancyEncode for Garbler<RNG, Wire>
Source§fn 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 wires for known values.
Source§fn receive_many(
&mut self,
_moduli: &[u16],
_: &mut Channel<'_>,
) -> Result<Vec<Self::Item>>
fn receive_many( &mut self, _moduli: &[u16], _: &mut Channel<'_>, ) -> Result<Vec<Self::Item>>
Receive many wires for unknown values.
Source§impl<RNG: RngCore + CryptoRng, Wire: WireLabel> FancyOutput for Garbler<RNG, Wire>
impl<RNG: RngCore + CryptoRng, Wire: WireLabel> FancyOutput for Garbler<RNG, Wire>
Auto Trait Implementations§
impl<RNG, Wire> Freeze for Garbler<RNG, Wire>
impl<RNG, Wire> RefUnwindSafe for Garbler<RNG, Wire>where
Wire: RefUnwindSafe,
RNG: RefUnwindSafe,
impl<RNG, Wire> Send for Garbler<RNG, Wire>
impl<RNG, Wire> Sync for Garbler<RNG, Wire>
impl<RNG, Wire> Unpin for Garbler<RNG, Wire>
impl<RNG, Wire> UnsafeUnpin for Garbler<RNG, Wire>where
Wire: UnsafeUnpin,
RNG: UnsafeUnpin,
impl<RNG, Wire> UnwindSafe for Garbler<RNG, Wire>where
Wire: UnwindSafe,
RNG: UnwindSafe,
Blanket Implementations§
Source§impl<F> BinaryGadgets for F
impl<F> BinaryGadgets for F
Source§fn bin_encode(
&mut self,
value: u128,
nbits: usize,
channel: &mut Channel<'_>,
) -> Result<BinaryBundle<Self::Item>>
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>>
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>>>
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>>>
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>>
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>>>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<F> CrtGadgets for F
impl<F> CrtGadgets for F
Source§fn crt_encode(
&mut self,
value: u128,
modulus: u128,
channel: &mut Channel<'_>,
) -> Result<CrtBundle<Self::Item>>
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>>
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>>>
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>>>
fn crt_receive_many( &mut self, n: usize, modulus: u128, channel: &mut Channel<'_>, ) -> Result<Vec<CrtBundle<Self::Item>>>
Receive many CRT input bundles.
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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
impl<T> IsSameType<T> for T
§type EqualityProposition = TrueEqualityProposition
type EqualityProposition = TrueEqualityProposition
The [
EqualityProposition] that Self == T