Rename to "Input"/"InputMap"
This commit is contained in:
parent
c9fbf490dc
commit
d228257da6
|
@ -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>,
|
||||
|
|
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue