Struct ark_r1cs_std::bits::boolean::AllocatedBool
source · pub struct AllocatedBool<F: Field> { /* private fields */ }
Expand description
Represents a variable in the constraint system which is guaranteed to be either zero or one.
In general, one should prefer using Boolean
instead of AllocatedBool
,
as Boolean
offers better support for constant values, and implements
more traits.
Implementations§
source§impl<F: Field> AllocatedBool<F>
impl<F: Field> AllocatedBool<F>
sourcepub fn value(&self) -> Result<bool, SynthesisError>
pub fn value(&self) -> Result<bool, SynthesisError>
Get the assigned value for self
.
sourcepub fn xor(&self, b: &Self) -> Result<Self, SynthesisError>
pub fn xor(&self, b: &Self) -> Result<Self, SynthesisError>
Performs an XOR operation over the two operands, returning
an AllocatedBool
.
sourcepub fn and(&self, b: &Self) -> Result<Self, SynthesisError>
pub fn and(&self, b: &Self) -> Result<Self, SynthesisError>
Performs an AND operation over the two operands, returning
an AllocatedBool
.
sourcepub fn or(&self, b: &Self) -> Result<Self, SynthesisError>
pub fn or(&self, b: &Self) -> Result<Self, SynthesisError>
Performs an OR operation over the two operands, returning
an AllocatedBool
.
sourcepub fn and_not(&self, b: &Self) -> Result<Self, SynthesisError>
pub fn and_not(&self, b: &Self) -> Result<Self, SynthesisError>
Calculates a AND (NOT b)
.
sourcepub fn nor(&self, b: &Self) -> Result<Self, SynthesisError>
pub fn nor(&self, b: &Self) -> Result<Self, SynthesisError>
Calculates (NOT a) AND (NOT b)
.
Trait Implementations§
source§impl<F: Field> AllocVar<bool, F> for AllocatedBool<F>
impl<F: Field> AllocVar<bool, F> for AllocatedBool<F>
source§fn new_variable<T: Borrow<bool>>(
cs: impl Into<Namespace<F>>,
f: impl FnOnce() -> Result<T, SynthesisError>,
mode: AllocationMode
) -> Result<Self, SynthesisError>
fn new_variable<T: Borrow<bool>>(
cs: impl Into<Namespace<F>>,
f: impl FnOnce() -> Result<T, SynthesisError>,
mode: AllocationMode
) -> Result<Self, SynthesisError>
Produces a new variable of the appropriate kind (instance or witness), with a booleanity check.
N.B.: we could omit the booleanity check when allocating self
as a new public input, but that places an additional burden on
protocol designers. Better safe than sorry!
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>
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>
Self
in the ConstraintSystem
cs
.source§impl<F: Clone + Field> Clone for AllocatedBool<F>
impl<F: Clone + Field> Clone for AllocatedBool<F>
source§fn clone(&self) -> AllocatedBool<F>
fn clone(&self) -> AllocatedBool<F>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<F: Field> CondSelectGadget<F> for AllocatedBool<F>
impl<F: Field> CondSelectGadget<F> for AllocatedBool<F>
source§fn conditionally_select(
cond: &Boolean<F>,
true_val: &Self,
false_val: &Self
) -> Result<Self, SynthesisError>
fn conditionally_select(
cond: &Boolean<F>,
true_val: &Self,
false_val: &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>
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<F: Field> From<AllocatedBool<F>> for Boolean<F>
impl<F: Field> From<AllocatedBool<F>> for Boolean<F>
source§fn from(b: AllocatedBool<F>) -> Self
fn from(b: AllocatedBool<F>) -> Self
source§impl<F: PartialEq + Field> PartialEq<AllocatedBool<F>> for AllocatedBool<F>
impl<F: PartialEq + Field> PartialEq<AllocatedBool<F>> for AllocatedBool<F>
source§fn eq(&self, other: &AllocatedBool<F>) -> bool
fn eq(&self, other: &AllocatedBool<F>) -> bool
self
and other
values to be equal, and is used
by ==
.