Rename to "Input"/"InputMap"

This commit is contained in:
Sean Bowe 2017-04-04 14:24:49 -06:00
parent c9fbf490dc
commit d228257da6
3 changed files with 13 additions and 13 deletions

View File

@ -307,7 +307,7 @@ pub fn prepare_verifying_key<E: Engine>(
}
}
pub fn verify<E: Engine, C: Witness<E>, F: FnOnce(&mut ConstraintSystem<E>) -> C>(
pub fn verify<E: Engine, C: Input<E>, F: FnOnce(&mut ConstraintSystem<E>) -> C>(
e: &E,
circuit: F,
proof: &Proof<E>,

View File

@ -6,12 +6,12 @@ struct RootCircuit<E: Engine> {
}
impl<E: Engine> Circuit<E> for RootCircuit<E> {
type WitnessMap = RootWitness<E>;
type InputMap = RootInput<E>;
fn synthesize<CS: ConstraintSystem<E>>(self,
e: &E,
cs: &mut CS)
-> Self::WitnessMap
-> Self::InputMap
{
let root_var = cs.alloc(self.root);
@ -31,19 +31,19 @@ impl<E: Engine> Circuit<E> for RootCircuit<E> {
cur = new;
}
RootWitness {
RootInput {
num: cur_val,
num_var: cur
}
}
}
struct RootWitness<E: Engine> {
struct RootInput<E: Engine> {
num: E::Fr,
num_var: Variable
}
impl<E: Engine> Witness<E> for RootWitness<E> {
impl<E: Engine> Input<E> for RootInput<E> {
fn synthesize<CS: PublicConstraintSystem<E>>(
self,
e: &E,
@ -96,7 +96,7 @@ fn test_snark_system<E: Engine, R: Rng>(
// verify proof
assert!(verify(e, |cs| {
RootWitness {
RootInput {
num: E::Fr::from_str(e, "1267650600228229401496703205376").unwrap(),
num_var: cs.alloc(E::Fr::one(e))
}
@ -104,7 +104,7 @@ fn test_snark_system<E: Engine, R: Rng>(
// verify invalid proof
assert!(!verify(e, |cs| {
RootWitness {
RootInput {
num: E::Fr::from_str(e, "1267650600228229401496703205375").unwrap(),
num_var: cs.alloc(E::Fr::one(e))
}
@ -181,7 +181,7 @@ fn test_snark_system<E: Engine, R: Rng>(
// verify fake proof
assert!(verify(e, |cs| {
RootWitness {
RootInput {
num: E::Fr::from_str(e, "100").unwrap(),
num_var: cs.alloc(E::Fr::one(e))
}
@ -189,7 +189,7 @@ fn test_snark_system<E: Engine, R: Rng>(
// verify fake proof with wrong input
assert!(!verify(e, |cs| {
RootWitness {
RootInput {
num: E::Fr::from_str(e, "101").unwrap(),
num_var: cs.alloc(E::Fr::one(e))
}

View File

@ -118,14 +118,14 @@ impl<'a, E: Engine> LinearCombination<'a, E> {
}
pub trait Circuit<E: Engine> {
type WitnessMap: Witness<E>;
type InputMap: Input<E>;
/// Synthesize the circuit into a rank-1 quadratic constraint system
#[must_use]
fn synthesize<CS: ConstraintSystem<E>>(self, engine: &E, cs: &mut CS) -> Self::WitnessMap;
fn synthesize<CS: ConstraintSystem<E>>(self, engine: &E, cs: &mut CS) -> Self::InputMap;
}
pub trait Witness<E: Engine> {
pub trait Input<E: Engine> {
/// Synthesize the circuit, except with additional access to public input
/// variables
fn synthesize<CS: PublicConstraintSystem<E>>(self, engine: &E, cs: &mut CS);