Struct fancy_garbling::Garbler
source · [−]pub struct Garbler<C, RNG, Wire> { /* private fields */ }
Expand description
Streams garbled circuit ciphertexts through a callback.
Implementations
sourceimpl<C: AbstractChannel, RNG: CryptoRng + RngCore, Wire: WireLabel> Garbler<C, RNG, Wire>
impl<C: AbstractChannel, RNG: CryptoRng + RngCore, Wire: WireLabel> Garbler<C, 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 send_wire(&mut self, wire: &Wire) -> Result<(), GarblerError>
pub fn send_wire(&mut self, wire: &Wire) -> Result<(), GarblerError>
Send a wire over the established channel.
sourcepub fn encode_wire(&mut self, val: u16, modulus: u16) -> (Wire, Wire)
pub fn encode_wire(&mut self, val: u16, modulus: u16) -> (Wire, Wire)
Encode a wire, producing the zero wire as well as the encoded value.
sourcepub fn encode_many_wires(
&mut self,
vals: &[u16],
moduli: &[u16]
) -> Result<(Vec<Wire>, Vec<Wire>), GarblerError>
pub fn encode_many_wires(
&mut self,
vals: &[u16],
moduli: &[u16]
) -> Result<(Vec<Wire>, Vec<Wire>), GarblerError>
Encode many wires, producing zero wires as well as encoded values.
sourcepub fn crt_encode_wire(
&mut self,
val: u128,
modulus: u128
) -> Result<(CrtBundle<Wire>, CrtBundle<Wire>), GarblerError>
pub fn crt_encode_wire(
&mut self,
val: u128,
modulus: u128
) -> Result<(CrtBundle<Wire>, CrtBundle<Wire>), GarblerError>
Encode a CrtBundle
, producing zero wires as well as encoded values.
sourcepub fn bin_encode_wire(
&mut self,
val: u128,
nbits: usize
) -> Result<(BinaryBundle<Wire>, BinaryBundle<Wire>), GarblerError>
pub fn bin_encode_wire(
&mut self,
val: u128,
nbits: usize
) -> Result<(BinaryBundle<Wire>, BinaryBundle<Wire>), GarblerError>
Encode a BinaryBundle
, producing zero wires as well as encoded values.
Trait Implementations
sourceimpl<C: AbstractChannel, RNG: RngCore + CryptoRng, Wire: WireLabel> Fancy for Garbler<C, RNG, Wire>
impl<C: AbstractChannel, RNG: RngCore + CryptoRng, Wire: WireLabel> Fancy for Garbler<C, RNG, Wire>
type Item = Wire
type Item = Wire
Fancy
.type Error = GarblerError
type Error = GarblerError
sourcefn constant(&mut self, x: u16, q: u16) -> Result<Wire, GarblerError>
fn constant(&mut self, x: u16, q: u16) -> Result<Wire, GarblerError>
x
with modulus q
.sourceimpl<C: AbstractChannel, RNG: RngCore + CryptoRng, Wire: WireLabel + ArithmeticWire> FancyArithmetic for Garbler<C, RNG, Wire>
impl<C: AbstractChannel, RNG: RngCore + CryptoRng, Wire: WireLabel + ArithmeticWire> FancyArithmetic for Garbler<C, RNG, Wire>
sourcefn cmul(&mut self, x: &Wire, c: u16) -> Result<Wire, GarblerError>
fn cmul(&mut self, x: &Wire, c: u16) -> Result<Wire, GarblerError>
x
times the constant c
.sourceimpl<C: AbstractChannel, RNG: RngCore + CryptoRng> FancyBinary for Garbler<C, RNG, AllWire>
impl<C: AbstractChannel, RNG: RngCore + CryptoRng> FancyBinary for Garbler<C, RNG, AllWire>
sourcefn negate(&mut self, x: &Self::Item) -> Result<Self::Item, Self::Error>
fn negate(&mut self, x: &Self::Item) -> Result<Self::Item, Self::Error>
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
sourcefn xor(
&mut self,
x: &Self::Item,
y: &Self::Item
) -> Result<Self::Item, Self::Error>
fn xor(
&mut self,
x: &Self::Item,
y: &Self::Item
) -> Result<Self::Item, Self::Error>
Xor is just addition
sourcefn and(
&mut self,
x: &Self::Item,
y: &Self::Item
) -> Result<Self::Item, Self::Error>
fn and(
&mut self,
x: &Self::Item,
y: &Self::Item
) -> Result<Self::Item, Self::Error>
Use binary and_gate
sourcefn or(
&mut self,
x: &Self::Item,
y: &Self::Item
) -> Result<Self::Item, Self::Error>
fn or(
&mut self,
x: &Self::Item,
y: &Self::Item
) -> Result<Self::Item, Self::Error>
sourcefn adder(
&mut self,
x: &Self::Item,
y: &Self::Item,
carry_in: Option<&Self::Item>
) -> Result<(Self::Item, Self::Item), Self::Error>
fn adder(
&mut self,
x: &Self::Item,
y: &Self::Item,
carry_in: Option<&Self::Item>
) -> Result<(Self::Item, Self::Item), Self::Error>
sourcefn and_many(&mut self, args: &[Self::Item]) -> Result<Self::Item, Self::Error>
fn and_many(&mut self, args: &[Self::Item]) -> Result<Self::Item, Self::Error>
sourcefn or_many(&mut self, args: &[Self::Item]) -> Result<Self::Item, Self::Error>
fn or_many(&mut self, args: &[Self::Item]) -> Result<Self::Item, Self::Error>
sourcefn xor_many(&mut self, args: &[Self::Item]) -> Result<Self::Item, Self::Error>
fn xor_many(&mut self, args: &[Self::Item]) -> Result<Self::Item, Self::Error>
sourceimpl<C: AbstractChannel, RNG: RngCore + CryptoRng> FancyBinary for Garbler<C, RNG, WireMod2>
impl<C: AbstractChannel, RNG: RngCore + CryptoRng> FancyBinary for Garbler<C, RNG, WireMod2>
sourcefn negate(&mut self, x: &Self::Item) -> Result<Self::Item, Self::Error>
fn negate(&mut self, x: &Self::Item) -> Result<Self::Item, Self::Error>
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
sourcefn and(
&mut self,
A: &Self::Item,
B: &Self::Item
) -> Result<Self::Item, Self::Error>
fn and(
&mut self,
A: &Self::Item,
B: &Self::Item
) -> Result<Self::Item, Self::Error>
sourcefn xor(
&mut self,
x: &Self::Item,
y: &Self::Item
) -> Result<Self::Item, Self::Error>
fn xor(
&mut self,
x: &Self::Item,
y: &Self::Item
) -> Result<Self::Item, Self::Error>
sourcefn or(
&mut self,
x: &Self::Item,
y: &Self::Item
) -> Result<Self::Item, Self::Error>
fn or(
&mut self,
x: &Self::Item,
y: &Self::Item
) -> Result<Self::Item, Self::Error>
sourcefn adder(
&mut self,
x: &Self::Item,
y: &Self::Item,
carry_in: Option<&Self::Item>
) -> Result<(Self::Item, Self::Item), Self::Error>
fn adder(
&mut self,
x: &Self::Item,
y: &Self::Item,
carry_in: Option<&Self::Item>
) -> Result<(Self::Item, Self::Item), Self::Error>
sourcefn and_many(&mut self, args: &[Self::Item]) -> Result<Self::Item, Self::Error>
fn and_many(&mut self, args: &[Self::Item]) -> Result<Self::Item, Self::Error>
sourcefn or_many(&mut self, args: &[Self::Item]) -> Result<Self::Item, Self::Error>
fn or_many(&mut self, args: &[Self::Item]) -> Result<Self::Item, Self::Error>
sourcefn xor_many(&mut self, args: &[Self::Item]) -> Result<Self::Item, Self::Error>
fn xor_many(&mut self, args: &[Self::Item]) -> Result<Self::Item, Self::Error>
sourceimpl<C: AbstractChannel, RNG: RngCore + CryptoRng, Wire: WireLabel> FancyReveal for Garbler<C, RNG, Wire>
impl<C: AbstractChannel, RNG: RngCore + CryptoRng, Wire: WireLabel> FancyReveal for Garbler<C, RNG, Wire>
sourcefn reveal(&mut self, x: &Wire) -> Result<u16, GarblerError>
fn reveal(&mut self, x: &Wire) -> Result<u16, GarblerError>
x
to all parties.sourcefn reveal_many(&mut self, xs: &[Self::Item]) -> Result<Vec<u16>, Self::Error>
fn reveal_many(&mut self, xs: &[Self::Item]) -> Result<Vec<u16>, Self::Error>
sourcefn reveal_bundle(
&mut self,
x: &Bundle<Self::Item>
) -> Result<Vec<u16>, Self::Error>
fn reveal_bundle(
&mut self,
x: &Bundle<Self::Item>
) -> Result<Vec<u16>, Self::Error>
sourcefn reveal_many_bundles(
&mut self,
xs: &[Bundle<Self::Item>]
) -> Result<Vec<Vec<u16>>, Self::Error>
fn reveal_many_bundles(
&mut self,
xs: &[Bundle<Self::Item>]
) -> Result<Vec<Vec<u16>>, Self::Error>
sourcefn crt_reveal(&mut self, x: &CrtBundle<Self::Item>) -> Result<u128, Self::Error>
fn crt_reveal(&mut self, x: &CrtBundle<Self::Item>) -> Result<u128, Self::Error>
sourcefn crt_reveal_many(
&mut self,
xs: &[CrtBundle<Self::Item>]
) -> Result<Vec<u128>, Self::Error>
fn crt_reveal_many(
&mut self,
xs: &[CrtBundle<Self::Item>]
) -> Result<Vec<u128>, Self::Error>
sourcefn bin_reveal(
&mut self,
x: &BinaryBundle<Self::Item>
) -> Result<u128, Self::Error>
fn bin_reveal(
&mut self,
x: &BinaryBundle<Self::Item>
) -> Result<u128, Self::Error>
sourcefn bin_reveal_many(
&mut self,
xs: &[BinaryBundle<Self::Item>]
) -> Result<Vec<u128>, Self::Error>
fn bin_reveal_many(
&mut self,
xs: &[BinaryBundle<Self::Item>]
) -> Result<Vec<u128>, Self::Error>
Auto Trait Implementations
impl<C, RNG, Wire> RefUnwindSafe for Garbler<C, RNG, Wire>where
C: RefUnwindSafe,
RNG: RefUnwindSafe,
Wire: RefUnwindSafe,
impl<C, RNG, Wire> Send for Garbler<C, RNG, Wire>where
C: Send,
RNG: Send,
Wire: Send,
impl<C, RNG, Wire> Sync for Garbler<C, RNG, Wire>where
C: Sync,
RNG: Sync,
Wire: Sync,
impl<C, RNG, Wire> Unpin for Garbler<C, RNG, Wire>where
C: Unpin,
RNG: Unpin,
Wire: Unpin,
impl<C, RNG, Wire> UnwindSafe for Garbler<C, RNG, Wire>where
C: UnwindSafe,
RNG: UnwindSafe,
Wire: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> FmtForward for T
impl<T> FmtForward for T
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read morefn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read morefn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
self
, then passes self.as_ref()
into the pipe function.fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> Rwhere
Self: Deref<Target = T>,
T: 'a + ?Sized,
R: 'a,
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> Rwhere
Self: Deref<Target = T>,
T: 'a + ?Sized,
R: 'a,
self
, then passes self.deref()
into the pipe function.impl<T> Tap for T
impl<T> Tap for T
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
Borrow<B>
of a value. Read morefn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
BorrowMut<B>
of a value. Read morefn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
AsRef<R>
view of a value. Read morefn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
AsMut<R>
view of a value. Read morefn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
Deref::Target
of a value. Read morefn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Deref::Target
of a value. Read morefn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds. Read morefn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
.tap_borrow()
only in debug builds, and is erased in release
builds. Read morefn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
.tap_borrow_mut()
only in debug builds, and is erased in release
builds. Read morefn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
.tap_ref()
only in debug builds, and is erased in release
builds. Read morefn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
.tap_ref_mut()
only in debug builds, and is erased in release
builds. Read more