Struct snarkvm_gadgets::fields::fp::AllocatedFp
source · [−]pub struct AllocatedFp<F: PrimeField> {
pub value: Option<F>,
pub variable: ConstraintVariable<F>,
}
Expand description
Represents a variable in the constraint system whose value can be an arbitrary field element.
Fields
value: Option<F>
variable: ConstraintVariable<F>
Implementations
sourceimpl<F: PrimeField> AllocatedFp<F>
impl<F: PrimeField> AllocatedFp<F>
pub fn from<CS: ConstraintSystem<F>>(cs: CS, value: &F) -> Self
sourceimpl<F: PrimeField> AllocatedFp<F>
impl<F: PrimeField> AllocatedFp<F>
sourcepub fn from_boolean<CS: ConstraintSystem<F>>(
cs: CS,
cond: Boolean
) -> Result<Self, SynthesisError>
pub fn from_boolean<CS: ConstraintSystem<F>>(
cs: CS,
cond: Boolean
) -> Result<Self, SynthesisError>
Constructs Self
from a Boolean
:
if cond
is false, this outputs zero
, else it outputs one
.
sourcepub fn is_neq<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &Self
) -> Result<Boolean, SynthesisError>
pub fn is_neq<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &Self
) -> Result<Boolean, SynthesisError>
Outputs the bit self != other
.
This requires three constraints.
Trait Implementations
sourceimpl<F: PrimeField> AllocGadget<F, F> for AllocatedFp<F>
impl<F: PrimeField> AllocGadget<F, F> for AllocatedFp<F>
fn alloc_constant<FN, T, CS: ConstraintSystem<F>>(
_cs: CS,
value_gen: FN
) -> Result<Self, SynthesisError> where
FN: FnOnce() -> Result<T, SynthesisError>,
T: Borrow<F>,
fn alloc<FN, T, CS: ConstraintSystem<F>>(
cs: CS,
value_gen: FN
) -> Result<Self, SynthesisError> where
FN: FnOnce() -> Result<T, SynthesisError>,
T: Borrow<F>,
fn alloc_input<FN, T, CS: ConstraintSystem<F>>(
cs: CS,
value_gen: FN
) -> Result<Self, SynthesisError> where
FN: FnOnce() -> Result<T, SynthesisError>,
T: Borrow<F>,
fn alloc_checked<Fn: FnOnce() -> Result<T, SynthesisError>, T: Borrow<V>, CS: ConstraintSystem<F>>(
cs: CS,
f: Fn
) -> Result<Self, SynthesisError>
fn alloc_input_checked<Fn: FnOnce() -> Result<T, SynthesisError>, T: Borrow<V>, CS: ConstraintSystem<F>>(
cs: CS,
f: Fn
) -> Result<Self, SynthesisError>
sourceimpl<F: PrimeField> Clone for AllocatedFp<F>
impl<F: PrimeField> Clone for AllocatedFp<F>
sourceimpl<F: PrimeField> CondSelectGadget<F> for AllocatedFp<F>
impl<F: PrimeField> CondSelectGadget<F> for AllocatedFp<F>
fn conditionally_select<CS: ConstraintSystem<F>>(
cs: CS,
cond: &Boolean,
first: &Self,
second: &Self
) -> Result<Self, SynthesisError>
fn cost() -> usize
sourceimpl<F: PrimeField> ConditionalEqGadget<F> for AllocatedFp<F>
impl<F: PrimeField> ConditionalEqGadget<F> for AllocatedFp<F>
fn conditional_enforce_equal<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &Self,
condition: &Boolean
) -> Result<(), SynthesisError>
fn cost() -> usize
sourceimpl<F: Debug + PrimeField> Debug for AllocatedFp<F>
impl<F: Debug + PrimeField> Debug for AllocatedFp<F>
sourceimpl<F: PrimeField> EqGadget<F> for AllocatedFp<F>
impl<F: PrimeField> EqGadget<F> for AllocatedFp<F>
sourcefn is_eq<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &Self
) -> Result<Boolean, SynthesisError>
fn is_eq<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &Self
) -> Result<Boolean, SynthesisError>
Output a Boolean
value representing whether self.value() == other.value()
. Read more
fn enforce_equal<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &Self
) -> Result<(), SynthesisError>
fn cost() -> usize
sourceimpl<F: PrimeField> From<AllocatedFp<F>> for FpGadget<F>
impl<F: PrimeField> From<AllocatedFp<F>> for FpGadget<F>
sourcefn from(other: AllocatedFp<F>) -> Self
fn from(other: AllocatedFp<F>) -> Self
Performs the conversion.
sourceimpl<F: PrimeField> NEqGadget<F> for AllocatedFp<F>
impl<F: PrimeField> NEqGadget<F> for AllocatedFp<F>
fn enforce_not_equal<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &Self
) -> Result<(), SynthesisError>
fn cost() -> usize
sourceimpl<F: PrimeField> PartialEq<AllocatedFp<F>> for AllocatedFp<F>
impl<F: PrimeField> PartialEq<AllocatedFp<F>> for AllocatedFp<F>
sourceimpl<F: PrimeField> ThreeBitCondNegLookupGadget<F> for AllocatedFp<F>
impl<F: PrimeField> ThreeBitCondNegLookupGadget<F> for AllocatedFp<F>
type TableConstant = F
fn three_bit_cond_neg_lookup<CS: ConstraintSystem<F>>(
cs: CS,
b: &[Boolean],
b0b1: &Boolean,
c: &[Self::TableConstant]
) -> Result<Self, SynthesisError>
fn cost() -> usize
sourceimpl<F: PrimeField> ToBitsBEGadget<F> for AllocatedFp<F>
impl<F: PrimeField> ToBitsBEGadget<F> for AllocatedFp<F>
sourcefn to_bits_be<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Vec<Boolean>, SynthesisError>
fn to_bits_be<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Vec<Boolean>, SynthesisError>
Outputs the binary representation of the value in self
in big-endian
form.
sourcefn to_bits_be_strict<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Vec<Boolean>, SynthesisError>
fn to_bits_be_strict<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Vec<Boolean>, SynthesisError>
Additionally checks if the produced list of booleans is ‘valid’.
sourceimpl<F: PrimeField> ToBitsLEGadget<F> for AllocatedFp<F>
impl<F: PrimeField> ToBitsLEGadget<F> for AllocatedFp<F>
sourcefn to_bits_le<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Vec<Boolean>, SynthesisError>
fn to_bits_le<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Vec<Boolean>, SynthesisError>
Outputs the binary representation of the value in self
in little-endian
form.
sourcefn to_bits_le_strict<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Vec<Boolean>, SynthesisError>
fn to_bits_le_strict<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Vec<Boolean>, SynthesisError>
Additionally checks if the produced list of booleans is ‘valid’.
sourceimpl<F: PrimeField> ToBytesGadget<F> for AllocatedFp<F>
impl<F: PrimeField> ToBytesGadget<F> for AllocatedFp<F>
fn to_bytes<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Vec<UInt8>, SynthesisError>
sourcefn to_bytes_strict<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Vec<UInt8>, SynthesisError>
fn to_bytes_strict<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Vec<UInt8>, SynthesisError>
Additionally checks if the produced list of booleans is ‘valid’.
sourceimpl<F: PrimeField> ToConstraintFieldGadget<F> for AllocatedFp<F>
impl<F: PrimeField> ToConstraintFieldGadget<F> for AllocatedFp<F>
sourcefn to_constraint_field<CS: ConstraintSystem<F>>(
&self,
_cs: CS
) -> Result<Vec<FpGadget<F>>, SynthesisError>
fn to_constraint_field<CS: ConstraintSystem<F>>(
&self,
_cs: CS
) -> Result<Vec<FpGadget<F>>, SynthesisError>
Converts self
to FpGadget<F>
variables.
sourceimpl<F: PrimeField> TwoBitLookupGadget<F> for AllocatedFp<F>
impl<F: PrimeField> TwoBitLookupGadget<F> for AllocatedFp<F>
Uses two bits to perform a lookup into a table
b
is little-endian: b[0]
is LSB.
type TableConstant = F
fn two_bit_lookup<CS: ConstraintSystem<F>>(
cs: CS,
b: &[Boolean],
c: &[Self::TableConstant]
) -> Result<Self, SynthesisError>
fn cost() -> usize
impl<F: PrimeField> Eq for AllocatedFp<F>
Auto Trait Implementations
impl<F> RefUnwindSafe for AllocatedFp<F> where
F: RefUnwindSafe,
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> where
F: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<F, T> ConditionalOrEqualsGadget<F> for T where
F: Field,
T: ConditionalEqGadget<F> + CondSelectGadget<F>,
impl<F, T> ConditionalOrEqualsGadget<F> for T where
F: Field,
T: ConditionalEqGadget<F> + CondSelectGadget<F>,
fn conditional_enforce_equal_or<CS: ConstraintSystem<F>>(
cs: CS,
cond: &Boolean,
var: &Self,
first: &Self,
second: &Self,
should_enforce: &Boolean
) -> Result<(), SynthesisError>
fn cost() -> usize
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcepub fn equivalent(&self, key: &K) -> bool
pub fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<F, T> OrEqualsGadget<F> for T where
F: Field,
T: ConditionalOrEqualsGadget<F>,
impl<F, T> OrEqualsGadget<F> for T where
F: Field,
T: ConditionalOrEqualsGadget<F>,
fn enforce_equal_or<CS: ConstraintSystem<F>>(
cs: CS,
cond: &Boolean,
var: &Self,
first: &Self,
second: &Self
) -> Result<(), SynthesisError>
fn cost() -> usize
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more