Struct kimchi::snarky::boolean::Boolean

source ·
pub struct Boolean<F: PrimeField>(_);
Expand description

A boolean variable.

Implementations§

source§

impl<F> Boolean<F>where F: PrimeField,

source

pub fn true_() -> Self

source

pub fn false_() -> Self

source

pub fn create_unsafe(x: FieldVar<F>) -> Self

source

pub fn to_field_var(&self) -> FieldVar<F>

source

pub fn not(&self) -> Self

source

pub fn and( &self, other: &Self, cs: &mut RunState<F>, loc: Cow<'static, str> ) -> Self

source

pub fn or( &self, other: &Self, loc: Cow<'static, str>, cs: &mut RunState<F> ) -> Self

source

pub fn any( xs: &[&Self], cs: &mut RunState<F>, loc: Cow<'static, str> ) -> SnarkyResult<Self>

source

pub fn all( xs: &[Self], cs: &mut RunState<F>, loc: Cow<'static, str> ) -> SnarkyResult<Self>

source

pub fn to_constant(&self) -> Option<bool>

source

pub fn xor( &self, other: &Self, state: &mut RunState<F>, loc: Cow<'static, str> ) -> SnarkyResult<Self>

Trait Implementations§

source§

impl<F: Clone + PrimeField> Clone for Boolean<F>

source§

fn clone(&self) -> Boolean<F>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<F: Debug + PrimeField> Debug for Boolean<F>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<F> SnarkyType<F> for Boolean<F>where F: PrimeField,

§

type Auxiliary = ()

Some ‘out-of-circuit’ data, which is carried as part of Self. This data isn’t encoded as CVars in the circuit, since the data may be large (e.g. a sparse merkle tree), or may only be used by witness computations / for debugging.
§

type OutOfCircuit = bool

The equivalent “out-of-circuit” type. For example, the super::boolean::Boolean snarky type has an out-of-circuit type of bool.
source§

const SIZE_IN_FIELD_ELEMENTS: usize = 1usize

The number of field elements that this type takes.
source§

fn to_cvars(&self) -> (Vec<FieldVar<F>>, Self::Auxiliary)

Returns the circuit variables (and auxiliary data) behind this type.
source§

fn from_cvars_unsafe(cvars: Vec<FieldVar<F>>, _aux: Self::Auxiliary) -> Self

Creates a new instance of this type from the given circuit variables (And some auxiliary data).
source§

fn check( &self, cs: &mut RunState<F>, loc: Cow<'static, str> ) -> SnarkyResult<()>

Checks that the circuit variables behind this type are valid. For some definition of valid. For example, a Boolean snarky type would check that the field element representing it is either 0 or 1. The function does this by adding constraints to your constraint system.
source§

fn constraint_system_auxiliary() -> Self::Auxiliary

The “default” value of Self::Auxiliary. This is passed to Self::from_cvars_unsafe when we are not generating a witness, since we have no candidate value to get the auxiliary data from. Note that we use an explicit value here rather than Auxiliary: Default, since the default value for the type may not match the default value we actually want to pass!
source§

fn value_to_field_elements( value: &Self::OutOfCircuit ) -> (Vec<F>, Self::Auxiliary)

Converts an out-of-circuit value
source§

fn value_of_field_elements( fields: Vec<F>, _aux: Self::Auxiliary ) -> Self::OutOfCircuit

source§

fn compute<FUNC>( cs: &mut RunState<F>, loc: Cow<'static, str>, to_compute_value: FUNC ) -> SnarkyResult<Self>where FUNC: Fn(&dyn WitnessGeneration<F>) -> Self::OutOfCircuit,

source§

fn read<G>(&self, g: G) -> Self::OutOfCircuitwhere G: WitnessGeneration<F>,

Auto Trait Implementations§

§

impl<F> RefUnwindSafe for Boolean<F>where F: RefUnwindSafe,

§

impl<F> Send for Boolean<F>

§

impl<F> Sync for Boolean<F>

§

impl<F> Unpin for Boolean<F>where F: Unpin,

§

impl<F> UnwindSafe for Boolean<F>where F: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V