mirror of
https://github.com/Qortal/pirate-librustzcash.git
synced 2025-11-02 12:27:02 +00:00
Rename to "Input"/"InputMap"
This commit is contained in:
@@ -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,
|
e: &E,
|
||||||
circuit: F,
|
circuit: F,
|
||||||
proof: &Proof<E>,
|
proof: &Proof<E>,
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ struct RootCircuit<E: Engine> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<E: Engine> Circuit<E> for RootCircuit<E> {
|
impl<E: Engine> Circuit<E> for RootCircuit<E> {
|
||||||
type WitnessMap = RootWitness<E>;
|
type InputMap = RootInput<E>;
|
||||||
|
|
||||||
fn synthesize<CS: ConstraintSystem<E>>(self,
|
fn synthesize<CS: ConstraintSystem<E>>(self,
|
||||||
e: &E,
|
e: &E,
|
||||||
cs: &mut CS)
|
cs: &mut CS)
|
||||||
-> Self::WitnessMap
|
-> Self::InputMap
|
||||||
{
|
{
|
||||||
let root_var = cs.alloc(self.root);
|
let root_var = cs.alloc(self.root);
|
||||||
|
|
||||||
@@ -31,19 +31,19 @@ impl<E: Engine> Circuit<E> for RootCircuit<E> {
|
|||||||
cur = new;
|
cur = new;
|
||||||
}
|
}
|
||||||
|
|
||||||
RootWitness {
|
RootInput {
|
||||||
num: cur_val,
|
num: cur_val,
|
||||||
num_var: cur
|
num_var: cur
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RootWitness<E: Engine> {
|
struct RootInput<E: Engine> {
|
||||||
num: E::Fr,
|
num: E::Fr,
|
||||||
num_var: Variable
|
num_var: Variable
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E: Engine> Witness<E> for RootWitness<E> {
|
impl<E: Engine> Input<E> for RootInput<E> {
|
||||||
fn synthesize<CS: PublicConstraintSystem<E>>(
|
fn synthesize<CS: PublicConstraintSystem<E>>(
|
||||||
self,
|
self,
|
||||||
e: &E,
|
e: &E,
|
||||||
@@ -96,7 +96,7 @@ fn test_snark_system<E: Engine, R: Rng>(
|
|||||||
|
|
||||||
// verify proof
|
// verify proof
|
||||||
assert!(verify(e, |cs| {
|
assert!(verify(e, |cs| {
|
||||||
RootWitness {
|
RootInput {
|
||||||
num: E::Fr::from_str(e, "1267650600228229401496703205376").unwrap(),
|
num: E::Fr::from_str(e, "1267650600228229401496703205376").unwrap(),
|
||||||
num_var: cs.alloc(E::Fr::one(e))
|
num_var: cs.alloc(E::Fr::one(e))
|
||||||
}
|
}
|
||||||
@@ -104,7 +104,7 @@ fn test_snark_system<E: Engine, R: Rng>(
|
|||||||
|
|
||||||
// verify invalid proof
|
// verify invalid proof
|
||||||
assert!(!verify(e, |cs| {
|
assert!(!verify(e, |cs| {
|
||||||
RootWitness {
|
RootInput {
|
||||||
num: E::Fr::from_str(e, "1267650600228229401496703205375").unwrap(),
|
num: E::Fr::from_str(e, "1267650600228229401496703205375").unwrap(),
|
||||||
num_var: cs.alloc(E::Fr::one(e))
|
num_var: cs.alloc(E::Fr::one(e))
|
||||||
}
|
}
|
||||||
@@ -181,7 +181,7 @@ fn test_snark_system<E: Engine, R: Rng>(
|
|||||||
|
|
||||||
// verify fake proof
|
// verify fake proof
|
||||||
assert!(verify(e, |cs| {
|
assert!(verify(e, |cs| {
|
||||||
RootWitness {
|
RootInput {
|
||||||
num: E::Fr::from_str(e, "100").unwrap(),
|
num: E::Fr::from_str(e, "100").unwrap(),
|
||||||
num_var: cs.alloc(E::Fr::one(e))
|
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
|
// verify fake proof with wrong input
|
||||||
assert!(!verify(e, |cs| {
|
assert!(!verify(e, |cs| {
|
||||||
RootWitness {
|
RootInput {
|
||||||
num: E::Fr::from_str(e, "101").unwrap(),
|
num: E::Fr::from_str(e, "101").unwrap(),
|
||||||
num_var: cs.alloc(E::Fr::one(e))
|
num_var: cs.alloc(E::Fr::one(e))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,14 +118,14 @@ impl<'a, E: Engine> LinearCombination<'a, E> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub trait Circuit<E: Engine> {
|
pub trait Circuit<E: Engine> {
|
||||||
type WitnessMap: Witness<E>;
|
type InputMap: Input<E>;
|
||||||
|
|
||||||
/// Synthesize the circuit into a rank-1 quadratic constraint system
|
/// Synthesize the circuit into a rank-1 quadratic constraint system
|
||||||
#[must_use]
|
#[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
|
/// Synthesize the circuit, except with additional access to public input
|
||||||
/// variables
|
/// variables
|
||||||
fn synthesize<CS: PublicConstraintSystem<E>>(self, engine: &E, cs: &mut CS);
|
fn synthesize<CS: PublicConstraintSystem<E>>(self, engine: &E, cs: &mut CS);
|
||||||
|
|||||||
Reference in New Issue
Block a user