pub enum FpGadget<F: PrimeField> {
Constant(F),
Variable(AllocatedFp<F>),
}
Expand description
Represent variables corresponding to a field element in F
.
Variants
Constant(F)
Constant (not an allocated variable).
Variable(AllocatedFp<F>)
Allocated variable in the constraint system.
Implementations
sourceimpl<F: PrimeField> FpGadget<F>
impl<F: PrimeField> FpGadget<F>
sourcepub fn from_boolean<CS: ConstraintSystem<F>>(
cs: CS,
other: Boolean
) -> Result<Self, SynthesisError>
pub fn from_boolean<CS: ConstraintSystem<F>>(
cs: CS,
other: Boolean
) -> Result<Self, SynthesisError>
Constructs Self
from a Boolean
: if other
is false, this outputs
zero
, else it outputs one
.
Trait Implementations
sourceimpl<F: PrimeField> AllocGadget<F, F> for FpGadget<F>
impl<F: PrimeField> AllocGadget<F, F> for FpGadget<F>
fn alloc_constant<FN, T, CS: ConstraintSystem<F>>(
cs: CS,
value_gen: FN
) -> Result<Self, SynthesisError> where
FN: FnOnce() -> Result<T, SynthesisError>,
T: Borrow<F>,
fn alloc<FN, T, CS: ConstraintSystem<F>>(
cs: CS,
value_gen: FN
) -> Result<Self, SynthesisError> where
FN: FnOnce() -> Result<T, SynthesisError>,
T: Borrow<F>,
fn alloc_input<FN, T, CS: ConstraintSystem<F>>(
cs: CS,
value_gen: FN
) -> Result<Self, SynthesisError> where
FN: FnOnce() -> Result<T, SynthesisError>,
T: Borrow<F>,
fn alloc_checked<Fn: FnOnce() -> Result<T, SynthesisError>, T: Borrow<V>, CS: ConstraintSystem<F>>(
cs: CS,
f: Fn
) -> Result<Self, SynthesisError>
fn alloc_input_checked<Fn: FnOnce() -> Result<T, SynthesisError>, T: Borrow<V>, CS: ConstraintSystem<F>>(
cs: CS,
f: Fn
) -> Result<Self, SynthesisError>
sourceimpl<F: Clone + PrimeField> Clone for FpGadget<F>
impl<F: Clone + PrimeField> Clone for FpGadget<F>
sourceimpl<F: PrimeField> CondSelectGadget<F> for FpGadget<F>
impl<F: PrimeField> CondSelectGadget<F> for FpGadget<F>
sourcefn conditionally_select<CS: ConstraintSystem<F>>(
cs: CS,
cond: &Boolean,
first: &Self,
second: &Self
) -> Result<Self, SynthesisError>
fn conditionally_select<CS: ConstraintSystem<F>>(
cs: CS,
cond: &Boolean,
first: &Self,
second: &Self
) -> Result<Self, SynthesisError>
Conditionally selects one of first
and second
based on the value of
self
:
If cond
is true
, this outputs first
; else, it outputs second
.
fn cost() -> usize
sourceimpl<F: PrimeField> ConditionalEqGadget<F> for FpGadget<F>
impl<F: PrimeField> ConditionalEqGadget<F> for FpGadget<F>
fn conditional_enforce_equal<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &Self,
condition: &Boolean
) -> Result<(), SynthesisError>
fn cost() -> usize
sourceimpl<F: Debug + PrimeField> Debug for FpGadget<F>
impl<F: Debug + PrimeField> Debug for FpGadget<F>
sourceimpl<F: PrimeField> EqGadget<F> for FpGadget<F>
impl<F: PrimeField> EqGadget<F> for FpGadget<F>
sourcefn is_eq<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &Self
) -> Result<Boolean, SynthesisError>
fn is_eq<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &Self
) -> Result<Boolean, SynthesisError>
Output a Boolean
value representing whether self.value() == other.value()
. Read more
fn enforce_equal<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &Self
) -> Result<(), SynthesisError>
fn cost() -> usize
sourceimpl<F: PrimeField> FieldGadget<F, F> for FpGadget<F>
impl<F: PrimeField> FieldGadget<F, F> for FpGadget<F>
type Variable = ConstraintVariable<F>
fn get_value(&self) -> Option<F>
fn get_variable(&self) -> <Self as FieldGadget<F, F>>::Variable
fn zero<CS: ConstraintSystem<F>>(_cs: CS) -> Result<Self, SynthesisError>
fn one<CS: ConstraintSystem<F>>(_cs: CS) -> Result<Self, SynthesisError>
fn conditionally_add_constant<CS: ConstraintSystem<F>>(
&self,
_cs: CS,
bit: &Boolean,
coeff: F
) -> Result<Self, SynthesisError>
fn add<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &Self
) -> Result<Self, SynthesisError>
fn double<CS: ConstraintSystem<F>>(
&self,
_cs: CS
) -> Result<Self, SynthesisError>
fn double_in_place<CS: ConstraintSystem<F>>(
&mut self,
_cs: CS
) -> Result<&mut Self, SynthesisError>
fn sub<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &Self
) -> Result<Self, SynthesisError>
fn negate<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Self, SynthesisError>
fn negate_in_place<CS: ConstraintSystem<F>>(
&mut self,
_cs: CS
) -> Result<&mut Self, SynthesisError>
fn mul<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &Self
) -> Result<Self, SynthesisError>
fn add_constant<CS: ConstraintSystem<F>>(
&self,
_cs: CS,
other: &F
) -> Result<Self, SynthesisError>
fn add_constant_in_place<CS: ConstraintSystem<F>>(
&mut self,
_cs: CS,
other: &F
) -> Result<&mut Self, SynthesisError>
fn mul_by_constant<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &F
) -> Result<Self, SynthesisError>
fn mul_by_constant_in_place<CS: ConstraintSystem<F>>(
&mut self,
_cs: CS,
other: &F
) -> Result<&mut Self, SynthesisError>
fn inverse<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Self, SynthesisError>
fn frobenius_map<CS: ConstraintSystem<F>>(
&self,
_cs: CS,
_power: usize
) -> Result<Self, SynthesisError>
fn frobenius_map_in_place<CS: ConstraintSystem<F>>(
&mut self,
_cs: CS,
_power: usize
) -> Result<&mut Self, SynthesisError>
fn mul_equals<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &Self,
result: &Self
) -> Result<(), SynthesisError>
fn square_equals<CS: ConstraintSystem<F>>(
&self,
cs: CS,
result: &Self
) -> Result<(), SynthesisError>
fn cost_of_mul() -> usize
fn cost_of_inv() -> usize
fn add_in_place<CS: ConstraintSystem<F>>(
&mut self,
cs: CS,
other: &Self
) -> Result<&mut Self, SynthesisError>
fn sub_in_place<CS: ConstraintSystem<F>>(
&mut self,
cs: CS,
other: &Self
) -> Result<&mut Self, SynthesisError>
fn mul_in_place<CS: ConstraintSystem<F>>(
&mut self,
cs: CS,
other: &Self
) -> Result<&mut Self, SynthesisError>
fn square<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Self, SynthesisError>
fn square_in_place<CS: ConstraintSystem<F>>(
&mut self,
cs: CS
) -> Result<&mut Self, SynthesisError>
fn sub_constant<CS: ConstraintSystem<F>>(
&self,
cs: CS,
fe: &NativeF
) -> Result<Self, SynthesisError>
fn sub_constant_in_place<CS: ConstraintSystem<F>>(
&mut self,
cs: CS,
other: &NativeF
) -> Result<&mut Self, SynthesisError>
sourcefn pow<CS: ConstraintSystem<F>>(
&self,
cs: CS,
bits: &[Boolean]
) -> Result<Self, SynthesisError>
fn pow<CS: ConstraintSystem<F>>(
&self,
cs: CS,
bits: &[Boolean]
) -> Result<Self, SynthesisError>
Accepts as input a list of bits which, when interpreted in big-endian form, are a scalar. Read more
sourcefn pow_by_constant<CS: ConstraintSystem<F>, S: AsRef<[u64]>>(
&self,
cs: CS,
exp: S
) -> Result<Self, SynthesisError>
fn pow_by_constant<CS: ConstraintSystem<F>, S: AsRef<[u64]>>(
&self,
cs: CS,
exp: S
) -> Result<Self, SynthesisError>
Computes self^S
, where S is interpreted as an little-endian
u64-decomposition of an integer. Read more
sourceimpl<F: PrimeField> From<AllocatedFp<F>> for FpGadget<F>
impl<F: PrimeField> From<AllocatedFp<F>> for FpGadget<F>
sourcefn from(other: AllocatedFp<F>) -> Self
fn from(other: AllocatedFp<F>) -> Self
Performs the conversion.
sourceimpl<F: PrimeField> NEqGadget<F> for FpGadget<F>
impl<F: PrimeField> NEqGadget<F> for FpGadget<F>
fn enforce_not_equal<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &Self
) -> Result<(), SynthesisError>
fn cost() -> usize
sourceimpl<F: PrimeField> PartialEq<FpGadget<F>> for FpGadget<F>
impl<F: PrimeField> PartialEq<FpGadget<F>> for FpGadget<F>
sourceimpl<F: PrimeField> ThreeBitCondNegLookupGadget<F> for FpGadget<F>
impl<F: PrimeField> ThreeBitCondNegLookupGadget<F> for FpGadget<F>
type TableConstant = F
fn three_bit_cond_neg_lookup<CS: ConstraintSystem<F>>(
cs: CS,
b: &[Boolean],
b0b1: &Boolean,
c: &[Self::TableConstant]
) -> Result<Self, SynthesisError>
fn cost() -> usize
sourceimpl<F: PrimeField> ToBitsBEGadget<F> for FpGadget<F>
impl<F: PrimeField> ToBitsBEGadget<F> for FpGadget<F>
sourcefn to_bits_be<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Vec<Boolean>, SynthesisError>
fn to_bits_be<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Vec<Boolean>, SynthesisError>
Outputs the binary representation of the value in self
in big-endian
form.
sourcefn to_bits_be_strict<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Vec<Boolean>, SynthesisError>
fn to_bits_be_strict<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Vec<Boolean>, SynthesisError>
Additionally checks if the produced list of booleans is ‘valid’.
sourceimpl<F: PrimeField> ToBitsLEGadget<F> for FpGadget<F>
impl<F: PrimeField> ToBitsLEGadget<F> for FpGadget<F>
sourcefn to_bits_le<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Vec<Boolean>, SynthesisError>
fn to_bits_le<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Vec<Boolean>, SynthesisError>
Outputs the binary representation of the value in self
in little-endian
form.
sourcefn to_bits_le_strict<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Vec<Boolean>, SynthesisError>
fn to_bits_le_strict<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Vec<Boolean>, SynthesisError>
Additionally checks if the produced list of booleans is ‘valid’.
sourceimpl<F: PrimeField> ToBytesGadget<F> for FpGadget<F>
impl<F: PrimeField> ToBytesGadget<F> for FpGadget<F>
fn to_bytes<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Vec<UInt8>, SynthesisError>
sourcefn to_bytes_strict<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Vec<UInt8>, SynthesisError>
fn to_bytes_strict<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Vec<UInt8>, SynthesisError>
Additionally checks if the produced list of booleans is ‘valid’.
sourceimpl<F: PrimeField> ToConstraintFieldGadget<F> for FpGadget<F>
impl<F: PrimeField> ToConstraintFieldGadget<F> for FpGadget<F>
sourcefn to_constraint_field<CS: ConstraintSystem<F>>(
&self,
_cs: CS
) -> Result<Vec<FpGadget<F>>, SynthesisError>
fn to_constraint_field<CS: ConstraintSystem<F>>(
&self,
_cs: CS
) -> Result<Vec<FpGadget<F>>, SynthesisError>
Converts self
to FpGadget<F>
variables.
sourceimpl<F: PrimeField> TwoBitLookupGadget<F> for FpGadget<F>
impl<F: PrimeField> TwoBitLookupGadget<F> for FpGadget<F>
Uses two bits to perform a lookup into a table
b
is little-endian: b[0]
is LSB.
type TableConstant = F
fn two_bit_lookup<CS: ConstraintSystem<F>>(
cs: CS,
b: &[Boolean],
c: &[Self::TableConstant]
) -> Result<Self, SynthesisError>
fn cost() -> usize
impl<F: PrimeField> Eq for FpGadget<F>
Auto Trait Implementations
impl<F> RefUnwindSafe for FpGadget<F> where
F: RefUnwindSafe,
impl<F> Send for FpGadget<F>
impl<F> Sync for FpGadget<F>
impl<F> Unpin for FpGadget<F> where
F: Unpin,
impl<F> UnwindSafe for FpGadget<F> where
F: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<F, T> ConditionalOrEqualsGadget<F> for T where
F: Field,
T: ConditionalEqGadget<F> + CondSelectGadget<F>,
impl<F, T> ConditionalOrEqualsGadget<F> for T where
F: Field,
T: ConditionalEqGadget<F> + CondSelectGadget<F>,
fn conditional_enforce_equal_or<CS: ConstraintSystem<F>>(
cs: CS,
cond: &Boolean,
var: &Self,
first: &Self,
second: &Self,
should_enforce: &Boolean
) -> Result<(), SynthesisError>
fn cost() -> usize
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcepub fn equivalent(&self, key: &K) -> bool
pub fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<F, T> OrEqualsGadget<F> for T where
F: Field,
T: ConditionalOrEqualsGadget<F>,
impl<F, T> OrEqualsGadget<F> for T where
F: Field,
T: ConditionalOrEqualsGadget<F>,
fn enforce_equal_or<CS: ConstraintSystem<F>>(
cs: CS,
cond: &Boolean,
var: &Self,
first: &Self,
second: &Self
) -> Result<(), SynthesisError>
fn cost() -> usize
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more