Struct franklin_crypto::plonk::circuit::bigint::field::FieldElement

source ·
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>

source

pub fn into_limbs(self) -> Vec<Term<E>>

source

pub fn new_allocated<CS: ConstraintSystem<E>>( cs: &mut CS, value: Option<F>, params: &'a RnsParameters<E, F>, ) -> Result<Self, SynthesisError>

source

pub fn new_allocated_in_field<CS: ConstraintSystem<E>>( cs: &mut CS, value: Option<F>, params: &'a RnsParameters<E, F>, ) -> Result<Self, SynthesisError>

source

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

source

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

source

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

source

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.

source

pub fn coarsely_allocate_for_unknown_width<CS: ConstraintSystem<E>>( cs: &mut CS, value: Option<BigUint>, params: &'a RnsParameters<E, F>, ) -> Result<Self, SynthesisError>

source

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>

source

pub fn new_constant(v: F, params: &'a RnsParameters<E, F>) -> Self

source

pub fn zero(params: &'a RnsParameters<E, F>) -> Self

source

pub fn one(params: &'a RnsParameters<E, F>) -> Self

source

pub fn get_field_value(&self) -> Option<F>

source

pub fn is_constant(&self) -> bool

source

pub fn is_zero<CS: ConstraintSystem<E>>( self, cs: &mut CS, ) -> Result<(Boolean, Self), SynthesisError>

source

pub fn negated<CS: ConstraintSystem<E>>( self, cs: &mut CS, ) -> Result<(Self, Self), SynthesisError>

source

pub fn is_within_2_in_modulus_len(&self) -> bool

source

pub fn needs_reduction(&self) -> bool

source

pub fn reduce_if_necessary<CS: ConstraintSystem<E>>( self, cs: &mut CS, ) -> Result<Self, SynthesisError>

source

pub fn force_reduce_into_field<CS: ConstraintSystem<E>>( self, cs: &mut CS, ) -> Result<Self, SynthesisError>

source

pub fn add<CS: ConstraintSystem<E>>( self, cs: &mut CS, other: Self, ) -> Result<(Self, (Self, Self)), SynthesisError>

source

pub fn double<CS: ConstraintSystem<E>>( self, cs: &mut CS, ) -> Result<(Self, Self), SynthesisError>

source

pub fn sub<CS: ConstraintSystem<E>>( self, cs: &mut CS, other: Self, ) -> Result<(Self, (Self, Self)), SynthesisError>

source

pub fn mul<CS: ConstraintSystem<E>>( self, cs: &mut CS, other: Self, ) -> Result<(Self, (Self, Self)), SynthesisError>

source

pub fn square<CS: ConstraintSystem<E>>( self, cs: &mut CS, ) -> Result<(Self, Self), SynthesisError>

source

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>

source

pub fn square_with_addition_chain<CS: ConstraintSystem<E>>( self, cs: &mut CS, to_add: Vec<Self>, ) -> Result<(Self, (Self, Vec<Self>)), SynthesisError>

source

pub fn div<CS: ConstraintSystem<E>>( self, cs: &mut CS, den: Self, ) -> Result<(Self, (Self, Self)), SynthesisError>

source

pub fn select<CS: ConstraintSystem<E>>( cs: &mut CS, flag: &Boolean, first: Self, second: Self, ) -> Result<(Self, (Self, Self)), SynthesisError>

source

pub fn conditional_negation<CS: ConstraintSystem<E>>( cs: &mut CS, flag: &Boolean, this: Self, ) -> Result<(Self, (Self, Self)), SynthesisError>

source

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

source

pub fn enforce_equal<CS: ConstraintSystem<E>>( cs: &mut CS, this: Self, other: Self, ) -> Result<(), SynthesisError>

source

pub fn special_case_enforce_not_equal<CS: ConstraintSystem<E>>( cs: &mut CS, first: Self, second: Self, ) -> Result<(Self, Self), SynthesisError>

source

pub fn force_reduce_close_to_modulus<CS: ConstraintSystem<E>>( self, cs: &mut CS, ) -> Result<Self, SynthesisError>

source

pub fn equals<CS: ConstraintSystem<E>>( cs: &mut CS, this: Self, other: Self, ) -> Result<(Boolean, (Self, Self)), SynthesisError>

source

pub fn equals_assuming_reduced<CS: ConstraintSystem<E>>( cs: &mut CS, first: Self, second: Self, ) -> Result<Boolean, SynthesisError>

source

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>

source§

fn clone(&self) -> FieldElement<'a, E, F>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a, E: Debug + Engine, F: Debug + PrimeField> Debug for FieldElement<'a, E, F>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a, E: Engine, F: PrimeField> Display for FieldElement<'a, E, F>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, E, F> Freeze for FieldElement<'a, E, F>
where <E as ScalarEngine>::Fr: Freeze, F: Freeze,

§

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>
where <E as ScalarEngine>::Fr: Unpin, F: Unpin,

§

impl<'a, E, F> UnwindSafe for FieldElement<'a, E, F>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.