Trait ArithmeticBundleGadgets

Source
pub trait ArithmeticBundleGadgets: FancyArithmetic {
    // Provided methods
    fn add_bundles(
        &mut self,
        x: &Bundle<Self::Item>,
        y: &Bundle<Self::Item>,
    ) -> Result<Bundle<Self::Item>, Self::Error> { ... }
    fn sub_bundles(
        &mut self,
        x: &Bundle<Self::Item>,
        y: &Bundle<Self::Item>,
    ) -> Result<Bundle<Self::Item>, Self::Error> { ... }
    fn mul_bundles(
        &mut self,
        x: &Bundle<Self::Item>,
        y: &Bundle<Self::Item>,
    ) -> Result<Bundle<Self::Item>, Self::Error> { ... }
    fn mixed_radix_addition(
        &mut self,
        xs: &[Bundle<Self::Item>],
    ) -> Result<Bundle<Self::Item>, Self::Error> { ... }
    fn mixed_radix_addition_msb_only(
        &mut self,
        xs: &[Bundle<Self::Item>],
    ) -> Result<Self::Item, Self::Error> { ... }
    fn mask(
        &mut self,
        b: &Self::Item,
        x: &Bundle<Self::Item>,
    ) -> Result<Bundle<Self::Item>, Self::Error> { ... }
    fn eq_bundles(
        &mut self,
        x: &Bundle<Self::Item>,
        y: &Bundle<Self::Item>,
    ) -> Result<Self::Item, Self::Error> { ... }
}
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>, ) -> Result<Bundle<Self::Item>, Self::Error>

Add two wire bundles pairwise, zipping addition.

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

Source

fn sub_bundles( &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.

Source

fn mul_bundles( &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.

Source

fn mixed_radix_addition( &mut self, xs: &[Bundle<Self::Item>], ) -> Result<Bundle<Self::Item>, Self::Error>

Mixed radix addition.

Source

fn mixed_radix_addition_msb_only( &mut self, xs: &[Bundle<Self::Item>], ) -> Result<Self::Item, Self::Error>

Mixed radix addition only returning the MSB.

Source

fn mask( &mut self, b: &Self::Item, x: &Bundle<Self::Item>, ) -> Result<Bundle<Self::Item>, Self::Error>

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

Source

fn eq_bundles( &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.

Implementors§