darkfi::zk::gadget::arithmetic

Trait ArithInstruction

Source
pub trait ArithInstruction<F: WithSmallOrderMulGroup<3> + Ord>: Chip<F> {
    // Required methods
    fn add(
        &self,
        layouter: impl Layouter<F>,
        a: &AssignedCell<F, F>,
        b: &AssignedCell<F, F>,
    ) -> Result<AssignedCell<F, F>, Error>;
    fn sub(
        &self,
        layouter: impl Layouter<F>,
        a: &AssignedCell<F, F>,
        b: &AssignedCell<F, F>,
    ) -> Result<AssignedCell<F, F>, Error>;
    fn mul(
        &self,
        layouter: impl Layouter<F>,
        a: &AssignedCell<F, F>,
        b: &AssignedCell<F, F>,
    ) -> Result<AssignedCell<F, F>, Error>;
}
Expand description

Arithmetic instructions implemented in the chip

Required Methods§

Source

fn add( &self, layouter: impl Layouter<F>, a: &AssignedCell<F, F>, b: &AssignedCell<F, F>, ) -> Result<AssignedCell<F, F>, Error>

Add two field elements and return their sum

Source

fn sub( &self, layouter: impl Layouter<F>, a: &AssignedCell<F, F>, b: &AssignedCell<F, F>, ) -> Result<AssignedCell<F, F>, Error>

Subtract two field elements and return their difference

Source

fn mul( &self, layouter: impl Layouter<F>, a: &AssignedCell<F, F>, b: &AssignedCell<F, F>, ) -> Result<AssignedCell<F, F>, Error>

Multiply two field elements and return their product

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<F: WithSmallOrderMulGroup<3> + Ord> ArithInstruction<F> for ArithChip<F>