pub struct Boolean<E>(/* private fields */)
where
E: Environment;
Implementations§
Source§impl<E> Boolean<E>where
E: Environment,
impl<E> Boolean<E>where
E: Environment,
Sourcepub fn from_variable(var: Variable<<E as Environment>::BaseField>) -> Boolean<E>
pub fn from_variable(var: Variable<<E as Environment>::BaseField>) -> Boolean<E>
Initializes a boolean from a variable.
Note: This method does not check the booleanity of the variable.
Methods from Deref<Target = LinearCombination<<E as Environment>::BaseField>>§
Sourcepub fn is_constant(&self) -> bool
pub fn is_constant(&self) -> bool
Returns true
if there are no terms in the linear combination.
Sourcepub fn is_public(&self) -> bool
pub fn is_public(&self) -> bool
Returns true
if there is exactly one term with a coefficient of one,
and the term contains a public variable.
Sourcepub fn is_private(&self) -> bool
pub fn is_private(&self) -> bool
Returns true
if the linear combination is not constant or public.
Sourcepub fn is_boolean_type(&self) -> bool
pub fn is_boolean_type(&self) -> bool
Returns true
if the linear combination represents a Boolean
type,
and is well-formed.
Properties:
- Either
constant
orterms
is utilized, however never both. - Every individual variable in the linear combination must always be either
0
or1
. - The value of the linear combination must always be either
0
or1
.
Trait Implementations§
Source§impl<E> Adder for Boolean<E>where
E: Environment,
impl<E> Adder for Boolean<E>where
E: Environment,
Source§impl<E> BitAnd for Boolean<E>where
E: Environment,
impl<E> BitAnd for Boolean<E>where
E: Environment,
Source§impl<E> BitAndAssign<&Boolean<E>> for Boolean<E>where
E: Environment,
impl<E> BitAndAssign<&Boolean<E>> for Boolean<E>where
E: Environment,
Source§fn bitand_assign(&mut self, other: &Boolean<E>)
fn bitand_assign(&mut self, other: &Boolean<E>)
Sets self
as (self AND other)
.
Source§impl<E> BitAndAssign for Boolean<E>where
E: Environment,
impl<E> BitAndAssign for Boolean<E>where
E: Environment,
Source§fn bitand_assign(&mut self, other: Boolean<E>)
fn bitand_assign(&mut self, other: Boolean<E>)
Sets self
as (self AND other)
.
Source§impl<E> BitOr for Boolean<E>where
E: Environment,
impl<E> BitOr for Boolean<E>where
E: Environment,
Source§impl<E> BitOrAssign<&Boolean<E>> for Boolean<E>where
E: Environment,
impl<E> BitOrAssign<&Boolean<E>> for Boolean<E>where
E: Environment,
Source§fn bitor_assign(&mut self, other: &Boolean<E>)
fn bitor_assign(&mut self, other: &Boolean<E>)
Sets self
as (self OR other)
.
Source§impl<E> BitOrAssign for Boolean<E>where
E: Environment,
impl<E> BitOrAssign for Boolean<E>where
E: Environment,
Source§fn bitor_assign(&mut self, other: Boolean<E>)
fn bitor_assign(&mut self, other: Boolean<E>)
Sets self
as (self OR other)
.
Source§impl<E> BitXor for Boolean<E>where
E: Environment,
impl<E> BitXor for Boolean<E>where
E: Environment,
Source§impl<E> BitXorAssign<&Boolean<E>> for Boolean<E>where
E: Environment,
impl<E> BitXorAssign<&Boolean<E>> for Boolean<E>where
E: Environment,
Source§fn bitxor_assign(&mut self, other: &Boolean<E>)
fn bitxor_assign(&mut self, other: &Boolean<E>)
Sets self
as (self != other)
.
Source§impl<E> BitXorAssign for Boolean<E>where
E: Environment,
impl<E> BitXorAssign for Boolean<E>where
E: Environment,
Source§fn bitxor_assign(&mut self, other: Boolean<E>)
fn bitxor_assign(&mut self, other: Boolean<E>)
Sets self
as (self != other)
.
Source§impl<E, I> Cast<Boolean<E>> for Integer<E, I>where
E: Environment,
I: IntegerType,
impl<E, I> Cast<Boolean<E>> for Integer<E, I>where
E: Environment,
I: IntegerType,
Source§impl<E, I> Cast<Integer<E, I>> for Boolean<E>where
E: Environment,
I: IntegerType,
impl<E, I> Cast<Integer<E, I>> for Boolean<E>where
E: Environment,
I: IntegerType,
Source§impl<E> Cast for Boolean<E>where
E: Environment,
impl<E> Cast for Boolean<E>where
E: Environment,
Source§impl<E> CastLossy<Address<E>> for Boolean<E>where
E: Environment,
impl<E> CastLossy<Address<E>> for Boolean<E>where
E: Environment,
Source§fn cast_lossy(&self) -> Address<E>
fn cast_lossy(&self) -> Address<E>
Casts a Boolean
to an Address
.
This is safe because casting from a boolean to any other type is always lossless.
If the boolean is true, the address is the generator of the prime-order subgroup. If the boolean is false, the address is the zero group element.
Source§impl<E> CastLossy<Boolean<E>> for Field<E>where
E: Environment,
impl<E> CastLossy<Boolean<E>> for Field<E>where
E: Environment,
Source§fn cast_lossy(&self) -> Boolean<E>
fn cast_lossy(&self) -> Boolean<E>
Casts a Field
to a Boolean
, with lossy truncation.
This operation returns the least significant bit of the field.
Source§impl<E, I> CastLossy<Boolean<E>> for Integer<E, I>where
E: Environment,
I: IntegerType,
impl<E, I> CastLossy<Boolean<E>> for Integer<E, I>where
E: Environment,
I: IntegerType,
Source§fn cast_lossy(&self) -> Boolean<E>
fn cast_lossy(&self) -> Boolean<E>
Casts an Integer
to a Boolean
, with lossy truncation.
This operation returns the least significant bit of the field.
Source§impl<E> CastLossy<Boolean<E>> for Scalar<E>where
E: Environment,
impl<E> CastLossy<Boolean<E>> for Scalar<E>where
E: Environment,
Source§fn cast_lossy(&self) -> Boolean<E>
fn cast_lossy(&self) -> Boolean<E>
Casts a Scalar
to a Boolean
, with lossy truncation.
This operation returns the least significant bit of the scalar.
Source§impl<E> CastLossy<Field<E>> for Boolean<E>where
E: Environment,
impl<E> CastLossy<Field<E>> for Boolean<E>where
E: Environment,
Source§fn cast_lossy(&self) -> Field<E>
fn cast_lossy(&self) -> Field<E>
Casts a Boolean
to a Field
.
This is safe because casting from a boolean to any other type is always lossless.
Source§impl<E> CastLossy<Group<E>> for Boolean<E>where
E: Environment,
impl<E> CastLossy<Group<E>> for Boolean<E>where
E: Environment,
Source§fn cast_lossy(&self) -> Group<E>
fn cast_lossy(&self) -> Group<E>
Casts a Boolean
to a Group
.
This is safe because casting from a boolean to any other type is always lossless.
If the boolean is true, the group element is the generator of the prime-order subgroup. If the boolean is false, the group element is the zero group element.
Source§impl<E, I> CastLossy<Integer<E, I>> for Boolean<E>where
E: Environment,
I: IntegerType,
impl<E, I> CastLossy<Integer<E, I>> for Boolean<E>where
E: Environment,
I: IntegerType,
Source§fn cast_lossy(&self) -> Integer<E, I>
fn cast_lossy(&self) -> Integer<E, I>
Casts a Boolean
to an Integer
.
Source§impl<E> CastLossy<Scalar<E>> for Boolean<E>where
E: Environment,
impl<E> CastLossy<Scalar<E>> for Boolean<E>where
E: Environment,
Source§fn cast_lossy(&self) -> Scalar<E>
fn cast_lossy(&self) -> Scalar<E>
Casts a Boolean
to a Scalar
.
This is safe because casting from a boolean to any other type is always lossless.
Source§impl<E> CastLossy for Boolean<E>where
E: Environment,
impl<E> CastLossy for Boolean<E>where
E: Environment,
Source§fn cast_lossy(&self) -> Boolean<E>
fn cast_lossy(&self) -> Boolean<E>
Casts a Boolean
to a Boolean
.
This is an identity cast, so it is always lossless.
Source§impl<E> Debug for Boolean<E>where
E: Environment,
impl<E> Debug for Boolean<E>where
E: Environment,
Source§impl<E> Deref for Boolean<E>where
E: Environment,
impl<E> Deref for Boolean<E>where
E: Environment,
Source§impl<E> Display for Boolean<E>where
E: Environment,
impl<E> Display for Boolean<E>where
E: Environment,
Source§impl<E> Eject for Boolean<E>where
E: Environment,
impl<E> Eject for Boolean<E>where
E: Environment,
Source§fn eject_mode(&self) -> Mode
fn eject_mode(&self) -> Mode
Ejects the mode of the boolean.
Source§fn eject_value(&self) -> <Boolean<E> as Eject>::Primitive
fn eject_value(&self) -> <Boolean<E> as Eject>::Primitive
Ejects the boolean as a constant boolean value.
type Primitive = bool
Source§fn eject(&self) -> (Mode, Self::Primitive)
fn eject(&self) -> (Mode, Self::Primitive)
Source§fn is_constant(&self) -> bool
fn is_constant(&self) -> bool
true
if the circuit is a constant.Source§fn is_private(&self) -> bool
fn is_private(&self) -> bool
true
if the circuit is a private.Source§impl<E> Equal for Boolean<E>where
E: Environment,
impl<E> Equal for Boolean<E>where
E: Environment,
Source§impl<E> From<&Boolean<E>> for LinearCombination<<E as Environment>::BaseField>where
E: Environment,
impl<E> From<&Boolean<E>> for LinearCombination<<E as Environment>::BaseField>where
E: Environment,
Source§fn from(
boolean: &Boolean<E>,
) -> LinearCombination<<E as Environment>::BaseField>
fn from( boolean: &Boolean<E>, ) -> LinearCombination<<E as Environment>::BaseField>
Source§impl<E> From<Boolean<E>> for LinearCombination<<E as Environment>::BaseField>where
E: Environment,
impl<E> From<Boolean<E>> for LinearCombination<<E as Environment>::BaseField>where
E: Environment,
Source§fn from(boolean: Boolean<E>) -> LinearCombination<<E as Environment>::BaseField>
fn from(boolean: Boolean<E>) -> LinearCombination<<E as Environment>::BaseField>
Source§impl<E> FromBits for Boolean<E>where
E: Environment,
impl<E> FromBits for Boolean<E>where
E: Environment,
Source§fn from_bits_le(bits_le: &[<Boolean<E> as FromBits>::Boolean]) -> Boolean<E>
fn from_bits_le(bits_le: &[<Boolean<E> as FromBits>::Boolean]) -> Boolean<E>
Returns a boolean circuit given a mode and single boolean.
Source§fn from_bits_be(bits_be: &[<Boolean<E> as FromBits>::Boolean]) -> Boolean<E>
fn from_bits_be(bits_be: &[<Boolean<E> as FromBits>::Boolean]) -> Boolean<E>
Returns a boolean circuit given a mode and single boolean.
type Boolean = Boolean<E>
Source§impl<E> FromStr for Boolean<E>where
E: Environment,
impl<E> FromStr for Boolean<E>where
E: Environment,
Source§impl<E> Inject for Boolean<E>where
E: Environment,
impl<E> Inject for Boolean<E>where
E: Environment,
Source§fn new(mode: Mode, value: <Boolean<E> as Inject>::Primitive) -> Boolean<E>
fn new(mode: Mode, value: <Boolean<E> as Inject>::Primitive) -> Boolean<E>
Initializes a new instance of a boolean from a primitive boolean value.
Source§fn constant(value: <Boolean<E> as Inject>::Primitive) -> Boolean<E>
fn constant(value: <Boolean<E> as Inject>::Primitive) -> Boolean<E>
Initializes a constant boolean circuit from a primitive boolean value.
type Primitive = bool
Source§impl<E> Metrics<dyn Nor<Boolean<E>, Output = Boolean<E>>> for Boolean<E>where
E: Environment,
impl<E> Metrics<dyn Nor<Boolean<E>, Output = Boolean<E>>> for Boolean<E>where
E: Environment,
Source§impl<E> Nand for Boolean<E>where
E: Environment,
impl<E> Nand for Boolean<E>where
E: Environment,
Source§impl<E> Nor for Boolean<E>where
E: Environment,
impl<E> Nor for Boolean<E>where
E: Environment,
Source§impl<E> Not for &Boolean<E>where
E: Environment,
impl<E> Not for &Boolean<E>where
E: Environment,
Source§impl<E> Not for Boolean<E>where
E: Environment,
impl<E> Not for Boolean<E>where
E: Environment,
Source§impl<E> OutputMode<dyn Nor<Boolean<E>, Output = Boolean<E>>> for Boolean<E>where
E: Environment,
impl<E> OutputMode<dyn Nor<Boolean<E>, Output = Boolean<E>>> for Boolean<E>where
E: Environment,
type Case = (CircuitType<Boolean<E>>, CircuitType<Boolean<E>>)
Source§fn output_mode(
case: &<Boolean<E> as OutputMode<dyn Nor<Boolean<E>, Output = Boolean<E>>>>::Case,
) -> Mode
fn output_mode( case: &<Boolean<E> as OutputMode<dyn Nor<Boolean<E>, Output = Boolean<E>>>>::Case, ) -> Mode
Source§impl<E> OutputMode<dyn Not<Output = Boolean<E>>> for Boolean<E>where
E: Environment,
impl<E> OutputMode<dyn Not<Output = Boolean<E>>> for Boolean<E>where
E: Environment,
Source§impl<E> Parser for Boolean<E>where
E: Environment,
impl<E> Parser for Boolean<E>where
E: Environment,
Source§impl<E> Subtractor for Boolean<E>where
E: Environment,
impl<E> Subtractor for Boolean<E>where
E: Environment,
Source§fn subtractor(
&self,
other: &Boolean<E>,
borrow: &Boolean<E>,
) -> (<Boolean<E> as Subtractor>::Difference, <Boolean<E> as Subtractor>::Borrow)
fn subtractor( &self, other: &Boolean<E>, borrow: &Boolean<E>, ) -> (<Boolean<E> as Subtractor>::Difference, <Boolean<E> as Subtractor>::Borrow)
Returns the difference of self
and other
as a difference bit and borrow bit.
type Borrow = Boolean<E>
type Difference = Boolean<E>
Source§impl<E> Ternary for Boolean<E>where
E: Environment,
impl<E> Ternary for Boolean<E>where
E: Environment,
Source§impl<E> ToBits for &Boolean<E>where
E: Environment,
impl<E> ToBits for &Boolean<E>where
E: Environment,
Source§fn write_bits_le(&self, vec: &mut Vec<<&Boolean<E> as ToBits>::Boolean>)
fn write_bits_le(&self, vec: &mut Vec<<&Boolean<E> as ToBits>::Boolean>)
Outputs self
as a single-element vector.
Source§fn write_bits_be(&self, vec: &mut Vec<<&Boolean<E> as ToBits>::Boolean>)
fn write_bits_be(&self, vec: &mut Vec<<&Boolean<E> as ToBits>::Boolean>)
Outputs self
as a single-element vector.
type Boolean = Boolean<E>
Source§fn to_bits_le(&self) -> Vec<Self::Boolean>
fn to_bits_le(&self) -> Vec<Self::Boolean>
Source§fn to_bits_be(&self) -> Vec<Self::Boolean>
fn to_bits_be(&self) -> Vec<Self::Boolean>
Source§impl<E> ToBits for Boolean<E>where
E: Environment,
impl<E> ToBits for Boolean<E>where
E: Environment,
Source§fn write_bits_le(&self, vec: &mut Vec<<Boolean<E> as ToBits>::Boolean>)
fn write_bits_le(&self, vec: &mut Vec<<Boolean<E> as ToBits>::Boolean>)
Outputs self
as a single-element vector.
Source§fn write_bits_be(&self, vec: &mut Vec<<Boolean<E> as ToBits>::Boolean>)
fn write_bits_be(&self, vec: &mut Vec<<Boolean<E> as ToBits>::Boolean>)
Outputs self
as a single-element vector.
type Boolean = Boolean<E>
Source§fn to_bits_le(&self) -> Vec<Self::Boolean>
fn to_bits_le(&self) -> Vec<Self::Boolean>
Source§fn to_bits_be(&self) -> Vec<Self::Boolean>
fn to_bits_be(&self) -> Vec<Self::Boolean>
Source§impl<E> TypeName for Boolean<E>where
E: Environment,
impl<E> TypeName for Boolean<E>where
E: Environment,
impl<E> BooleanTrait for Boolean<E>where
E: Environment,
Auto Trait Implementations§
impl<E> Freeze for Boolean<E>
impl<E> RefUnwindSafe for Boolean<E>
impl<E> Send for Boolean<E>
impl<E> Sync for Boolean<E>
impl<E> Unpin for Boolean<E>
impl<E> UnwindSafe for Boolean<E>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more