pub struct CircuitBuilder<Circuit> { /* private fields */ }Expand description
CircuitBuilder is used to build circuits.
Implementations§
Source§impl<Circuit: CircuitType> CircuitBuilder<Circuit>
impl<Circuit: CircuitType> CircuitBuilder<Circuit>
Sourcepub fn garbler_input(&mut self, modulus: u16) -> CircuitRef
pub fn garbler_input(&mut self, modulus: u16) -> CircuitRef
Get CircuitRef for a garbler input wire.
Sourcepub fn evaluator_input(&mut self, modulus: u16) -> CircuitRef
pub fn evaluator_input(&mut self, modulus: u16) -> CircuitRef
Get CircuitRef for an evaluator input wire.
Sourcepub fn garbler_inputs(&mut self, mods: &[u16]) -> Vec<CircuitRef>
pub fn garbler_inputs(&mut self, mods: &[u16]) -> Vec<CircuitRef>
Get a vec of CircuitRefs for garbler inputs.
Sourcepub fn evaluator_inputs(&mut self, mods: &[u16]) -> Vec<CircuitRef>
pub fn evaluator_inputs(&mut self, mods: &[u16]) -> Vec<CircuitRef>
Get a vec of CircuitRefs for garbler inputs.
Sourcepub fn crt_garbler_input(&mut self, modulus: u128) -> CrtBundle<CircuitRef>
pub fn crt_garbler_input(&mut self, modulus: u128) -> CrtBundle<CircuitRef>
Get a CrtBundle for the garbler using composite modulus Q
Sourcepub fn crt_evaluator_input(&mut self, modulus: u128) -> CrtBundle<CircuitRef>
pub fn crt_evaluator_input(&mut self, modulus: u128) -> CrtBundle<CircuitRef>
Get a CrtBundle for the evaluator using composite modulus Q
Sourcepub fn bin_garbler_input(&mut self, nbits: usize) -> BinaryBundle<CircuitRef>
pub fn bin_garbler_input(&mut self, nbits: usize) -> BinaryBundle<CircuitRef>
Get a BinaryBundle for the garbler with n bits.
Sourcepub fn bin_evaluator_input(&mut self, nbits: usize) -> BinaryBundle<CircuitRef>
pub fn bin_evaluator_input(&mut self, nbits: usize) -> BinaryBundle<CircuitRef>
Get a BinaryBundle for the evaluator with n bits.
Trait Implementations§
Source§impl<Circuit: CircuitType> Default for CircuitBuilder<Circuit>
impl<Circuit: CircuitType> Default for CircuitBuilder<Circuit>
Source§impl<Circuit: CircuitType> Fancy for CircuitBuilder<Circuit>
impl<Circuit: CircuitType> Fancy for CircuitBuilder<Circuit>
Source§type Item = CircuitRef
type Item = CircuitRef
The underlying wire datatype created by an object implementing
Fancy.Source§fn constant(
&mut self,
val: u16,
modulus: u16,
_: &mut Channel<'_>,
) -> Result<CircuitRef>
fn constant( &mut self, val: u16, modulus: u16, _: &mut Channel<'_>, ) -> Result<CircuitRef>
Create a constant
x with modulus q.Source§impl FancyArithmetic for CircuitBuilder<ArithmeticCircuit>
impl FancyArithmetic for CircuitBuilder<ArithmeticCircuit>
Source§fn add(&mut self, xref: &CircuitRef, yref: &CircuitRef) -> CircuitRef
fn add(&mut self, xref: &CircuitRef, yref: &CircuitRef) -> CircuitRef
Source§fn sub(&mut self, xref: &CircuitRef, yref: &CircuitRef) -> CircuitRef
fn sub(&mut self, xref: &CircuitRef, yref: &CircuitRef) -> CircuitRef
Source§fn cmul(&mut self, xref: &CircuitRef, c: u16) -> CircuitRef
fn cmul(&mut self, xref: &CircuitRef, c: u16) -> CircuitRef
Multiply
x times the constant c.Source§fn proj(
&mut self,
xref: &CircuitRef,
output_modulus: u16,
tt: Option<Vec<u16>>,
_: &mut Channel<'_>,
) -> Result<CircuitRef>
fn proj( &mut self, xref: &CircuitRef, output_modulus: u16, tt: Option<Vec<u16>>, _: &mut Channel<'_>, ) -> Result<CircuitRef>
Source§fn mul(
&mut self,
xref: &CircuitRef,
yref: &CircuitRef,
_channel: &mut Channel<'_>,
) -> Result<CircuitRef>
fn mul( &mut self, xref: &CircuitRef, yref: &CircuitRef, _channel: &mut Channel<'_>, ) -> Result<CircuitRef>
Multiply
x and y.Source§impl FancyBinary for CircuitBuilder<ArithmeticCircuit>
impl FancyBinary for CircuitBuilder<ArithmeticCircuit>
Source§fn and(
&mut self,
x: &Self::Item,
y: &Self::Item,
channel: &mut Channel<'_>,
) -> Result<Self::Item>
fn and( &mut self, x: &Self::Item, y: &Self::Item, channel: &mut Channel<'_>, ) -> Result<Self::Item>
Binary And
Source§fn or(
&mut self,
x: &Self::Item,
y: &Self::Item,
channel: &mut Channel<'_>,
) -> Result<Self::Item>
fn or( &mut self, x: &Self::Item, y: &Self::Item, channel: &mut Channel<'_>, ) -> Result<Self::Item>
Uses Demorgan’s Rule implemented with an and gate and negation.
Source§fn adder(
&mut self,
x: &Self::Item,
y: &Self::Item,
carry_in: Option<&Self::Item>,
channel: &mut Channel<'_>,
) -> Result<(Self::Item, Self::Item)>
fn adder( &mut self, x: &Self::Item, y: &Self::Item, carry_in: Option<&Self::Item>, channel: &mut Channel<'_>, ) -> Result<(Self::Item, Self::Item)>
Binary adder. Returns the result and the carry.
Source§fn and_many(
&mut self,
args: &[Self::Item],
channel: &mut Channel<'_>,
) -> Result<Self::Item>
fn and_many( &mut self, args: &[Self::Item], channel: &mut Channel<'_>, ) -> Result<Self::Item>
Returns 1 if all wires equal 1. Read more
Source§fn or_many(
&mut self,
args: &[Self::Item],
channel: &mut Channel<'_>,
) -> Result<Self::Item>
fn or_many( &mut self, args: &[Self::Item], channel: &mut Channel<'_>, ) -> Result<Self::Item>
Returns 1 if any wire equals 1. Read more
Source§impl FancyBinary for CircuitBuilder<BinaryCircuit>
impl FancyBinary for CircuitBuilder<BinaryCircuit>
Source§fn and(
&mut self,
xref: &Self::Item,
yref: &Self::Item,
_: &mut Channel<'_>,
) -> Result<Self::Item>
fn and( &mut self, xref: &Self::Item, yref: &Self::Item, _: &mut Channel<'_>, ) -> Result<Self::Item>
Binary And
Source§fn or(
&mut self,
x: &Self::Item,
y: &Self::Item,
channel: &mut Channel<'_>,
) -> Result<Self::Item>
fn or( &mut self, x: &Self::Item, y: &Self::Item, channel: &mut Channel<'_>, ) -> Result<Self::Item>
Uses Demorgan’s Rule implemented with an and gate and negation.
Source§fn adder(
&mut self,
x: &Self::Item,
y: &Self::Item,
carry_in: Option<&Self::Item>,
channel: &mut Channel<'_>,
) -> Result<(Self::Item, Self::Item)>
fn adder( &mut self, x: &Self::Item, y: &Self::Item, carry_in: Option<&Self::Item>, channel: &mut Channel<'_>, ) -> Result<(Self::Item, Self::Item)>
Binary adder. Returns the result and the carry.
Source§fn and_many(
&mut self,
args: &[Self::Item],
channel: &mut Channel<'_>,
) -> Result<Self::Item>
fn and_many( &mut self, args: &[Self::Item], channel: &mut Channel<'_>, ) -> Result<Self::Item>
Returns 1 if all wires equal 1. Read more
Source§fn or_many(
&mut self,
args: &[Self::Item],
channel: &mut Channel<'_>,
) -> Result<Self::Item>
fn or_many( &mut self, args: &[Self::Item], channel: &mut Channel<'_>, ) -> Result<Self::Item>
Returns 1 if any wire equals 1. Read more
Auto Trait Implementations§
impl<Circuit> Freeze for CircuitBuilder<Circuit>where
Circuit: Freeze,
impl<Circuit> RefUnwindSafe for CircuitBuilder<Circuit>where
Circuit: RefUnwindSafe,
impl<Circuit> Send for CircuitBuilder<Circuit>where
Circuit: Send,
impl<Circuit> Sync for CircuitBuilder<Circuit>where
Circuit: Sync,
impl<Circuit> Unpin for CircuitBuilder<Circuit>where
Circuit: Unpin,
impl<Circuit> UnwindSafe for CircuitBuilder<Circuit>where
Circuit: UnwindSafe,
Blanket Implementations§
Source§impl<F> ArithmeticBundleGadgets for Fwhere
F: FancyArithmetic,
impl<F> ArithmeticBundleGadgets for Fwhere
F: FancyArithmetic,
Source§fn add_bundles(
&mut self,
x: &Bundle<Self::Item>,
y: &Bundle<Self::Item>,
) -> Bundle<Self::Item>
fn add_bundles( &mut self, x: &Bundle<Self::Item>, y: &Bundle<Self::Item>, ) -> Bundle<Self::Item>
Add two wire bundles pairwise, zipping addition. Read more
Source§fn sub_bundles(
&mut self,
x: &Bundle<Self::Item>,
y: &Bundle<Self::Item>,
) -> Bundle<Self::Item>
fn sub_bundles( &mut self, x: &Bundle<Self::Item>, y: &Bundle<Self::Item>, ) -> Bundle<Self::Item>
Subtract two wire bundles, residue by residue. Read more
Source§fn mul_bundles(
&mut self,
x: &Bundle<Self::Item>,
y: &Bundle<Self::Item>,
channel: &mut Channel<'_>,
) -> Result<Bundle<Self::Item>>
fn mul_bundles( &mut self, x: &Bundle<Self::Item>, y: &Bundle<Self::Item>, channel: &mut Channel<'_>, ) -> Result<Bundle<Self::Item>>
Source§fn mixed_radix_addition(
&mut self,
xs: &[Bundle<Self::Item>],
channel: &mut Channel<'_>,
) -> Result<Bundle<Self::Item>>
fn mixed_radix_addition( &mut self, xs: &[Bundle<Self::Item>], channel: &mut Channel<'_>, ) -> Result<Bundle<Self::Item>>
Mixed radix addition. Read more
Source§fn mixed_radix_addition_msb_only(
&mut self,
xs: &[Bundle<Self::Item>],
channel: &mut Channel<'_>,
) -> Result<Self::Item>
fn mixed_radix_addition_msb_only( &mut self, xs: &[Bundle<Self::Item>], channel: &mut Channel<'_>, ) -> Result<Self::Item>
Mixed radix addition only returning the MSB. Read more
Source§impl<F> BinaryBundleGadgets for Fwhere
F: FancyBinary,
impl<F> BinaryBundleGadgets for Fwhere
F: FancyBinary,
Source§impl<F> BinaryGadgets for Fwhere
F: FancyBinary,
impl<F> BinaryGadgets for Fwhere
F: FancyBinary,
Source§fn bin_constant_bundle(
&mut self,
val: u128,
nbits: usize,
channel: &mut Channel<'_>,
) -> Result<BinaryBundle<Self::Item>>
fn bin_constant_bundle( &mut self, val: u128, nbits: usize, channel: &mut Channel<'_>, ) -> Result<BinaryBundle<Self::Item>>
Create a constant bundle using base 2 inputs.
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§fn bin_xor(
&mut self,
x: &BinaryBundle<Self::Item>,
y: &BinaryBundle<Self::Item>,
) -> BinaryBundle<Self::Item>
fn bin_xor( &mut self, x: &BinaryBundle<Self::Item>, y: &BinaryBundle<Self::Item>, ) -> BinaryBundle<Self::Item>
Xor the bits of two bundles together pairwise.
Source§fn bin_and(
&mut self,
x: &BinaryBundle<Self::Item>,
y: &BinaryBundle<Self::Item>,
channel: &mut Channel<'_>,
) -> Result<BinaryBundle<Self::Item>>
fn bin_and( &mut self, x: &BinaryBundle<Self::Item>, y: &BinaryBundle<Self::Item>, channel: &mut Channel<'_>, ) -> Result<BinaryBundle<Self::Item>>
And the bits of two bundles together pairwise.
Source§fn bin_or(
&mut self,
x: &BinaryBundle<Self::Item>,
y: &BinaryBundle<Self::Item>,
channel: &mut Channel<'_>,
) -> Result<BinaryBundle<Self::Item>>
fn bin_or( &mut self, x: &BinaryBundle<Self::Item>, y: &BinaryBundle<Self::Item>, channel: &mut Channel<'_>, ) -> Result<BinaryBundle<Self::Item>>
Or the bits of two bundles together pairwise.
Source§fn bin_addition(
&mut self,
xs: &BinaryBundle<Self::Item>,
ys: &BinaryBundle<Self::Item>,
channel: &mut Channel<'_>,
) -> Result<(BinaryBundle<Self::Item>, Self::Item)>
fn bin_addition( &mut self, xs: &BinaryBundle<Self::Item>, ys: &BinaryBundle<Self::Item>, channel: &mut Channel<'_>, ) -> Result<(BinaryBundle<Self::Item>, Self::Item)>
Binary addition. Returns the result and the carry. Read more
Source§fn bin_addition_no_carry(
&mut self,
xs: &BinaryBundle<Self::Item>,
ys: &BinaryBundle<Self::Item>,
channel: &mut Channel<'_>,
) -> Result<BinaryBundle<Self::Item>>
fn bin_addition_no_carry( &mut self, xs: &BinaryBundle<Self::Item>, ys: &BinaryBundle<Self::Item>, channel: &mut Channel<'_>, ) -> Result<BinaryBundle<Self::Item>>
Binary addition. Avoids creating extra gates for the final carry. Read more
Source§fn bin_multiplication_lower_half(
&mut self,
xs: &BinaryBundle<Self::Item>,
ys: &BinaryBundle<Self::Item>,
channel: &mut Channel<'_>,
) -> Result<BinaryBundle<Self::Item>>
fn bin_multiplication_lower_half( &mut self, xs: &BinaryBundle<Self::Item>, ys: &BinaryBundle<Self::Item>, channel: &mut Channel<'_>, ) -> Result<BinaryBundle<Self::Item>>
Binary multiplication. Read more
Source§fn bin_mul(
&mut self,
xs: &BinaryBundle<Self::Item>,
ys: &BinaryBundle<Self::Item>,
channel: &mut Channel<'_>,
) -> Result<BinaryBundle<Self::Item>>
fn bin_mul( &mut self, xs: &BinaryBundle<Self::Item>, ys: &BinaryBundle<Self::Item>, channel: &mut Channel<'_>, ) -> Result<BinaryBundle<Self::Item>>
Full multiplier. Read more
Source§fn bin_div(
&mut self,
xs: &BinaryBundle<Self::Item>,
ys: &BinaryBundle<Self::Item>,
channel: &mut Channel<'_>,
) -> Result<BinaryBundle<Self::Item>>
fn bin_div( &mut self, xs: &BinaryBundle<Self::Item>, ys: &BinaryBundle<Self::Item>, channel: &mut Channel<'_>, ) -> Result<BinaryBundle<Self::Item>>
Divider. Read more
Source§fn bin_twos_complement(
&mut self,
xs: &BinaryBundle<Self::Item>,
channel: &mut Channel<'_>,
) -> Result<BinaryBundle<Self::Item>>
fn bin_twos_complement( &mut self, xs: &BinaryBundle<Self::Item>, channel: &mut Channel<'_>, ) -> Result<BinaryBundle<Self::Item>>
Compute the twos complement of the input bundle (which must be base 2).
Source§fn bin_subtraction(
&mut self,
xs: &BinaryBundle<Self::Item>,
ys: &BinaryBundle<Self::Item>,
channel: &mut Channel<'_>,
) -> Result<(BinaryBundle<Self::Item>, Self::Item)>
fn bin_subtraction( &mut self, xs: &BinaryBundle<Self::Item>, ys: &BinaryBundle<Self::Item>, channel: &mut Channel<'_>, ) -> Result<(BinaryBundle<Self::Item>, Self::Item)>
Subtract two binary bundles. Returns the result and whether it underflowed. Read more
Source§fn bin_multiplex_constant_bits(
&mut self,
x: &Self::Item,
c1: u128,
c2: u128,
nbits: usize,
channel: &mut Channel<'_>,
) -> Result<BinaryBundle<Self::Item>>
fn bin_multiplex_constant_bits( &mut self, x: &Self::Item, c1: u128, c2: u128, nbits: usize, channel: &mut Channel<'_>, ) -> Result<BinaryBundle<Self::Item>>
If
x=0 return c1 as a bundle of constant bits, else return c2.Source§fn bin_multiplex(
&mut self,
b: &Self::Item,
x: &BinaryBundle<Self::Item>,
y: &BinaryBundle<Self::Item>,
channel: &mut Channel<'_>,
) -> Result<BinaryBundle<Self::Item>>
fn bin_multiplex( &mut self, b: &Self::Item, x: &BinaryBundle<Self::Item>, y: &BinaryBundle<Self::Item>, channel: &mut Channel<'_>, ) -> Result<BinaryBundle<Self::Item>>
Multiplex gadget for binary bundles
Source§fn bin_cmul(
&mut self,
x: &BinaryBundle<Self::Item>,
c: u128,
nbits: usize,
channel: &mut Channel<'_>,
) -> Result<BinaryBundle<Self::Item>>
fn bin_cmul( &mut self, x: &BinaryBundle<Self::Item>, c: u128, nbits: usize, channel: &mut Channel<'_>, ) -> Result<BinaryBundle<Self::Item>>
Write the constant in binary and that gives you the shift amounts, Eg.. 7x is 4x+2x+x.
Source§fn bin_abs(
&mut self,
x: &BinaryBundle<Self::Item>,
channel: &mut Channel<'_>,
) -> Result<BinaryBundle<Self::Item>>
fn bin_abs( &mut self, x: &BinaryBundle<Self::Item>, channel: &mut Channel<'_>, ) -> Result<BinaryBundle<Self::Item>>
Compute the absolute value of a binary bundle.
Source§fn bin_lt_signed(
&mut self,
x: &BinaryBundle<Self::Item>,
y: &BinaryBundle<Self::Item>,
channel: &mut Channel<'_>,
) -> Result<Self::Item>
fn bin_lt_signed( &mut self, x: &BinaryBundle<Self::Item>, y: &BinaryBundle<Self::Item>, channel: &mut Channel<'_>, ) -> Result<Self::Item>
Returns 1 if
x < y (signed version)Source§fn bin_lt(
&mut self,
x: &BinaryBundle<Self::Item>,
y: &BinaryBundle<Self::Item>,
channel: &mut Channel<'_>,
) -> Result<Self::Item>
fn bin_lt( &mut self, x: &BinaryBundle<Self::Item>, y: &BinaryBundle<Self::Item>, channel: &mut Channel<'_>, ) -> Result<Self::Item>
Returns 1 if
x < y.Source§fn bin_geq(
&mut self,
x: &BinaryBundle<Self::Item>,
y: &BinaryBundle<Self::Item>,
channel: &mut Channel<'_>,
) -> Result<Self::Item>
fn bin_geq( &mut self, x: &BinaryBundle<Self::Item>, y: &BinaryBundle<Self::Item>, channel: &mut Channel<'_>, ) -> Result<Self::Item>
Returns 1 if
x >= y.Source§fn bin_max(
&mut self,
xs: &[BinaryBundle<Self::Item>],
channel: &mut Channel<'_>,
) -> Result<BinaryBundle<Self::Item>>
fn bin_max( &mut self, xs: &[BinaryBundle<Self::Item>], channel: &mut Channel<'_>, ) -> Result<BinaryBundle<Self::Item>>
Compute the maximum bundle in
xs. Read moreSource§fn bin_demux(
&mut self,
x: &BinaryBundle<Self::Item>,
channel: &mut Channel<'_>,
) -> Result<Vec<Self::Item>>
fn bin_demux( &mut self, x: &BinaryBundle<Self::Item>, channel: &mut Channel<'_>, ) -> Result<Vec<Self::Item>>
Demux a binary bundle into a unary vector. Read more
Source§fn bin_rsa(
&mut self,
x: &BinaryBundle<Self::Item>,
c: usize,
) -> BinaryBundle<Self::Item>
fn bin_rsa( &mut self, x: &BinaryBundle<Self::Item>, c: usize, ) -> BinaryBundle<Self::Item>
arithmetic right shift (shifts the sign of the MSB into the new spaces)
Source§fn bin_rsl(
&mut self,
x: &BinaryBundle<Self::Item>,
c: usize,
channel: &mut Channel<'_>,
) -> Result<BinaryBundle<Self::Item>>
fn bin_rsl( &mut self, x: &BinaryBundle<Self::Item>, c: usize, channel: &mut Channel<'_>, ) -> Result<BinaryBundle<Self::Item>>
logical right shift (shifts 0 into the empty spaces)
Source§fn bin_shr(
&mut self,
x: &BinaryBundle<Self::Item>,
c: usize,
pad: &Self::Item,
) -> BinaryBundle<Self::Item>
fn bin_shr( &mut self, x: &BinaryBundle<Self::Item>, c: usize, pad: &Self::Item, ) -> BinaryBundle<Self::Item>
shift a value right by a constant, filling space on the right by
padSource§fn bin_eq_bundles(
&mut self,
x: &BinaryBundle<Self::Item>,
y: &BinaryBundle<Self::Item>,
channel: &mut Channel<'_>,
) -> Result<Self::Item>
fn bin_eq_bundles( &mut self, x: &BinaryBundle<Self::Item>, y: &BinaryBundle<Self::Item>, channel: &mut Channel<'_>, ) -> Result<Self::Item>
Compute
x == y for binary bundles.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> BundleGadgets for Fwhere
F: Fancy,
impl<F> BundleGadgets for Fwhere
F: Fancy,
Source§fn constant_bundle(
&mut self,
xs: &[u16],
ps: &[u16],
channel: &mut Channel<'_>,
) -> Result<Bundle<Self::Item>>
fn constant_bundle( &mut self, xs: &[u16], ps: &[u16], channel: &mut Channel<'_>, ) -> Result<Bundle<Self::Item>>
Creates a bundle of constant wires using moduli
ps.Source§fn output_bundle(
&mut self,
x: &Bundle<Self::Item>,
channel: &mut Channel<'_>,
) -> Result<Option<Vec<u16>>>
fn output_bundle( &mut self, x: &Bundle<Self::Item>, channel: &mut Channel<'_>, ) -> Result<Option<Vec<u16>>>
Output the wires that make up a bundle.
Source§fn output_bundles(
&mut self,
xs: &[Bundle<Self::Item>],
channel: &mut Channel<'_>,
) -> Result<Option<Vec<Vec<u16>>>>
fn output_bundles( &mut self, xs: &[Bundle<Self::Item>], channel: &mut Channel<'_>, ) -> Result<Option<Vec<Vec<u16>>>>
Output a slice of bundles.
Source§impl<F> CrtGadgets for Fwhere
F: FancyArithmetic + FancyBinary,
impl<F> CrtGadgets for Fwhere
F: FancyArithmetic + FancyBinary,
Source§fn crt_constant_bundle(
&mut self,
x: u128,
q: u128,
channel: &mut Channel<'_>,
) -> Result<CrtBundle<Self::Item>>
fn crt_constant_bundle( &mut self, x: u128, q: u128, channel: &mut Channel<'_>, ) -> Result<CrtBundle<Self::Item>>
Creates a bundle of constant wires for the CRT representation of
x under
composite modulus q.Source§fn crt_output(
&mut self,
x: &CrtBundle<Self::Item>,
channel: &mut Channel<'_>,
) -> Result<Option<u128>>
fn crt_output( &mut self, x: &CrtBundle<Self::Item>, channel: &mut Channel<'_>, ) -> Result<Option<u128>>
Output a CRT bundle and interpret it mod Q.
Source§fn crt_outputs(
&mut self,
xs: &[CrtBundle<Self::Item>],
channel: &mut Channel<'_>,
) -> Result<Option<Vec<u128>>>
fn crt_outputs( &mut self, xs: &[CrtBundle<Self::Item>], channel: &mut Channel<'_>, ) -> Result<Option<Vec<u128>>>
Output a slice of CRT bundles and interpret the outputs mod Q.
Source§fn crt_add(
&mut self,
x: &CrtBundle<Self::Item>,
y: &CrtBundle<Self::Item>,
) -> CrtBundle<Self::Item>
fn crt_add( &mut self, x: &CrtBundle<Self::Item>, y: &CrtBundle<Self::Item>, ) -> CrtBundle<Self::Item>
Add two CRT bundles.
Source§fn crt_sub(
&mut self,
x: &CrtBundle<Self::Item>,
y: &CrtBundle<Self::Item>,
) -> CrtBundle<Self::Item>
fn crt_sub( &mut self, x: &CrtBundle<Self::Item>, y: &CrtBundle<Self::Item>, ) -> CrtBundle<Self::Item>
Subtract two CRT bundles.
Source§fn crt_cmul(
&mut self,
x: &CrtBundle<Self::Item>,
c: u128,
) -> CrtBundle<Self::Item>
fn crt_cmul( &mut self, x: &CrtBundle<Self::Item>, c: u128, ) -> CrtBundle<Self::Item>
Multiplies each wire in
x by the corresponding residue of c.Source§fn crt_mul(
&mut self,
x: &CrtBundle<Self::Item>,
y: &CrtBundle<Self::Item>,
channel: &mut Channel<'_>,
) -> Result<CrtBundle<Self::Item>>
fn crt_mul( &mut self, x: &CrtBundle<Self::Item>, y: &CrtBundle<Self::Item>, channel: &mut Channel<'_>, ) -> Result<CrtBundle<Self::Item>>
Multiply
x with y.Source§fn crt_cexp(
&mut self,
x: &CrtBundle<Self::Item>,
c: u16,
channel: &mut Channel<'_>,
) -> Result<CrtBundle<Self::Item>>
fn crt_cexp( &mut self, x: &CrtBundle<Self::Item>, c: u16, channel: &mut Channel<'_>, ) -> Result<CrtBundle<Self::Item>>
Exponentiate
x by the constant c.Source§fn crt_rem(
&mut self,
x: &CrtBundle<Self::Item>,
p: u16,
channel: &mut Channel<'_>,
) -> Result<CrtBundle<Self::Item>>
fn crt_rem( &mut self, x: &CrtBundle<Self::Item>, p: u16, channel: &mut Channel<'_>, ) -> Result<CrtBundle<Self::Item>>
Compute the remainder with respect to modulus
p. Read moreSource§fn crt_fractional_mixed_radix(
&mut self,
bun: &CrtBundle<Self::Item>,
ms: &[u16],
channel: &mut Channel<'_>,
) -> Result<Self::Item>
fn crt_fractional_mixed_radix( &mut self, bun: &CrtBundle<Self::Item>, ms: &[u16], channel: &mut Channel<'_>, ) -> Result<Self::Item>
Helper function for advanced gadgets, returns the MSB of the fractional part of
X/M where M=product(ms).Source§fn crt_relu(
&mut self,
x: &CrtBundle<Self::Item>,
accuracy: &str,
output_moduli: Option<&[u16]>,
channel: &mut Channel<'_>,
) -> Result<CrtBundle<Self::Item>>
fn crt_relu( &mut self, x: &CrtBundle<Self::Item>, accuracy: &str, output_moduli: Option<&[u16]>, channel: &mut Channel<'_>, ) -> Result<CrtBundle<Self::Item>>
Compute
max(x,0). Read moreSource§fn crt_sign(
&mut self,
x: &CrtBundle<Self::Item>,
accuracy: &str,
channel: &mut Channel<'_>,
) -> Result<Self::Item>
fn crt_sign( &mut self, x: &CrtBundle<Self::Item>, accuracy: &str, channel: &mut Channel<'_>, ) -> Result<Self::Item>
Return 0 if
x is positive and 1 if x is negative.Source§fn crt_sgn(
&mut self,
x: &CrtBundle<Self::Item>,
accuracy: &str,
output_moduli: Option<&[u16]>,
channel: &mut Channel<'_>,
) -> Result<CrtBundle<Self::Item>>
fn crt_sgn( &mut self, x: &CrtBundle<Self::Item>, accuracy: &str, output_moduli: Option<&[u16]>, channel: &mut Channel<'_>, ) -> Result<CrtBundle<Self::Item>>
Source§fn crt_lt(
&mut self,
x: &CrtBundle<Self::Item>,
y: &CrtBundle<Self::Item>,
accuracy: &str,
channel: &mut Channel<'_>,
) -> Result<Self::Item>
fn crt_lt( &mut self, x: &CrtBundle<Self::Item>, y: &CrtBundle<Self::Item>, accuracy: &str, channel: &mut Channel<'_>, ) -> Result<Self::Item>
Returns 1 if
x < y.Source§fn crt_geq(
&mut self,
x: &CrtBundle<Self::Item>,
y: &CrtBundle<Self::Item>,
accuracy: &str,
channel: &mut Channel<'_>,
) -> Result<Self::Item>
fn crt_geq( &mut self, x: &CrtBundle<Self::Item>, y: &CrtBundle<Self::Item>, accuracy: &str, channel: &mut Channel<'_>, ) -> Result<Self::Item>
Returns 1 if
x >= y.Source§fn crt_max(
&mut self,
xs: &[CrtBundle<Self::Item>],
accuracy: &str,
channel: &mut Channel<'_>,
) -> Result<CrtBundle<Self::Item>>
fn crt_max( &mut self, xs: &[CrtBundle<Self::Item>], accuracy: &str, channel: &mut Channel<'_>, ) -> Result<CrtBundle<Self::Item>>
Compute the maximum bundle in
xs. Read moreSource§fn crt_to_pmr(
&mut self,
xs: &CrtBundle<Self::Item>,
channel: &mut Channel<'_>,
) -> Result<Bundle<Self::Item>>
fn crt_to_pmr( &mut self, xs: &CrtBundle<Self::Item>, channel: &mut Channel<'_>, ) -> Result<Bundle<Self::Item>>
Convert the xs bundle to PMR representation. Useful for extracting out of CRT.
Source§fn pmr_lt(
&mut self,
x: &CrtBundle<Self::Item>,
y: &CrtBundle<Self::Item>,
channel: &mut Channel<'_>,
) -> Result<Self::Item>
fn pmr_lt( &mut self, x: &CrtBundle<Self::Item>, y: &CrtBundle<Self::Item>, channel: &mut Channel<'_>, ) -> Result<Self::Item>
Comparison based on PMR, more expensive than crt_lt but works on more things. For
it to work, there must be an extra modulus in the CRT that is not necessary to
represent the values. This ensures that if x < y, the most significant PMR digit
is nonzero after subtracting them. You could add a prime to your CrtBundles right
before using this gadget.
Source§fn pmr_geq(
&mut self,
x: &CrtBundle<Self::Item>,
y: &CrtBundle<Self::Item>,
channel: &mut Channel<'_>,
) -> Result<Self::Item>
fn pmr_geq( &mut self, x: &CrtBundle<Self::Item>, y: &CrtBundle<Self::Item>, channel: &mut Channel<'_>, ) -> Result<Self::Item>
Comparison based on PMR, more expensive than crt_lt but works on more things. For
it to work, there must be an extra modulus in the CRT that is not necessary to
represent the values. This ensures that if x < y, the most significant PMR digit
is nonzero after subtracting them. You could add a prime to your CrtBundles right
before using this gadget.
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