Struct ark_r1cs_std::fields::fp::AllocatedFp[][src]

#[must_use]pub struct AllocatedFp<F: PrimeField> {
    pub variable: Variable,
    pub cs: ConstraintSystemRef<F>,
    // some fields omitted
}

Represents a variable in the constraint system whose value can be an arbitrary field element.

Fields

variable: Variable

The allocated variable corresponding to self in self.cs.

cs: ConstraintSystemRef<F>

The constraint system that self was allocated in.

Implementations

impl<F: PrimeField> AllocatedFp<F>[src]

pub fn new(
    value: Option<F>,
    variable: Variable,
    cs: ConstraintSystemRef<F>
) -> Self
[src]

Constructs a new AllocatedFp from a (optional) value, a low-level Variable, and a ConstraintSystemRef.

impl<F: PrimeField> AllocatedFp<F>[src]

pub fn from(other: Boolean<F>) -> Self[src]

Constructs Self from a Boolean: if other is false, this outputs zero, else it outputs one.

pub fn value(&self) -> Result<F, SynthesisError>[src]

Returns the value assigned to self in the underlying constraint system (if a value was assigned).

pub fn add(&self, other: &Self) -> Self[src]

Outputs self + other.

This does not create any constraints.

pub fn sub(&self, other: &Self) -> Self[src]

Outputs self - other.

This does not create any constraints.

pub fn mul(&self, other: &Self) -> Self[src]

Outputs self * other.

This requires one constraint.

pub fn add_constant(&self, other: F) -> Self[src]

Output self + other

This does not create any constraints.

pub fn sub_constant(&self, other: F) -> Self[src]

Output self - other

This does not create any constraints.

pub fn mul_constant(&self, other: F) -> Self[src]

Output self * other

This does not create any constraints.

pub fn double(&self) -> Result<Self, SynthesisError>[src]

Output self + self

This does not create any constraints.

pub fn negate(&self) -> Self[src]

Output -self

This does not create any constraints.

pub fn negate_in_place(&mut self) -> &mut Self[src]

Sets self = -self

This does not create any constraints.

pub fn square(&self) -> Result<Self, SynthesisError>[src]

Outputs self * self

This requires one constraint.

pub fn inverse(&self) -> Result<Self, SynthesisError>[src]

Outputs result such that result * self = 1.

This requires one constraint.

pub fn frobenius_map(&self, _: usize) -> Result<Self, SynthesisError>[src]

This is a no-op for prime fields.

pub fn mul_equals(
    &self,
    other: &Self,
    result: &Self
) -> Result<(), SynthesisError>
[src]

Enforces that self * other = result.

This requires one constraint.

pub fn square_equals(&self, result: &Self) -> Result<(), SynthesisError>[src]

Enforces that self * self = result.

This requires one constraint.

pub fn is_eq(&self, other: &Self) -> Result<Boolean<F>, SynthesisError>[src]

Outputs the bit self == other.

This requires three constraints.

pub fn is_neq(&self, other: &Self) -> Result<Boolean<F>, SynthesisError>[src]

Outputs the bit self != other.

This requires three constraints.

pub fn conditional_enforce_equal(
    &self,
    other: &Self,
    should_enforce: &Boolean<F>
) -> Result<(), SynthesisError>
[src]

Enforces that self == other if should_enforce.is_eq(&Boolean::TRUE).

This requires one constraint.

pub fn conditional_enforce_not_equal(
    &self,
    other: &Self,
    should_enforce: &Boolean<F>
) -> Result<(), SynthesisError>
[src]

Enforces that self != other if should_enforce.is_eq(&Boolean::TRUE).

This requires one constraint.

Trait Implementations

impl<F: PrimeField> AllocVar<F, F> for AllocatedFp<F>[src]

impl<F: Clone + PrimeField> Clone for AllocatedFp<F>[src]

impl<F: PrimeField> CondSelectGadget<F> for AllocatedFp<F>[src]

impl<F: Debug + PrimeField> Debug for AllocatedFp<F>[src]

impl<F: PrimeField> From<AllocatedFp<F>> for FpVar<F>[src]

impl<F: PrimeField> ThreeBitCondNegLookupGadget<F> for AllocatedFp<F>[src]

type TableConstant = F

The type of values being looked up.

impl<F: PrimeField> ToBitsGadget<F> for AllocatedFp<F>[src]



fn to_bits_le(&self) -> Result<Vec<Boolean<F>>, SynthesisError>[src]

Outputs the unique bit-wise decomposition of self in little-endian form.

This method enforces that the output is in the field, i.e. it invokes Boolean::enforce_in_field_le on the bit decomposition.

impl<F: PrimeField> ToBytesGadget<F> for AllocatedFp<F>[src]

fn to_bytes(&self) -> Result<Vec<UInt8<F>>, SynthesisError>[src]

Outputs the unique byte decomposition of self in little-endian form.

This method enforces that the decomposition represents an integer that is less than F::MODULUS.

impl<F: PrimeField> ToConstraintFieldGadget<F> for AllocatedFp<F>[src]

impl<F: PrimeField> TwoBitLookupGadget<F> for AllocatedFp<F>[src]

Uses two bits to perform a lookup into a table b is little-endian: b[0] is LSB.

type TableConstant = F

The type of values being looked up.

Auto Trait Implementations

impl<F> !RefUnwindSafe for AllocatedFp<F>

impl<F> !Send for AllocatedFp<F>

impl<F> !Sync for AllocatedFp<F>

impl<F> Unpin for AllocatedFp<F> where
    F: Unpin

impl<F> !UnwindSafe for AllocatedFp<F>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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