ark_r1cs_std::fields::fp

Enum FpVar

Source
pub enum FpVar<F: PrimeField> {
    Constant(F),
    Var(AllocatedFp<F>),
}
Expand description

Represent variables corresponding to a field element in F.

Variants§

§

Constant(F)

Represents a constant in the constraint system, which means that it does not have a corresponding variable.

§

Var(AllocatedFp<F>)

Represents an allocated variable constant in the constraint system.

Implementations§

Source§

impl<F: PrimeField> FpVar<F>

Source

pub fn enforce_cmp( &self, other: &FpVar<F>, ordering: Ordering, should_also_check_equality: bool, ) -> Result<(), SynthesisError>

This function enforces the ordering between self and other. The constraint system will not be satisfied otherwise. If self should also be checked for equality, e.g. self <= other instead of self < other, set should_also_check_quality to true. This variant verifies self and other are <= (p-1)/2.

Source

pub fn enforce_cmp_unchecked( &self, other: &FpVar<F>, ordering: Ordering, should_also_check_equality: bool, ) -> Result<(), SynthesisError>

This function enforces the ordering between self and other. The constraint system will not be satisfied otherwise. If self should also be checked for equality, e.g. self <= other instead of self < other, set should_also_check_quality to true. This variant assumes self and other are <= (p-1)/2 and does not generate constraints to verify that.

Source

pub fn is_cmp( &self, other: &FpVar<F>, ordering: Ordering, should_also_check_equality: bool, ) -> Result<Boolean<F>, SynthesisError>

This function checks the ordering between self and other. It outputs self Boolean that contains the result - 1 if true, 0 otherwise. The constraint system will be satisfied in any case. If self should also be checked for equality, e.g. self <= other instead of self < other, set should_also_check_quality to true. This variant verifies self and other are <= (p-1)/2.

Source

pub fn is_cmp_unchecked( &self, other: &FpVar<F>, ordering: Ordering, should_also_check_equality: bool, ) -> Result<Boolean<F>, SynthesisError>

This function checks the ordering between self and other. It outputs a Boolean that contains the result - 1 if true, 0 otherwise. The constraint system will be satisfied in any case. If self should also be checked for equality, e.g. self <= other instead of self < other, set should_also_check_quality to true. This variant assumes self and other are <= (p-1)/2 and does not generate constraints to verify that.

Source

pub fn enforce_smaller_or_equal_than_mod_minus_one_div_two( &self, ) -> Result<(), SynthesisError>

Helper function to enforce that self <= (p-1)/2.

Source§

impl<F: PrimeField> FpVar<F>

Source

pub fn to_bits_le_with_top_bits_zero( &self, size: usize, ) -> Result<(Vec<Boolean<F>>, Self), SynthesisError>

Decomposes self into a vector of bits and a remainder rest such that

  • bits.len() == size, and
  • rest == 0.

Trait Implementations§

Source§

impl<'a, F: PrimeField> Add<&'a FpVar<F>> for FpVar<F>

Source§

type Output = FpVar<F>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'a FpVar<F>) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a, F: PrimeField> Add<F> for &'a FpVar<F>

Source§

type Output = FpVar<F>

The resulting type after applying the + operator.
Source§

fn add(self, other: F) -> Self::Output

Performs the + operation. Read more
Source§

impl<F: PrimeField> Add<F> for FpVar<F>

Source§

type Output = FpVar<F>

The resulting type after applying the + operator.
Source§

fn add(self, other: F) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a, F: PrimeField> Add<FpVar<F>> for &'a FpVar<F>

Source§

type Output = FpVar<F>

The resulting type after applying the + operator.
Source§

fn add(self, other: FpVar<F>) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a, F: PrimeField> Add for &'a FpVar<F>

Source§

type Output = FpVar<F>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'a FpVar<F>) -> Self::Output

Performs the + operation. Read more
Source§

impl<F: PrimeField> Add for FpVar<F>

Source§

type Output = FpVar<F>

The resulting type after applying the + operator.
Source§

fn add(self, other: FpVar<F>) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a, F: PrimeField> AddAssign<&'a FpVar<F>> for FpVar<F>

Source§

