mirror of
https://github.com/saymrwulf/pasta_curves-source.git
synced 2026-09-05 20:10:32 +00:00
Relocate computation of the degree of the constraint system to the ConstraintSystem struct.
This commit is contained in:
parent
4e7d4a0f64
commit
d92b1c4fb9
2 changed files with 33 additions and 25 deletions
|
|
@ -753,4 +753,36 @@ impl<F: Field> ConstraintSystem<F> {
|
||||||
self.num_instance_columns += 1;
|
self.num_instance_columns += 1;
|
||||||
tmp
|
tmp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Compute the degree of the constraint system (the maximum degree of all
|
||||||
|
/// constraints).
|
||||||
|
pub fn degree(&self) -> usize {
|
||||||
|
// The permutation argument will serve alongside the gates, so must be
|
||||||
|
// accounted for.
|
||||||
|
let mut degree = self
|
||||||
|
.permutations
|
||||||
|
.iter()
|
||||||
|
.map(|p| p.required_degree())
|
||||||
|
.max()
|
||||||
|
.unwrap_or(1);
|
||||||
|
|
||||||
|
// The lookup argument also serves alongside the gates and must be accounted
|
||||||
|
// for.
|
||||||
|
degree = std::cmp::max(
|
||||||
|
degree,
|
||||||
|
self.lookups
|
||||||
|
.iter()
|
||||||
|
.map(|l| l.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 self.gates.iter() {
|
||||||
|
degree = std::cmp::max(degree, poly.degree());
|
||||||
|
}
|
||||||
|
|
||||||
|
degree
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,31 +25,7 @@ where
|
||||||
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 degree = cs.degree();
|
||||||
// accounted for.
|
|
||||||
let mut degree = cs
|
|
||||||
.permutations
|
|
||||||
.iter()
|
|
||||||
.map(|p| p.required_degree())
|
|
||||||
.max()
|
|
||||||
.unwrap_or(1);
|
|
||||||
|
|
||||||
// The lookup argument also serves alongside the gates and must be accounted
|
|
||||||
// for.
|
|
||||||
degree = std::cmp::max(
|
|
||||||
degree,
|
|
||||||
cs.lookups
|
|
||||||
.iter()
|
|
||||||
.map(|l| l.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, params.k);
|
let domain = EvaluationDomain::new(degree as u32, params.k);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue