diff --git a/src/gates/interpolation.rs b/src/gates/interpolation.rs index f7934b71..0225ce59 100644 --- a/src/gates/interpolation.rs +++ b/src/gates/interpolation.rs @@ -25,6 +25,21 @@ pub(crate) struct HighDegreeInterpolationGate, cons _phantom: PhantomData, } +impl, const D: usize> InterpolationGate + for HighDegreeInterpolationGate +{ + fn new(subgroup_bits: usize) -> Self { + Self { + subgroup_bits, + _phantom: PhantomData, + } + } + + fn num_points(&self) -> usize { + 1 << self.subgroup_bits + } +} + impl, const D: usize> HighDegreeInterpolationGate { /// End of wire indices, exclusive. fn end(&self) -> usize { @@ -64,74 +79,6 @@ impl, const D: usize> HighDegreeInterpolationGate, const D: usize> InterpolationGate - for HighDegreeInterpolationGate -{ - fn new(subgroup_bits: usize) -> Self { - Self { - subgroup_bits, - _phantom: PhantomData, - } - } - - fn num_points(&self) -> usize { - 1 << self.subgroup_bits - } - - /// Wire index of the coset shift. - fn wire_shift(&self) -> usize { - 0 - } - - fn start_values(&self) -> usize { - 1 - } - - /// Wire indices of the `i`th interpolant value. - fn wires_value(&self, i: usize) -> Range { - debug_assert!(i < self.num_points()); - let start = self.start_values() + i * D; - start..start + D - } - - fn start_evaluation_point(&self) -> usize { - self.start_values() + self.num_points() * D - } - - /// Wire indices of the point to evaluate the interpolant at. - fn wires_evaluation_point(&self) -> Range { - let start = self.start_evaluation_point(); - start..start + D - } - - fn start_evaluation_value(&self) -> usize { - self.start_evaluation_point() + D - } - - /// Wire indices of the interpolated value. - fn wires_evaluation_value(&self) -> Range { - let start = self.start_evaluation_value(); - start..start + D - } - - fn start_coeffs(&self) -> usize { - self.start_evaluation_value() + D - } - - /// The number of routed wires required in the typical usage of this gate, where the points to - /// interpolate, the evaluation point, and the corresponding value are all routed. - fn num_routed_wires(&self) -> usize { - self.start_coeffs() - } - - /// Wire indices of the interpolant's `i`th coefficient. - fn wires_coeff(&self, i: usize) -> Range { - debug_assert!(i < self.num_points()); - let start = self.start_coeffs() + i * D; - start..start + D - } -} - impl, const D: usize> Gate for HighDegreeInterpolationGate { @@ -227,7 +174,7 @@ impl, const D: usize> Gate ) -> Vec>> { let gen = InterpolationGenerator:: { gate_index, - gate: self.clone(), + gate: *self, _phantom: PhantomData, }; vec![Box::new(gen.adapter())] diff --git a/src/gates/low_degree_interpolation.rs b/src/gates/low_degree_interpolation.rs index abbdb00e..1c2b41e4 100644 --- a/src/gates/low_degree_interpolation.rs +++ b/src/gates/low_degree_interpolation.rs @@ -38,63 +38,6 @@ impl, const D: usize> InterpolationGate fn num_points(&self) -> usize { 1 << self.subgroup_bits } - - /// Wire index of the coset shift. - fn wire_shift(&self) -> usize { - 0 - } - - fn start_values(&self) -> usize { - 1 - } - - /// Wire indices of the `i`th interpolant value. - fn wires_value(&self, i: usize) -> Range { - debug_assert!(i < self.num_points()); - let start = self.start_values() + i * D; - start..start + D - } - - fn start_evaluation_point(&self) -> usize { - self.start_values() + self.num_points() * D - } - - /// Wire indices of the point to evaluate the interpolant at. - fn wires_evaluation_point(&self) -> Range { - let start = self.start_evaluation_point(); - start..start + D - } - - fn start_evaluation_value(&self) -> usize { - self.start_evaluation_point() + D - } - - /// Wire indices of the interpolated value. - fn wires_evaluation_value(&self) -> Range { - let start = self.start_evaluation_value(); - start..start + D - } - - fn start_coeffs(&self) -> usize { - self.start_evaluation_value() + D - } - - /// The number of routed wires required in the typical usage of this gate, where the points to - /// interpolate, the evaluation point, and the corresponding value are all routed. - fn num_routed_wires(&self) -> usize { - self.start_coeffs() - } - - /// Wire indices of the interpolant's `i`th coefficient. - fn wires_coeff(&self, i: usize) -> Range { - debug_assert!(i < self.num_points()); - let start = self.start_coeffs() + i * D; - start..start + D - } - - fn end_coeffs(&self) -> usize { - self.start_coeffs() + D * self.num_points() - } } impl, const D: usize> LowDegreeInterpolationGate { @@ -322,7 +265,7 @@ impl, const D: usize> Gate for LowDegreeInter ) -> Vec>> { let gen = InterpolationGenerator:: { gate_index, - gate: self.clone(), + gate: *self, _phantom: PhantomData, }; vec![Box::new(gen.adapter())]