Enum ark_r1cs_std::fields::fp::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>
impl<F: PrimeField> FpVar<F>
sourcepub fn enforce_cmp(
&self,
other: &FpVar<F>,
ordering: Ordering,
should_also_check_equality: bool
) -> Result<(), SynthesisError>
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
.
sourcepub fn enforce_cmp_unchecked(
&self,
other: &FpVar<F>,
ordering: Ordering,
should_also_check_equality: bool
) -> Result<(), SynthesisError>
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.
sourcepub fn is_cmp(
&self,
other: &FpVar<F>,
ordering: Ordering,
should_also_check_equality: bool
) -> Result<Boolean<F>, SynthesisError>
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
.
sourcepub fn is_cmp_unchecked(
&self,
other: &FpVar<F>,
ordering: Ordering,
should_also_check_equality: bool
) -> Result<Boolean<F>, SynthesisError>
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.
sourcepub fn enforce_smaller_or_equal_than_mod_minus_one_div_two(
&self
) -> Result<(), SynthesisError>
pub fn enforce_smaller_or_equal_than_mod_minus_one_div_two(
&self
) -> Result<(), SynthesisError>
Helper function to enforce that self <= (p-1)/2
.
Trait Implementations§
source§impl<'a, F: PrimeField> Add<F> for &'a FpVar<F>
impl<'a, F: PrimeField> Add<F> for &'a FpVar<F>
source§impl<F: PrimeField> Add<F> for FpVar<F>
impl<F: PrimeField> Add<F> for FpVar<F>
source§impl<'a, F: PrimeField> AddAssign<&'a FpVar<F>> for FpVar<F>
impl<'a, F: PrimeField> AddAssign<&'a FpVar<F>> for FpVar<F>
source§fn add_assign(&mut self, other: &'a FpVar<F>)
fn add_assign(&mut self, other: &'a FpVar<F>)
+=
operation. Read moresource§impl<F: PrimeField> AddAssign<F> for FpVar<F>
impl<F: PrimeField> AddAssign<F> for FpVar<F>
source§fn add_assign(&mut self, other: F)
fn add_assign(&mut self, other: F)
+=
operation. Read moresource§impl<F: PrimeField> AddAssign<FpVar<F>> for FpVar<F>
impl<F: PrimeField> AddAssign<FpVar<F>> for FpVar<F>
source§fn add_assign(&mut self, other: FpVar<F>)
fn add_assign(&mut self, other: FpVar<F>)
+=
operation. Read moresource§impl<F: PrimeField> AllocVar<F, F> for FpVar<F>
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>
fn new_variable<T: Borrow<F>>(
cs: impl Into<Namespace<F>>,
f: impl FnOnce() -> Result<T, SynthesisError>,
mode: AllocationMode
) -> Result<Self, SynthesisError>
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>
fn new_constant(
cs: impl Into<Namespace<F>>,
t: impl Borrow<V>
) -> Result<Self, SynthesisError>
source§fn new_input<T: Borrow<V>>(
cs: impl Into<Namespace<F>>,
f: impl FnOnce() -> Result<T, SynthesisError>
) -> Result<Self, SynthesisError>
fn new_input<T: Borrow<V>>(
cs: impl Into<Namespace<F>>,
f: impl FnOnce() -> Result<T, SynthesisError>
) -> Result<Self, SynthesisError>
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>
fn new_witness<T: Borrow<V>>(
cs: impl Into<Namespace<F>>,
f: impl FnOnce() -> Result<T, SynthesisError>
) -> Result<Self, SynthesisError>
Self
in the ConstraintSystem
cs
.source§impl<F: PrimeField> CondSelectGadget<F> for FpVar<F>
impl<F: PrimeField> CondSelectGadget<F> for FpVar<F>
source§fn conditionally_select(
cond: &Boolean<F>,
true_value: &Self,
false_value: &Self
) -> Result<Self, SynthesisError>
fn conditionally_select(
cond: &Boolean<F>,
true_value: &Self,
false_value: &Self
) -> Result<Self, SynthesisError>
source§fn conditionally_select_power_of_two_vector(
position: &[Boolean<ConstraintF>],
values: &[Self]
) -> Result<Self, SynthesisError>
fn conditionally_select_power_of_two_vector(
position: &[Boolean<ConstraintF>],
values: &[Self]
) -> Result<Self, SynthesisError>
values
whose index in represented by position
.
position
is an array of boolean that represents an unsigned integer in
big endian order. Read moresource§impl<P: Fp3Config> CubicExtVarConfig<FpVar<<P as Fp3Config>::Fp>> for Fp3ConfigWrapper<P>
impl<P: Fp3Config> CubicExtVarConfig<FpVar<<P as Fp3Config>::Fp>> for Fp3ConfigWrapper<P>
source§impl<F: PrimeField> EqGadget<F> for FpVar<F>
impl<F: PrimeField> EqGadget<F> for FpVar<F>
source§fn is_eq(&self, other: &Self) -> Result<Boolean<F>, SynthesisError>
fn is_eq(&self, other: &Self) -> Result<Boolean<F>, SynthesisError>
Boolean
value representing whether self.value() == other.value()
.source§fn conditional_enforce_equal(
&self,
other: &Self,
should_enforce: &Boolean<F>
) -> Result<(), SynthesisError>
fn conditional_enforce_equal(
&self,
other: &Self,
should_enforce: &Boolean<F>
) -> Result<(), SynthesisError>
should_enforce == true
, enforce that self
and other
are equal;
else, enforce a vacuously true statement. Read moresource§fn conditional_enforce_not_equal(
&self,
other: &Self,
should_enforce: &Boolean<F>
) -> Result<(), SynthesisError>
fn conditional_enforce_not_equal(
&self,
other: &Self,
should_enforce: &Boolean<F>
) -> Result<(), SynthesisError>
should_enforce == true
, enforce that self
and other
are not
equal; else, enforce a vacuously true statement. Read moresource§fn enforce_equal(&self, other: &Self) -> Result<(), SynthesisError>
fn enforce_equal(&self, other: &Self) -> Result<(), SynthesisError>
source§fn enforce_not_equal(&self, other: &Self) -> Result<(), SynthesisError>
fn enforce_not_equal(&self, other: &Self) -> Result<(), SynthesisError>
source§impl<F: PrimeField> FieldVar<F, F> for FpVar<F>
impl<F: PrimeField> FieldVar<F, F> for FpVar<F>
source§fn mul_equals(&self, other: &Self, result: &Self) -> Result<(), SynthesisError>
fn mul_equals(&self, other: &Self, result: &Self) -> Result<(), SynthesisError>
Enforce that self * other == result
.
source§fn square_equals(&self, result: &Self) -> Result<(), SynthesisError>
fn square_equals(&self, result: &Self) -> Result<(), SynthesisError>
Enforce that self * self == result
.
source§fn double(&self) -> Result<Self, SynthesisError>
fn double(&self) -> Result<Self, SynthesisError>
self + self
.source§fn negate(&self) -> Result<Self, SynthesisError>
fn negate(&self) -> Result<Self, SynthesisError>
-self
.source§fn inverse(&self) -> Result<Self, SynthesisError>
fn inverse(&self) -> Result<Self, SynthesisError>
result
such that self * result == Self::one()
.source§fn frobenius_map(&self, power: usize) -> Result<Self, SynthesisError>
fn frobenius_map(&self, power: usize) -> Result<Self, SynthesisError>
self
.source§fn frobenius_map_in_place(
&mut self,
power: usize
) -> Result<&mut Self, SynthesisError>
fn frobenius_map_in_place(
&mut self,
power: usize
) -> Result<&mut Self, SynthesisError>
self = self.frobenius_map()
.source§fn is_zero(&self) -> Result<Boolean<ConstraintF>, SynthesisError>
fn is_zero(&self) -> Result<Boolean<ConstraintF>, SynthesisError>
Boolean
representing whether self == Self::zero()
.source§fn is_one(&self) -> Result<Boolean<ConstraintF>, SynthesisError>
fn is_one(&self) -> Result<Boolean<ConstraintF>, SynthesisError>
Boolean
representing whether self == Self::one()
.source§fn double_in_place(&mut self) -> Result<&mut Self, SynthesisError>
fn double_in_place(&mut self) -> Result<&mut Self, SynthesisError>
self = self + self
.source§fn negate_in_place(&mut self) -> Result<&mut Self, SynthesisError>
fn negate_in_place(&mut self) -> Result<&mut Self, SynthesisError>
self = -self
.source§fn square_in_place(&mut self) -> Result<&mut Self, SynthesisError>
fn square_in_place(&mut self) -> Result<&mut Self, SynthesisError>
self = self.square()
.source§fn mul_by_inverse(&self, d: &Self) -> Result<Self, SynthesisError>
fn mul_by_inverse(&self, d: &Self) -> Result<Self, SynthesisError>
(self / d)
.
The constraint system will be unsatisfiable when d = 0
.source§fn mul_by_inverse_unchecked(&self, d: &Self) -> Result<Self, SynthesisError>
fn mul_by_inverse_unchecked(&self, d: &Self) -> Result<Self, SynthesisError>
(self / d)
. Read moresource§fn pow_le(&self, bits: &[Boolean<ConstraintF>]) -> Result<Self, SynthesisError>
fn pow_le(&self, bits: &[Boolean<ConstraintF>]) -> Result<Self, SynthesisError>
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>
fn pow_by_constant<S: AsRef<[u64]>>(
&self,
exp: S
) -> Result<Self, SynthesisError>
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>
impl<F: PrimeField> From<AllocatedFp<F>> for FpVar<F>
source§fn from(other: AllocatedFp<F>) -> Self
fn from(other: AllocatedFp<F>) -> Self
source§impl<'a, F: PrimeField> Mul<F> for &'a FpVar<F>
impl<'a, F: PrimeField> Mul<F> for &'a FpVar<F>
source§impl<F: PrimeField> Mul<F> for FpVar<F>
impl<F: PrimeField> Mul<F> for FpVar<F>
source§impl<'a, F: PrimeField> MulAssign<&'a FpVar<F>> for FpVar<F>
impl<'a, F: PrimeField> MulAssign<&'a FpVar<F>> for FpVar<F>
source§fn mul_assign(&mut self, other: &'a FpVar<F>)
fn mul_assign(&mut self, other: &'a FpVar<F>)
*=
operation. Read moresource§impl<F: PrimeField> MulAssign<F> for FpVar<F>
impl<F: PrimeField> MulAssign<F> for FpVar<F>
source§fn mul_assign(&mut self, other: F)
fn mul_assign(&mut self, other: F)
*=
operation. Read moresource§impl<F: PrimeField> MulAssign<FpVar<F>> for FpVar<F>
impl<F: PrimeField> MulAssign<FpVar<F>> for FpVar<F>
source§fn mul_assign(&mut self, other: FpVar<F>)
fn mul_assign(&mut self, other: FpVar<F>)
*=
operation. Read moresource§impl<P: Fp2Config> QuadExtVarConfig<FpVar<<P as Fp2Config>::Fp>> for Fp2ConfigWrapper<P>
impl<P: Fp2Config> QuadExtVarConfig<FpVar<<P as Fp2Config>::Fp>> for Fp2ConfigWrapper<P>
source§impl<F: PrimeField> R1CSVar<F> for FpVar<F>
impl<F: PrimeField> R1CSVar<F> for FpVar<F>
source§fn cs(&self) -> ConstraintSystemRef<F>
fn cs(&self) -> ConstraintSystemRef<F>
ConstraintSystemRef
. Read moresource§fn value(&self) -> Result<Self::Value, SynthesisError>
fn value(&self) -> Result<Self::Value, SynthesisError>
self
in the underlying
ConstraintSystem
.source§fn is_constant(&self) -> bool
fn is_constant(&self) -> bool
true
if self
is a circuit-generation-time constant.source§impl<'a, F: PrimeField> Sub<F> for &'a FpVar<F>
impl<'a, F: PrimeField> Sub<F> for &'a FpVar<F>
source§impl<F: PrimeField> Sub<F> for FpVar<F>
impl<F: PrimeField> Sub<F> for FpVar<F>
source§impl<'a, F: PrimeField> SubAssign<&'a FpVar<F>> for FpVar<F>
impl<'a, F: PrimeField> SubAssign<&'a FpVar<F>> for FpVar<F>
source§fn sub_assign(&mut self, other: &'a FpVar<F>)
fn sub_assign(&mut self, other: &'a FpVar<F>)
-=
operation. Read moresource§impl<F: PrimeField> SubAssign<F> for FpVar<F>
impl<F: PrimeField> SubAssign<F> for FpVar<F>
source§fn sub_assign(&mut self, other: F)
fn sub_assign(&mut self, other: F)
-=
operation. Read moresource§impl<F: PrimeField> SubAssign<FpVar<F>> for FpVar<F>
impl<F: PrimeField> SubAssign<FpVar<F>> for FpVar<F>
source§fn sub_assign(&mut self, other: FpVar<F>)
fn sub_assign(&mut self, other: FpVar<F>)
-=
operation. Read moresource§impl<F: PrimeField> ThreeBitCondNegLookupGadget<F> for FpVar<F>
impl<F: PrimeField> ThreeBitCondNegLookupGadget<F> for FpVar<F>
§type TableConstant = F
type TableConstant = F
source§fn three_bit_cond_neg_lookup(
b: &[Boolean<F>],
b0b1: &Boolean<F>,
c: &[Self::TableConstant]
) -> Result<Self, SynthesisError>
fn three_bit_cond_neg_lookup(
b: &[Boolean<F>],
b0b1: &Boolean<F>,
c: &[Self::TableConstant]
) -> Result<Self, SynthesisError>
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 moresource§impl<F: PrimeField> ToBitsGadget<F> for FpVar<F>
impl<F: PrimeField> ToBitsGadget<F> for FpVar<F>
source§fn to_bits_le(&self) -> Result<Vec<Boolean<F>>, SynthesisError>
fn to_bits_le(&self) -> Result<Vec<Boolean<F>>, SynthesisError>
self
. Read moresource§fn to_non_unique_bits_le(&self) -> Result<Vec<Boolean<F>>, SynthesisError>
fn to_non_unique_bits_le(&self) -> Result<Vec<Boolean<F>>, SynthesisError>
self
. Read moresource§fn to_bits_be(&self) -> Result<Vec<Boolean<F>>, SynthesisError>
fn to_bits_be(&self) -> Result<Vec<Boolean<F>>, SynthesisError>
self
.source§fn to_non_unique_bits_be(&self) -> Result<Vec<Boolean<F>>, SynthesisError>
fn to_non_unique_bits_be(&self) -> Result<Vec<Boolean<F>>, SynthesisError>
self
.source§impl<F: PrimeField> ToBytesGadget<F> for FpVar<F>
impl<F: PrimeField> ToBytesGadget<F> for FpVar<F>
source§fn to_bytes(&self) -> Result<Vec<UInt8<F>>, SynthesisError>
fn to_bytes(&self) -> Result<Vec<UInt8<F>>, SynthesisError>
Outputs the unique byte decomposition of self
in little-endian
form.
source§fn to_non_unique_bytes(&self) -> Result<Vec<UInt8<F>>, SynthesisError>
fn to_non_unique_bytes(&self) -> Result<Vec<UInt8<F>>, SynthesisError>
self
. Read moresource§impl<F: PrimeField> ToConstraintFieldGadget<F> for FpVar<F>
impl<F: PrimeField> ToConstraintFieldGadget<F> for FpVar<F>
source§fn to_constraint_field(&self) -> Result<Vec<FpVar<F>>, SynthesisError>
fn to_constraint_field(&self) -> Result<Vec<FpVar<F>>, SynthesisError>
self
to FpVar<ConstraintF>
variables.source§impl<F: PrimeField> TwoBitLookupGadget<F> for FpVar<F>
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.
§type TableConstant = F
type TableConstant = F
source§fn two_bit_lookup(
b: &[Boolean<F>],
c: &[Self::TableConstant]
) -> Result<Self, SynthesisError>
fn two_bit_lookup(
b: &[Boolean<F>],
c: &[Self::TableConstant]
) -> Result<Self, SynthesisError>
bits
as a two-bit integer b = bits[0] + (bits[1] << 1)
, and then outputs constants[b]
. Read more