pub struct Fp2Gadget<P: Fp2Parameters<Fp = F>, F: PrimeField> {
pub c0: FpGadget<F>,
pub c1: FpGadget<F>,
/* private fields */
}
Fields
c0: FpGadget<F>
c1: FpGadget<F>
Implementations
sourceimpl<P: Fp2Parameters<Fp = F>, F: PrimeField> Fp2Gadget<P, F>
impl<P: Fp2Parameters<Fp = F>, F: PrimeField> Fp2Gadget<P, F>
pub fn new(c0: FpGadget<F>, c1: FpGadget<F>) -> Self
sourcepub fn mul_fp_gadget_by_nonresidue<CS: ConstraintSystem<F>>(
cs: CS,
fe: &FpGadget<F>
) -> Result<FpGadget<F>, SynthesisError>
pub fn mul_fp_gadget_by_nonresidue<CS: ConstraintSystem<F>>(
cs: CS,
fe: &FpGadget<F>
) -> Result<FpGadget<F>, SynthesisError>
Multiply a FpGadget by quadratic nonresidue P::NONRESIDUE.
sourcepub fn mul_by_fp_constant_in_place<CS: ConstraintSystem<F>>(
&mut self,
cs: CS,
fe: &P::Fp
) -> Result<&mut Self, SynthesisError>
pub fn mul_by_fp_constant_in_place<CS: ConstraintSystem<F>>(
&mut self,
cs: CS,
fe: &P::Fp
) -> Result<&mut Self, SynthesisError>
Multiply a Fp2Gadget by an element of fp.
sourcepub fn mul_by_fp_constant<CS: ConstraintSystem<F>>(
&self,
cs: CS,
fe: &P::Fp
) -> Result<Self, SynthesisError>
pub fn mul_by_fp_constant<CS: ConstraintSystem<F>>(
&self,
cs: CS,
fe: &P::Fp
) -> Result<Self, SynthesisError>
Multiply a Fp2Gadget by an element of fp.
Trait Implementations
sourceimpl<P: Fp2Parameters<Fp = F>, F: PrimeField> AllocGadget<Fp2<P>, F> for Fp2Gadget<P, F>
impl<P: Fp2Parameters<Fp = F>, F: PrimeField> AllocGadget<Fp2<P>, F> for Fp2Gadget<P, 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<Fp2<P>>,
fn alloc<Fn, T, CS: ConstraintSystem<F>>(
cs: CS,
value_gen: Fn
) -> Result<Self, SynthesisError> where
Fn: FnOnce() -> Result<T, SynthesisError>,
T: Borrow<Fp2<P>>,
fn alloc_input<Fn, T, CS: ConstraintSystem<F>>(
cs: CS,
value_gen: Fn
) -> Result<Self, SynthesisError> where
Fn: FnOnce() -> Result<T, SynthesisError>,
T: Borrow<Fp2<P>>,
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<P: Fp2Parameters<Fp = F>, F: PrimeField> Clone for Fp2Gadget<P, F>
impl<P: Fp2Parameters<Fp = F>, F: PrimeField> Clone for Fp2Gadget<P, F>
sourceimpl<P: Fp2Parameters<Fp = F>, F: PrimeField> CondSelectGadget<F> for Fp2Gadget<P, F>
impl<P: Fp2Parameters<Fp = F>, F: PrimeField> CondSelectGadget<F> for Fp2Gadget<P, F>
fn conditionally_select<CS: ConstraintSystem<F>>(
cs: CS,
cond: &Boolean,
first: &Self,
second: &Self
) -> Result<Self, SynthesisError>
fn cost() -> usize
sourceimpl<P: Fp2Parameters<Fp = F>, F: PrimeField> ConditionalEqGadget<F> for Fp2Gadget<P, F>
impl<P: Fp2Parameters<Fp = F>, F: PrimeField> ConditionalEqGadget<F> for Fp2Gadget<P, F>
fn conditional_enforce_equal<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &Self,
condition: &Boolean
) -> Result<(), SynthesisError>
fn cost() -> usize
sourceimpl<P: Fp2Parameters<Fp = F>, F: PrimeField> Debug for Fp2Gadget<P, F> where
P: Fp2Parameters,
F: PrimeField,
impl<P: Fp2Parameters<Fp = F>, F: PrimeField> Debug for Fp2Gadget<P, F> where
P: Fp2Parameters,
F: PrimeField,
sourceimpl<P: Fp2Parameters<Fp = F>, F: PrimeField> EqGadget<F> for Fp2Gadget<P, F>
impl<P: Fp2Parameters<Fp = F>, F: PrimeField> EqGadget<F> for Fp2Gadget<P, 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<P: Fp2Parameters<Fp = F>, F: PrimeField> FieldGadget<Fp2<P>, F> for Fp2Gadget<P, F>
impl<P: Fp2Parameters<Fp = F>, F: PrimeField> FieldGadget<Fp2<P>, F> for Fp2Gadget<P, F>
type Variable = (ConstraintVariable<F>, ConstraintVariable<F>)
fn get_value(&self) -> Option<Fp2<P>>
fn get_variable(&self) -> Self::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: Fp2<P>
) -> Result<Self, SynthesisError>
fn add<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &Self
) -> Result<Self, SynthesisError>
fn sub<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 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 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 inverse<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Self, SynthesisError>
fn mul_equals<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &Self,
result: &Self
) -> Result<(), 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 add_constant<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &Fp2<P>
) -> Result<Self, SynthesisError>
fn add_constant_in_place<CS: ConstraintSystem<F>>(
&mut self,
cs: CS,
other: &Fp2<P>
) -> Result<&mut Self, SynthesisError>
fn mul_by_constant<CS: ConstraintSystem<F>>(
&self,
cs: CS,
fe: &Fp2<P>
) -> Result<Self, 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_equals<CS: ConstraintSystem<F>>(
&self,
cs: CS,
result: &Self
) -> Result<(), 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>
fn mul_by_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<P: Fp2Parameters<Fp = F>, F: PrimeField> NEqGadget<F> for Fp2Gadget<P, F>
impl<P: Fp2Parameters<Fp = F>, F: PrimeField> NEqGadget<F> for Fp2Gadget<P, F>
fn enforce_not_equal<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &Self
) -> Result<(), SynthesisError>
fn cost() -> usize
sourceimpl<P: Fp2Parameters<Fp = F>, F: PrimeField> PartialEq<Fp2Gadget<P, F>> for Fp2Gadget<P, F>
impl<P: Fp2Parameters<Fp = F>, F: PrimeField> PartialEq<Fp2Gadget<P, F>> for Fp2Gadget<P, F>
sourceimpl<P: Fp2Parameters<Fp = F>, F: PrimeField> ThreeBitCondNegLookupGadget<F> for Fp2Gadget<P, F>
impl<P: Fp2Parameters<Fp = F>, F: PrimeField> ThreeBitCondNegLookupGadget<F> for Fp2Gadget<P, F>
type TableConstant = Fp2<P>
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<P: Fp2Parameters<Fp = F>, F: PrimeField> ToBitsBEGadget<F> for Fp2Gadget<P, F>
impl<P: Fp2Parameters<Fp = F>, F: PrimeField> ToBitsBEGadget<F> for Fp2Gadget<P, F>
fn to_bits_be<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Vec<Boolean>, SynthesisError>
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<P: Fp2Parameters<Fp = F>, F: PrimeField> ToBitsLEGadget<F> for Fp2Gadget<P, F>
impl<P: Fp2Parameters<Fp = F>, F: PrimeField> ToBitsLEGadget<F> for Fp2Gadget<P, F>
fn to_bits_le<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Vec<Boolean>, SynthesisError>
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<P: Fp2Parameters<Fp = F>, F: PrimeField> ToBytesGadget<F> for Fp2Gadget<P, F>
impl<P: Fp2Parameters<Fp = F>, F: PrimeField> ToBytesGadget<F> for Fp2Gadget<P, 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<P: Fp2Parameters<Fp = F>, F: PrimeField> ToConstraintFieldGadget<F> for Fp2Gadget<P, F>
impl<P: Fp2Parameters<Fp = F>, F: PrimeField> ToConstraintFieldGadget<F> for Fp2Gadget<P, 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<P: Fp2Parameters<Fp = F>, F: PrimeField> TwoBitLookupGadget<F> for Fp2Gadget<P, F>
impl<P: Fp2Parameters<Fp = F>, F: PrimeField> TwoBitLookupGadget<F> for Fp2Gadget<P, F>
type TableConstant = Fp2<P>
fn two_bit_lookup<CS: ConstraintSystem<F>>(
cs: CS,
b: &[Boolean],
c: &[Self::TableConstant]
) -> Result<Self, SynthesisError>
fn cost() -> usize
impl<P: Fp2Parameters<Fp = F>, F: PrimeField> Eq for Fp2Gadget<P, F>
Auto Trait Implementations
impl<P, F> RefUnwindSafe for Fp2Gadget<P, F> where
F: RefUnwindSafe,
P: RefUnwindSafe,
impl<P, F> Send for Fp2Gadget<P, F>
impl<P, F> Sync for Fp2Gadget<P, F>
impl<P, F> Unpin for Fp2Gadget<P, F> where
F: Unpin,
P: Unpin,
impl<P, F> UnwindSafe for Fp2Gadget<P, F> where
F: UnwindSafe,
P: 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