pub trait CircuitExecutor<F: Fancy> {
// Required methods
fn execute(
&self,
backend: &mut F,
inputs: &[F::Item],
channel: &mut Channel<'_>,
) -> Result<Vec<F::Item>>;
fn ninputs(&self) -> usize;
fn modulus(&self, i: usize) -> u16;
}Expand description
Trait for executing computations directly over a Fancy object.
§Example
Below is a simple example of computing an add gate over an arbitrary
modulus. The computation is defined in execute by directly calling
operations on the underlying Fancy backend. We also need to track how
many inputs the computation takes, and the moduli of those inputs; these are
given in the ninputs and modulus methods, respectively.
struct AddCircuit(u16);
impl<F: FancyArithmetic> CircuitExecutor<F> for AddCircuit {
fn execute(
&self,
backend: &mut F,
inputs: &[F::Item],
channel: &mut Channel,
) -> Result<Vec<F::Item>> {
let output = backend.add(&inputs[0], &inputs[1]);
Ok(vec![output])
}
fn ninputs(&self) -> usize {
2
}
fn modulus(&self, _: usize) -> u16 {
2
}
}Required Methods§
Sourcefn execute(
&self,
backend: &mut F,
inputs: &[F::Item],
channel: &mut Channel<'_>,
) -> Result<Vec<F::Item>>
fn execute( &self, backend: &mut F, inputs: &[F::Item], channel: &mut Channel<'_>, ) -> Result<Vec<F::Item>>
Execute a circuit on a given Fancy backend using the provided inputs.
Sourcefn ninputs(&self) -> usize
fn ninputs(&self) -> usize
The number of inputs to provide to CircuitExecutor::execute.