[−][src]Trait fancy_garbling::CrtGadgets
Extension trait for Fancy
providing advanced CRT gadgets based on bundles of wires.
Provided methods
fn crt_constant_bundle(
&mut self,
x: u128,
q: u128
) -> Result<CrtBundle<Self::Item>, Self::Error>
&mut self,
x: u128,
q: u128
) -> Result<CrtBundle<Self::Item>, Self::Error>
Creates a bundle of constant wires for the CRT representation of x
under
composite modulus q
.
fn crt_outputs(
&mut self,
xs: &[CrtBundle<Self::Item>]
) -> Result<(), Self::Error>
&mut self,
xs: &[CrtBundle<Self::Item>]
) -> Result<(), Self::Error>
Output a slice of CRT bundles.
fn crt_add(
&mut self,
x: &CrtBundle<Self::Item>,
y: &CrtBundle<Self::Item>
) -> Result<CrtBundle<Self::Item>, Self::Error>
&mut self,
x: &CrtBundle<Self::Item>,
y: &CrtBundle<Self::Item>
) -> Result<CrtBundle<Self::Item>, Self::Error>
Add two CRT bundles.
fn crt_sub(
&mut self,
x: &CrtBundle<Self::Item>,
y: &CrtBundle<Self::Item>
) -> Result<CrtBundle<Self::Item>, Self::Error>
&mut self,
x: &CrtBundle<Self::Item>,
y: &CrtBundle<Self::Item>
) -> Result<CrtBundle<Self::Item>, Self::Error>
Subtract two CRT bundles.
fn crt_cmul(
&mut self,
x: &CrtBundle<Self::Item>,
c: u128
) -> Result<CrtBundle<Self::Item>, Self::Error>
&mut self,
x: &CrtBundle<Self::Item>,
c: u128
) -> Result<CrtBundle<Self::Item>, Self::Error>
Multiplies each wire in x
by the corresponding residue of c
.
fn crt_mul(
&mut self,
x: &CrtBundle<Self::Item>,
y: &CrtBundle<Self::Item>
) -> Result<CrtBundle<Self::Item>, Self::Error>
&mut self,
x: &CrtBundle<Self::Item>,
y: &CrtBundle<Self::Item>
) -> Result<CrtBundle<Self::Item>, Self::Error>
Multiply x
with y
.
fn crt_cexp(
&mut self,
x: &CrtBundle<Self::Item>,
c: u16
) -> Result<CrtBundle<Self::Item>, Self::Error>
&mut self,
x: &CrtBundle<Self::Item>,
c: u16
) -> Result<CrtBundle<Self::Item>, Self::Error>
Exponentiate x
by the constant c
.
fn crt_rem(
&mut self,
x: &CrtBundle<Self::Item>,
p: u16
) -> Result<CrtBundle<Self::Item>, Self::Error>
&mut self,
x: &CrtBundle<Self::Item>,
p: u16
) -> Result<CrtBundle<Self::Item>, Self::Error>
Compute the remainder with respect to modulus p
.
fn crt_fractional_mixed_radix(
&mut self,
bun: &CrtBundle<Self::Item>,
ms: &[u16]
) -> Result<Self::Item, Self::Error>
&mut self,
bun: &CrtBundle<Self::Item>,
ms: &[u16]
) -> Result<Self::Item, Self::Error>
Helper function for advanced gadgets, returns the MSB of the fractional part of
X/M
where M=product(ms)
.
fn crt_relu(
&mut self,
x: &CrtBundle<Self::Item>,
accuracy: &str,
output_moduli: Option<&[u16]>
) -> Result<CrtBundle<Self::Item>, Self::Error>
&mut self,
x: &CrtBundle<Self::Item>,
accuracy: &str,
output_moduli: Option<&[u16]>
) -> Result<CrtBundle<Self::Item>, Self::Error>
Compute max(x,0)
.
Optional output moduli.
fn crt_sign(
&mut self,
x: &CrtBundle<Self::Item>,
accuracy: &str
) -> Result<Self::Item, Self::Error>
&mut self,
x: &CrtBundle<Self::Item>,
accuracy: &str
) -> Result<Self::Item, Self::Error>
Return 0 if x
is positive and 1 if x
is negative.
fn crt_sgn(
&mut self,
x: &CrtBundle<Self::Item>,
accuracy: &str,
output_moduli: Option<&[u16]>
) -> Result<CrtBundle<Self::Item>, Self::Error>
&mut self,
x: &CrtBundle<Self::Item>,
accuracy: &str,
output_moduli: Option<&[u16]>
) -> Result<CrtBundle<Self::Item>, Self::Error>
Return if x >= 0 then 1 else -1
, where -1
is interpreted as Q-1
.
If provided, will produce a bundle under output_moduli
instead of x.moduli()
fn crt_lt(
&mut self,
x: &CrtBundle<Self::Item>,
y: &CrtBundle<Self::Item>,
accuracy: &str
) -> Result<Self::Item, Self::Error>
&mut self,
x: &CrtBundle<Self::Item>,
y: &CrtBundle<Self::Item>,
accuracy: &str
) -> Result<Self::Item, Self::Error>
Returns 1 if x < y
.
fn crt_geq(
&mut self,
x: &CrtBundle<Self::Item>,
y: &CrtBundle<Self::Item>,
accuracy: &str
) -> Result<Self::Item, Self::Error>
&mut self,
x: &CrtBundle<Self::Item>,
y: &CrtBundle<Self::Item>,
accuracy: &str
) -> Result<Self::Item, Self::Error>
Returns 1 if x >= y
.
fn crt_max(
&mut self,
xs: &[CrtBundle<Self::Item>],
accuracy: &str
) -> Result<CrtBundle<Self::Item>, Self::Error>
&mut self,
xs: &[CrtBundle<Self::Item>],
accuracy: &str
) -> Result<CrtBundle<Self::Item>, Self::Error>
Compute the maximum bundle in xs
.