mirror of
https://github.com/saymrwulf/pasta_curves-source.git
synced 2026-09-04 20:03:39 +00:00
Refactor wire pattern matching when computing permutation product
This commit is contained in:
parent
24fe3fae29
commit
e8839a7579
1 changed files with 27 additions and 58 deletions
|
|
@ -171,34 +171,20 @@ impl<C: CurveAffine> Proof<C> {
|
||||||
|
|
||||||
// Iterate over each wire of the permutation
|
// Iterate over each wire of the permutation
|
||||||
for (&(wire, _), permuted_wire_values) in wires.iter().zip(permuted_values.iter()) {
|
for (&(wire, _), permuted_wire_values) in wires.iter().zip(permuted_values.iter()) {
|
||||||
match wire {
|
parallelize(&mut modified_advice, |modified_advice, start| {
|
||||||
Wire::Advice(wire) => {
|
for ((modified_advice, advice_value), permuted_advice_value) in modified_advice
|
||||||
parallelize(&mut modified_advice, |modified_advice, start| {
|
.iter_mut()
|
||||||
for ((modified_advice, advice_value), permuted_advice_value) in
|
.zip(match wire {
|
||||||
modified_advice
|
Wire::Advice(wire) => witness.advice[wire.0][start..].iter(),
|
||||||
.iter_mut()
|
Wire::Aux(wire) => aux_lagrange_polys[wire.0][start..].iter(),
|
||||||
.zip(witness.advice[wire.0][start..].iter())
|
// TODO: implement for fixed wires
|
||||||
.zip(permuted_wire_values[start..].iter())
|
_ => unreachable!(),
|
||||||
{
|
})
|
||||||
*modified_advice *=
|
.zip(permuted_wire_values[start..].iter())
|
||||||
&(x_0 * permuted_advice_value + &x_1 + advice_value);
|
{
|
||||||
}
|
*modified_advice *= &(x_0 * permuted_advice_value + &x_1 + advice_value);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
Wire::Aux(wire) => {
|
});
|
||||||
parallelize(&mut modified_advice, |modified_aux, start| {
|
|
||||||
for ((modified_aux, aux_value), permuted_aux_value) in modified_aux
|
|
||||||
.iter_mut()
|
|
||||||
.zip(aux_lagrange_polys[wire.0][start..].iter())
|
|
||||||
.zip(permuted_wire_values[start..].iter())
|
|
||||||
{
|
|
||||||
*modified_aux *= &(x_0 * permuted_aux_value + &x_1 + aux_value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// TODO: implement for fixed wires
|
|
||||||
_ => unreachable!(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
permutation_modified_advice.push(modified_advice);
|
permutation_modified_advice.push(modified_advice);
|
||||||
|
|
@ -222,38 +208,21 @@ impl<C: CurveAffine> Proof<C> {
|
||||||
let mut deltaomega = C::Scalar::one();
|
let mut deltaomega = C::Scalar::one();
|
||||||
for &(wire, _) in wires.iter() {
|
for &(wire, _) in wires.iter() {
|
||||||
let omega = domain.get_omega();
|
let omega = domain.get_omega();
|
||||||
match wire {
|
parallelize(&mut modified_advice, |modified_advice, start| {
|
||||||
Wire::Advice(wire) => {
|
let mut deltaomega = deltaomega * &omega.pow_vartime(&[start as u64, 0, 0, 0]);
|
||||||
parallelize(&mut modified_advice, |modified_advice, start| {
|
for (modified_advice, advice_value) in
|
||||||
let mut deltaomega =
|
modified_advice.iter_mut().zip(match wire {
|
||||||
deltaomega * &omega.pow_vartime(&[start as u64, 0, 0, 0]);
|
Wire::Advice(wire) => witness.advice[wire.0][start..].iter(),
|
||||||
for (modified_advice, advice_value) in modified_advice
|
Wire::Aux(wire) => aux_lagrange_polys[wire.0][start..].iter(),
|
||||||
.iter_mut()
|
// TODO: implement for fixed wires
|
||||||
.zip(witness.advice[wire.0][start..].iter())
|
_ => unreachable!(),
|
||||||
{
|
})
|
||||||
// Multiply by p_j(\omega^i) + \delta^j \omega^i \beta
|
{
|
||||||
*modified_advice *= &(deltaomega * &x_0 + &x_1 + advice_value);
|
// Multiply by p_j(\omega^i) + \delta^j \omega^i \beta
|
||||||
deltaomega *= ω
|
*modified_advice *= &(deltaomega * &x_0 + &x_1 + advice_value);
|
||||||
}
|
deltaomega *= ω
|
||||||
});
|
|
||||||
}
|
}
|
||||||
Wire::Aux(wire) => {
|
});
|
||||||
parallelize(&mut modified_advice, |modified_advice, start| {
|
|
||||||
let mut deltaomega =
|
|
||||||
deltaomega * &omega.pow_vartime(&[start as u64, 0, 0, 0]);
|
|
||||||
for (modified_advice, advice_value) in modified_advice
|
|
||||||
.iter_mut()
|
|
||||||
.zip(aux_lagrange_polys[wire.0][start..].iter())
|
|
||||||
{
|
|
||||||
// Multiply by p_j(\omega^i) + \delta^j \omega^i \beta
|
|
||||||
*modified_advice *= &(deltaomega * &x_0 + &x_1 + advice_value);
|
|
||||||
deltaomega *= ω
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// TODO: implement for fixed wires
|
|
||||||
_ => unreachable!(),
|
|
||||||
}
|
|
||||||
deltaomega *= &C::Scalar::DELTA;
|
deltaomega *= &C::Scalar::DELTA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue