pub trait CrtGadgets: FancyArithmetic + FancyBinary + ArithmeticBundleGadgets + BundleGadgets {
Show 20 methods fn crt_constant_bundle(
        &mut self,
        x: u128,
        q: u128
    ) -> Result<CrtBundle<Self::Item>, Self::Error> { ... } fn crt_output(
        &mut self,
        x: &CrtBundle<Self::Item>
    ) -> Result<Option<u128>, Self::Error> { ... } fn crt_outputs(
        &mut self,
        xs: &[CrtBundle<Self::Item>]
    ) -> Result<Option<Vec<u128>>, Self::Error> { ... } fn crt_add(
        &mut self,
        x: &CrtBundle<Self::Item>,
        y: &CrtBundle<Self::Item>
    ) -> Result<CrtBundle<Self::Item>, Self::Error> { ... } fn crt_sub(
        &mut self,
        x: &CrtBundle<Self::Item>,
        y: &CrtBundle<Self::Item>
    ) -> Result<CrtBundle<Self::Item>, Self::Error> { ... } fn crt_cmul(
        &mut self,
        x: &CrtBundle<Self::Item>,
        c: u128
    ) -> Result<CrtBundle<Self::Item>, Self::Error> { ... } fn crt_mul(
        &mut self,
        x: &CrtBundle<Self::Item>,
        y: &CrtBundle<Self::Item>
    ) -> Result<CrtBundle<Self::Item>, Self::Error> { ... } fn crt_cexp(
        &mut self,
        x: &CrtBundle<Self::Item>,
        c: u16
    ) -> Result<CrtBundle<Self::Item>, Self::Error> { ... } fn crt_rem(
        &mut self,
        x: &CrtBundle<Self::Item>,
        p: u16
    ) -> Result<CrtBundle<Self::Item>, Self::Error> { ... } fn crt_fractional_mixed_radix(
        &mut self,
        bun: &CrtBundle<Self::Item>,
        ms: &[u16]
    ) -> Result<Self::Item, Self::Error> { ... } fn crt_relu(
        &mut self,
        x: &CrtBundle<Self::Item>,
        accuracy: &str,
        output_moduli: Option<&[u16]>
    ) -> Result<CrtBundle<Self::Item>, Self::Error> { ... } fn crt_sign(
        &mut self,
        x: &CrtBundle<Self::Item>,
        accuracy: &str
    ) -> Result<Self::Item, Self::Error> { ... } fn crt_sgn(
        &mut self,
        x: &CrtBundle<Self::Item>,
        accuracy: &str,
        output_moduli: Option<&[u16]>
    ) -> Result<CrtBundle<Self::Item>, Self::Error> { ... } fn crt_lt(
        &mut self,
        x: &CrtBundle<Self::Item>,
        y: &CrtBundle<Self::Item>,
        accuracy: &str
    ) -> Result<Self::Item, Self::Error> { ... } fn crt_geq(
        &mut self,
        x: &CrtBundle<Self::Item>,
        y: &CrtBundle<Self::Item>,
        accuracy: &str
    ) -> Result<Self::Item, Self::Error> { ... } fn crt_max(
        &mut self,
        xs: &[CrtBundle<Self::Item>],
        accuracy: &str
    ) -> Result<CrtBundle<Self::Item>, Self::Error> { ... } fn crt_to_pmr(
        &mut self,
        xs: &CrtBundle<Self::Item>
    ) -> Result<Bundle<Self::Item>, Self::Error> { ... } fn pmr_lt(
        &mut self,
        x: &CrtBundle<Self::Item>,
        y: &CrtBundle<Self::Item>
    ) -> Result<Self::Item, Self::Error> { ... } fn pmr_geq(
        &mut self,
        x: &CrtBundle<Self::Item>,
        y: &CrtBundle<Self::Item>
    ) -> Result<Self::Item, Self::Error> { ... } fn crt_div(
        &mut self,
        x: &CrtBundle<Self::Item>,
        y: &CrtBundle<Self::Item>
    ) -> Result<CrtBundle<Self::Item>, Self::Error> { ... }
}
Expand description

Extension trait for Fancy providing advanced CRT gadgets based on bundles of wires.

Provided Methods

Creates a bundle of constant wires for the CRT representation of x under composite modulus q.

Output a CRT bundle and interpret it mod Q.

Output a slice of CRT bundles and interpret the outputs mod Q.

Add two CRT bundles.

Subtract two CRT bundles.

Multiplies each wire in x by the corresponding residue of c.

Multiply x with y.

Exponentiate x by the constant c.

Compute the remainder with respect to modulus p.

Helper function for advanced gadgets, returns the MSB of the fractional part of X/M where M=product(ms).

Compute max(x,0).

Optional output moduli.

Return 0 if x is positive and 1 if x is negative.

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()

Returns 1 if x < y.

Returns 1 if x >= y.

Compute the maximum bundle in xs.

Convert the xs bundle to PMR representation. Useful for extracting out of CRT.

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.

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.

Generic, and expensive, CRT-based addition for two ciphertexts. Uses PMR comparison repeatedly. Requires an extra unused prime in both inputs.

Implementors