Struct ark_r1cs_std::bits::uint128::UInt128
source · pub struct UInt128<F: Field> { /* private fields */ }Expand description
This struct represent an unsigned
128
bit integer as a sequence of
128
Booleans.
This is the R1CS equivalent of the native
u128
unsigned integer type.
Implementations§
source§impl<F: Field> UInt128<F>
impl<F: Field> UInt128<F>
sourcepub fn to_bits_le(&self) -> Vec<Boolean<F>> ⓘ
pub fn to_bits_le(&self) -> Vec<Boolean<F>> ⓘ
Turns self into the underlying little-endian bits.
sourcepub fn from_bits_le(bits: &[Boolean<F>]) -> Self
pub fn from_bits_le(bits: &[Boolean<F>]) -> Self
sourcepub fn xor(&self, other: &Self) -> Result<Self, SynthesisError>
pub fn xor(&self, other: &Self) -> Result<Self, SynthesisError>
Outputs self ^ other.
If at least one of self and other are constants, then this
method does not create any constraints or variables.
sourcepub fn addmany(operands: &[Self]) -> Result<Self, SynthesisError>where
F: PrimeField,
pub fn addmany(operands: &[Self]) -> Result<Self, SynthesisError>where
F: PrimeField,
Perform modular addition of operands.
The user must ensure that overflow does not occur.
Trait Implementations§
source§impl<ConstraintF: Field> AllocVar<u128, ConstraintF> for UInt128<ConstraintF>
impl<ConstraintF: Field> AllocVar<u128, ConstraintF> for UInt128<ConstraintF>
source§fn new_variable<T: Borrow<u128>>(
cs: impl Into<Namespace<ConstraintF>>,
f: impl FnOnce() -> Result<T, SynthesisError>,
mode: AllocationMode
) -> Result<Self, SynthesisError>
fn new_variable<T: Borrow<u128>>(
cs: impl Into<Namespace<ConstraintF>>,
f: impl FnOnce() -> Result<T, SynthesisError>,
mode: AllocationMode
) -> Result<Self, SynthesisError>
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>
fn new_constant(
cs: impl Into<Namespace<F>>,
t: impl Borrow<V>
) -> Result<Self, SynthesisError>
source§fn new_input<T: Borrow<V>>(
cs: impl Into<Namespace<F>>,
f: impl FnOnce() -> Result<T, SynthesisError>
) -> Result<Self, SynthesisError>
fn new_input<T: Borrow<V>>(
cs: impl Into<Namespace<F>>,
f: impl FnOnce() -> Result<T, SynthesisError>
) -> Result<Self, SynthesisError>
Allocates a new public input of type
Self in the ConstraintSystem
cs.source§fn new_witness<T: Borrow<V>>(
cs: impl Into<Namespace<F>>,
f: impl FnOnce() -> Result<T, SynthesisError>
) -> Result<Self, SynthesisError>
fn new_witness<T: Borrow<V>>(
cs: impl Into<Namespace<F>>,
f: impl FnOnce() -> Result<T, SynthesisError>
) -> Result<Self, SynthesisError>
Allocates a new private witness of type
Self in the ConstraintSystem
cs.source§impl<ConstraintF: Field> CondSelectGadget<ConstraintF> for UInt128<ConstraintF>
impl<ConstraintF: Field> CondSelectGadget<ConstraintF> for UInt128<ConstraintF>
source§fn conditionally_select(
cond: &Boolean<ConstraintF>,
true_value: &Self,
false_value: &Self
) -> Result<Self, SynthesisError>
fn conditionally_select(
cond: &Boolean<ConstraintF>,
true_value: &Self,
false_value: &Self
) -> Result<Self, SynthesisError>
source§fn conditionally_select_power_of_two_vector(
position: &[Boolean<ConstraintF>],
values: &[Self]
) -> Result<Self, SynthesisError>
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 moresource§impl<ConstraintF: Field> EqGadget<ConstraintF> for UInt128<ConstraintF>
impl<ConstraintF: Field> EqGadget<ConstraintF> for UInt128<ConstraintF>
source§fn is_eq(&self, other: &Self) -> Result<Boolean<ConstraintF>, SynthesisError>
fn is_eq(&self, other: &Self) -> Result<Boolean<ConstraintF>, SynthesisError>
Output a
Boolean value representing whether self.value() == other.value().source§fn conditional_enforce_equal(
&self,
other: &Self,
condition: &Boolean<ConstraintF>
) -> Result<(), SynthesisError>
fn conditional_enforce_equal(
&self,
other: &Self,
condition: &Boolean<ConstraintF>
) -> Result<(), SynthesisError>
If
should_enforce == true, enforce that self and other are equal;
else, enforce a vacuously true statement. Read moresource§fn conditional_enforce_not_equal(
&self,
other: &Self,
condition: &Boolean<ConstraintF>
) -> Result<(), SynthesisError>
fn conditional_enforce_not_equal(
&self,
other: &Self,
condition: &Boolean<ConstraintF>
) -> Result<(), SynthesisError>
If
should_enforce == true, enforce that self and other are not
equal; else, enforce a vacuously true statement. Read moresource§fn enforce_equal(&self, other: &Self) -> Result<(), SynthesisError>
fn enforce_equal(&self, other: &Self) -> Result<(), SynthesisError>
source§fn enforce_not_equal(&self, other: &Self) -> Result<(), SynthesisError>
fn enforce_not_equal(&self, other: &Self) -> Result<(), SynthesisError>
source§impl<F: Field> R1CSVar<F> for UInt128<F>
impl<F: Field> R1CSVar<F> for UInt128<F>
source§fn cs(&self) -> ConstraintSystemRef<F>
fn cs(&self) -> ConstraintSystemRef<F>
Returns the underlying
ConstraintSystemRef. Read moresource§fn value(&self) -> Result<Self::Value, SynthesisError>
fn value(&self) -> Result<Self::Value, SynthesisError>
Returns the value that is assigned to
self in the underlying
ConstraintSystem.source§fn is_constant(&self) -> bool
fn is_constant(&self) -> bool
Returns
true if self is a circuit-generation-time constant.