diff --git a/CHANGELOG.md b/CHANGELOG.md index ecaf1b70..8456b8c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,11 @@ and this project adheres to Rust's notion of ### Removed - `halo2::arithmetic::BatchInvert` (use `ff::BatchInvert` instead). - `impl Default for halo2::poly::Rotation` (use `Rotation::cur()` instead). +- `halo2::poly`: + - `EvaluationDomain::{add_extended, sub_extended, mul_extended}` + - `Polynomial::one_minus` + - `impl Neg, Sub for Polynomial` + - `impl Mul for Polynomial<_, ExtendedLagrangeCoeff>` ## [0.1.0-beta.1] - 2021-09-24 Initial beta release! diff --git a/src/poly.rs b/src/poly.rs index bcf0e9c5..9535d3b6 100644 --- a/src/poly.rs +++ b/src/poly.rs @@ -9,7 +9,7 @@ use group::ff::{BatchInvert, Field}; use pasta_curves::arithmetic::FieldExt; use std::fmt::Debug; use std::marker::PhantomData; -use std::ops::{Add, Deref, DerefMut, Index, IndexMut, Mul, Neg, RangeFrom, RangeFull, Sub}; +use std::ops::{Add, Deref, DerefMut, Index, IndexMut, Mul, RangeFrom, RangeFull}; pub mod commitment; mod domain; @@ -181,32 +181,6 @@ impl Polynomial, LagrangeCoeff> { } } -impl Polynomial { - /// Maps every coefficient `c` in `p` to `1 - c`. - pub fn one_minus(mut p: Self) -> Self { - parallelize(&mut p.values, |p, _start| { - for term in p { - *term = F::one() - *term; - } - }); - p - } -} - -impl<'a, F: Field, B: Basis> Neg for Polynomial { - type Output = Polynomial; - - fn neg(mut self) -> Polynomial { - parallelize(&mut self.values, |lhs, _| { - for lhs in lhs.iter_mut() { - *lhs = -*lhs; - } - }); - - self - } -} - impl<'a, F: Field, B: Basis> Add<&'a Polynomial> for Polynomial { type Output = Polynomial; @@ -221,39 +195,6 @@ impl<'a, F: Field, B: Basis> Add<&'a Polynomial> for Polynomial { } } -impl<'a, F: Field, B: Basis> Sub<&'a Polynomial> for Polynomial { - type Output = Polynomial; - - fn sub(mut self, rhs: &'a Polynomial) -> Polynomial { - parallelize(&mut self.values, |lhs, start| { - for (lhs, rhs) in lhs.iter_mut().zip(rhs.values[start..].iter()) { - *lhs -= *rhs; - } - }); - - self - } -} - -impl<'a, F: Field> Mul<&'a Polynomial> - for Polynomial -{ - type Output = Polynomial; - - fn mul( - mut self, - rhs: &'a Polynomial, - ) -> Polynomial { - parallelize(&mut self.values, |lhs, start| { - for (lhs, rhs) in lhs.iter_mut().zip(rhs.values[start..].iter()) { - *lhs *= *rhs; - } - }); - - self - } -} - impl<'a, F: Field> Polynomial { /// Rotates the values in a Lagrange basis polynomial by `Rotation` pub fn rotate(&self, rotation: Rotation) -> Polynomial { diff --git a/src/poly/domain.rs b/src/poly/domain.rs index fe3e58ba..c1d702a9 100644 --- a/src/poly/domain.rs +++ b/src/poly/domain.rs @@ -253,83 +253,6 @@ impl EvaluationDomain { } } - fn op_extended( - &self, - mut left: Polynomial, - right: &Polynomial, - rotation: Rotation, - op: impl Fn(&mut G, &G) + Send + Sync + 'static, - ) -> Polynomial - where - G: Field, - { - // Rotation while in the extended domain is simply exaggerated by how - // much larger the extended domain is compared to the original domain. - let rotation = (1 << (self.extended_k - self.k)) * rotation.0; - - parallelize(&mut left.values, |lhs, start| { - let start = ((((start + self.extended_len()) as i32) + rotation) as usize) - % self.extended_len(); - - for (lhs, rhs) in lhs - .iter_mut() - .zip(right.values[start..].iter().chain(right.values.iter())) - { - op(lhs, rhs); - } - }); - - left - } - - /// Multiply two polynomials in the extended domain, rotating the latter - /// polynomial over the original domain first. - pub fn mul_extended( - &self, - left: Polynomial, - right: &Polynomial, - rotation: Rotation, - ) -> Polynomial - where - G: Field, - { - self.op_extended(left, right, rotation, |lhs, rhs| { - *lhs *= *rhs; - }) - } - - /// Add two polynomials in the extended domain, rotating the latter - /// polynomial over the original domain first. - pub fn add_extended( - &self, - left: Polynomial, - right: &Polynomial, - rotation: Rotation, - ) -> Polynomial - where - G: Field, - { - self.op_extended(left, right, rotation, |lhs, rhs| { - *lhs += *rhs; - }) - } - - /// Subtract a polynomial from another in the extended domain, rotating the - /// former polynomial over the original domain first. - pub fn sub_extended( - &self, - left: Polynomial, - right: &Polynomial, - rotation: Rotation, - ) -> Polynomial - where - G: Field, - { - self.op_extended(left, right, rotation, |lhs, rhs| { - *lhs -= *rhs; - }) - } - /// Rotate the extended domain polynomial over the original domain. pub fn rotate_extended( &self,