Trait IntegerInstructions

Source
pub trait IntegerInstructions<F: PrimeField>: Clone + Debug {
    type Context: Debug;
    type AssignedCell: Clone + Debug;
    type AssignedInteger: Clone + Debug;

    // Required methods
    fn assign_integer(
        &self,
        ctx: &mut Self::Context,
        integer: F,
    ) -> Self::AssignedInteger;
    fn assign_constant(
        &self,
        ctx: &mut Self::Context,
        integer: F,
    ) -> Self::AssignedInteger;
    fn sum_with_coeff_and_const(
        &self,
        ctx: &mut Self::Context,
        values: &[(F, impl Deref<Target = Self::AssignedInteger>)],
        constant: F,
    ) -> Self::AssignedInteger;
    fn sum_products_with_coeff_and_const(
        &self,
        ctx: &mut Self::Context,
        values: &[(F, impl Deref<Target = Self::AssignedInteger>, impl Deref<Target = Self::AssignedInteger>)],
        constant: F,
    ) -> Self::AssignedInteger;
    fn sub(
        &self,
        ctx: &mut Self::Context,
        lhs: &Self::AssignedInteger,
        rhs: &Self::AssignedInteger,
    ) -> Self::AssignedInteger;
    fn neg(
        &self,
        ctx: &mut Self::Context,
        value: &Self::AssignedInteger,
    ) -> Self::AssignedInteger;
    fn invert(
        &self,
        ctx: &mut Self::Context,
        value: &Self::AssignedInteger,
    ) -> Self::AssignedInteger;
    fn assert_equal(
        &self,
        ctx: &mut Self::Context,
        lhs: &Self::AssignedInteger,
        rhs: &Self::AssignedInteger,
    );
    fn pow_var(
        &self,
        ctx: &mut Self::Context,
        base: &Self::AssignedInteger,
        exponent: &Self::AssignedInteger,
        max_bits: usize,
    ) -> Self::AssignedInteger;
}
Expand description

Instructions to handle field element operations.

Required Associated Types§

Source

type Context: Debug

Context (either enhanced region or some kind of builder).

Source

type AssignedCell: Clone + Debug

Assigned cell.

Source

type AssignedInteger: Clone + Debug

Assigned integer.

Required Methods§

Source

fn assign_integer( &self, ctx: &mut Self::Context, integer: F, ) -> Self::AssignedInteger

Assign an integer witness.

Source

fn assign_constant( &self, ctx: &mut Self::Context, integer: F, ) -> Self::AssignedInteger

Assign an integer constant.

Source

fn sum_with_coeff_and_const( &self, ctx: &mut Self::Context, values: &[(F, impl Deref<Target = Self::AssignedInteger>)], constant: F, ) -> Self::AssignedInteger

Sum integers with coefficients and constant.

Source

fn sum_products_with_coeff_and_const( &self, ctx: &mut Self::Context, values: &[(F, impl Deref<Target = Self::AssignedInteger>, impl Deref<Target = Self::AssignedInteger>)], constant: F, ) -> Self::AssignedInteger

Sum product of integers with coefficients and constant.

Source

fn sub( &self, ctx: &mut Self::Context, lhs: &Self::AssignedInteger, rhs: &Self::AssignedInteger, ) -> Self::AssignedInteger

Returns lhs - rhs.

Source

fn neg( &self, ctx: &mut Self::Context, value: &Self::AssignedInteger, ) -> Self::AssignedInteger

Returns -value.

Source

fn invert( &self, ctx: &mut Self::Context, value: &Self::AssignedInteger, ) -> Self::AssignedInteger

Returns 1/value.

Source

fn assert_equal( &self, ctx: &mut Self::Context, lhs: &Self::AssignedInteger, rhs: &Self::AssignedInteger, )

Enforce lhs and rhs are equal.

Source

fn pow_var( &self, ctx: &mut Self::Context, base: &Self::AssignedInteger, exponent: &Self::AssignedInteger, max_bits: usize, ) -> Self::AssignedInteger

Returns base^exponent and constrains that exponent has at most max_bits bits.

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.

Implementations on Foreign Types§

Source§

impl<F: BigPrimeField> IntegerInstructions<F> for GateChip<F>

Source§

type Context = SinglePhaseCoreManager<F>

Source§

type AssignedCell = AssignedValue<F>

Source§

type AssignedInteger = AssignedValue<F>

Source§

fn assign_integer( &self, ctx: &mut Self::Context, integer: F, ) -> Self::AssignedInteger

Source§

fn assign_constant( &self, ctx: &mut Self::Context, integer: F, ) -> Self::AssignedInteger

Source§

fn sum_with_coeff_and_const( &self, ctx: &mut Self::Context, values: &[(F, impl Deref<Target = Self::AssignedInteger>)], constant: F, ) -> Self::AssignedInteger

Source§

fn sum_products_with_coeff_and_const( &self, ctx: &mut Self::Context, values: &[(F, impl Deref<Target = Self::AssignedInteger>, impl Deref<Target = Self::AssignedInteger>)], constant: F, ) -> Self::AssignedInteger

Source§

fn sub( &self, ctx: &mut Self::Context, a: &Self::AssignedInteger, b: &Self::AssignedInteger, ) -> Self::AssignedInteger

Source§

fn neg( &self, ctx: &mut Self::Context, a: &Self::AssignedInteger, ) -> Self::AssignedInteger

Source§

fn invert( &self, ctx: &mut Self::Context, a: &Self::AssignedInteger, ) -> Self::AssignedInteger

Source§

fn assert_equal( &self, ctx: &mut Self::Context, a: &Self::AssignedInteger, b: &Self::AssignedInteger, )

Source§

fn pow_var( &self, ctx: &mut Self::Context, base: &Self::AssignedInteger, exponent: &Self::AssignedInteger, max_bits: usize, ) -> Self::AssignedInteger

Implementors§