mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-08 00:33:06 +00:00
Merge remote-tracking branch 'origin/permutation_argument' into permutation_argument
This commit is contained in:
commit
f8f28a167c
@ -21,7 +21,7 @@ use crate::plonk_common::PlonkPolynomials;
|
||||
use crate::polynomial::commitment::ListPolynomialCommitment;
|
||||
use crate::polynomial::polynomial::PolynomialValues;
|
||||
use crate::target::Target;
|
||||
use crate::util::{log2_strict, transpose};
|
||||
use crate::util::{log2_strict, transpose, transpose_poly_values};
|
||||
use crate::wire::Wire;
|
||||
|
||||
pub struct CircuitBuilder<F: Extendable<D>, const D: usize> {
|
||||
@ -307,7 +307,7 @@ impl<F: Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
let k_is = get_unique_coset_shifts(degree, self.config.num_routed_wires);
|
||||
let sigma_vecs = self.sigma_vecs(&k_is, &subgroup);
|
||||
|
||||
let constants_sigmas_vecs = [constant_vecs, sigma_vecs].concat();
|
||||
let constants_sigmas_vecs = [constant_vecs, sigma_vecs.clone()].concat();
|
||||
let constants_sigmas_commitment = ListPolynomialCommitment::new(
|
||||
constants_sigmas_vecs,
|
||||
self.config.fri_config.rate_bits,
|
||||
@ -322,6 +322,7 @@ impl<F: Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
let prover_only = ProverOnlyCircuitData {
|
||||
generators: self.generators,
|
||||
constants_sigmas_commitment,
|
||||
sigmas: transpose_poly_values(sigma_vecs),
|
||||
subgroup,
|
||||
copy_constraints: self.copy_constraints,
|
||||
gate_instances: self.gate_instances,
|
||||
|
||||
@ -120,6 +120,8 @@ pub(crate) struct ProverOnlyCircuitData<F: Extendable<D>, const D: usize> {
|
||||
pub generators: Vec<Box<dyn WitnessGenerator<F>>>,
|
||||
/// Commitments to the constants polynomials and sigma polynomials.
|
||||
pub constants_sigmas_commitment: ListPolynomialCommitment<F>,
|
||||
/// The transpose of the list of sigma polynomials.
|
||||
pub sigmas: Vec<Vec<F>>,
|
||||
/// Subgroup of order `degree`.
|
||||
pub subgroup: Vec<F>,
|
||||
/// The circuit's copy constraints.
|
||||
|
||||
@ -19,7 +19,6 @@ pub const SALT_SIZE: usize = 2;
|
||||
|
||||
pub struct ListPolynomialCommitment<F: Field> {
|
||||
pub polynomials: Vec<PolynomialCoeffs<F>>,
|
||||
pub values: Vec<PolynomialValues<F>>,
|
||||
pub merkle_tree: MerkleTree<F>,
|
||||
pub degree: usize,
|
||||
pub degree_log: usize,
|
||||
@ -40,7 +39,7 @@ impl<F: Field> ListPolynomialCommitment<F> {
|
||||
"to compute LDE"
|
||||
);
|
||||
|
||||
Self::new_from_data(polynomials, values, lde_values, degree, rate_bits, blinding)
|
||||
Self::new_from_data(polynomials, lde_values, degree, rate_bits, blinding)
|
||||
}
|
||||
|
||||
/// Creates a list polynomial commitment for the polynomials `polynomials`.
|
||||
@ -50,21 +49,16 @@ impl<F: Field> ListPolynomialCommitment<F> {
|
||||
blinding: bool,
|
||||
) -> Self {
|
||||
let degree = polynomials[0].len();
|
||||
let values = polynomials
|
||||
.iter()
|
||||
.map(|v| v.clone().fft())
|
||||
.collect::<Vec<_>>();
|
||||
let lde_values = timed!(
|
||||
Self::lde_values(&polynomials, rate_bits, blinding),
|
||||
"to compute LDE"
|
||||
);
|
||||
|
||||
Self::new_from_data(polynomials, values, lde_values, degree, rate_bits, blinding)
|
||||
Self::new_from_data(polynomials, lde_values, degree, rate_bits, blinding)
|
||||
}
|
||||
|
||||
fn new_from_data(
|
||||
polynomials: Vec<PolynomialCoeffs<F>>,
|
||||
values: Vec<PolynomialValues<F>>,
|
||||
lde_values: Vec<Vec<F>>,
|
||||
degree: usize,
|
||||
rate_bits: usize,
|
||||
@ -76,7 +70,6 @@ impl<F: Field> ListPolynomialCommitment<F> {
|
||||
|
||||
Self {
|
||||
polynomials,
|
||||
values,
|
||||
merkle_tree,
|
||||
degree,
|
||||
degree_log: log2_strict(degree),
|
||||
@ -108,9 +101,6 @@ impl<F: Field> ListPolynomialCommitment<F> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn original_values(&self, index: usize) -> Vec<F> {
|
||||
self.values.iter().map(|v| v.values[index]).collect()
|
||||
}
|
||||
pub fn get_lde_values(&self, index: usize) -> &[F] {
|
||||
let index = reverse_bits(index, self.degree_log + self.rate_bits);
|
||||
let slice = &self.merkle_tree.leaves[index];
|
||||
|
||||
@ -194,9 +194,7 @@ fn compute_z<F: Extendable<D>, const D: usize>(
|
||||
let x = subgroup[i - 1];
|
||||
let mut numerator = F::ONE;
|
||||
let mut denominator = F::ONE;
|
||||
let s_sigmas = &prover_data
|
||||
.constants_sigmas_commitment
|
||||
.original_values(i - 1)[common_data.sigmas_range()];
|
||||
let s_sigmas = &prover_data.sigmas[i - 1];
|
||||
for j in 0..common_data.config.num_routed_wires {
|
||||
let wire_value = witness.get_wire(i - 1, j);
|
||||
let k_i = k_is[j];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user