From 4d78d534cb55a9b13f34dd76b9702cae3ab2a2a1 Mon Sep 17 00:00:00 2001
From: Yuncong Hu <yuncong_hu@berkeley.edu>
Date: Wed, 26 Jan 2022 10:19:29 -0800
Subject: [PATCH] Update dependencies of algebra, std and curves repos (#90)

* Use the latest algebra and std repo

* address the stdrng issue

Co-authored-by: Weikeng Chen <w.k@berkeley.edu>
---
 Cargo.toml                        | 11 ++++++
 src/ipa_pc/mod.rs                 | 20 +++++++---
 src/kzg10/mod.rs                  | 41 +++++++-------------
 src/lib.rs                        | 62 +++++++++++++++----------------
 src/marlin/marlin_pc/mod.rs       |  8 ++--
 src/marlin/marlin_pst13_pc/mod.rs | 37 ++++++++----------
 src/multilinear_pc/mod.rs         | 48 ++++++++++++------------
 src/sonic_pc/mod.rs               |  6 +--
 8 files changed, 117 insertions(+), 116 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index b4805c1..75dd24a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -42,6 +42,7 @@ ark-ed-on-bls12-381 = { version = "^0.3.0", default-features = false }
 ark-bls12-381 = { version = "^0.3.0", default-features = false, features = [ "curve" ] }
 ark-bls12-377 = { version = "^0.3.0", default-features = false, features = [ "curve" ] }
 blake2 = { version = "0.9", default-features = false }
+rand_chacha = { version = "0.3.0", default-features = false }
 
 [profile.release]
 opt-level = 3
@@ -55,6 +56,16 @@ debug-assertions = true
 incremental = true
 debug = true
 
+# To be removed in the new release.
+[patch.crates-io]
+ark-std = { git = "https://github.com/arkworks-rs/std" }
+ark-ec = { git = "https://github.com/arkworks-rs/algebra" }
+ark-ff = { git = "https://github.com/arkworks-rs/algebra" }
+ark-serialize = { git = "https://github.com/arkworks-rs/algebra" }
+ark-bls12-381 = { git = "https://github.com/arkworks-rs/curves" }
+ark-bls12-377 = { git = "https://github.com/arkworks-rs/curves" }
+ark-ed-on-bls12-381 = { git = "https://github.com/arkworks-rs/curves" }
+
 [features]
 default = [ "std", "parallel" ]
 std = [ "ark-ff/std", "ark-ec/std", "ark-nonnative-field/std", "ark-poly/std", "ark-std/std", "ark-relations/std", "ark-serialize/std", "ark-sponge/std"]
diff --git a/src/ipa_pc/mod.rs b/src/ipa_pc/mod.rs
index fb9cc38..aabf2ad 100644
--- a/src/ipa_pc/mod.rs
+++ b/src/ipa_pc/mod.rs
@@ -3,7 +3,7 @@ use crate::{BatchLCProof, Error, Evaluations, QuerySet, UVPolynomial};
 use crate::{LabeledCommitment, LabeledPolynomial, LinearCombination};
 use crate::{PCCommitterKey, PCRandomness, PCUniversalParams, PolynomialCommitment};
 
-use ark_ec::{msm::VariableBaseMSM, AffineCurve, ProjectiveCurve};
+use ark_ec::{msm::VariableBase, AffineCurve, ProjectiveCurve};
 use ark_ff::{to_bytes, Field, One, PrimeField, UniformRand, Zero};
 use ark_std::rand::RngCore;
 use ark_std::{convert::TryInto, format, marker::PhantomData, vec};
@@ -65,7 +65,7 @@ where
             .map(|s| s.into_repr())
             .collect::<Vec<_>>();
 
-        let mut comm = VariableBaseMSM::multi_scalar_mul(comm_key, &scalars_bigint);
+        let mut comm = VariableBase::msm(comm_key, &scalars_bigint);
 
         if randomizer.is_some() {
             assert!(hiding_generator.is_some());
@@ -1044,23 +1044,31 @@ mod tests {
     use ark_ff::PrimeField;
     use ark_poly::{univariate::DensePolynomial as DensePoly, UVPolynomial};
     use ark_sponge::poseidon::PoseidonSponge;
-    use ark_std::rand::rngs::StdRng;
     use blake2::Blake2s;
+    use rand_chacha::ChaCha20Rng;
 
     type UniPoly = DensePoly<Fr>;
     type Sponge = PoseidonSponge<<EdwardsAffine as AffineCurve>::ScalarField>;
     type PC<E, D, P, S> = InnerProductArgPC<E, D, P, S>;
     type PC_JJB2S = PC<EdwardsAffine, Blake2s, UniPoly, Sponge>;
 
-    fn rand_poly<F: PrimeField>(degree: usize, _: Option<usize>, rng: &mut StdRng) -> DensePoly<F> {
+    fn rand_poly<F: PrimeField>(
+        degree: usize,
+        _: Option<usize>,
+        rng: &mut ChaCha20Rng,
+    ) -> DensePoly<F> {
         DensePoly::rand(degree, rng)
     }
 
-    fn constant_poly<F: PrimeField>(_: usize, _: Option<usize>, rng: &mut StdRng) -> DensePoly<F> {
+    fn constant_poly<F: PrimeField>(
+        _: usize,
+        _: Option<usize>,
+        rng: &mut ChaCha20Rng,
+    ) -> DensePoly<F> {
         DensePoly::from_coefficients_slice(&[F::rand(rng)])
     }
 
-    fn rand_point<F: PrimeField>(_: Option<usize>, rng: &mut StdRng) -> F {
+    fn rand_point<F: PrimeField>(_: Option<usize>, rng: &mut ChaCha20Rng) -> F {
         F::rand(rng)
     }
 
diff --git a/src/kzg10/mod.rs b/src/kzg10/mod.rs
index e4f1c49..2f5a5a5 100644
--- a/src/kzg10/mod.rs
+++ b/src/kzg10/mod.rs
@@ -6,7 +6,7 @@
 //! This construction achieves extractability in the algebraic group model (AGM).
 
 use crate::{BTreeMap, Error, LabeledPolynomial, PCRandomness, ToString, Vec};
-use ark_ec::msm::{FixedBaseMSM, VariableBaseMSM};
+use ark_ec::msm::{FixedBase, VariableBase};
 use ark_ec::{group::Group, AffineCurve, PairingEngine, ProjectiveCurve};
 use ark_ff::{One, PrimeField, UniformRand, Zero};
 use ark_poly::UVPolynomial;
@@ -58,21 +58,17 @@ where
             cur *= &beta;
         }
 
-        let window_size = FixedBaseMSM::get_mul_window_size(max_degree + 1);
+        let window_size = FixedBase::get_mul_window_size(max_degree + 1);
 
         let scalar_bits = E::Fr::size_in_bits();
         let g_time = start_timer!(|| "Generating powers of G");
-        let g_table = FixedBaseMSM::get_window_table(scalar_bits, window_size, g);
-        let powers_of_g = FixedBaseMSM::multi_scalar_mul::<E::G1Projective>(
-            scalar_bits,
-            window_size,
-            &g_table,
-            &powers_of_beta,
-        );
+        let g_table = FixedBase::get_window_table(scalar_bits, window_size, g);
+        let powers_of_g =
+            FixedBase::msm::<E::G1Projective>(scalar_bits, window_size, &g_table, &powers_of_beta);
         end_timer!(g_time);
         let gamma_g_time = start_timer!(|| "Generating powers of gamma * G");
-        let gamma_g_table = FixedBaseMSM::get_window_table(scalar_bits, window_size, gamma_g);
-        let mut powers_of_gamma_g = FixedBaseMSM::multi_scalar_mul::<E::G1Projective>(
+        let gamma_g_table = FixedBase::get_window_table(scalar_bits, window_size, gamma_g);
+        let mut powers_of_gamma_g = FixedBase::msm::<E::G1Projective>(
             scalar_bits,
             window_size,
             &gamma_g_table,
@@ -99,8 +95,8 @@ where
                 cur /= &beta;
             }
 
-            let neg_h_table = FixedBaseMSM::get_window_table(scalar_bits, window_size, h);
-            let neg_powers_of_h = FixedBaseMSM::multi_scalar_mul::<E::G2Projective>(
+            let neg_h_table = FixedBase::get_window_table(scalar_bits, window_size, h);
+            let neg_powers_of_h = FixedBase::msm::<E::G2Projective>(
                 scalar_bits,
                 window_size,
                 &neg_h_table,
@@ -156,10 +152,8 @@ where
             skip_leading_zeros_and_convert_to_bigints(polynomial);
 
         let msm_time = start_timer!(|| "MSM to compute commitment to plaintext poly");
-        let mut commitment = VariableBaseMSM::multi_scalar_mul(
-            &powers.powers_of_g[num_leading_zeros..],
-            &plain_coeffs,
-        );
+        let mut commitment =
+            VariableBase::msm(&powers.powers_of_g[num_leading_zeros..], &plain_coeffs);
         end_timer!(msm_time);
 
         let mut randomness = Randomness::<E::Fr, P>::empty();
@@ -181,8 +175,7 @@ where
         let random_ints = convert_to_bigints(&randomness.blinding_polynomial.coeffs());
         let msm_time = start_timer!(|| "MSM to compute commitment to random poly");
         let random_commitment =
-            VariableBaseMSM::multi_scalar_mul(&powers.powers_of_gamma_g, random_ints.as_slice())
-                .into_affine();
+            VariableBase::msm(&powers.powers_of_gamma_g, random_ints.as_slice()).into_affine();
         end_timer!(msm_time);
 
         commitment.add_assign_mixed(&random_commitment);
@@ -233,10 +226,7 @@ where
             skip_leading_zeros_and_convert_to_bigints(witness_polynomial);
 
         let witness_comm_time = start_timer!(|| "Computing commitment to witness polynomial");
-        let mut w = VariableBaseMSM::multi_scalar_mul(
-            &powers.powers_of_g[num_leading_zeros..],
-            &witness_coeffs,
-        );
+        let mut w = VariableBase::msm(&powers.powers_of_g[num_leading_zeros..], &witness_coeffs);
         end_timer!(witness_comm_time);
 
         let random_v = if let Some(hiding_witness_polynomial) = hiding_witness_polynomial {
@@ -248,10 +238,7 @@ where
             let random_witness_coeffs = convert_to_bigints(&hiding_witness_polynomial.coeffs());
             let witness_comm_time =
                 start_timer!(|| "Computing commitment to random witness polynomial");
-            w += &VariableBaseMSM::multi_scalar_mul(
-                &powers.powers_of_gamma_g,
-                &random_witness_coeffs,
-            );
+            w += &VariableBase::msm(&powers.powers_of_gamma_g, &random_witness_coeffs);
             end_timer!(witness_comm_time);
             Some(blinding_evaluation)
         } else {
diff --git a/src/lib.rs b/src/lib.rs
index 0107c1e..a6dc40b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -530,10 +530,10 @@ pub mod tests {
     use ark_sponge::poseidon::{PoseidonParameters, PoseidonSponge};
     use ark_std::rand::{
         distributions::{Distribution, Uniform},
-        rngs::StdRng,
-        Rng,
+        Rng, SeedableRng,
     };
     use ark_std::test_rng;
+    use rand_chacha::ChaCha20Rng;
 
     struct TestInfo<F: PrimeField, P: Polynomial<F>, S: CryptographicSponge> {
         num_iters: usize,
@@ -544,14 +544,14 @@ pub mod tests {
         enforce_degree_bounds: bool,
         max_num_queries: usize,
         num_equations: Option<usize>,
-        rand_poly: fn(usize, Option<usize>, &mut StdRng) -> P,
-        rand_point: fn(Option<usize>, &mut StdRng) -> P::Point,
+        rand_poly: fn(usize, Option<usize>, &mut ChaCha20Rng) -> P,
+        rand_point: fn(Option<usize>, &mut ChaCha20Rng) -> P::Point,
         sponge: fn() -> S,
     }
 
     pub fn bad_degree_bound_test<F, P, PC, S>(
-        rand_poly: fn(usize, Option<usize>, &mut StdRng) -> P,
-        rand_point: fn(Option<usize>, &mut StdRng) -> P::Point,
+        rand_poly: fn(usize, Option<usize>, &mut ChaCha20Rng) -> P,
+        rand_point: fn(Option<usize>, &mut ChaCha20Rng) -> P::Point,
         sponge: fn() -> S,
     ) -> Result<(), PC::Error>
     where
@@ -566,7 +566,7 @@ pub mod tests {
         ];
 
         for challenge_gen in challenge_generators {
-            let rng = &mut test_rng();
+            let rng = &mut ChaCha20Rng::from_rng(test_rng()).unwrap();
             let max_degree = 100;
             let pp = PC::setup(max_degree, None, rng)?;
             for _ in 0..10 {
@@ -674,7 +674,7 @@ pub mod tests {
         ];
 
         for challenge_gen in challenge_gens {
-            let rng = &mut test_rng();
+            let rng = &mut ChaCha20Rng::from_rng(test_rng()).unwrap();
             // If testing multivariate polynomials, make the max degree lower
             let max_degree = match num_vars {
                 Some(_) => max_degree.unwrap_or(Uniform::from(2..=10).sample(rng)),
@@ -819,7 +819,7 @@ pub mod tests {
         ];
 
         for challenge_gen in challenge_gens {
-            let rng = &mut test_rng();
+            let rng = &mut ChaCha20Rng::from_rng(test_rng()).unwrap();
             // If testing multivariate polynomials, make the max degree lower
             let max_degree = match num_vars {
                 Some(_) => max_degree.unwrap_or(Uniform::from(2..=10).sample(rng)),
@@ -979,8 +979,8 @@ pub mod tests {
 
     pub fn single_poly_test<F, P, PC, S>(
         num_vars: Option<usize>,
-        rand_poly: fn(usize, Option<usize>, &mut StdRng) -> P,
-        rand_point: fn(Option<usize>, &mut StdRng) -> P::Point,
+        rand_poly: fn(usize, Option<usize>, &mut ChaCha20Rng) -> P,
+        rand_point: fn(Option<usize>, &mut ChaCha20Rng) -> P::Point,
         sponge: fn() -> S,
     ) -> Result<(), PC::Error>
     where
@@ -1006,8 +1006,8 @@ pub mod tests {
     }
 
     pub fn linear_poly_degree_bound_test<F, P, PC, S>(
-        rand_poly: fn(usize, Option<usize>, &mut StdRng) -> P,
-        rand_point: fn(Option<usize>, &mut StdRng) -> P::Point,
+        rand_poly: fn(usize, Option<usize>, &mut ChaCha20Rng) -> P,
+        rand_point: fn(Option<usize>, &mut ChaCha20Rng) -> P::Point,
         sponge: fn() -> S,
     ) -> Result<(), PC::Error>
     where
@@ -1033,8 +1033,8 @@ pub mod tests {
     }
 
     pub fn single_poly_degree_bound_test<F, P, PC, S>(
-        rand_poly: fn(usize, Option<usize>, &mut StdRng) -> P,
-        rand_point: fn(Option<usize>, &mut StdRng) -> P::Point,
+        rand_poly: fn(usize, Option<usize>, &mut ChaCha20Rng) -> P,
+        rand_point: fn(Option<usize>, &mut ChaCha20Rng) -> P::Point,
         sponge: fn() -> S,
     ) -> Result<(), PC::Error>
     where
@@ -1060,8 +1060,8 @@ pub mod tests {
     }
 
     pub fn quadratic_poly_degree_bound_multiple_queries_test<F, P, PC, S>(
-        rand_poly: fn(usize, Option<usize>, &mut StdRng) -> P,
-        rand_point: fn(Option<usize>, &mut StdRng) -> P::Point,
+        rand_poly: fn(usize, Option<usize>, &mut ChaCha20Rng) -> P,
+        rand_point: fn(Option<usize>, &mut ChaCha20Rng) -> P::Point,
         sponge: fn() -> S,
     ) -> Result<(), PC::Error>
     where
@@ -1087,8 +1087,8 @@ pub mod tests {
     }
 
     pub fn single_poly_degree_bound_multiple_queries_test<F, P, PC, S>(
-        rand_poly: fn(usize, Option<usize>, &mut StdRng) -> P,
-        rand_point: fn(Option<usize>, &mut StdRng) -> P::Point,
+        rand_poly: fn(usize, Option<usize>, &mut ChaCha20Rng) -> P,
+        rand_point: fn(Option<usize>, &mut ChaCha20Rng) -> P::Point,
         sponge: fn() -> S,
     ) -> Result<(), PC::Error>
     where
@@ -1114,8 +1114,8 @@ pub mod tests {
     }
 
     pub fn two_polys_degree_bound_single_query_test<F, P, PC, S>(
-        rand_poly: fn(usize, Option<usize>, &mut StdRng) -> P,
-        rand_point: fn(Option<usize>, &mut StdRng) -> P::Point,
+        rand_poly: fn(usize, Option<usize>, &mut ChaCha20Rng) -> P,
+        rand_point: fn(Option<usize>, &mut ChaCha20Rng) -> P::Point,
         sponge: fn() -> S,
     ) -> Result<(), PC::Error>
     where
@@ -1142,8 +1142,8 @@ pub mod tests {
 
     pub fn full_end_to_end_test<F, P, PC, S>(
         num_vars: Option<usize>,
-        rand_poly: fn(usize, Option<usize>, &mut StdRng) -> P,
-        rand_point: fn(Option<usize>, &mut StdRng) -> P::Point,
+        rand_poly: fn(usize, Option<usize>, &mut ChaCha20Rng) -> P,
+        rand_point: fn(Option<usize>, &mut ChaCha20Rng) -> P::Point,
         sponge: fn() -> S,
     ) -> Result<(), PC::Error>
     where
@@ -1170,8 +1170,8 @@ pub mod tests {
 
     pub fn full_end_to_end_equation_test<F, P, PC, S>(
         num_vars: Option<usize>,
-        rand_poly: fn(usize, Option<usize>, &mut StdRng) -> P,
-        rand_point: fn(Option<usize>, &mut StdRng) -> P::Point,
+        rand_poly: fn(usize, Option<usize>, &mut ChaCha20Rng) -> P,
+        rand_point: fn(Option<usize>, &mut ChaCha20Rng) -> P::Point,
         sponge: fn() -> S,
     ) -> Result<(), PC::Error>
     where
@@ -1198,8 +1198,8 @@ pub mod tests {
 
     pub fn single_equation_test<F, P, PC, S>(
         num_vars: Option<usize>,
-        rand_poly: fn(usize, Option<usize>, &mut StdRng) -> P,
-        rand_point: fn(Option<usize>, &mut StdRng) -> P::Point,
+        rand_poly: fn(usize, Option<usize>, &mut ChaCha20Rng) -> P,
+        rand_point: fn(Option<usize>, &mut ChaCha20Rng) -> P::Point,
         sponge: fn() -> S,
     ) -> Result<(), PC::Error>
     where
@@ -1226,8 +1226,8 @@ pub mod tests {
 
     pub fn two_equation_test<F, P, PC, S>(
         num_vars: Option<usize>,
-        rand_poly: fn(usize, Option<usize>, &mut StdRng) -> P,
-        rand_point: fn(Option<usize>, &mut StdRng) -> P::Point,
+        rand_poly: fn(usize, Option<usize>, &mut ChaCha20Rng) -> P,
+        rand_point: fn(Option<usize>, &mut ChaCha20Rng) -> P::Point,
         sponge: fn() -> S,
     ) -> Result<(), PC::Error>
     where
@@ -1253,8 +1253,8 @@ pub mod tests {
     }
 
     pub fn two_equation_degree_bound_test<F, P, PC, S>(
-        rand_poly: fn(usize, Option<usize>, &mut StdRng) -> P,
-        rand_point: fn(Option<usize>, &mut StdRng) -> P::Point,
+        rand_poly: fn(usize, Option<usize>, &mut ChaCha20Rng) -> P,
+        rand_point: fn(Option<usize>, &mut ChaCha20Rng) -> P::Point,
         sponge: fn() -> S,
     ) -> Result<(), PC::Error>
     where
diff --git a/src/marlin/marlin_pc/mod.rs b/src/marlin/marlin_pc/mod.rs
index 918d5c4..535fde4 100644
--- a/src/marlin/marlin_pc/mod.rs
+++ b/src/marlin/marlin_pc/mod.rs
@@ -542,7 +542,7 @@ mod tests {
     use ark_ff::UniformRand;
     use ark_poly::{univariate::DensePolynomial as DensePoly, UVPolynomial};
     use ark_sponge::poseidon::PoseidonSponge;
-    use ark_std::rand::rngs::StdRng;
+    use rand_chacha::ChaCha20Rng;
 
     type UniPoly_381 = DensePoly<<Bls12_381 as PairingEngine>::Fr>;
     type UniPoly_377 = DensePoly<<Bls12_377 as PairingEngine>::Fr>;
@@ -558,7 +558,7 @@ mod tests {
     fn rand_poly<E: PairingEngine>(
         degree: usize,
         _: Option<usize>,
-        rng: &mut StdRng,
+        rng: &mut ChaCha20Rng,
     ) -> DensePoly<E::Fr> {
         DensePoly::<E::Fr>::rand(degree, rng)
     }
@@ -566,12 +566,12 @@ mod tests {
     fn constant_poly<E: PairingEngine>(
         _: usize,
         _: Option<usize>,
-        rng: &mut StdRng,
+        rng: &mut ChaCha20Rng,
     ) -> DensePoly<E::Fr> {
         DensePoly::<E::Fr>::from_coefficients_slice(&[E::Fr::rand(rng)])
     }
 
-    fn rand_point<E: PairingEngine>(_: Option<usize>, rng: &mut StdRng) -> E::Fr {
+    fn rand_point<E: PairingEngine>(_: Option<usize>, rng: &mut ChaCha20Rng) -> E::Fr {
         E::Fr::rand(rng)
     }
 
diff --git a/src/marlin/marlin_pst13_pc/mod.rs b/src/marlin/marlin_pst13_pc/mod.rs
index d418eb8..944066c 100644
--- a/src/marlin/marlin_pst13_pc/mod.rs
+++ b/src/marlin/marlin_pst13_pc/mod.rs
@@ -8,7 +8,7 @@ use crate::{LabeledCommitment, LabeledPolynomial, LinearCombination};
 use crate::{PCRandomness, PCUniversalParams, PolynomialCommitment};
 use crate::{ToString, Vec};
 use ark_ec::{
-    msm::{FixedBaseMSM, VariableBaseMSM},
+    msm::{FixedBase, VariableBase},
     AffineCurve, PairingEngine, ProjectiveCurve,
 };
 use ark_ff::{One, PrimeField, UniformRand, Zero};
@@ -215,21 +215,17 @@ where
 
         let scalar_bits = E::Fr::size_in_bits();
         let g_time = start_timer!(|| "Generating powers of G");
-        let window_size = FixedBaseMSM::get_mul_window_size(max_degree + 1);
-        let g_table = FixedBaseMSM::get_window_table(scalar_bits, window_size, g);
-        let mut powers_of_g = FixedBaseMSM::multi_scalar_mul::<E::G1Projective>(
-            scalar_bits,
-            window_size,
-            &g_table,
-            &powers_of_beta,
-        );
+        let window_size = FixedBase::get_mul_window_size(max_degree + 1);
+        let g_table = FixedBase::get_window_table(scalar_bits, window_size, g);
+        let mut powers_of_g =
+            FixedBase::msm::<E::G1Projective>(scalar_bits, window_size, &g_table, &powers_of_beta);
         powers_of_g.push(g);
         powers_of_beta_terms.push(P::Term::new(vec![]));
         end_timer!(g_time);
 
         let gamma_g_time = start_timer!(|| "Generating powers of gamma * G");
-        let window_size = FixedBaseMSM::get_mul_window_size(max_degree + 2);
-        let gamma_g_table = FixedBaseMSM::get_window_table(scalar_bits, window_size, gamma_g);
+        let window_size = FixedBase::get_mul_window_size(max_degree + 2);
+        let gamma_g_table = FixedBase::get_window_table(scalar_bits, window_size, gamma_g);
         // Each element `i` of `powers_of_gamma_g` is a vector of length `max_degree+1`
         // containing `betas[i]^j \gamma G` for `j` from 1 to `max_degree+1` to support
         // up to `max_degree` queries
@@ -243,7 +239,7 @@ where
                     cur *= &betas[i];
                     powers_of_beta.push(cur);
                 }
-                *v = FixedBaseMSM::multi_scalar_mul::<E::G1Projective>(
+                *v = FixedBase::msm::<E::G1Projective>(
                     scalar_bits,
                     window_size,
                     &gamma_g_table,
@@ -387,7 +383,7 @@ where
             end_timer!(to_bigint_time);
 
             let msm_time = start_timer!(|| "MSM to compute commitment to plaintext poly");
-            let mut commitment = VariableBaseMSM::multi_scalar_mul(&powers_of_g, &plain_ints);
+            let mut commitment = VariableBase::msm(&powers_of_g, &plain_ints);
             end_timer!(msm_time);
 
             // Sample random polynomial
@@ -423,7 +419,7 @@ where
 
             let msm_time = start_timer!(|| "MSM to compute commitment to random poly");
             let random_commitment =
-                VariableBaseMSM::multi_scalar_mul(&powers_of_gamma_g, &random_ints).into_affine();
+                VariableBase::msm(&powers_of_gamma_g, &random_ints).into_affine();
             end_timer!(msm_time);
 
             // Mask commitment with random poly
@@ -491,7 +487,7 @@ where
                 // Convert coefficients to BigInt
                 let witness_ints = Self::convert_to_bigints(&w);
                 // Compute MSM
-                VariableBaseMSM::multi_scalar_mul(&powers_of_g, &witness_ints)
+                VariableBase::msm(&powers_of_g, &witness_ints)
             })
             .collect::<Vec<_>>();
         end_timer!(witness_comm_time);
@@ -521,10 +517,7 @@ where
                     // Convert coefficients to BigInt
                     let hiding_witness_ints = Self::convert_to_bigints(hiding_witness);
                     // Compute MSM and add result to witness
-                    *witness += &VariableBaseMSM::multi_scalar_mul(
-                        &powers_of_gamma_g,
-                        &hiding_witness_ints,
-                    );
+                    *witness += &VariableBase::msm(&powers_of_gamma_g, &hiding_witness_ints);
                 });
             end_timer!(witness_comm_time);
             Some(r.blinding_polynomial.evaluate(point))
@@ -727,7 +720,7 @@ mod tests {
         MVPolynomial,
     };
     use ark_sponge::poseidon::PoseidonSponge;
-    use ark_std::rand::rngs::StdRng;
+    use rand_chacha::ChaCha20Rng;
 
     type MVPoly_381 = SparsePoly<<Bls12_381 as PairingEngine>::Fr, SparseTerm>;
     type MVPoly_377 = SparsePoly<<Bls12_377 as PairingEngine>::Fr, SparseTerm>;
@@ -743,12 +736,12 @@ mod tests {
     fn rand_poly<E: PairingEngine>(
         degree: usize,
         num_vars: Option<usize>,
-        rng: &mut StdRng,
+        rng: &mut ChaCha20Rng,
     ) -> SparsePoly<E::Fr, SparseTerm> {
         SparsePoly::<E::Fr, SparseTerm>::rand(degree, num_vars.unwrap(), rng)
     }
 
-    fn rand_point<E: PairingEngine>(num_vars: Option<usize>, rng: &mut StdRng) -> Vec<E::Fr> {
+    fn rand_point<E: PairingEngine>(num_vars: Option<usize>, rng: &mut ChaCha20Rng) -> Vec<E::Fr> {
         let num_vars = num_vars.unwrap();
         let mut point = Vec::with_capacity(num_vars);
         for _ in 0..num_vars {
diff --git a/src/multilinear_pc/mod.rs b/src/multilinear_pc/mod.rs
index 8cf5b25..81dafd1 100644
--- a/src/multilinear_pc/mod.rs
+++ b/src/multilinear_pc/mod.rs
@@ -1,7 +1,7 @@
 use crate::multilinear_pc::data_structures::{
     Commitment, CommitterKey, Proof, UniversalParams, VerifierKey,
 };
-use ark_ec::msm::{FixedBaseMSM, VariableBaseMSM};
+use ark_ec::msm::{FixedBase, VariableBase};
 use ark_ec::{AffineCurve, PairingEngine, ProjectiveCurve};
 use ark_ff::{Field, PrimeField};
 use ark_ff::{One, Zero};
@@ -59,16 +59,22 @@ impl<E: PairingEngine> MultilinearPC<E> {
             pp_powers.extend(pp_k_powers);
             total_scalars += 1 << (num_vars - i);
         }
-        let window_size = FixedBaseMSM::get_mul_window_size(total_scalars);
-        let g_table = FixedBaseMSM::get_window_table(scalar_bits, window_size, g.into_projective());
-        let h_table = FixedBaseMSM::get_window_table(scalar_bits, window_size, h.into_projective());
-
-        let pp_g = E::G1Projective::batch_normalization_into_affine(
-            &FixedBaseMSM::multi_scalar_mul(scalar_bits, window_size, &g_table, &pp_powers),
-        );
-        let pp_h = E::G2Projective::batch_normalization_into_affine(
-            &FixedBaseMSM::multi_scalar_mul(scalar_bits, window_size, &h_table, &pp_powers),
-        );
+        let window_size = FixedBase::get_mul_window_size(total_scalars);
+        let g_table = FixedBase::get_window_table(scalar_bits, window_size, g.into_projective());
+        let h_table = FixedBase::get_window_table(scalar_bits, window_size, h.into_projective());
+
+        let pp_g = E::G1Projective::batch_normalization_into_affine(&FixedBase::msm(
+            scalar_bits,
+            window_size,
+            &g_table,
+            &pp_powers,
+        ));
+        let pp_h = E::G2Projective::batch_normalization_into_affine(&FixedBase::msm(
+            scalar_bits,
+            window_size,
+            &h_table,
+            &pp_powers,
+        ));
         let mut start = 0;
         for i in 0..num_vars {
             let size = 1 << (num_vars - i);
@@ -82,10 +88,10 @@ impl<E: PairingEngine> MultilinearPC<E> {
         // uncomment to measure the time for calculating vp
         // let vp_generation_timer = start_timer!(|| "VP generation");
         let g_mask = {
-            let window_size = FixedBaseMSM::get_mul_window_size(num_vars);
+            let window_size = FixedBase::get_mul_window_size(num_vars);
             let g_table =
-                FixedBaseMSM::get_window_table(scalar_bits, window_size, g.into_projective());
-            E::G1Projective::batch_normalization_into_affine(&FixedBaseMSM::multi_scalar_mul(
+                FixedBase::get_window_table(scalar_bits, window_size, g.into_projective());
+            E::G1Projective::batch_normalization_into_affine(&FixedBase::msm(
                 scalar_bits,
                 window_size,
                 &g_table,
@@ -140,8 +146,7 @@ impl<E: PairingEngine> MultilinearPC<E> {
             .into_iter()
             .map(|x| x.into_repr())
             .collect();
-        let g_product =
-            VariableBaseMSM::multi_scalar_mul(&ck.powers_of_g[0], scalars.as_slice()).into_affine();
+        let g_product = VariableBase::msm(&ck.powers_of_g[0], scalars.as_slice()).into_affine();
         Commitment { nv, g_product }
     }
 
@@ -173,8 +178,7 @@ impl<E: PairingEngine> MultilinearPC<E> {
                 .map(|x| q[k][x >> 1].into_repr()) // fine
                 .collect();
 
-            let pi_h =
-                VariableBaseMSM::multi_scalar_mul(&ck.powers_of_h[i], &scalars).into_affine(); // no need to move outside and partition
+            let pi_h = VariableBase::msm(&ck.powers_of_h[i], &scalars).into_affine(); // no need to move outside and partition
             proofs.push(pi_h);
         }
 
@@ -196,12 +200,10 @@ impl<E: PairingEngine> MultilinearPC<E> {
         );
 
         let scalar_size = E::Fr::size_in_bits();
-        let window_size = FixedBaseMSM::get_mul_window_size(vk.nv);
+        let window_size = FixedBase::get_mul_window_size(vk.nv);
 
-        let g_table =
-            FixedBaseMSM::get_window_table(scalar_size, window_size, vk.g.into_projective());
-        let g_mul: Vec<E::G1Projective> =
-            FixedBaseMSM::multi_scalar_mul(scalar_size, window_size, &g_table, point);
+        let g_table = FixedBase::get_window_table(scalar_size, window_size, vk.g.into_projective());
+        let g_mul: Vec<E::G1Projective> = FixedBase::msm(scalar_size, window_size, &g_table, point);
 
         let pairing_lefts: Vec<_> = (0..vk.nv)
             .map(|i| vk.g_mask_random[i].into_projective() - &g_mul[i])
diff --git a/src/sonic_pc/mod.rs b/src/sonic_pc/mod.rs
index e02d635..1ddd1f6 100644
--- a/src/sonic_pc/mod.rs
+++ b/src/sonic_pc/mod.rs
@@ -685,7 +685,7 @@ mod tests {
     use ark_ff::UniformRand;
     use ark_poly::{univariate::DensePolynomial as DensePoly, UVPolynomial};
     use ark_sponge::poseidon::PoseidonSponge;
-    use ark_std::rand::rngs::StdRng;
+    use rand_chacha::ChaCha20Rng;
 
     type UniPoly_381 = DensePoly<<Bls12_381 as PairingEngine>::Fr>;
     type UniPoly_377 = DensePoly<<Bls12_377 as PairingEngine>::Fr>;
@@ -699,12 +699,12 @@ mod tests {
     fn rand_poly<E: PairingEngine>(
         degree: usize,
         _: Option<usize>,
-        rng: &mut StdRng,
+        rng: &mut ChaCha20Rng,
     ) -> DensePoly<E::Fr> {
         DensePoly::<E::Fr>::rand(degree, rng)
     }
 
-    fn rand_point<E: PairingEngine>(_: Option<usize>, rng: &mut StdRng) -> E::Fr {
+    fn rand_point<E: PairingEngine>(_: Option<usize>, rng: &mut ChaCha20Rng) -> E::Fr {
         E::Fr::rand(rng)
     }
 
-- 
GitLab