AllocatedNonNativeFieldVar

Struct AllocatedNonNativeFieldVar 

Source
pub struct AllocatedNonNativeFieldVar<TargetField: PrimeField, BaseField: PrimeField> {
    pub cs: ConstraintSystemRef<BaseField>,
    pub limbs: Vec<FpVar<BaseField>>,
    pub num_of_additions_over_normal_form: BaseField,
    pub is_in_the_normal_form: bool,
    /* private fields */
}
Expand description

The allocated version of NonNativeFieldVar (introduced below)

Fields§

§cs: ConstraintSystemRef<BaseField>

Constraint system reference

§limbs: Vec<FpVar<BaseField>>

The limbs, each of which is a BaseField gadget.

§num_of_additions_over_normal_form: BaseField

Number of additions done over this gadget, using which the gadget decides when to reduce.

§is_in_the_normal_form: bool

Whether the limb representation is the normal form (using only the bits specified in the parameters, and the representation is strictly within the range of TargetField).

Implementations§

Source§

impl<TargetField: PrimeField, BaseField: PrimeField> AllocatedNonNativeFieldVar<TargetField, BaseField>

Source

pub fn cs(&self) -> ConstraintSystemRef<BaseField>

Return cs

Source

pub fn limbs_to_value( limbs: Vec<BaseField>, optimization_type: OptimizationType, ) -> TargetField

Obtain the value of limbs

Source

pub fn value(&self) -> R1CSResult<TargetField>

Obtain the value of a nonnative field element

Source

pub fn constant( cs: ConstraintSystemRef<BaseField>, value: TargetField, ) -> R1CSResult<Self>

Obtain the nonnative field element of a constant value

Source

pub fn one(cs: ConstraintSystemRef<BaseField>) -> R1CSResult<Self>

Obtain the nonnative field element of one

Source

pub fn zero(cs: ConstraintSystemRef<BaseField>) -> R1CSResult<Self>

Obtain the nonnative field element of zero

Source

pub fn add(&self, other: &Self) -> R1CSResult<Self>

Add a nonnative field element

Source

pub fn add_constant(&self, other: &TargetField) -> R1CSResult<Self>

Add a constant

Source

pub fn sub_without_reduce(&self, other: &Self) -> R1CSResult<Self>

Subtract a nonnative field element, without the final reduction step

Source

pub fn sub(&self, other: &Self) -> R1CSResult<Self>

Subtract a nonnative field element

Source

pub fn sub_constant(&self, other: &TargetField) -> R1CSResult<Self>

Subtract a constant

Source

pub fn mul(&self, other: &Self) -> R1CSResult<Self>

Multiply a nonnative field element

Source

pub fn mul_constant(&self, other: &TargetField) -> R1CSResult<Self>

Multiply a constant

Source

pub fn negate(&self) -> R1CSResult<Self>

Compute the negate of a nonnative field element

Source

pub fn inverse(&self) -> R1CSResult<Self>

Compute the inverse of a nonnative field element

Source

pub fn get_limbs_representations( elem: &TargetField, optimization_type: OptimizationType, ) -> R1CSResult<Vec<BaseField>>

Convert a TargetField element into limbs (not constraints) This is an internal function that would be reused by a number of other functions

Source

pub fn get_limbs_representations_from_big_integer( elem: &<TargetField as PrimeField>::BigInt, optimization_type: OptimizationType, ) -> R1CSResult<Vec<BaseField>>

Obtain the limbs directly from a big int

Source

pub fn mul_without_reduce( &self, other: &Self, ) -> R1CSResult<AllocatedNonNativeFieldMulResultVar<TargetField, BaseField>>

for advanced use, multiply and output the intermediate representations (without reduction) This intermediate representations can be added with each other, and they can later be reduced back to the NonNativeFieldVar.

Trait Implementations§

Source§

impl<TargetField: PrimeField, BaseField: PrimeField> AllocVar<TargetField, BaseField> for AllocatedNonNativeFieldVar<TargetField, BaseField>

Source§

fn new_variable<T: Borrow<TargetField>>( cs: impl Into<Namespace<BaseField>>, f: impl FnOnce() -> Result<T, SynthesisError>, mode: AllocationMode, ) -> R1CSResult<Self>

Allocates a new variable of type Self in the ConstraintSystem cs. The mode of allocation is decided by mode.
Source§

fn new_constant( cs: impl Into<Namespace<F>>, t: impl Borrow<V>, ) -> Result<Self, SynthesisError>

Allocates a new constant of type Self in the ConstraintSystem cs. Read more
Source§

fn new_input<T>( cs: impl Into<Namespace<F>>, f: impl FnOnce() -> Result<T, SynthesisError>, ) -> Result<Self, SynthesisError>
where T: Borrow<V>,

Allocates a new public input of type Self in the ConstraintSystem cs.
Source§

fn new_witness<T>( cs: impl Into<Namespace<F>>, f: impl FnOnce() -> Result<T, SynthesisError>, ) -> Result<Self, SynthesisError>
where T: Borrow<V>,

Allocates a new private witness of type Self in the ConstraintSystem cs.
Source§

impl<TargetField: PrimeField, BaseField: PrimeField> Clone for AllocatedNonNativeFieldVar<TargetField, BaseField>

Source§

fn clone(&self) -> Self

