pub trait BinaryInstructions<F: CircuitField> {
// Required methods
fn and(
&self,
layouter: &mut impl Layouter<F>,
bits: &[AssignedBit<F>],
) -> Result<AssignedBit<F>, Error>;
fn or(
&self,
layouter: &mut impl Layouter<F>,
bits: &[AssignedBit<F>],
) -> Result<AssignedBit<F>, Error>;
fn xor(
&self,
layouter: &mut impl Layouter<F>,
bits: &[AssignedBit<F>],
) -> Result<AssignedBit<F>, Error>;
fn not(
&self,
layouter: &mut impl Layouter<F>,
bit: &AssignedBit<F>,
) -> Result<AssignedBit<F>, Error>;
}Expand description
The set of circuit instructions for binary operations.
Required Methods§
Sourcefn and(
&self,
layouter: &mut impl Layouter<F>,
bits: &[AssignedBit<F>],
) -> Result<AssignedBit<F>, Error>
fn and( &self, layouter: &mut impl Layouter<F>, bits: &[AssignedBit<F>], ) -> Result<AssignedBit<F>, Error>
Conjunction of the given assigned bits.
§Panics
If bits is empty.
let b0 = chip.assign(&mut layouter, Value::known(false))?;
let b1 = chip.assign(&mut layouter, Value::known(true))?;
let res = chip.and(&mut layouter, &[b0, b1])?;
chip.assert_equal_to_fixed(&mut layouter, &res, false)?;ⓘ
let res = chip.and(&mut layouter, &[])?;Sourcefn or(
&self,
layouter: &mut impl Layouter<F>,
bits: &[AssignedBit<F>],
) -> Result<AssignedBit<F>, Error>
fn or( &self, layouter: &mut impl Layouter<F>, bits: &[AssignedBit<F>], ) -> Result<AssignedBit<F>, Error>
Disjunction of the given assigned bits.
§Panics
If bits is empty.
let b0 = chip.assign(&mut layouter, Value::known(false))?;
let b1 = chip.assign(&mut layouter, Value::known(true))?;
let res = chip.or(&mut layouter, &[b0, b1])?;
chip.assert_equal_to_fixed(&mut layouter, &res, true)?;Sourcefn xor(
&self,
layouter: &mut impl Layouter<F>,
bits: &[AssignedBit<F>],
) -> Result<AssignedBit<F>, Error>
fn xor( &self, layouter: &mut impl Layouter<F>, bits: &[AssignedBit<F>], ) -> Result<AssignedBit<F>, Error>
Exclusive-OR of all the given assigned bits.
§Panics
If bits is empty.
let b0 = chip.assign(&mut layouter, Value::known(false))?;
let b1 = chip.assign(&mut layouter, Value::known(true))?;
let b2 = chip.assign(&mut layouter, Value::known(true))?;
let res = chip.xor(&mut layouter, &[b0, b1, b2])?;
chip.assert_equal_to_fixed(&mut layouter, &res, false)?;Sourcefn not(
&self,
layouter: &mut impl Layouter<F>,
bit: &AssignedBit<F>,
) -> Result<AssignedBit<F>, Error>
fn not( &self, layouter: &mut impl Layouter<F>, bit: &AssignedBit<F>, ) -> Result<AssignedBit<F>, Error>
Negation of the given assigned bit.
let b = chip.assign(&mut layouter, Value::known(false))?;
let res = chip.not(&mut layouter, &b)?;
chip.assert_equal_to_fixed(&mut layouter, &res, true)?;Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.