Account for Rotations of LagrangeCoeff values

This commit is contained in:
therealyingtong 2021-02-14 23:17:54 +08:00 committed by Sean Bowe
parent 8e56b415fb
commit df2d818891
No known key found for this signature in database
GPG Key ID: 95684257D8F8B031
2 changed files with 28 additions and 6 deletions

View File

@ -97,16 +97,22 @@ impl<F: FieldExt> Argument<F> {
.map(|expression| {
expression.evaluate(
&|index| {
let column_index = pk.vk.cs.fixed_queries[index].0.index();
fixed_values[column_index].clone()
let query = pk.vk.cs.fixed_queries[index];
let column_index = query.0.index();
let rotation = query.1;
fixed_values[column_index].clone().rotate(rotation)
},
&|index| {
let column_index = pk.vk.cs.advice_queries[index].0.index();
advice_values[column_index].clone()
let query = pk.vk.cs.advice_queries[index];
let column_index = query.0.index();
let rotation = query.1;
advice_values[column_index].clone().rotate(rotation)
},
&|index| {
let column_index = pk.vk.cs.instance_queries[index].0.index();
instance_values[column_index].clone()
let query = pk.vk.cs.instance_queries[index];
let column_index = query.0.index();
let rotation = query.1;
instance_values[column_index].clone().rotate(rotation)
},
&|a, b| a + &b,
&|a, b| {

View File

@ -187,6 +187,22 @@ impl<'a, F: Field> Mul<&'a Polynomial<F, ExtendedLagrangeCoeff>>
}
}
impl<'a, F: Field> Polynomial<F, LagrangeCoeff> {
/// Rotates the values in a Lagrange basis polynomial by `Rotation`
pub fn rotate(&self, rotation: Rotation) -> Polynomial<F, LagrangeCoeff> {
let mut values = self.values.clone();
if rotation.0 < 0 {
values.rotate_right((-rotation.0) as usize);
} else {
values.rotate_left(rotation.0 as usize);
}
Polynomial {
values,
_marker: PhantomData,
}
}
}
impl<'a, F: Field, B: Basis> Mul<F> for Polynomial<F, B> {
type Output = Polynomial<F, B>;