mirror of
https://github.com/saymrwulf/pasta_curves-source.git
synced 2026-09-08 20:40:31 +00:00
Remove unnecessary parts from MockProver per review comments
This commit is contained in:
parent
49f1598c0e
commit
8590211585
2 changed files with 7 additions and 32 deletions
37
src/dev.rs
37
src/dev.rs
|
|
@ -5,12 +5,8 @@ use ff::Field;
|
||||||
use crate::{
|
use crate::{
|
||||||
arithmetic::{FieldExt, Group},
|
arithmetic::{FieldExt, Group},
|
||||||
plonk::{permutation, Any, Assignment, Circuit, Column, ConstraintSystem, Error},
|
plonk::{permutation, Any, Assignment, Circuit, Column, ConstraintSystem, Error},
|
||||||
poly::{EvaluationDomain, LagrangeCoeff, Polynomial},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
struct Cell(usize, usize);
|
|
||||||
|
|
||||||
/// The reasons why a particular circuit is not satisfied.
|
/// The reasons why a particular circuit is not satisfied.
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum VerifyFailure {
|
pub enum VerifyFailure {
|
||||||
|
|
@ -131,15 +127,14 @@ pub enum VerifyFailure {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct MockProver<F: Group> {
|
pub struct MockProver<F: Group> {
|
||||||
n: u32,
|
n: u32,
|
||||||
domain: EvaluationDomain<F>,
|
|
||||||
cs: ConstraintSystem<F>,
|
cs: ConstraintSystem<F>,
|
||||||
|
|
||||||
// The fixed cells in the circuit, arranged as [column][row].
|
// The fixed cells in the circuit, arranged as [column][row].
|
||||||
fixed: Vec<Polynomial<F, LagrangeCoeff>>,
|
fixed: Vec<Vec<F>>,
|
||||||
// The advice cells in the circuit, arranged as [column][row].
|
// The advice cells in the circuit, arranged as [column][row].
|
||||||
advice: Vec<Polynomial<F, LagrangeCoeff>>,
|
advice: Vec<Vec<F>>,
|
||||||
// The aux cells in the circuit, arranged as [column][row].
|
// The aux cells in the circuit, arranged as [column][row].
|
||||||
aux: Vec<Polynomial<F, LagrangeCoeff>>,
|
aux: Vec<Vec<F>>,
|
||||||
|
|
||||||
permutations: Vec<permutation::keygen::Assembly>,
|
permutations: Vec<permutation::keygen::Assembly>,
|
||||||
}
|
}
|
||||||
|
|
@ -198,32 +193,15 @@ impl<F: FieldExt> MockProver<F> {
|
||||||
pub fn run<ConcreteCircuit: Circuit<F>>(
|
pub fn run<ConcreteCircuit: Circuit<F>>(
|
||||||
k: u32,
|
k: u32,
|
||||||
circuit: &ConcreteCircuit,
|
circuit: &ConcreteCircuit,
|
||||||
aux: Vec<Polynomial<F, LagrangeCoeff>>,
|
aux: Vec<Vec<F>>,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
let n = 1 << k;
|
let n = 1 << k;
|
||||||
|
|
||||||
let mut cs = ConstraintSystem::default();
|
let mut cs = ConstraintSystem::default();
|
||||||
let config = ConcreteCircuit::configure(&mut cs);
|
let config = ConcreteCircuit::configure(&mut cs);
|
||||||
|
|
||||||
// The permutation argument will serve alongside the gates, so must be
|
let fixed = vec![vec![F::zero(); n as usize]; cs.num_fixed_columns];
|
||||||
// accounted for.
|
let advice = vec![vec![F::zero(); n as usize]; cs.num_advice_columns];
|
||||||
let mut degree = cs
|
|
||||||
.permutations
|
|
||||||
.iter()
|
|
||||||
.map(|p| p.required_degree())
|
|
||||||
.max()
|
|
||||||
.unwrap_or(1);
|
|
||||||
|
|
||||||
// Account for each gate to ensure our quotient polynomial is the
|
|
||||||
// correct degree and that our extended domain is the right size.
|
|
||||||
for poly in cs.gates.iter() {
|
|
||||||
degree = std::cmp::max(degree, poly.degree());
|
|
||||||
}
|
|
||||||
|
|
||||||
let domain = EvaluationDomain::new(degree as u32, k);
|
|
||||||
|
|
||||||
let fixed = vec![domain.empty_lagrange(); cs.num_fixed_columns];
|
|
||||||
let advice = vec![domain.empty_lagrange(); cs.num_advice_columns];
|
|
||||||
let permutations = cs
|
let permutations = cs
|
||||||
.permutations
|
.permutations
|
||||||
.iter()
|
.iter()
|
||||||
|
|
@ -232,7 +210,6 @@ impl<F: FieldExt> MockProver<F> {
|
||||||
|
|
||||||
let mut prover = MockProver {
|
let mut prover = MockProver {
|
||||||
n,
|
n,
|
||||||
domain,
|
|
||||||
cs,
|
cs,
|
||||||
fixed,
|
fixed,
|
||||||
advice,
|
advice,
|
||||||
|
|
@ -336,8 +313,6 @@ impl<F: FieldExt> MockProver<F> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Implement the rest of the verification checks.
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -464,7 +464,7 @@ fn test_proving() {
|
||||||
.to_affine();
|
.to_affine();
|
||||||
|
|
||||||
// Check this circuit is satisfied.
|
// Check this circuit is satisfied.
|
||||||
let prover = match MockProver::run(K, &circuit, vec![pubinputs.clone()]) {
|
let prover = match MockProver::run(K, &circuit, vec![pubinputs.to_vec()]) {
|
||||||
Ok(prover) => prover,
|
Ok(prover) => prover,
|
||||||
Err(e) => panic!("{:?}", e),
|
Err(e) => panic!("{:?}", e),
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue