[−][src]Enum snarkvm_models::gadgets::utilities::boolean::Boolean
This is a boolean value which may be either a constant or
an interpretation of an AllocatedBit.
Variants
Is(AllocatedBit)Existential view of the boolean variable
Not(AllocatedBit)Negated view of the boolean variable
Constant(bool)Constant (not an allocated variable)
Implementations
impl Boolean[src]
pub fn get_value(&self) -> Option<bool>[src]
pub fn lc<F: Field>(&self, one: Variable, coeff: F) -> LinearCombination<F>[src]
pub fn constant_u8_vec<F: Field, CS: ConstraintSystem<F>>(
cs: &mut CS,
values: &[u8]
) -> Vec<Self>[src]
cs: &mut CS,
values: &[u8]
) -> Vec<Self>
Construct a boolean vector from a vector of u8
pub fn constant(b: bool) -> Self[src]
Construct a boolean from a known constant.
pub fn not(&self) -> Self[src]
Return a negated interpretation of this boolean.
pub fn xor<'a, F, CS>(
cs: CS,
a: &'a Self,
b: &'a Self
) -> Result<Self, SynthesisError> where
F: Field,
CS: ConstraintSystem<F>, [src]
cs: CS,
a: &'a Self,
b: &'a Self
) -> Result<Self, SynthesisError> where
F: Field,
CS: ConstraintSystem<F>,
Perform XOR over two boolean operands.
pub fn or<'a, F, CS>(
cs: CS,
a: &'a Self,
b: &'a Self
) -> Result<Self, SynthesisError> where
F: Field,
CS: ConstraintSystem<F>, [src]
cs: CS,
a: &'a Self,
b: &'a Self
) -> Result<Self, SynthesisError> where
F: Field,
CS: ConstraintSystem<F>,
Perform OR over two boolean operands.
pub fn and<'a, F: Field, CS: ConstraintSystem<F>>(
cs: CS,
a: &'a Self,
b: &'a Self
) -> Result<Self, SynthesisError>[src]
cs: CS,
a: &'a Self,
b: &'a Self
) -> Result<Self, SynthesisError>
Perform AND over two boolean operands.
pub fn kary_and<F, CS>(cs: CS, bits: &[Self]) -> Result<Self, SynthesisError> where
F: Field,
CS: ConstraintSystem<F>, [src]
F: Field,
CS: ConstraintSystem<F>,
Perform AND over all the given boolean operands.
pub fn enforce_nand<F, CS>(cs: CS, bits: &[Self]) -> Result<(), SynthesisError> where
F: Field,
CS: ConstraintSystem<F>, [src]
F: Field,
CS: ConstraintSystem<F>,
Asserts that at least one operand is false.
pub fn enforce_in_field<F, CS, NativeF: PrimeField>(
cs: CS,
bits: &[Self]
) -> Result<(), SynthesisError> where
F: Field,
CS: ConstraintSystem<F>, [src]
cs: CS,
bits: &[Self]
) -> Result<(), SynthesisError> where
F: Field,
CS: ConstraintSystem<F>,
Asserts that this bit_gadget representation is "in the field" when interpreted in big endian.
Trait Implementations
impl<F: Field> AllocGadget<bool, F> for Boolean[src]
pub fn alloc<Fn, T, CS: ConstraintSystem<F>>(
cs: CS,
value_gen: Fn
) -> Result<Self, SynthesisError> where
Fn: FnOnce() -> Result<T, SynthesisError>,
T: Borrow<bool>, [src]
cs: CS,
value_gen: Fn
) -> Result<Self, SynthesisError> where
Fn: FnOnce() -> Result<T, SynthesisError>,
T: Borrow<bool>,
pub fn alloc_input<Fn, T, CS: ConstraintSystem<F>>(
cs: CS,
value_gen: Fn
) -> Result<Self, SynthesisError> where
Fn: FnOnce() -> Result<T, SynthesisError>,
T: Borrow<bool>, [src]
cs: CS,
value_gen: Fn
) -> Result<Self, SynthesisError> where
Fn: FnOnce() -> Result<T, SynthesisError>,
T: Borrow<bool>,
pub fn alloc_checked<Fn: FnOnce() -> Result<T, SynthesisError>, T: Borrow<V>, CS: ConstraintSystem<F>>(
cs: CS,
f: Fn
) -> Result<Self, SynthesisError>[src]
cs: CS,
f: Fn
) -> Result<Self, SynthesisError>
pub fn alloc_input_checked<Fn: FnOnce() -> Result<T, SynthesisError>, T: Borrow<V>, CS: ConstraintSystem<F>>(
cs: CS,
f: Fn
) -> Result<Self, SynthesisError>[src]
cs: CS,
f: Fn
) -> Result<Self, SynthesisError>
impl Clone for Boolean[src]
impl<F: PrimeField> CondSelectGadget<F> for Boolean[src]
pub fn conditionally_select<CS>(
cs: CS,
cond: &Self,
first: &Self,
second: &Self
) -> Result<Self, SynthesisError> where
CS: ConstraintSystem<F>, [src]
cs: CS,
cond: &Self,
first: &Self,
second: &Self
) -> Result<Self, SynthesisError> where
CS: ConstraintSystem<F>,
pub fn cost() -> usize[src]
impl<F: Field> ConditionalEqGadget<F> for Boolean[src]
pub fn conditional_enforce_equal<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &Self,
condition: &Boolean
) -> Result<(), SynthesisError>[src]
&self,
cs: CS,
other: &Self,
condition: &Boolean
) -> Result<(), SynthesisError>
pub fn cost() -> usize[src]
impl Copy for Boolean[src]
impl Debug for Boolean[src]
impl Eq for Boolean[src]
impl<F: Field> EqGadget<F> for Boolean[src]
pub fn enforce_equal<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &Self
) -> Result<(), SynthesisError>[src]
&self,
cs: CS,
other: &Self
) -> Result<(), SynthesisError>
pub fn cost() -> usize[src]
impl<F: PrimeField> EvaluateEqGadget<F> for Boolean[src]
a == b = !(a XOR b)
pub fn evaluate_equal<CS: ConstraintSystem<F>>(
&self,
cs: CS,
other: &Self
) -> Result<Boolean, SynthesisError>[src]
&self,
cs: CS,
other: &Self
) -> Result<Boolean, SynthesisError>
impl From<AllocatedBit> for Boolean[src]
pub fn from(b: AllocatedBit) -> Boolean[src]
impl<'a, F: Field> FullAdder<'a, F> for Boolean[src]
pub fn add<CS: ConstraintSystem<F>>(
cs: CS,
a: &'a Self,
b: &'a Self,
carry: &'a Self
) -> Result<(Self, Self), SynthesisError>[src]
cs: CS,
a: &'a Self,
b: &'a Self,
carry: &'a Self
) -> Result<(Self, Self), SynthesisError>
impl PartialEq<Boolean> for Boolean[src]
pub fn eq(&self, other: &Self) -> bool[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool1.0.0[src]
impl<F: Field> ToBitsGadget<F> for Boolean[src]
pub fn to_bits<CS: ConstraintSystem<F>>(
&self,
_: CS
) -> Result<Vec<Boolean>, SynthesisError>[src]
&self,
_: CS
) -> Result<Vec<Boolean>, SynthesisError>
pub fn to_bits_strict<CS: ConstraintSystem<F>>(
&self,
_: CS
) -> Result<Vec<Boolean>, SynthesisError>[src]
&self,
_: CS
) -> Result<Vec<Boolean>, SynthesisError>
impl<F: Field> ToBytesGadget<F> for Boolean[src]
pub fn to_bytes<CS: ConstraintSystem<F>>(
&self,
_cs: CS
) -> Result<Vec<UInt8>, SynthesisError>[src]
&self,
_cs: CS
) -> Result<Vec<UInt8>, SynthesisError>
pub fn to_bytes_strict<CS: ConstraintSystem<F>>(
&self,
cs: CS
) -> Result<Vec<UInt8>, SynthesisError>[src]
&self,
cs: CS
) -> Result<Vec<UInt8>, SynthesisError>
Additionally checks if the produced list of booleans is 'valid'.
Auto Trait Implementations
impl RefUnwindSafe for Boolean[src]
impl Send for Boolean[src]
impl Sync for Boolean[src]
impl Unpin for Boolean[src]
impl UnwindSafe for Boolean[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<F, T> ConditionalOrEqualsGadget<F> for T where
F: Field,
T: ConditionalEqGadget<F> + CondSelectGadget<F>, [src]
F: Field,
T: ConditionalEqGadget<F> + CondSelectGadget<F>,
pub fn conditional_enforce_equal_or<CS>(
CS,
&Boolean,
&T,
&T,
&T,
&Boolean
) -> Result<(), SynthesisError> where
CS: ConstraintSystem<F>, [src]
CS,
&Boolean,
&T,
&T,
&T,
&Boolean
) -> Result<(), SynthesisError> where
CS: ConstraintSystem<F>,
pub fn cost() -> usize[src]
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized, [src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
pub fn equivalent(&self, key: &K) -> bool[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<F, T> OrEqualsGadget<F> for T where
F: Field,
T: ConditionalOrEqualsGadget<F>, [src]
F: Field,
T: ConditionalOrEqualsGadget<F>,
pub fn enforce_equal_or<CS>(
CS,
&Boolean,
&T,
&T,
&T
) -> Result<(), SynthesisError> where
CS: ConstraintSystem<F>, [src]
CS,
&Boolean,
&T,
&T,
&T
) -> Result<(), SynthesisError> where
CS: ConstraintSystem<F>,
pub fn cost() -> usize[src]
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,