mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-07 16:23:12 +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 quotient = self.div_unsafe_extension(numerator, denominator);
|
||||||
let sum = self.add_extension(sum, quotient);
|
let sum = self.add_extension(sum, quotient);
|
||||||
|
|
||||||
// let ev: F::Extension = proof
|
let evs = proof
|
||||||
// .unsalted_evals(3, config)
|
.unsalted_evals(3, config)
|
||||||
// .iter()
|
.iter()
|
||||||
// .zip(alpha_powers.clone())
|
.map(|&e| self.convert_to_ext(e))
|
||||||
// .map(|(&e, a)| a * e.into())
|
.collect::<Vec<_>>();
|
||||||
// .sum();
|
let mut ev = self.zero_extension();
|
||||||
// let zeta_right = F::Extension::primitive_root_of_unity(degree_log) * zeta;
|
for &e in &evs {
|
||||||
// let zs_interpol = interpolant(&[
|
let a = alpha_powers.next(self);
|
||||||
// (zeta, reduce_with_iter(&os.plonk_zs, alpha_powers.clone())),
|
let tmp = self.mul_extension(a, e);
|
||||||
// (
|
ev = self.add_extension(ev, tmp);
|
||||||
// zeta_right,
|
}
|
||||||
// reduce_with_iter(&os.plonk_zs_right, &mut alpha_powers),
|
|
||||||
// ),
|
let g = self.constant_extension(F::Extension::primitive_root_of_unity(degree_log));
|
||||||
// ]);
|
let zeta_right = self.mul_extension(g, zeta);
|
||||||
// let numerator = ev - zs_interpol.eval(subgroup_x);
|
let zs_interpol = self.interpolate2([
|
||||||
// let denominator = (subgroup_x - zeta) * (subgroup_x - zeta_right);
|
(zeta, reduce_with_iter(&os.plonk_zs, alpha_powers.clone())),
|
||||||
// sum += numerator / denominator;
|
(
|
||||||
|
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
|
// let ev: F::Extension = proof
|
||||||
// .unsalted_evals(2, config)
|
// .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 arithmetic;
|
||||||
pub mod hash;
|
pub mod hash;
|
||||||
|
pub mod interpolation;
|
||||||
pub mod polynomial;
|
pub mod polynomial;
|
||||||
pub mod split_base;
|
pub mod split_base;
|
||||||
pub(crate) mod split_join;
|
pub(crate) mod split_join;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user