Trait fancy_garbling::FancyBinary
source · [−]pub trait FancyBinary: Fancy {
fn xor(
&mut self,
x: &Self::Item,
y: &Self::Item
) -> Result<Self::Item, Self::Error>;
fn and(
&mut self,
x: &Self::Item,
y: &Self::Item
) -> Result<Self::Item, Self::Error>;
fn negate(&mut self, x: &Self::Item) -> Result<Self::Item, Self::Error>;
fn or(
&mut self,
x: &Self::Item,
y: &Self::Item
) -> Result<Self::Item, Self::Error> { ... }
fn adder(
&mut self,
x: &Self::Item,
y: &Self::Item,
carry_in: Option<&Self::Item>
) -> Result<(Self::Item, Self::Item), Self::Error> { ... }
fn and_many(
&mut self,
args: &[Self::Item]
) -> Result<Self::Item, Self::Error> { ... }
fn or_many(&mut self, args: &[Self::Item]) -> Result<Self::Item, Self::Error> { ... }
fn xor_many(
&mut self,
args: &[Self::Item]
) -> Result<Self::Item, Self::Error> { ... }
fn mux_constant_bits(
&mut self,
x: &Self::Item,
b1: bool,
b2: bool
) -> Result<Self::Item, Self::Error> { ... }
fn mux(
&mut self,
b: &Self::Item,
x: &Self::Item,
y: &Self::Item
) -> Result<Self::Item, Self::Error> { ... }
}
Expand description
Fancy DSL providing binary operations
Required Methods
Binary Xor
Binary And
Provided Methods
Uses Demorgan’s Rule implemented with an and gate and negation.
Binary adder. Returns the result and the carry.
Returns 1 if all wires equal 1.
Returns 1 if any wire equals 1.
XOR many wires together
If x = 0
returns the constant b1
else return b2
. Folds constants if possible.