[−][src]Trait fancy_garbling::BundleGadgets
Extension trait for Fancy which provides Bundle constructions which are not necessarily CRT nor binary-based.
Provided methods
fn constant_bundle(
&mut self,
xs: &[u16],
ps: &[u16]
) -> Result<Bundle<Self::Item>, Self::Error>
&mut self,
xs: &[u16],
ps: &[u16]
) -> Result<Bundle<Self::Item>, Self::Error>
Creates a bundle of constant wires using moduli ps
.
fn output_bundle(&mut self, x: &Bundle<Self::Item>) -> Result<(), Self::Error>
Output the wires that make up a bundle.
fn output_bundles(
&mut self,
xs: &[Bundle<Self::Item>]
) -> Result<(), Self::Error>
&mut self,
xs: &[Bundle<Self::Item>]
) -> Result<(), Self::Error>
Output a slice of bundles.
fn add_bundles(
&mut self,
x: &Bundle<Self::Item>,
y: &Bundle<Self::Item>
) -> Result<Bundle<Self::Item>, Self::Error>
&mut self,
x: &Bundle<Self::Item>,
y: &Bundle<Self::Item>
) -> Result<Bundle<Self::Item>, Self::Error>
Add two wire bundles pairwise, zipping addition.
In CRT this is plain addition. In binary this is xor.
fn sub_bundles(
&mut self,
x: &Bundle<Self::Item>,
y: &Bundle<Self::Item>
) -> Result<Bundle<Self::Item>, Self::Error>
&mut self,
x: &Bundle<Self::Item>,
y: &Bundle<Self::Item>
) -> Result<Bundle<Self::Item>, Self::Error>
Subtract two wire bundles, residue by residue.
In CRT this is plain subtraction. In binary this is xor
.
fn mul_bundles(
&mut self,
x: &Bundle<Self::Item>,
y: &Bundle<Self::Item>
) -> Result<Bundle<Self::Item>, Self::Error>
&mut self,
x: &Bundle<Self::Item>,
y: &Bundle<Self::Item>
) -> Result<Bundle<Self::Item>, Self::Error>
Multiply each wire in x
with each wire in y
, pairwise.
In CRT this is plain multiplication. In binary this is and
.
fn mixed_radix_addition(
&mut self,
xs: &[Bundle<Self::Item>]
) -> Result<Bundle<Self::Item>, Self::Error>
&mut self,
xs: &[Bundle<Self::Item>]
) -> Result<Bundle<Self::Item>, Self::Error>
Mixed radix addition.
fn mixed_radix_addition_msb_only(
&mut self,
xs: &[Bundle<Self::Item>]
) -> Result<Self::Item, Self::Error>
&mut self,
xs: &[Bundle<Self::Item>]
) -> Result<Self::Item, Self::Error>
Mixed radix addition only returning the MSB.
fn multiplex(
&mut self,
b: &Self::Item,
x: &Bundle<Self::Item>,
y: &Bundle<Self::Item>
) -> Result<Bundle<Self::Item>, Self::Error>
&mut self,
b: &Self::Item,
x: &Bundle<Self::Item>,
y: &Bundle<Self::Item>
) -> Result<Bundle<Self::Item>, Self::Error>
If b=0 then return x, else return y.
fn mask(
&mut self,
b: &Self::Item,
x: &Bundle<Self::Item>
) -> Result<Bundle<Self::Item>, Self::Error>
&mut self,
b: &Self::Item,
x: &Bundle<Self::Item>
) -> Result<Bundle<Self::Item>, Self::Error>
If b=0 then return 0, else return x.
fn shift(
&mut self,
x: &Bundle<Self::Item>,
n: usize
) -> Result<Bundle<Self::Item>, Self::Error>
&mut self,
x: &Bundle<Self::Item>,
n: usize
) -> Result<Bundle<Self::Item>, Self::Error>
Shift residues, replacing them with zeros in the modulus of the least signifigant residue.
fn eq_bundles(
&mut self,
x: &Bundle<Self::Item>,
y: &Bundle<Self::Item>
) -> Result<Self::Item, Self::Error>
&mut self,
x: &Bundle<Self::Item>,
y: &Bundle<Self::Item>
) -> Result<Self::Item, Self::Error>
Compute x == y
. Returns a wire encoding the result mod 2.