Optimizations (#100)

* avoid creating commitments to zero vectors

* reduce the number of constraints in each iteration from 4 to 3
This commit is contained in:
Srinath Setty
2022-07-27 14:07:44 -07:00
committed by GitHub
parent 3dc26fd7e4
commit 06192ac3d4
6 changed files with 51 additions and 10 deletions

View File

@@ -124,14 +124,10 @@ where
x_i_plus_1.square(cs.namespace(|| format!("x_i_plus_1_sq_iter_{}", i)))?;
let x_i_plus_1_quad =
x_i_plus_1_sq.square(cs.namespace(|| format!("x_i_plus_1_quad_{}", i)))?;
let x_i_plus_1_pow_5 = x_i_plus_1_quad.mul(
cs.namespace(|| format!("x_i_plus_1_pow_5_{}", i)),
&x_i_plus_1,
)?;
cs.enforce(
|| format!("x_i_plus_1_pow_5 = x_i + y_i_iter_{}", i),
|lc| lc + x_i_plus_1_pow_5.get_variable(),
|lc| lc + CS::one(),
|| format!("x_i_plus_1_quad * x_i_plus_1 = x_i + y_i_iter_{}", i),
|lc| lc + x_i_plus_1_quad.get_variable(),
|lc| lc + x_i_plus_1.get_variable(),
|lc| lc + x_i.get_variable() + y_i.get_variable(),
);
@@ -211,6 +207,15 @@ fn main() {
pp.num_constraints().1
);
println!(
"Number of variables per step (primary circuit): {}",
pp.num_variables().0
);
println!(
"Number of variables per step (secondary circuit): {}",
pp.num_variables().1
);
// produce non-deterministic advice
let (z0_primary, minroot_iterations) = MinRootIteration::new(
num_iters_per_step * num_steps,