Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poly-commitment: rename elems into chunks [develop] - DON'T MERGE #2673

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions kimchi/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ where

PolyComm {
// blinding_f - Z_H(zeta) * blinding_t
elems: vec![
chunks: vec![
blinding_f - (zeta_to_domain_size - G::ScalarField::one()) * blinding_t,
],
}
Expand Down Expand Up @@ -1189,7 +1189,7 @@ where
.map(|RecursionChallenge { chals, comm }| {
(
DensePolynomial::from_coefficients_vec(b_poly_coefficients(chals)),
comm.elems.len(),
comm.chunks.len(),
)
})
.collect::<Vec<_>>();
Expand Down Expand Up @@ -1224,7 +1224,7 @@ where
//~ (and evaluation proofs) in the protocol.
//~ First, include the previous challenges, in case we are in a recursive prover.
let non_hiding = |d1_size: usize| PolyComm {
elems: vec![G::ScalarField::zero(); d1_size],
chunks: vec![G::ScalarField::zero(); d1_size],
};

let coefficients_form = DensePolynomialOrEvaluations::DensePolynomial;
Expand All @@ -1236,7 +1236,7 @@ where
.collect::<Vec<_>>();

let fixed_hiding = |d1_size: usize| PolyComm {
elems: vec![G::ScalarField::one(); d1_size],
chunks: vec![G::ScalarField::one(); d1_size],
};

//~ 1. Then, include:
Expand Down Expand Up @@ -1383,17 +1383,17 @@ where
if lcs.runtime_selector.is_some() {
let runtime_comm = lookup_context.runtime_table_comm.as_ref().unwrap();

let elems = runtime_comm
let chunks = runtime_comm
.blinders
.elems
.chunks
.iter()
.map(|blinding| *joint_combiner * blinding + base_blinding)
.collect();

PolyComm { elems }
PolyComm { chunks }
} else {
let elems = vec![base_blinding; num_chunks];
PolyComm { elems }
let chunks = vec![base_blinding; num_chunks];
PolyComm { chunks }
}
};

Expand Down
4 changes: 2 additions & 2 deletions kimchi/src/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,11 @@ where
let alpha = alpha_chal.to_field(endo_r);

