franklin_crypto::plonk::circuit::bigint::field

Struct 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§

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

🔬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> PipeOp<T> for T

Source§

fn to<F, U>(self, f: F) -> U
where F: FnOnce(T) -> U,

Source§

fn op<F>(self, f: F) -> T
where F: FnOnce(&mut T),

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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>,

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V