ArithmeticBundleGadgets

Trait ArithmeticBundleGadgets 

Source
pub trait ArithmeticBundleGadgets: FancyArithmetic {
    // Provided methods
    fn add_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> { ... }
    fn mul_bundles(
        &mut self,
        x: &Bundle<Self::Item>,
        y: &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>> { ... }
    fn mixed_radix_addition_msb_only(
        &mut self,
        xs: &[Bundle<Self::Item>],
        channel: &mut Channel<'_>,
    ) -> Result<Self::Item> { ... }
    fn mask(
        &mut self,
        b: &Self::Item,
        x: &Bundle<Self::Item>,
        channel: &mut Channel<'_>,
    ) -> Result<Bundle<Self::Item>> { ... }
    fn eq_bundles(
        &mut self,
        x: &Bundle<Self::Item>,
        y: &Bundle<Self::Item>,
        channel: &mut Channel<'_>,
    ) -> Result<Self::Item> { ... }
}
Expand description

Arithmetic operations on wire bundles, extending the capability of FancyArithmetic operating on individual wires.

Provided Methods§

Source

fn add_bundles( &mut self, x: &Bundle<Self::Item>, y: &Bundle<Self::Item>, ) -> Bundle<Self::Item>

Add two wire bundles pairwise, zipping addition.

In CRT this is plain addition. In binary this is xor.

§Panics

Panics if x and y are not of the same length.

Source

fn sub_bundles( &mut self, x: &Bundle<Self::Item>, y: &Bundle<Self::Item>, ) -> Bundle<Self::Item>

Subtract two wire bundles, residue by residue.

In CRT this is plain subtraction. In binary this is xor.

§Panics

Panics if x and y are not of the same length.

Source

fn mul_bundles( &mut self, x: &Bundle<Self::Item>, y: &Bundle<Self::Item>, channel: &mut Channel<'_>, ) -> Result<Bundle<Self::Item>>

Multiply each wire in x with each wire in y, pairwise.

In CRT this is plain multiplication. In binary this is and.

Source

fn mixed_radix_addition( &mut self, xs: &[Bundle<Self::Item>], channel: &mut Channel<'_>, ) -> Result<Bundle<Self::Item>>

Mixed radix addition.

§Panics

Panics if xs is empty, or the moduli in xs are not all equal.

Source

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.

§Panics

Panics if xs is empty, or the moduli in xs are not all equal.

Source

fn mask( &mut self, b: &Self::Item, x: &Bundle<Self::Item>, channel: &mut Channel<'_>, ) -> Result<Bundle<Self::Item>>

If b=0 then return 0, else return x.

Source

fn eq_bundles( &mut self, x: &Bundle<Self::Item>, y: &Bundle<Self::Item>, channel: &mut Channel<'_>, ) -> Result<Self::Item>

Compute x == y. Returns a wire encoding the result mod 2.

§Panics

Panics if x and y do not have equal moduli.

Implementors§