pub trait FieldVar<F: Field, ConstraintF: PrimeField>:
'static
+ Clone
+ From<Boolean<ConstraintF>>
+ R1CSVar<ConstraintF, Value = F>
+ EqGadget<ConstraintF>
+ ToBitsGadget<ConstraintF>
+ AllocVar<F, ConstraintF>
+ ToBytesGadget<ConstraintF>
+ CondSelectGadget<ConstraintF>
+ ToConstraintFieldGadget<ConstraintF>
+ for<'a> FieldOpsBounds<'a, F, Self>
+ for<'a> AddAssign<&'a Self>
+ for<'a> SubAssign<&'a Self>
+ for<'a> MulAssign<&'a Self>
+ AddAssign<Self>
+ SubAssign<Self>
+ MulAssign<Self>
+ AddAssign<F>
+ SubAssign<F>
+ MulAssign<F>
+ Debug {
Show 20 methods
// Required methods
fn zero() -> Self;
fn one() -> Self;
fn constant(v: F) -> Self;
fn negate(&self) -> Result<Self, SynthesisError>;
fn inverse(&self) -> Result<Self, SynthesisError>;
fn frobenius_map(&self, power: usize) -> Result<Self, SynthesisError>;
// Provided methods
fn is_zero(&self) -> Result<Boolean<ConstraintF>, SynthesisError> { ... }
fn is_one(&self) -> Result<Boolean<ConstraintF>, SynthesisError> { ... }
fn double(&self) -> Result<Self, SynthesisError> { ... }
fn double_in_place(&mut self) -> Result<&mut Self, SynthesisError> { ... }
fn negate_in_place(&mut self) -> Result<&mut Self, SynthesisError> { ... }
fn square(&self) -> Result<Self, SynthesisError> { ... }
fn square_in_place(&mut self) -> Result<&mut Self, SynthesisError> { ... }
fn mul_equals(
&self,
other: &Self,
result: &Self,
) -> Result<(), SynthesisError> { ... }
fn square_equals(&self, result: &Self) -> Result<(), SynthesisError> { ... }
fn mul_by_inverse(&self, d: &Self) -> Result<Self, SynthesisError> { ... }
fn mul_by_inverse_unchecked(&self, d: &Self) -> Result<Self, SynthesisError> { ... }
fn frobenius_map_in_place(
&mut self,
power: usize,
) -> Result<&mut Self, SynthesisError> { ... }
fn pow_le(
&self,
bits: &[Boolean<ConstraintF>],
) -> Result<Self, SynthesisError> { ... }
fn pow_by_constant<S: AsRef<[u64]>>(
&self,
exp: S,
) -> Result<Self, SynthesisError> { ... }
}
Expand description
A variable representing a field. Corresponds to the native type F
.
Required Methods§
Sourcefn constant(v: F) -> Self
fn constant(v: F) -> Self
Returns a constant with value v
.
This should not allocate any variables.
Sourcefn negate(&self) -> Result<Self, SynthesisError>
fn negate(&self) -> Result<Self, SynthesisError>
Coputes -self
.
Sourcefn inverse(&self) -> Result<Self, SynthesisError>
fn inverse(&self) -> Result<Self, SynthesisError>
Computes result
such that self * result == Self::one()
.
Sourcefn frobenius_map(&self, power: usize) -> Result<Self, SynthesisError>
fn frobenius_map(&self, power: usize) -> Result<Self, SynthesisError>
Computes the frobenius map over self
.
Provided Methods§
Sourcefn is_zero(&self) -> Result<Boolean<ConstraintF>, SynthesisError>
fn is_zero(&self) -> Result<Boolean<ConstraintF>, SynthesisError>
Returns a Boolean
representing whether self == Self::zero()
.
Sourcefn is_one(&self) -> Result<Boolean<ConstraintF>, SynthesisError>
fn is_one(&self) -> Result<Boolean<ConstraintF>, SynthesisError>
Returns a Boolean
representing whether self == Self::one()
.
Sourcefn double(&self) -> Result<Self, SynthesisError>
fn double(&self) -> Result<Self, SynthesisError>
Computes self + self
.
Sourcefn double_in_place(&mut self) -> Result<&mut Self, SynthesisError>
fn double_in_place(&mut self) -> Result<&mut Self, SynthesisError>
Sets self = self + self
.
Sourcefn negate_in_place(&mut self) -> Result<&mut Self, SynthesisError>
fn negate_in_place(&mut self) -> Result<&mut Self, SynthesisError>
Sets self = -self
.
Sourcefn square(&self) -> Result<Self, SynthesisError>
fn square(&self) -> Result<Self, SynthesisError>
Computes self * self
.
A default implementation is provided which just invokes the underlying multiplication routine. However, this method should be specialized for extension fields, where faster algorithms exist for squaring.
Sourcefn square_in_place(&mut self) -> Result<&mut Self, SynthesisError>
fn square_in_place(&mut self) -> Result<&mut Self, SynthesisError>
Sets self = self.square()
.
Sourcefn mul_equals(&self, other: &Self, result: &Self) -> Result<(), SynthesisError>
fn mul_equals(&self, other: &Self, result: &Self) -> Result<(), SynthesisError>
Enforces that self * other == result
.
Sourcefn square_equals(&self, result: &Self) -> Result<(), SynthesisError>
fn square_equals(&self, result: &Self) -> Result<(), SynthesisError>
Enforces that self * self == result
.
Sourcefn mul_by_inverse(&self, d: &Self) -> Result<Self, SynthesisError>
fn mul_by_inverse(&self, d: &Self) -> Result<Self, SynthesisError>
Returns (self / d)
.
The constraint system will be unsatisfiable when d = 0
.
Sourcefn mul_by_inverse_unchecked(&self, d: &Self) -> Result<Self, SynthesisError>
fn mul_by_inverse_unchecked(&self, d: &Self) -> Result<Self, SynthesisError>
Returns (self / d)
.
The precondition for this method is that d != 0
. If d == 0
, this
method offers no guarantees about the soundness of the resulting
constraint system. For example, if self == d == 0
, the current
implementation allows the constraint system to be trivially satisfiable.
Sourcefn 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>
Sets self = self.frobenius_map()
.
Sourcefn pow_le(&self, bits: &[Boolean<ConstraintF>]) -> Result<Self, SynthesisError>
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.
Sourcefn 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>
Computes self^S
, where S is interpreted as an little-endian
u64-decomposition of an integer.
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.