pub trait FancyArithmetic: Fancy {
// Required methods
fn add(&mut self, x: &Self::Item, y: &Self::Item) -> Self::Item;
fn sub(&mut self, x: &Self::Item, y: &Self::Item) -> Self::Item;
fn cmul(&mut self, x: &Self::Item, c: u16) -> Self::Item;
fn mul(
&mut self,
x: &Self::Item,
y: &Self::Item,
channel: &mut Channel<'_>,
) -> Result<Self::Item>;
fn proj(
&mut self,
x: &Self::Item,
q: u16,
tt: Option<Vec<u16>>,
channel: &mut Channel<'_>,
) -> Result<Self::Item>;
// Provided methods
fn add_many(&mut self, args: &[Self::Item]) -> Self::Item { ... }
fn mod_change(
&mut self,
x: &Self::Item,
to_modulus: u16,
channel: &mut Channel<'_>,
) -> Result<Self::Item> { ... }
}Expand description
DSL for arithmetic computation.
Required Methods§
Sourcefn mul(
&mut self,
x: &Self::Item,
y: &Self::Item,
channel: &mut Channel<'_>,
) -> Result<Self::Item>
fn mul( &mut self, x: &Self::Item, y: &Self::Item, channel: &mut Channel<'_>, ) -> Result<Self::Item>
Multiply x and y.
Sourcefn proj(
&mut self,
x: &Self::Item,
q: u16,
tt: Option<Vec<u16>>,
channel: &mut Channel<'_>,
) -> Result<Self::Item>
fn proj( &mut self, x: &Self::Item, q: u16, tt: Option<Vec<u16>>, channel: &mut Channel<'_>, ) -> Result<Self::Item>
Project x according to the truth table tt. Resulting wire has modulus q.
Optional tt is useful for hiding the gate from the evaluator.
§Panics
This may panic in certain implementations if tt is None when it
should be Some. In addition, it may panic if tt is improperly
formed: either the length of tt is smaller than xs modulus, or the
values in tt are larger than q.
Provided Methods§
Sourcefn mod_change(
&mut self,
x: &Self::Item,
to_modulus: u16,
channel: &mut Channel<'_>,
) -> Result<Self::Item>
fn mod_change( &mut self, x: &Self::Item, to_modulus: u16, channel: &mut Channel<'_>, ) -> Result<Self::Item>
Change the modulus of x to to_modulus using a projection gate.