[−][src]Struct fancy_garbling::Garbler
Streams garbled circuit ciphertexts through a callback. Parallelizable.
Methods
impl<C: AbstractChannel, RNG: CryptoRng + RngCore> Garbler<C, RNG>
[src]
pub fn new(channel: C, rng: RNG, reused_deltas: &[Wire]) -> Self
[src]
Create a new garbler.
pub fn delta(&mut self, q: u16) -> Wire
[src]
Create a delta if it has not been created yet for this modulus, otherwise just return the existing one.
pub fn get_deltas(self) -> HashMap<u16, Wire>
[src]
Get the deltas, consuming the Garbler.
This is useful for reusing wires in multiple garbled circuit instances.
pub fn send_wire(&mut self, wire: &Wire) -> Result<(), GarblerError>
[src]
Send a wire using the Sender.
pub fn encode_wire(&mut self, val: u16, modulus: u16) -> (Wire, Wire)
[src]
Encode a wire, producing the zero wire as well as the encoded value.
pub fn encode_many_wires(
&mut self,
vals: &[u16],
moduli: &[u16]
) -> Result<(Vec<Wire>, Vec<Wire>), GarblerError>
[src]
&mut self,
vals: &[u16],
moduli: &[u16]
) -> Result<(Vec<Wire>, Vec<Wire>), GarblerError>
Encode many wires, producing zero wires as well as encoded values.
pub fn crt_encode_wire(
&mut self,
val: u128,
modulus: u128
) -> Result<(CrtBundle<Wire>, CrtBundle<Wire>), GarblerError>
[src]
&mut self,
val: u128,
modulus: u128
) -> Result<(CrtBundle<Wire>, CrtBundle<Wire>), GarblerError>
Encode a CrtBundle, producing the zero wires as well as the encoded values.
pub fn bin_encode_wire(
&mut self,
val: u128,
nbits: usize
) -> Result<(BinaryBundle<Wire>, BinaryBundle<Wire>), GarblerError>
[src]
&mut self,
val: u128,
nbits: usize
) -> Result<(BinaryBundle<Wire>, BinaryBundle<Wire>), GarblerError>
Encode a BinaryBundle, producing the zero wires as well as the encoded values.
Trait Implementations
impl<C: AbstractChannel, RNG: CryptoRng + RngCore> Fancy for Garbler<C, RNG>
[src]
type Item = Wire
The underlying wire datatype created by an object implementing Fancy
.
type Error = GarblerError
Errors which may be thrown by the users of Fancy.
fn constant(&mut self, x: u16, q: u16) -> Result<Wire, GarblerError>
[src]
fn add(&mut self, x: &Wire, y: &Wire) -> Result<Wire, GarblerError>
[src]
fn sub(&mut self, x: &Wire, y: &Wire) -> Result<Wire, GarblerError>
[src]
fn cmul(&mut self, x: &Wire, c: u16) -> Result<Wire, GarblerError>
[src]
fn mul(&mut self, A: &Wire, B: &Wire) -> Result<Wire, GarblerError>
[src]
fn proj(
&mut self,
A: &Wire,
q_out: u16,
tt: Option<Vec<u16>>
) -> Result<Wire, GarblerError>
[src]
&mut self,
A: &Wire,
q_out: u16,
tt: Option<Vec<u16>>
) -> Result<Wire, GarblerError>
fn output(&mut self, X: &Wire) -> Result<(), GarblerError>
[src]
fn add_many(&mut self, args: &[Self::Item]) -> Result<Self::Item, Self::Error>
[src]
Sum up a slice of wires.
fn xor(
&mut self,
x: &Self::Item,
y: &Self::Item
) -> Result<Self::Item, Self::Error>
[src]
&mut self,
x: &Self::Item,
y: &Self::Item
) -> Result<Self::Item, Self::Error>
Xor is just addition, with the requirement that x
and y
are mod 2.
fn negate(&mut self, x: &Self::Item) -> Result<Self::Item, Self::Error>
[src]
Negate by xoring x
with 1
.
fn and(
&mut self,
x: &Self::Item,
y: &Self::Item
) -> Result<Self::Item, Self::Error>
[src]
&mut self,
x: &Self::Item,
y: &Self::Item
) -> Result<Self::Item, Self::Error>
And is just multiplication, with the requirement that x
and y
are mod 2.
fn or(
&mut self,
x: &Self::Item,
y: &Self::Item
) -> Result<Self::Item, Self::Error>
[src]
&mut self,
x: &Self::Item,
y: &Self::Item
) -> Result<Self::Item, Self::Error>
Or uses Demorgan's Rule implemented with multiplication and negation.
fn and_many(&mut self, args: &[Self::Item]) -> Result<Self::Item, Self::Error>
[src]
Returns 1 if all wires equal 1.
fn or_many(&mut self, args: &[Self::Item]) -> Result<Self::Item, Self::Error>
[src]
Returns 1 if any wire equals 1.
fn mod_change(
&mut self,
x: &Self::Item,
to_modulus: u16
) -> Result<Self::Item, Self::Error>
[src]
&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.
fn adder(
&mut self,
x: &Self::Item,
y: &Self::Item,
carry_in: Option<&Self::Item>
) -> Result<(Self::Item, Self::Item), Self::Error>
[src]
&mut self,
x: &Self::Item,
y: &Self::Item,
carry_in: Option<&Self::Item>
) -> Result<(Self::Item, Self::Item), Self::Error>
Binary adder. Returns the result and the carry.
fn mux(
&mut self,
b: &Self::Item,
x: &Self::Item,
y: &Self::Item
) -> Result<Self::Item, Self::Error>
[src]
&mut self,
b: &Self::Item,
x: &Self::Item,
y: &Self::Item
) -> Result<Self::Item, Self::Error>
If b = 0
returns x
else y
. Read more
fn mux_constant_bits(
&mut self,
x: &Self::Item,
b1: bool,
b2: bool
) -> Result<Self::Item, Self::Error>
[src]
&mut self,
x: &Self::Item,
b1: bool,
b2: bool
) -> Result<Self::Item, Self::Error>
If x = 0
returns the constant b1
else return b2
. Folds constants if possible.
fn outputs(&mut self, xs: &[Self::Item]) -> Result<(), Self::Error>
[src]
Output a slice of wires.
Auto Trait Implementations
impl<C, RNG> Send for Garbler<C, RNG> where
C: Send,
RNG: Send,
C: Send,
RNG: Send,
impl<C, RNG> Sync for Garbler<C, RNG> where
C: Sync,
RNG: Sync,
C: Sync,
RNG: Sync,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T, U> IntoBits<U> for T where
U: FromBits<T>,
U: FromBits<T>,
fn into_bits(self) -> U
impl<T> FromCast<T> for T
fn from_cast(t: T) -> T
impl<T, U> Cast<U> for T where
U: FromCast<T>,
U: FromCast<T>,
fn cast(self) -> U
impl<T> FromBits<T> for T
fn from_bits(t: T) -> T
impl<T> Same<T> for T
type Output = T
Should always be Self