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

Fix according to breaking changes in ark-ec #141

Merged
merged 6 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
43 changes: 11 additions & 32 deletions poly-commit/src/kzg10/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use crate::{BTreeMap, Error, LabeledPolynomial, PCRandomness, ToString, Vec};
use ark_ec::AffineRepr;
use ark_ec::{pairing::Pairing, CurveGroup};
use ark_ec::{scalar_mul::fixed_base::FixedBase, VariableBaseMSM};
use ark_ec::{scalar_mul::ScalarMul, VariableBaseMSM};
use ark_ff::{One, PrimeField, UniformRand, Zero};
use ark_poly::DenseUVPolynomial;
use ark_std::{format, marker::PhantomData, ops::Div, ops::Mul, vec};
Expand Down Expand Up @@ -69,33 +69,22 @@ where
let mut powers_of_beta = vec![E::ScalarField::one()];

let mut cur = beta;
for _ in 0..max_degree {
for _ in 0..=max_degree + 1 {
Pratyush marked this conversation as resolved.
Show resolved Hide resolved
powers_of_beta.push(cur);
cur *= β
}

let window_size = FixedBase::get_mul_window_size(max_degree + 1);

let scalar_bits = E::ScalarField::MODULUS_BIT_SIZE as usize;
let g_time = start_timer!(|| "Generating powers of G");
let g_table = FixedBase::get_window_table(scalar_bits, window_size, g);
let powers_of_g =
FixedBase::msm::<E::G1>(scalar_bits, window_size, &g_table, &powers_of_beta);
let powers_of_g = g.batch_mul(&powers_of_beta[0..max_degree + 1]);
end_timer!(g_time);
let gamma_g_time = start_timer!(|| "Generating powers of gamma * G");
let gamma_g_table = FixedBase::get_window_table(scalar_bits, window_size, gamma_g);
let mut powers_of_gamma_g =
FixedBase::msm::<E::G1>(scalar_bits, window_size, &gamma_g_table, &powers_of_beta);
// Add an additional power of gamma_g, because we want to be able to support
// up to D queries.
powers_of_gamma_g.push(powers_of_gamma_g.last().unwrap().mul(&beta));
end_timer!(gamma_g_time);

let powers_of_g = E::G1::normalize_batch(&powers_of_g);
let powers_of_gamma_g = E::G1::normalize_batch(&powers_of_gamma_g)
let gamma_g_time = start_timer!(|| "Generating powers of gamma * G");
let powers_of_gamma_g = gamma_g
.batch_mul(&powers_of_beta)
.into_iter()
.enumerate()
.collect();
end_timer!(gamma_g_time);

let neg_powers_of_h_time = start_timer!(|| "Generating negative powers of h in G2");
let neg_powers_of_h = if produce_g2_powers {
Expand All @@ -106,20 +95,10 @@ where
cur /= &beta;
}

let neg_h_table = FixedBase::get_window_table(scalar_bits, window_size, h);
let neg_powers_of_h = FixedBase::msm::<E::G2>(
scalar_bits,
window_size,
&neg_h_table,
&neg_powers_of_beta,
);

let affines = E::G2::normalize_batch(&neg_powers_of_h);
let mut affines_map = BTreeMap::new();
affines.into_iter().enumerate().for_each(|(i, a)| {
affines_map.insert(i, a);
});
affines_map
h.batch_mul(&neg_powers_of_beta)
.into_iter()
.enumerate()
.collect()
} else {
BTreeMap::new()
};
Expand Down
Loading
Loading