fn add_assign(&mut self, other: &'a FpVar<F>)

Performs the += operation. Read more
Source§

impl<F: PrimeField> AddAssign<F> for FpVar<F>

Source§

fn add_assign(&mut self, other: F)

Performs the += operation. Read more
Source§

impl<F: PrimeField> AddAssign for FpVar<F>

Source§

fn add_assign(&mut self, other: FpVar<F>)

Performs the += operation. Read more
Source§

impl<F: PrimeField> AllocVar<F, F> for FpVar<F>

Source§

fn new_variable<T: Borrow<F>>( cs: impl Into<Namespace<F>>, f: impl FnOnce() -> Result<T, SynthesisError>, mode: AllocationMode, ) -> Result<Self, SynthesisError>

Allocates a new variable of type Self in the ConstraintSystem cs. The mode of allocation is decided by mode.
Source§

fn new_constant( cs: impl Into<Namespace<F>>, t: impl Borrow<V>, ) -> Result<Self, SynthesisError>

Allocates a new constant of type Self in the ConstraintSystem cs. Read more
Source§

fn new_input<T: Borrow<V>>( cs: impl Into<Namespace<F>>, f: impl FnOnce() -> Result<T, SynthesisError>, ) -> Result<Self, SynthesisError>

Allocates a new public input of type Self in the ConstraintSystem cs.
Source§

fn new_witness<T: Borrow<V>>( cs: impl Into<Namespace<F>>, f: impl FnOnce() -> Result<T, SynthesisError>, ) -> Result<Self, SynthesisError>

Allocates a new private witness of type Self in the ConstraintSystem cs.
Source§

fn new_variable_with_inferred_mode<T: Borrow<V>>( cs: impl Into<Namespace<F>>, f: impl FnOnce() -> Result<T, SynthesisError>, ) -> Result<Self, SynthesisError>

Allocates a new constant or private witness of type Self in the ConstraintSystem cs with the allocation mode inferred from cs. A constant is allocated if cs is None, and a private witness is allocated otherwise. Read more
Source§

impl<F: Clone + PrimeField> Clone for FpVar<F>

Source§

fn clone(&self) -> FpVar<F>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<F: PrimeField> CondSelectGadget<F> for FpVar<F>

Source§

fn conditionally_select( cond: &Boolean<F>, true_value: &Self, false_value: &Self, ) -> Result<Self, SynthesisError>

If cond == &Boolean::TRUE, then this returns true_value; else, returns false_value. Read more
Source§

fn conditionally_select_power_of_two_vector( position: &[Boolean<ConstraintF>], values: &[Self], ) -> Result<Self, SynthesisError>

Returns an element of values whose index in represented by position. position is an array of boolean that represents an unsigned integer in big endian order. Read more
Source§

impl<P: Fp3Config> CubicExtVarConfig<FpVar<<P as Fp3Config>::Fp>> for Fp3ConfigWrapper<P>

Source§

fn mul_base_field_vars_by_frob_coeff( c1: &mut FpVar<P::Fp>, c2: &mut FpVar<P::Fp>, power: usize, )

Multiply the base field of the CubicExtVar by the appropriate Frobenius coefficient. This is equivalent to Self::mul_base_field_by_frob_coeff(c1, c2, power).
Source§

impl<F: Debug + PrimeField> Debug for FpVar<F>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<F: PrimeField> EqGadget<F> for FpVar<F>



Source§

fn is_eq(&self, other: &Self) -> Result<Boolean<F>, SynthesisError>

Output a Boolean value representing whether self.value() == other.value().
Source§

fn conditional_enforce_equal( &self, other: &Self, should_enforce: &Boolean<F>, ) -> Result<(), SynthesisError>

If should_enforce == true, enforce that self and other are equal; else, enforce a vacuously true statement. Read more
Source§

fn conditional_enforce_not_equal( &self, other: &Self, should_enforce: &Boolean<F>, ) -> Result<(), SynthesisError>

If should_enforce == true, enforce that self and other are not equal; else, enforce a vacuously true statement. Read more
Source§

fn is_neq(&self, other: &Self) -> Result<Boolean<F>, SynthesisError>

Output a Boolean value representing whether self.value() != other.value(). Read more
Source§

fn enforce_equal(&self, other: &Self) -> Result<(), SynthesisError>

Enforce that self and other are equal. Read more
Source§

fn enforce_not_equal(&self, other: &Self) -> Result<(), SynthesisError>

Enforce that self and other are not equal. Read more
Source§

impl<F: PrimeField> FieldVar<F, F> for FpVar<F>

Source§

fn mul_equals(&self, other: &Self, result: &Self) -> Result<(), SynthesisError>

Enforce that self * other == result.

Source§

fn square_equals(&self, result: &Self) -> Result<(), SynthesisError>

Enforce that self * self == result.

Source§

fn constant(f: F) -> Self

Returns a constant with value v. Read more
Source§

fn zero() -> Self

Returns the constant F::zero().
Source§

fn one() -> Self

Returns the constant F::one().
Source§

fn double(&self) -> Result<Self, SynthesisError>

Computes self + self.
Source§

fn negate(&self) -> Result<Self, SynthesisError>

Coputes -self.
Source§

fn square(&self) -> Result<Self, SynthesisError>

Computes self * self. Read more
Source§

fn inverse(&self) -> Result<Self, SynthesisError>

Computes result such that self * result == Self::one().
Source§

fn frobenius_map(&self, power: usize) -> Result<Self, SynthesisError>

Computes the frobenius map over self.
Source§

fn frobenius_map_in_place( &mut self, power: usize, ) -> Result<&mut Self, SynthesisError>

Sets self = self.frobenius_map().
Source§

fn is_zero(&self) -> Result<Boolean<ConstraintF>, SynthesisError>

Returns a Boolean representing whether self == Self::zero().
Source§

fn is_one(&self) -> Result<Boolean<ConstraintF>, SynthesisError>

Returns a Boolean representing whether self == Self::one().
Source§

fn double_in_place(&mut self) -> Result<&mut Self, SynthesisError>

Sets self = self + self.
Source§

fn negate_in_place(&mut self) -> Result<&mut Self, SynthesisError>

Sets self = -self.
Source§

fn square_in_place(&mut self) -> Result<&mut Self, SynthesisError>

Sets self = self.square().
Source§

fn mul_by_inverse(&self, d: &Self) -> Result<Self, SynthesisError>

Returns (self / d). The constraint system will be unsatisfiable when d = 0.
Source§

fn mul_by_inverse_unchecked(&self, d: &Self) -> Result<Self, SynthesisError>

Returns (self / d). Read more
Source§

fn pow_le(&self, bits: &[Boolean<ConstraintF>]) -> Result<Self, SynthesisError>

Comptues self^bits, where bits is a little-endian bit-wise decomposition of the exponent.
Source§

fn pow_by_constant<S: AsRef<[u64]>>( &self, exp: S, ) -> Result<Self, SynthesisError>

Computes self^S, where S is interpreted as an little-endian u64-decomposition of an integer.
Source§

impl<F: PrimeField> From<AllocatedFp<F>> for FpVar<F>

Source§

fn from(other: AllocatedFp<F>) -> Self

Converts to this type from the input type.
Source§

impl<F: PrimeField> From<Boolean<F>> for FpVar<F>

Source§

fn from(other: Boolean<F>) -> Self

Converts to this type from the input type.
Source§

impl<'a, F: PrimeField> Mul<&'a FpVar<F>> for FpVar<F>

Source§

type Output = FpVar<F>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'a FpVar<F>) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a, F: PrimeField> Mul<F> for &'a FpVar<F>

Source§

type Output = FpVar<F>

The resulting type after applying the * operator.
Source§

fn mul(self, other: F) -> Self::Output

Performs the * operation. Read more
Source§

impl<F: PrimeField> Mul<F> for FpVar<F>

Source§

type Output = FpVar<F>

The resulting type after applying the * operator.
Source§

fn mul(self, other: F) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a, F: PrimeField> Mul<FpVar<F>> for &'a FpVar<F>

Source§

type Output = FpVar<F>

The resulting type after applying the * operator.
Source§

fn mul(self, other: FpVar<F>) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a, F: PrimeField> Mul for &'a FpVar<F>

Source§

type Output = FpVar<F>

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'a FpVar<F>) -> Self::Output

Performs the * operation. Read more
Source§

impl<F: PrimeField> Mul for FpVar<F>

Source§

type Output = FpVar<F>

The resulting type after applying the * operator.
Source§

fn mul(self, other: FpVar<F>) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a, F: PrimeField> MulAssign<&'a FpVar<F>> for FpVar<F>

Source§

fn mul_assign(&mut self, other: &'a FpVar<F>)

Performs the *= operation. Read more
Source§

impl<F: PrimeField> MulAssign<F> for FpVar<F>

Source§

fn mul_assign(&mut self, other: F)

Performs the *= operation. Read more
Source§

impl<F: PrimeField> MulAssign for FpVar<F>

Source§

fn mul_assign(&mut self, other: FpVar<F>)

Performs the *= operation. Read more
Source§

impl<P: Fp2Config> QuadExtVarConfig<FpVar<<P as Fp2Config>::Fp>> for Fp2ConfigWrapper<P>

Source§

fn mul_base_field_var_by_frob_coeff(fe: &mut FpVar<P::Fp>, power: usize)

Multiply the base field of the QuadExtVar by the appropriate Frobenius coefficient. This is equivalent to Self::mul_base_field_by_frob_coeff(power).
Source§

impl<'a, F: PrimeField> Sub<&'a FpVar<F>> for FpVar<F>

Source§

type Output = FpVar<F>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'a FpVar<F>) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a, F: PrimeField> Sub<F> for &'a FpVar<F>

Source§

type Output = FpVar<F>

The resulting type after applying the - operator.
Source§

fn sub(self, other: F) -> Self::Output

Performs the - operation. Read more
Source§

impl<F: PrimeField> Sub<F> for FpVar<F>

Source§

type Output = FpVar<F>

The resulting type after applying the - operator.
Source§

fn sub(self, other: F) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a, F: PrimeField> Sub<FpVar<F>> for &'a FpVar<F>

Source§

type Output = FpVar<F>

The resulting type after applying the - operator.
Source§

fn sub(self, other: FpVar<F>) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a, F: PrimeField> Sub for &'a FpVar<F>

Source§

type Output = FpVar<F>

The resulting type after applying the - operator.
Source§

fn sub(self, other: &'a FpVar<F>) -> Self::Output

Performs the - operation. Read more
Source§

impl<F: PrimeField> Sub for FpVar<F>

Source§

type Output = FpVar<F>

The resulting type after applying the - operator.
Source§

fn sub(self, other: FpVar<F>) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a, F: PrimeField> SubAssign<&'a FpVar<F>> for FpVar<F>

Source§

fn sub_assign(&mut self, other: &'a FpVar<F>)

Performs the -= operation. Read more
Source§

impl<F: PrimeField> SubAssign<F> for FpVar<F>

Source§

fn sub_assign(&mut self, other: F)

Performs the -= operation. Read more
Source§

impl<F: PrimeField> SubAssign for FpVar<F>

Source§

fn sub_assign(&mut self, other: FpVar<F>)

Performs the -= operation. Read more
Source§

impl<'a, F: PrimeField> Sum<&'a FpVar<F>> for FpVar<F>

Source§

fn sum<I: Iterator<Item = &'a FpVar<F>>>(iter: I) -> FpVar<F>

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl<'a, F: PrimeField> Sum for FpVar<F>

Source§

fn sum<I: Iterator<Item = FpVar<F>>>(iter: I) -> FpVar<F>

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl<F: PrimeField> ThreeBitCondNegLookupGadget<F> for FpVar<F>

Source§

type TableConstant = F

The type of values being looked up.
Source§

fn three_bit_cond_neg_lookup( b: &[Boolean<F>], b0b1: &Boolean<F>, c: &[Self::TableConstant], ) -> Result<Self, SynthesisError>

Interprets the slice bits as a two-bit integer b = bits[0] + (bits[1] << 1), and then outputs constants[b] * c, where c = if bits[2] { -1 } else { 1 };. Read more
Source§

impl<F: PrimeField> ToBitsGadget<F> for FpVar<F>

Source§

fn to_bits_le(&self) -> Result<Vec<Boolean<F>>, SynthesisError>

Outputs the canonical little-endian bit-wise representation of self. Read more
Source§

fn to_non_unique_bits_le(&self) -> Result<Vec<Boolean<F>>, SynthesisError>

Outputs a possibly non-unique little-endian bit-wise representation of self. Read more
Source§

fn to_bits_be(&self) -> Result<Vec<Boolean<F>>, SynthesisError>

Outputs the canonical big-endian bit-wise representation of self.
Source§

fn to_non_unique_bits_be(&self) -> Result<Vec<Boolean<F>>, SynthesisError>

Outputs a possibly non-unique big-endian bit-wise representation of self.
Source§

impl<F: PrimeField> ToBytesGadget<F> for FpVar<F>

Source§

fn to_bytes_le(&self) -> Result<Vec<UInt8<F>>, SynthesisError>

Outputs the unique byte decomposition of self in little-endian form.

Source§

fn to_non_unique_bytes_le(&self) -> Result<Vec<UInt8<F>>, SynthesisError>

Outputs a possibly non-unique byte decomposition of self. Read more
Source§

impl<F: PrimeField> ToConstraintFieldGadget<F> for FpVar<F>

Source§

fn to_constraint_field(&self) -> Result<Vec<FpVar<F>>, SynthesisError>

Converts self to FpVar<ConstraintF> variables.
Source§

impl<F: PrimeField> TwoBitLookupGadget<F> for FpVar<F>

Uses two bits to perform a lookup into a table b is little-endian: b[0] is LSB.

Source§

type TableConstant = F

The type of values being looked up.
Source§

fn two_bit_lookup( b: &[Boolean<F>], c: &[Self::TableConstant], ) -> Result<Self, SynthesisError>

Interprets the slice bits as a two-bit integer b = bits[0] + (bits[1] << 1), and then outputs constants[b]. Read more
Source§

impl<'a, F: PrimeField> FieldOpsBounds<'a, F, FpVar<F>> for &'a FpVar<F>

Source§

impl<'a, F: PrimeField> FieldOpsBounds<'a, F, FpVar<F>> for FpVar<F>

Auto Trait Implementations§

§

impl<F> Freeze for FpVar<F>
where F: Freeze,

§

impl<F> !RefUnwindSafe for FpVar<F>

§

impl<F> !Send for FpVar<F>

§

impl<F> !Sync for FpVar<F>

§

impl<F> Unpin for FpVar<F>
where F: Unpin,

§

impl<F> !UnwindSafe for FpVar<F>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more