//~ 1. Enforce that the length of the $t$ commitment is of size 7.
if self.commitments.t_comm.elems.len() > chunk_size * 7 {
if self.commitments.t_comm.chunks.len() > chunk_size * 7 {
return Err(VerifyError::IncorrectCommitmentLength(
"t",
chunk_size * 7,
self.commitments.t_comm.elems.len(),
self.commitments.t_comm.chunks.len(),
));
}

Expand Down
42 changes: 21 additions & 21 deletions kimchi/src/verifier_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,42 +439,42 @@ impl<G: KimchiCurve, OpeningProof: OpenProof<G>> VerifierIndex<G, OpeningProof>
// Always present

for comm in sigma_comm.iter() {
fq_sponge.absorb_g(&comm.elems);
fq_sponge.absorb_g(&comm.chunks);
}
for comm in coefficients_comm.iter() {
fq_sponge.absorb_g(&comm.elems);
fq_sponge.absorb_g(&comm.chunks);
}
fq_sponge.absorb_g(&generic_comm.elems);
fq_sponge.absorb_g(&psm_comm.elems);
fq_sponge.absorb_g(&complete_add_comm.elems);
fq_sponge.absorb_g(&mul_comm.elems);
fq_sponge.absorb_g(&emul_comm.elems);
fq_sponge.absorb_g(&endomul_scalar_comm.elems);
fq_sponge.absorb_g(&generic_comm.chunks);
fq_sponge.absorb_g(&psm_comm.chunks);
fq_sponge.absorb_g(&complete_add_comm.chunks);
fq_sponge.absorb_g(&mul_comm.chunks);
fq_sponge.absorb_g(&emul_comm.chunks);
fq_sponge.absorb_g(&endomul_scalar_comm.chunks);

// Optional gates

if let Some(range_check0_comm) = range_check0_comm {
fq_sponge.absorb_g(&range_check0_comm.elems);
fq_sponge.absorb_g(&range_check0_comm.chunks);
}

if let Some(range_check1_comm) = range_check1_comm {
fq_sponge.absorb_g(&range_check1_comm.elems);
fq_sponge.absorb_g(&range_check1_comm.chunks);
}

if let Some(foreign_field_mul_comm) = foreign_field_mul_comm {
fq_sponge.absorb_g(&foreign_field_mul_comm.elems);
fq_sponge.absorb_g(&foreign_field_mul_comm.chunks);
}

if let Some(foreign_field_add_comm) = foreign_field_add_comm {
fq_sponge.absorb_g(&foreign_field_add_comm.elems);
fq_sponge.absorb_g(&foreign_field_add_comm.chunks);
}

if let Some(xor_comm) = xor_comm {
fq_sponge.absorb_g(&xor_comm.elems);
fq_sponge.absorb_g(&xor_comm.chunks);
}

if let Some(rot_comm) = rot_comm {
fq_sponge.absorb_g(&rot_comm.elems);
fq_sponge.absorb_g(&rot_comm.chunks);
}

// Lookup index; optional
Expand All @@ -496,26 +496,26 @@ impl<G: KimchiCurve, OpeningProof: OpenProof<G>> VerifierIndex<G, OpeningProof>
}) = lookup_index
{
for entry in lookup_table {
fq_sponge.absorb_g(&entry.elems);
fq_sponge.absorb_g(&entry.chunks);
}
if let Some(table_ids) = table_ids {
fq_sponge.absorb_g(&table_ids.elems);
fq_sponge.absorb_g(&table_ids.chunks);
}
if let Some(runtime_tables_selector) = runtime_tables_selector {
fq_sponge.absorb_g(&runtime_tables_selector.elems);
fq_sponge.absorb_g(&runtime_tables_selector.chunks);
}

if let Some(xor) = xor {
fq_sponge.absorb_g(&xor.elems);
fq_sponge.absorb_g(&xor.chunks);
}
if let Some(lookup) = lookup {
fq_sponge.absorb_g(&lookup.elems);
fq_sponge.absorb_g(&lookup.chunks);
}
if let Some(range_check) = range_check {
fq_sponge.absorb_g(&range_check.elems);
fq_sponge.absorb_g(&range_check.chunks);
}
if let Some(ffmul) = ffmul {
fq_sponge.absorb_g(&ffmul.elems);
fq_sponge.absorb_g(&ffmul.chunks);
}
}
fq_sponge.digest_fq()
Expand Down
4 changes: 2 additions & 2 deletions poly-commitment/benches/poly_comm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ fn generate_poly_comm<RNG, F: PrimeField, C: SWCurveConfig<ScalarField = F>>(
where
RNG: RngCore + CryptoRng,
{
let elems: Vec<Affine<C>> = (0..n)
let chunks: Vec<Affine<C>> = (0..n)
.map(|_| {
let x = F::rand(rng);
Affine::<C>::generator().mul_bigint(x.into_bigint()).into()
})
.collect();
PolyComm::new(elems)
PolyComm::new(chunks)
}

fn benchmark_polycomm_add(c: &mut Criterion) {
Expand Down
6 changes: 3 additions & 3 deletions poly-commitment/src/chunked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ where
// use Horner's to compute chunk[0] + z^n chunk[1] + z^2n chunk[2] + ...
// as ( chunk[-1] * z^n + chunk[-2] ) * z^n + chunk[-3]
// (https://en.wikipedia.org/wiki/Horner%27s_method)
for chunk in self.elems.iter().rev() {
for chunk in self.chunks.iter().rev() {
res *= zeta_n;
res.add_assign(chunk);
}

PolyComm {
elems: vec![res.into_affine()],
chunks: vec![res.into_affine()],
}
}
}
Expand All @@ -37,7 +37,7 @@ where
// use Horner's to compute chunk[0] + z^n chunk[1] + z^2n chunk[2] + ...
// as ( chunk[-1] * z^n + chunk[-2] ) * z^n + chunk[-3]
// (https://en.wikipedia.org/wiki/Horner%27s_method)
for chunk in self.elems.iter().rev() {
for chunk in self.chunks.iter().rev() {
res *= zeta_n;
res += chunk
}
Expand Down
Loading