pub struct FieldElement<'a, E: Engine, F: PrimeField> {
pub binary_limbs: Vec<Limb<E>>,
pub base_field_limb: Term<E>,
pub representation_params: &'a RnsParameters<E, F>,
pub value: Option<F>,
}
Fields§
§binary_limbs: Vec<Limb<E>>
§base_field_limb: Term<E>
§representation_params: &'a RnsParameters<E, F>
§value: Option<F>
Implementations§
Source§impl<'a, E: Engine, F: PrimeField> FieldElement<'a, E, F>
impl<'a, E: Engine, F: PrimeField> FieldElement<'a, E, F>
pub fn into_limbs(self) -> Vec<Term<E>>
pub fn new_allocated<CS: ConstraintSystem<E>>( cs: &mut CS, value: Option<F>, params: &'a RnsParameters<E, F>, ) -> Result<Self, SynthesisError>
pub fn new_allocated_in_field<CS: ConstraintSystem<E>>( cs: &mut CS, value: Option<F>, params: &'a RnsParameters<E, F>, ) -> Result<Self, SynthesisError>
Sourcepub fn allocate_from_single_limb_witnesses_in_field<CS: ConstraintSystem<E>>(
cs: &mut CS,
witnesses: &[Num<E>],
params: &'a RnsParameters<E, F>,
) -> Result<Self, SynthesisError>
pub fn allocate_from_single_limb_witnesses_in_field<CS: ConstraintSystem<E>>( cs: &mut CS, witnesses: &[Num<E>], params: &'a RnsParameters<E, F>, ) -> Result<Self, SynthesisError>
Allocate a field element from witnesses for individual binary(!) limbs, such that highest limb may be a little (up to range constraint granularity) larger than for an element that is in a field. Number of limbs is limited, so that number of binary limbs is strictly enough to represent value in-field
Sourcepub fn from_single_limb_witnesses_unchecked<CS: ConstraintSystem<E>>(
cs: &mut CS,
witnesses: &[Num<E>],
params: &'a RnsParameters<E, F>,
) -> Result<Self, SynthesisError>
pub fn from_single_limb_witnesses_unchecked<CS: ConstraintSystem<E>>( cs: &mut CS, witnesses: &[Num<E>], params: &'a RnsParameters<E, F>, ) -> Result<Self, SynthesisError>
Use limb witnesses from some other source to cast them into field element. Caller must ensure that witnesses are properly range constrainted
Sourcepub fn coarsely_allocate_from_single_limb_witnesses<CS: ConstraintSystem<E>>(
cs: &mut CS,
witnesses: &[Num<E>],
may_overflow: bool,
params: &'a RnsParameters<E, F>,
) -> Result<Self, SynthesisError>
pub fn coarsely_allocate_from_single_limb_witnesses<CS: ConstraintSystem<E>>( cs: &mut CS, witnesses: &[Num<E>], may_overflow: bool, params: &'a RnsParameters<E, F>, ) -> Result<Self, SynthesisError>
Allocate a field element from witnesses for individual binary(!) limbs,
such that highest limb may be a little (up to range constraint granularity)
larger than for an element that is in a field.
If may_overflow
== true then all limbs may be as large limb bit width
Sourcepub fn coarsely_allocate_for_known_bit_width<CS: ConstraintSystem<E>>(
cs: &mut CS,
value: Option<BigUint>,
width: usize,
params: &'a RnsParameters<E, F>,
) -> Result<Self, SynthesisError>
pub fn coarsely_allocate_for_known_bit_width<CS: ConstraintSystem<E>>( cs: &mut CS, value: Option<BigUint>, width: usize, params: &'a RnsParameters<E, F>, ) -> Result<Self, SynthesisError>
Allocate a field element from witnesses for individual binary(!) limbs, such that highest limb may be a little (up to range constraint granularity) larger than for an element that is in a field.
pub fn coarsely_allocate_for_unknown_width<CS: ConstraintSystem<E>>( cs: &mut CS, value: Option<BigUint>, params: &'a RnsParameters<E, F>, ) -> Result<Self, SynthesisError>
pub fn from_double_size_limb_witnesses<CS: ConstraintSystem<E>>( cs: &mut CS, witnesses: &[Num<E>], top_limb_may_overflow: bool, params: &'a RnsParameters<E, F>, ) -> Result<Self, SynthesisError>
pub fn new_constant(v: F, params: &'a RnsParameters<E, F>) -> Self
pub fn zero(params: &'a RnsParameters<E, F>) -> Self
pub fn one(params: &'a RnsParameters<E, F>) -> Self
pub fn get_field_value(&self) -> Option<F>
pub fn is_constant(&self) -> bool
pub fn is_zero<CS: ConstraintSystem<E>>( self, cs: &mut CS, ) -> Result<(Boolean, Self), SynthesisError>
pub fn negated<CS: ConstraintSystem<E>>( self, cs: &mut CS, ) -> Result<(Self, Self), SynthesisError>
pub fn is_within_2_in_modulus_len(&self) -> bool
pub fn needs_reduction(&self) -> bool
pub fn reduce_if_necessary<CS: ConstraintSystem<E>>( self, cs: &mut CS, ) -> Result<Self, SynthesisError>
pub fn force_reduce_into_field<CS: ConstraintSystem<E>>( self, cs: &mut CS, ) -> Result<Self, SynthesisError>
pub fn add<CS: ConstraintSystem<E>>( self, cs: &mut CS, other: Self, ) -> Result<(Self, (Self, Self)), SynthesisError>
pub fn double<CS: ConstraintSystem<E>>( self, cs: &mut CS, ) -> Result<(Self, Self), SynthesisError>
pub fn sub<CS: ConstraintSystem<E>>( self, cs: &mut CS, other: Self, ) -> Result<(Self, (Self, Self)), SynthesisError>
pub fn mul<CS: ConstraintSystem<E>>( self, cs: &mut CS, other: Self, ) -> Result<(Self, (Self, Self)), SynthesisError>
pub fn square<CS: ConstraintSystem<E>>( self, cs: &mut CS, ) -> Result<(Self, Self), SynthesisError>
pub fn fma_with_addition_chain<CS: ConstraintSystem<E>>( self, cs: &mut CS, to_mul: Self, to_add: Vec<Self>, ) -> Result<(Self, (Self, Self, Vec<Self>)), SynthesisError>
pub fn square_with_addition_chain<CS: ConstraintSystem<E>>( self, cs: &mut CS, to_add: Vec<Self>, ) -> Result<(Self, (Self, Vec<Self>)), SynthesisError>
pub fn div<CS: ConstraintSystem<E>>( self, cs: &mut CS, den: Self, ) -> Result<(Self, (Self, Self)), SynthesisError>
pub fn select<CS: ConstraintSystem<E>>( cs: &mut CS, flag: &Boolean, first: Self, second: Self, ) -> Result<(Self, (Self, Self)), SynthesisError>
pub fn conditional_negation<CS: ConstraintSystem<E>>( cs: &mut CS, flag: &Boolean, this: Self, ) -> Result<(Self, (Self, Self)), SynthesisError>
Sourcepub fn enforce_is_normalized<CS: ConstraintSystem<E>>(
self,
cs: &mut CS,
) -> Result<Self, SynthesisError>
pub fn enforce_is_normalized<CS: ConstraintSystem<E>>( self, cs: &mut CS, ) -> Result<Self, SynthesisError>
check that element is in a field and is strictly less than modulus
pub fn enforce_equal<CS: ConstraintSystem<E>>( cs: &mut CS, this: Self, other: Self, ) -> Result<(), SynthesisError>
pub fn special_case_enforce_not_equal<CS: ConstraintSystem<E>>( cs: &mut CS, first: Self, second: Self, ) -> Result<(Self, Self), SynthesisError>
pub fn force_reduce_close_to_modulus<CS: ConstraintSystem<E>>( self, cs: &mut CS, ) -> Result<Self, SynthesisError>
pub fn equals<CS: ConstraintSystem<E>>( cs: &mut CS, this: Self, other: Self, ) -> Result<(Boolean, (Self, Self)), SynthesisError>
pub fn equals_assuming_reduced<CS: ConstraintSystem<E>>( cs: &mut CS, first: Self, second: Self, ) -> Result<Boolean, SynthesisError>
pub fn enforce_not_equal<CS: ConstraintSystem<E>>( cs: &mut CS, this: Self, other: Self, ) -> Result<(Self, Self), SynthesisError>
Trait Implementations§
Source§impl<'a, E: Clone + Engine, F: Clone + PrimeField> Clone for FieldElement<'a, E, F>
impl<'a, E: Clone + Engine, F: Clone + PrimeField> Clone for FieldElement<'a, E, F>
Source§fn clone(&self) -> FieldElement<'a, E, F>
fn clone(&self) -> FieldElement<'a, E, F>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<'a, E: Debug + Engine, F: Debug + PrimeField> Debug for FieldElement<'a, E, F>
impl<'a, E: Debug + Engine, F: Debug + PrimeField> Debug for FieldElement<'a, E, F>
Auto Trait Implementations§
impl<'a, E, F> Freeze for FieldElement<'a, E, F>
impl<'a, E, F> RefUnwindSafe for FieldElement<'a, E, F>
impl<'a, E, F> Send for FieldElement<'a, E, F>
impl<'a, E, F> Sync for FieldElement<'a, E, F>
impl<'a, E, F> Unpin for FieldElement<'a, E, F>
impl<'a, E, F> UnwindSafe for FieldElement<'a, E, F>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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