Minor cleanups

This commit is contained in:
therealyingtong 2020-09-06 06:34:29 +08:00
parent 965362c1f5
commit 503939db05
No known key found for this signature in database
GPG Key ID: 179F32A1503D607E
3 changed files with 12 additions and 14 deletions

View File

@ -213,14 +213,14 @@ fn test_proving() {
Variable(self.config.c, index), Variable(self.config.c, index),
)) ))
} }
fn copy(&mut self, a: Variable, b: Variable) -> Result<(), Error> { fn copy(&mut self, left: Variable, right: Variable) -> Result<(), Error> {
let left_wire = match a.0 { let left_wire = match left.0 {
x if x == self.config.a => 0, x if x == self.config.a => 0,
x if x == self.config.b => 1, x if x == self.config.b => 1,
x if x == self.config.c => 2, x if x == self.config.c => 2,
_ => unreachable!(), _ => unreachable!(),
}; };
let right_wire = match b.0 { let right_wire = match right.0 {
x if x == self.config.a => 0, x if x == self.config.a => 0,
x if x == self.config.b => 1, x if x == self.config.b => 1,
x if x == self.config.c => 2, x if x == self.config.c => 2,
@ -228,7 +228,7 @@ fn test_proving() {
}; };
self.cs self.cs
.copy(self.config.perm, left_wire, a.1, right_wire, b.1) .copy(self.config.perm, left_wire, left.1, right_wire, right.1)
} }
} }

View File

@ -156,8 +156,8 @@ impl<C: CurveAffine> Proof<C> {
.iter_mut() .iter_mut()
.zip(permuted_wire_values.iter()) .zip(permuted_wire_values.iter())
{ {
*tmp_advice_value += &(x_0 * permuted_advice_value); *tmp_advice_value += &(x_0 * permuted_advice_value); // p_j(\omega^i) + \beta s_j(\omega^i)
*tmp_advice_value += &x_1; *tmp_advice_value += &x_1; // p_j(\omega^i) + \beta s_j(\omega^i) + \gamma
} }
modified_advice.push(tmp_advice_values); modified_advice.push(tmp_advice_values);
} }
@ -175,15 +175,13 @@ impl<C: CurveAffine> Proof<C> {
// For each row i, we compute // For each row i, we compute
// p_j(\omega^i) + \delta^j \omega^i \beta + \gamma // p_j(\omega^i) + \delta^j \omega^i \beta + \gamma
// for the jth wire of the permutation // for the jth wire of the permutation
for (advice_value, modified_advice) in witness.advice[wire.0] for (tmp_advice_value, modified_advice) in witness.advice[wire.0]
.iter_mut() .iter_mut()
.zip(modified_advice.iter_mut()) .zip(modified_advice.iter_mut())
{ {
let mut tmp = deltaomega; // \delta^j \omega^i *tmp_advice_value += &(deltaomega * &x_0); // p_j(\omega^i) + \delta^j \omega^i \beta
tmp *= &x_0; // \delta^j \omega^i \beta *tmp_advice_value += &x_1; // p_j(\omega^i) + \delta^j \omega^i \beta + \gamma
tmp += &x_1; // \delta^j \omega^i \beta + \gamma *modified_advice *= tmp_advice_value;
tmp += advice_value; // p_j(\omega^i) + \delta^j \omega^i \beta + \gamma
*modified_advice *= &tmp;
deltaomega *= &domain.get_omega(); deltaomega *= &domain.get_omega();
} }
deltaomega *= &C::Scalar::DELTA; deltaomega *= &C::Scalar::DELTA;

View File

@ -157,7 +157,7 @@ impl<C: CurveAffine> SRS<C> {
// the permutation arguments. // the permutation arguments.
for permutation in &meta.permutations { for permutation in &meta.permutations {
let mut wires = vec![]; let mut wires = vec![];
for (i, _) in permutation.iter().enumerate() { for i in 0..permutation.len() {
// Computes [(i, 0), (i, 1), ..., (i, n - 1)] // Computes [(i, 0), (i, 1), ..., (i, n - 1)]
wires.push((0..params.n).map(|j| (i, j as usize)).collect()); wires.push((0..params.n).map(|j| (i, j as usize)).collect());
} }
@ -182,7 +182,7 @@ impl<C: CurveAffine> SRS<C> {
let mut inner_permutations = vec![]; let mut inner_permutations = vec![];
let mut polys = vec![]; let mut polys = vec![];
let mut cosets = vec![]; let mut cosets = vec![];
for (i, _) in permutation.iter().enumerate() { for i in 0..permutation.len() {
// Computes the permutation polynomial based on the permutation // Computes the permutation polynomial based on the permutation
// description in the assembly. // description in the assembly.
let permutation_poly: Vec<_> = (0..params.n as usize) let permutation_poly: Vec<_> = (0..params.n as usize)