Returns a duplicate 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<TargetField: PrimeField, BaseField: PrimeField> CondSelectGadget<BaseField> for AllocatedNonNativeFieldVar<TargetField, BaseField>

Source§

fn conditionally_select( cond: &Boolean<BaseField>, true_value: &Self, false_value: &Self, ) -> R1CSResult<Self>

If cond == &Boolean::TRUE, then this returns true_value; else, returns false_value. Read more
Source§

fn conditionally_select_power_of_two_vector( position: &[Boolean<ConstraintF>], values: &[Self], ) -> Result<Self, SynthesisError>

Returns an element of values whose index in represented by position. position is an array of boolean that represents an unsigned integer in big endian order. Read more
Source§

impl<TargetField: Debug + PrimeField, BaseField: Debug + PrimeField> Debug for AllocatedNonNativeFieldVar<TargetField, BaseField>

Source§

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

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

impl<TargetField: PrimeField, BaseField: PrimeField> From<&AllocatedNonNativeFieldVar<TargetField, BaseField>> for AllocatedNonNativeFieldMulResultVar<TargetField, BaseField>

Source§

fn from(src: &AllocatedNonNativeFieldVar<TargetField, BaseField>) -> Self

Converts to this type from the input type.
Source§

impl<TargetField: PrimeField, BaseField: PrimeField> From<AllocatedNonNativeFieldVar<TargetField, BaseField>> for NonNativeFieldVar<TargetField, BaseField>

Source§

fn from(other: AllocatedNonNativeFieldVar<TargetField, BaseField>) -> Self

Converts to this type from the input type.
Source§

impl<TargetField: PrimeField, BaseField: PrimeField> ThreeBitCondNegLookupGadget<BaseField> for AllocatedNonNativeFieldVar<TargetField, BaseField>

Source§

type TableConstant = TargetField

The type of values being looked up.
Source§

fn three_bit_cond_neg_lookup( bits: &[Boolean<BaseField>], b0b1: &Boolean<BaseField>, constants: &[Self::TableConstant], ) -> R1CSResult<Self>

Interprets the slice bits as a two-bit integer b = bits[0] + (bits[1] << 1), and then outputs constants[b] * c, where c = if bits[2] { -1 } else { 1 };. Read more
Source§

impl<TargetField: PrimeField, BaseField: PrimeField> ToBitsGadget<BaseField> for AllocatedNonNativeFieldVar<TargetField, BaseField>

Source§

fn to_bits_le(&self) -> R1CSResult<Vec<Boolean<BaseField>>>

Outputs the canonical little-endian bit-wise representation of self. Read more
Source§

fn to_non_unique_bits_le(&self) -> Result<Vec<Boolean<F>>, SynthesisError>

Outputs a possibly non-unique little-endian bit-wise representation of self. Read more
Source§

fn to_bits_be(&self) -> Result<Vec<Boolean<F>>, SynthesisError>

Outputs the canonical big-endian bit-wise representation of self.
Source§

fn to_non_unique_bits_be(&self) -> Result<Vec<Boolean<F>>, SynthesisError>

Outputs a possibly non-unique big-endian bit-wise representation of self.
Source§

impl<TargetField: PrimeField, BaseField: PrimeField> ToBytesGadget<BaseField> for AllocatedNonNativeFieldVar<TargetField, BaseField>

Source§

fn to_bytes(&self) -> R1CSResult<Vec<UInt8<BaseField>>>

Outputs a canonical, little-endian, byte decomposition of self. Read more
Source§

fn to_non_unique_bytes(&self) -> Result<Vec<UInt8<F>>, SynthesisError>

Outputs a possibly non-unique byte decomposition of self. Read more
Source§

impl<TargetField: PrimeField, BaseField: PrimeField> ToConstraintFieldGadget<BaseField> for AllocatedNonNativeFieldVar<TargetField, BaseField>

Source§

fn to_constraint_field(&self) -> R1CSResult<Vec<FpVar<BaseField>>>

Converts self to FpVar<ConstraintF> variables.
Source§

impl<TargetField: PrimeField, BaseField: PrimeField> TwoBitLookupGadget<BaseField> for AllocatedNonNativeFieldVar<TargetField, BaseField>

Source§

type TableConstant = TargetField

The type of values being looked up.
Source§

fn two_bit_lookup( bits: &[Boolean<BaseField>], constants: &[Self::TableConstant], ) -> R1CSResult<Self>

Interprets the slice bits as a two-bit integer b = bits[0] + (bits[1] << 1), and then outputs constants[b]. Read more

Auto Trait Implementations§

§

impl<TargetField, BaseField> Freeze for AllocatedNonNativeFieldVar<TargetField, BaseField>
where BaseField: Freeze,

§

impl<TargetField, BaseField> !RefUnwindSafe for AllocatedNonNativeFieldVar<TargetField, BaseField>

§

impl<TargetField, BaseField> !Send for AllocatedNonNativeFieldVar<TargetField, BaseField>

§

impl<TargetField, BaseField> !Sync for AllocatedNonNativeFieldVar<TargetField, BaseField>

§

impl<TargetField, BaseField> Unpin for AllocatedNonNativeFieldVar<TargetField, BaseField>
where BaseField: Unpin, TargetField: Unpin,

§

impl<TargetField, BaseField> !UnwindSafe for AllocatedNonNativeFieldVar<TargetField, BaseField>

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, dest: *mut u8)

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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, 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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more