mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-05 23:33:07 +00:00
Interpolation of two points
This commit is contained in:
parent
8cf2758b6c
commit
e50d0aa63d
@ -174,23 +174,34 @@ impl<F: Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
let quotient = self.div_unsafe_extension(numerator, denominator);
|
||||
let sum = self.add_extension(sum, quotient);
|
||||
|
||||
// let ev: F::Extension = proof
|
||||
// .unsalted_evals(3, config)
|
||||
// .iter()
|
||||
// .zip(alpha_powers.clone())
|
||||
// .map(|(&e, a)| a * e.into())
|
||||
// .sum();
|
||||
// let zeta_right = F::Extension::primitive_root_of_unity(degree_log) * zeta;
|
||||
// let zs_interpol = interpolant(&[
|
||||
// (zeta, reduce_with_iter(&os.plonk_zs, alpha_powers.clone())),
|
||||
// (
|
||||
// zeta_right,
|
||||
// reduce_with_iter(&os.plonk_zs_right, &mut alpha_powers),
|
||||
// ),
|
||||
// ]);
|
||||
// let numerator = ev - zs_interpol.eval(subgroup_x);
|
||||
// let denominator = (subgroup_x - zeta) * (subgroup_x - zeta_right);
|
||||
// sum += numerator / denominator;
|
||||
let evs = proof
|
||||
.unsalted_evals(3, config)
|
||||
.iter()
|
||||
.map(|&e| self.convert_to_ext(e))
|
||||
.collect::<Vec<_>>();
|
||||
let mut ev = self.zero_extension();
|
||||
for &e in &evs {
|
||||
let a = alpha_powers.next(self);
|
||||
let tmp = self.mul_extension(a, e);
|
||||
ev = self.add_extension(ev, tmp);
|
||||
}
|
||||
|
||||
let g = self.constant_extension(F::Extension::primitive_root_of_unity(degree_log));
|
||||
let zeta_right = self.mul_extension(g, zeta);
|
||||
let zs_interpol = self.interpolate2([
|
||||
(zeta, reduce_with_iter(&os.plonk_zs, alpha_powers.clone())),
|
||||
(
|
||||
zeta_right,
|
||||
reduce_with_iter(&os.plonk_zs_right, &mut alpha_powers),
|
||||
),
|
||||
]);
|
||||
let interpol_val = zs_interpol.eval(self, subgroup_x);
|
||||
let numerator = self.sub_extension(ev, interpol_val);
|
||||
let vanish = self.sub_extension(subgroup_x, zeta);
|
||||
let vanish_right = self.sub_extension(subgroup_x, zeta_right);
|
||||
let denominator = self.mul_extension(vanish, vanish_right);
|
||||
let quotient = self.div_unsafe_extension(numerator, denominator);
|
||||
let sum = self.add_extension(sum, quotient);
|
||||
//
|
||||
// let ev: F::Extension = proof
|
||||
// .unsalted_evals(2, config)
|
||||
|
||||
15
src/gadgets/interpolation.rs
Normal file
15
src/gadgets/interpolation.rs
Normal file
@ -0,0 +1,15 @@
|
||||
use crate::circuit_builder::CircuitBuilder;
|
||||
use crate::field::extension_field::target::ExtensionTarget;
|
||||
use crate::field::extension_field::Extendable;
|
||||
use crate::gadgets::polynomial::PolynomialCoeffsExtTarget;
|
||||
|
||||
impl<F: Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
/// Interpolate two points. No need for an `InterpolationGate` since the coefficients
|
||||
/// of the linear interpolation polynomial can be easily computed with arithmetic operations.
|
||||
pub fn interpolate2(
|
||||
&mut self,
|
||||
points: [(ExtensionTarget<D>, ExtensionTarget<D>); 2],
|
||||
) -> PolynomialCoeffsExtTarget<D> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
pub mod arithmetic;
|
||||
pub mod hash;
|
||||
pub mod interpolation;
|
||||
pub mod polynomial;
|
||||
pub mod split_base;
|
||||
pub(crate) mod split_join;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user