Skip to content

Commit

Permalink
update arkworks dependency for improved deserialization
Browse files Browse the repository at this point in the history
  • Loading branch information
tess-eract committed Feb 23, 2024
1 parent a0410e2 commit 7c3b725
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 63 deletions.
34 changes: 17 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 16 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
elf = { version = "0.7", default-features = false, features = ["std"] }

ark-crypto-primitives = { version = "0.4.0", features = ["r1cs", "sponge", "crh", "merkle_tree"] }
ark-crypto-primitives = { version = "0.4.0", features = [
"r1cs",
"sponge",
"crh",
"merkle_tree",
] }
ark-std = "0.4.0"

ark-relations = { version = "0.4.0" }
Expand All @@ -65,19 +70,19 @@ ark-crypto-primitives = { git = "https://github.com/arkworks-rs/crypto-primitive

ark-r1cs-std = { git = "https://github.com/arkworks-rs/r1cs-std/", rev = "2ca3bd7" }

ark-ff = { git = "https://github.com/arkworks-rs/algebra/", rev = "c92be0e" }
ark-ec = { git = "https://github.com/arkworks-rs/algebra/", rev = "c92be0e" }
ark-serialize = { git = "https://github.com/arkworks-rs/algebra/", rev = "c92be0e" }
ark-poly = { git = "https://github.com/arkworks-rs/algebra/", rev = "c92be0e" }
ark-test-curves = { git = "https://github.com/arkworks-rs/algebra/", rev = "c92be0e" }
ark-ff = { git = "https://github.com/arkworks-rs/algebra/", rev = "2a80c54" }
ark-ec = { git = "https://github.com/arkworks-rs/algebra/", rev = "2a80c54" }
ark-serialize = { git = "https://github.com/arkworks-rs/algebra/", rev = "2a80c54" }
ark-poly = { git = "https://github.com/arkworks-rs/algebra/", rev = "2a80c54" }
ark-test-curves = { git = "https://github.com/arkworks-rs/algebra/", rev = "2a80c54" }

ark-poly-commit = { git = "https://github.com/arkworks-rs/poly-commit/", rev = "c724fa6" }
ark-poly-commit = { git = "https://github.com/arkworks-rs/poly-commit/", rev = "12f5529" }

# note bls is using a different commit from the other curves
ark-bn254 = { git = "https://github.com/arkworks-rs/curves/", rev = "8c0256a" }
ark-grumpkin = { git = "https://github.com/arkworks-rs/curves/", rev = "8c0256a" }
ark-pallas = { git = "https://github.com/arkworks-rs/curves/", rev = "8c0256a" }
ark-vesta = { git = "https://github.com/arkworks-rs/curves/", rev = "8c0256a" }
ark-bn254 = { git = "https://github.com/arkworks-rs/curves/", rev = "8c0256a" }
ark-grumpkin = { git = "https://github.com/arkworks-rs/curves/", rev = "8c0256a" }
ark-pallas = { git = "https://github.com/arkworks-rs/curves/", rev = "8c0256a" }
ark-vesta = { git = "https://github.com/arkworks-rs/curves/", rev = "8c0256a" }
ark-bls12-381 = { git = "https://github.com/arkworks-rs/curves/", rev = "3fded1f" }

[profile.release]
Expand Down
4 changes: 2 additions & 2 deletions nova/src/folding/hypernova/ml_sumcheck/data_structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::collections::HashMap;

use ark_crypto_primitives::sponge::Absorb;
use ark_ff::{Field, PrimeField};
use ark_poly::{DenseMultilinearExtension, MultilinearExtension};
use ark_poly::{DenseMultilinearExtension, MultilinearExtension, Polynomial};
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
use ark_std::{cmp::max, rc::Rc};

Expand Down Expand Up @@ -118,7 +118,7 @@ impl<F: Field> ListOfProductsOfPolynomials<F> {
.map(|(c, p)| {
*c * p
.iter()
.map(|&i| self.flattened_ml_extensions[i].evaluate(point).unwrap())
.map(|&i| self.flattened_ml_extensions[i].evaluate(&point.to_vec()))
.product::<F>()
})
.sum()
Expand Down
43 changes: 10 additions & 33 deletions spartan/src/polycommitments/zeromorph/mod.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
use ark_ec::{pairing::Pairing, scalar_mul::fixed_base::FixedBase, AffineRepr, CurveGroup};
use ark_ff::PrimeField;
use ark_ec::{pairing::Pairing, AffineRepr, CurveGroup, ScalarMul};
use ark_poly::{univariate::DensePolynomial as DenseUnivarPolynomial, DenseUVPolynomial};
use ark_poly_commit::{
error::Error,
kzg10::{Commitment as KZGCommitment, KZG10},
PCUniversalParams,
};
use ark_std::{
collections::BTreeMap, end_timer, marker::PhantomData, ops::Mul, rand::RngCore, start_timer,
vec::Vec, One, UniformRand, Zero,
end_timer, marker::PhantomData, ops::Mul, rand::RngCore, start_timer, vec::Vec, One, UniformRand,
Zero,
};
use merlin::Transcript;

Expand Down Expand Up @@ -275,34 +274,19 @@ where
));
let beta = E::ScalarField::rand(rng);
let g = E::G1::rand(rng);
let gamma_g = E::G1::rand(rng);
let h = E::G2::rand(rng);
// powers_of_beta = [1, b, ..., b^(max_degree + 1)], len = max_degree + 2
let mut powers_of_beta = vec![E::ScalarField::one()];

let mut cur = beta;
for _ in 0..max_degree {
for _ in 0..=max_degree {
powers_of_beta.push(cur);
cur *= &beta;
}

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_h_time = start_timer!(|| "Generating powers of h in G2");
let shift_powers_of_tau_h = {
Expand All @@ -311,17 +295,10 @@ where
// powers_of_beta[k] = beta^k and N_max = max_degree + 1; we want shift_powers_of_beta[n] = beta^(N_max - 2^n + 1)
shift_powers_of_beta.push(powers_of_beta[max_degree + 1 - Math::pow2(n) + 1]);
}
let window_size = FixedBase::get_mul_window_size(max_num_poly_vars + 1);
let h_table = FixedBase::get_window_table(scalar_bits, window_size, h);
let powers_of_h =
FixedBase::msm::<E::G2>(scalar_bits, window_size, &h_table, &shift_powers_of_beta);

let affines = E::G2::normalize_batch(&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(&shift_powers_of_beta)
.into_iter()
.enumerate()
.collect()
};

end_timer!(powers_of_h_time);
Expand Down

0 comments on commit 7c3b725

Please sign in to comment.