From 2d627e3b044270057d090306310f765e8d481b11 Mon Sep 17 00:00:00 2001
From: Marti <marcin.gorny.94@protonmail.com>
Date: Fri, 25 Oct 2024 02:06:47 +0200
Subject: [PATCH] Simplify `PolynomialCommitment` trait: remove the generic on
 `S: CryptographicSponge` (#145)

* `PolynomialCommitment` trait is no longer generic on `S`

Instead, pass `&mut impl CryptographicSponge` as an argument to the functions that need it

* fix example in README

* fmt

* remove the now-redundant definitions of Sponge in tests

* clean up all imports

clean up imports acc to nightly

Revert "dont need to use full path"

This reverts commit b272524abeaa9f7d6697539f22682bc081e3e8a5.

more fmt

* fix the constraints mod

* fix imports in tests

* Test to see

* Revert "Test to see"

This reverts commit acdbaaee8becb68db9430ca1b413e43ea26f6c25.

* Add `std` to patch

* Revert "Revert "Test to see""

This reverts commit 3448c900b066d49733da28da40fe12ef6953af6f.

* Reorder imports and simplify

* Update dependency on `hashbrown`, temporarily update `crypto-primitive`

* Update `Cargo.toml`

* Downgrade `hashbrown`

* Add dummy doc for nightly

* Reorder deps

* Add attribute for missing test docs

---------

Co-authored-by: autquis <autquis@gmail.com>
---
 Cargo.toml                                    |   7 +-
 README.md                                     |   3 +-
 bench-templates/src/lib.rs                    |  32 ++---
 poly-commit/Cargo.toml                        |   7 +-
 poly-commit/benches/pcs.rs                    |   5 +-
 poly-commit/benches/size.rs                   |   7 +-
 poly-commit/src/constraints.rs                |  16 +--
 poly-commit/src/data_structures.rs            |   6 +-
 poly-commit/src/error.rs                      |   3 +-
 poly-commit/src/ipa_pc/data_structures.rs     |   5 +-
 poly-commit/src/ipa_pc/mod.rs                 |  87 +++++++-------
 poly-commit/src/kzg10/data_structures.rs      |   6 +-
 poly-commit/src/kzg10/mod.rs                  |  13 +--
 poly-commit/src/lib.rs                        |  54 ++++-----
 .../src/marlin/marlin_pc/data_structures.rs   |  17 +--
 poly-commit/src/marlin/marlin_pc/mod.rs       | 109 ++++++++----------
 .../marlin/marlin_pst13_pc/combinations.rs    |   4 +-
 .../marlin/marlin_pst13_pc/data_structures.rs |  15 +--
 poly-commit/src/marlin/marlin_pst13_pc/mod.rs |  81 ++++++-------
 poly-commit/src/marlin/mod.rs                 |  41 +++----
 .../src/multilinear_pc/data_structures.rs     |   1 +
 poly-commit/src/multilinear_pc/mod.rs         |  31 +++--
 poly-commit/src/sonic_pc/data_structures.rs   |   8 +-
 poly-commit/src/sonic_pc/mod.rs               | 103 ++++++++---------
 .../src/streaming_kzg/data_structures.rs      |   7 +-
 poly-commit/src/streaming_kzg/mod.rs          |  26 ++---
 poly-commit/src/streaming_kzg/space.rs        |  25 ++--
 poly-commit/src/streaming_kzg/tests.rs        |  21 ++--
 poly-commit/src/streaming_kzg/time.rs         |  17 ++-
 29 files changed, 352 insertions(+), 405 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index bc7f3243..a7d77201 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -28,11 +28,12 @@ incremental = true
 debug = true
 
 [patch.crates-io]
+ark-std = { git = "https://github.com/arkworks-rs/std/" }
 ark-ff = { git = "https://github.com/arkworks-rs/algebra/" }
 ark-ec = { git = "https://github.com/arkworks-rs/algebra/" }
 ark-serialize = { git = "https://github.com/arkworks-rs/algebra/" }
-ark-crypto-primitives = { git = "https://github.com/arkworks-rs/crypto-primitives" }
+ark-crypto-primitives = { git = "https://github.com/arkworks-rs/crypto-primitives/" }
 ark-r1cs-std = { git = "https://github.com/arkworks-rs/r1cs-std/" }
 
-ark-bls12-377 = { git = "https://github.com/arkworks-rs/curves/" }
-ark-bls12-381 = { git = "https://github.com/arkworks-rs/curves/" }
+ark-bls12-377 = { git = "https://github.com/arkworks-rs/algebra/" }
+ark-bls12-381 = { git = "https://github.com/arkworks-rs/algebra/" }
diff --git a/README.md b/README.md
index 82c3e9a6..316f81ce 100644
--- a/README.md
+++ b/README.md
@@ -69,8 +69,7 @@ use rand_chacha::ChaCha20Rng;
 use ark_ff::PrimeField;
 
 type UniPoly_377 = DensePolynomial<<Bls12_377 as Pairing>::ScalarField>;
-type Sponge_Bls12_377 = PoseidonSponge<<Bls12_377 as Pairing>::ScalarField>;
-type PCS = MarlinKZG10<Bls12_377, UniPoly_377, Sponge_Bls12_377>;
+type PCS = MarlinKZG10<Bls12_377, UniPoly_377>;
 
 let rng = &mut test_rng();
 
diff --git a/bench-templates/src/lib.rs b/bench-templates/src/lib.rs
index 9451c313..0dca88fa 100644
--- a/bench-templates/src/lib.rs
+++ b/bench-templates/src/lib.rs
@@ -17,11 +17,7 @@ pub use criterion::*;
 pub use paste::paste;
 
 /// Measure the time cost of {commit/open/verify} across a range of num_vars
-pub fn bench_pcs_method<
-    F: PrimeField,
-    P: Polynomial<F>,
-    PCS: PolynomialCommitment<F, P, PoseidonSponge<F>>,
->(
+pub fn bench_pcs_method<F: PrimeField, P: Polynomial<F>, PCS: PolynomialCommitment<F, P>>(
     c: &mut Criterion,
     range: Vec<usize>,
     msg: &str,
@@ -53,11 +49,7 @@ pub fn bench_pcs_method<
 }
 
 /// Report the time cost of a commitment
-pub fn commit<
-    F: PrimeField,
-    P: Polynomial<F>,
-    PCS: PolynomialCommitment<F, P, PoseidonSponge<F>>,
->(
+pub fn commit<F: PrimeField, P: Polynomial<F>, PCS: PolynomialCommitment<F, P>>(
     ck: &PCS::CommitterKey,
     _vk: &PCS::VerifierKey,
     num_vars: usize,
@@ -74,11 +66,7 @@ pub fn commit<
 }
 
 /// Report the size of a commitment
-pub fn commitment_size<
-    F: PrimeField,
-    P: Polynomial<F>,
-    PCS: PolynomialCommitment<F, P, PoseidonSponge<F>>,
->(
+pub fn commitment_size<F: PrimeField, P: Polynomial<F>, PCS: PolynomialCommitment<F, P>>(
     num_vars: usize,
     rand_poly: fn(usize, &mut ChaCha20Rng) -> P,
 ) -> usize {
@@ -106,7 +94,7 @@ pub fn open<F, P, PCS>(
 where
     F: PrimeField,
     P: Polynomial<F>,
-    PCS: PolynomialCommitment<F, P, PoseidonSponge<F>>,
+    PCS: PolynomialCommitment<F, P>,
     P::Point: UniformRand,
 {
     let rng = &mut ChaCha20Rng::from_rng(test_rng()).unwrap();
@@ -123,7 +111,7 @@ where
         [&labeled_poly],
         &coms,
         &point,
-        &mut test_sponge(),
+        &mut test_sponge::<F>(),
         &states,
         Some(rng),
     )
@@ -136,7 +124,7 @@ pub fn proof_size<F, P, PCS>(num_vars: usize, rand_poly: fn(usize, &mut ChaCha20
 where
     F: PrimeField,
     P: Polynomial<F>,
-    PCS: PolynomialCommitment<F, P, PoseidonSponge<F>>,
+    PCS: PolynomialCommitment<F, P>,
 
     P::Point: UniformRand,
 {
@@ -156,7 +144,7 @@ where
         [&labeled_poly],
         &coms,
         &point,
-        &mut test_sponge(),
+        &mut test_sponge::<F>(),
         &states,
         Some(rng),
     )
@@ -177,7 +165,7 @@ pub fn verify<F, P, PCS>(
 where
     F: PrimeField,
     P: Polynomial<F>,
-    PCS: PolynomialCommitment<F, P, PoseidonSponge<F>>,
+    PCS: PolynomialCommitment<F, P>,
     P::Point: UniformRand,
 {
     let rng = &mut ChaCha20Rng::from_rng(test_rng()).unwrap();
@@ -193,7 +181,7 @@ where
         [&labeled_poly],
         &coms,
         &point,
-        &mut test_sponge(),
+        &mut test_sponge::<F>(),
         &states,
         Some(rng),
     )
@@ -206,7 +194,7 @@ where
         &point,
         [claimed_eval],
         &proof,
-        &mut test_sponge(),
+        &mut test_sponge::<F>(),
         None,
     )
     .unwrap();
diff --git a/poly-commit/Cargo.toml b/poly-commit/Cargo.toml
index 19098ce0..c2b2e7cc 100644
--- a/poly-commit/Cargo.toml
+++ b/poly-commit/Cargo.toml
@@ -16,12 +16,13 @@ ark-poly = {version = "^0.4.0", default-features = false }
 ark-crypto-primitives = {version = "^0.4.0", default-features = false, features = ["sponge", "merkle_tree"] }
 ark-std = { version = "^0.4.0", default-features = false }
 
+derivative = { version = "2", features = [ "use_core" ] }
+digest = "0.10"
+
 ark-relations = { version = "^0.4.0", default-features = false, optional = true }
 ark-r1cs-std = { version = "^0.4.0", default-features = false, optional = true }
-hashbrown = { version = "0.13", default-features = false, optional = true }
 
-digest = "0.10"
-derivative = { version = "2", features = [ "use_core" ] }
+hashbrown = { version = "0.13", default-features = false, optional = true}
 rayon = { version = "1", optional = true }
 
 [[bench]]
diff --git a/poly-commit/benches/pcs.rs b/poly-commit/benches/pcs.rs
index 77ab04f7..250428d6 100644
--- a/poly-commit/benches/pcs.rs
+++ b/poly-commit/benches/pcs.rs
@@ -1,9 +1,7 @@
-use ark_ec::AffineRepr;
 use ark_pcs_bench_templates::*;
 use ark_poly::DenseUVPolynomial;
 use blake2::Blake2s256;
 
-use ark_crypto_primitives::sponge::poseidon::PoseidonSponge;
 use ark_ed_on_bls12_381::{EdwardsAffine, Fr};
 use ark_ff::PrimeField;
 use ark_poly::univariate::DensePolynomial as DenseUnivariatePoly;
@@ -12,11 +10,10 @@ use ark_poly_commit::ipa_pc::InnerProductArgPC;
 use rand_chacha::ChaCha20Rng;
 
 type UniPoly = DenseUnivariatePoly<Fr>;
-type Sponge = PoseidonSponge<<EdwardsAffine as AffineRepr>::ScalarField>;
 
 // IPA_PC over the JubJub curve with Blake2s as the hash function
 #[allow(non_camel_case_types)]
-type IPA_JubJub = InnerProductArgPC<EdwardsAffine, Blake2s256, UniPoly, Sponge>;
+type IPA_JubJub = InnerProductArgPC<EdwardsAffine, Blake2s256, UniPoly>;
 
 fn rand_poly_ipa_pc<F: PrimeField>(degree: usize, rng: &mut ChaCha20Rng) -> DenseUnivariatePoly<F> {
     DenseUnivariatePoly::rand(degree, rng)
diff --git a/poly-commit/benches/size.rs b/poly-commit/benches/size.rs
index ab09d8cd..f4cfdc86 100644
--- a/poly-commit/benches/size.rs
+++ b/poly-commit/benches/size.rs
@@ -1,9 +1,7 @@
-use ark_ec::AffineRepr;
 use ark_pcs_bench_templates::*;
 use ark_poly::DenseUVPolynomial;
 use blake2::Blake2s256;
 
-use ark_crypto_primitives::sponge::poseidon::PoseidonSponge;
 use ark_ed_on_bls12_381::{EdwardsAffine, Fr};
 use ark_ff::PrimeField;
 use ark_poly::univariate::DensePolynomial as DenseUnivariatePoly;
@@ -12,12 +10,11 @@ use ark_poly_commit::ipa_pc::InnerProductArgPC;
 use rand_chacha::ChaCha20Rng;
 
 type UniPoly = DenseUnivariatePoly<Fr>;
-type Sponge = PoseidonSponge<<EdwardsAffine as AffineRepr>::ScalarField>;
-type PC<E, D, P, S> = InnerProductArgPC<E, D, P, S>;
+type PC<E, D, P> = InnerProductArgPC<E, D, P>;
 
 // IPA_PC over the JubJub curve with Blake2s as the hash function
 #[allow(non_camel_case_types)]
-type IPA_JubJub = PC<EdwardsAffine, Blake2s256, UniPoly, Sponge>;
+type IPA_JubJub = PC<EdwardsAffine, Blake2s256, UniPoly>;
 
 fn rand_poly_ipa_pc<F: PrimeField>(degree: usize, rng: &mut ChaCha20Rng) -> DenseUnivariatePoly<F> {
     DenseUnivariatePoly::rand(degree, rng)
diff --git a/poly-commit/src/constraints.rs b/poly-commit/src/constraints.rs
index 1300509a..e766524d 100644
--- a/poly-commit/src/constraints.rs
+++ b/poly-commit/src/constraints.rs
@@ -1,14 +1,17 @@
 use crate::{
     data_structures::LabeledCommitment, BatchLCProof, LCTerm, LinearCombination,
-    PCPreparedCommitment, PCPreparedVerifierKey, PolynomialCommitment, String, Vec,
+    PCPreparedCommitment, PCPreparedVerifierKey, PolynomialCommitment,
 };
-use ark_crypto_primitives::sponge::CryptographicSponge;
 use ark_ff::PrimeField;
 use ark_poly::Polynomial;
-use ark_r1cs_std::fields::emulated_fp::EmulatedFpVar;
-use ark_r1cs_std::{fields::fp::FpVar, prelude::*};
+use ark_r1cs_std::{
+    fields::{emulated_fp::EmulatedFpVar, fp::FpVar},
+    prelude::*,
+};
 use ark_relations::r1cs::{ConstraintSystemRef, Namespace, Result as R1CSResult, SynthesisError};
-use ark_std::{borrow::Borrow, cmp::Eq, cmp::PartialEq, hash::Hash, marker::Sized};
+use ark_std::{borrow::Borrow, cmp::Eq, cmp::PartialEq, hash::Hash};
+#[cfg(not(feature = "std"))]
+use ark_std::{string::String, vec::Vec};
 use hashbrown::{HashMap, HashSet};
 
 /// Define the minimal interface of prepared allocated structures.
@@ -94,9 +97,8 @@ pub struct PCCheckRandomDataVar<TargetField: PrimeField, BaseField: PrimeField>
 pub trait PCCheckVar<
     PCF: PrimeField,
     P: Polynomial<PCF>,
-    PC: PolynomialCommitment<PCF, P, S>,
+    PC: PolynomialCommitment<PCF, P>,
     ConstraintF: PrimeField,
-    S: CryptographicSponge,
 >: Clone
 {
     /// The prepared verifier key for the scheme; used to check an evaluation proof.
diff --git a/poly-commit/src/data_structures.rs b/poly-commit/src/data_structures.rs
index 2b942ee1..cd822b98 100644
--- a/poly-commit/src/data_structures.rs
+++ b/poly-commit/src/data_structures.rs
@@ -1,12 +1,14 @@
-use crate::{Polynomial, String, Vec};
+use crate::Polynomial;
 use ark_ff::{Field, PrimeField, ToConstraintField};
 use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
-use ark_std::rand::RngCore;
 use ark_std::{
     borrow::Borrow,
     marker::PhantomData,
     ops::{AddAssign, MulAssign, SubAssign},
+    rand::RngCore,
 };
+#[cfg(not(feature = "std"))]
+use ark_std::{string::String, vec::Vec};
 
 /// Labels a `LabeledPolynomial` or a `LabeledCommitment`.
 pub type PolynomialLabel = String;
diff --git a/poly-commit/src/error.rs b/poly-commit/src/error.rs
index de7091eb..6534aaae 100644
--- a/poly-commit/src/error.rs
+++ b/poly-commit/src/error.rs
@@ -1,4 +1,5 @@
-use crate::String;
+#[cfg(not(feature = "std"))]
+use ark_std::string::String;
 
 /// The error type for `PolynomialCommitment`.
 #[derive(Debug)]
diff --git a/poly-commit/src/ipa_pc/data_structures.rs b/poly-commit/src/ipa_pc/data_structures.rs
index 84fcb7f2..7eb6f1d3 100644
--- a/poly-commit/src/ipa_pc/data_structures.rs
+++ b/poly-commit/src/ipa_pc/data_structures.rs
@@ -1,10 +1,7 @@
 use crate::*;
-use crate::{PCCommitterKey, PCVerifierKey, Vec};
 use ark_ec::AffineRepr;
-use ark_ff::{Field, UniformRand, Zero};
+use ark_ff::{UniformRand, Zero};
 use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
-use ark_std::rand::RngCore;
-use ark_std::vec;
 
 /// `UniversalParams` are the universal parameters for the inner product arg scheme.
 #[derive(Derivative, CanonicalSerialize, CanonicalDeserialize)]
diff --git a/poly-commit/src/ipa_pc/mod.rs b/poly-commit/src/ipa_pc/mod.rs
index 43a40852..8afbacd9 100644
--- a/poly-commit/src/ipa_pc/mod.rs
+++ b/poly-commit/src/ipa_pc/mod.rs
@@ -1,22 +1,24 @@
-use crate::{BTreeMap, BTreeSet, String, ToString, Vec, CHALLENGE_SIZE};
-use crate::{BatchLCProof, DenseUVPolynomial, Error, Evaluations, QuerySet};
-use crate::{LabeledCommitment, LabeledPolynomial, LinearCombination};
-use crate::{PCCommitmentState, PCCommitterKey, PCUniversalParams, PolynomialCommitment};
-
+use crate::{
+    BTreeMap, BTreeSet, BatchLCProof, DenseUVPolynomial, Error, Evaluations, LabeledCommitment,
+    LabeledPolynomial, LinearCombination, PCCommitmentState, PCCommitterKey, PCUniversalParams,
+    PolynomialCommitment, QuerySet, CHALLENGE_SIZE,
+};
+use ark_crypto_primitives::sponge::CryptographicSponge;
 use ark_ec::{AffineRepr, CurveGroup, VariableBaseMSM};
 use ark_ff::{Field, One, PrimeField, UniformRand, Zero};
 use ark_serialize::CanonicalSerialize;
-use ark_std::rand::RngCore;
-use ark_std::{convert::TryInto, format, marker::PhantomData, ops::Mul, vec};
-
-mod data_structures;
-pub use data_structures::*;
-
+use ark_std::{convert::TryInto, format, marker::PhantomData, ops::Mul, rand::RngCore};
+#[cfg(not(feature = "std"))]
+use ark_std::{
+    string::{String, ToString},
+    vec::Vec,
+};
+use digest::Digest;
 #[cfg(feature = "parallel")]
 use rayon::prelude::*;
 
-use ark_crypto_primitives::sponge::CryptographicSponge;
-use digest::Digest;
+mod data_structures;
+pub use data_structures::*;
 
 /// A polynomial commitment scheme based on the hardness of the
 /// discrete logarithm problem in prime-order groups.
@@ -31,25 +33,18 @@ use digest::Digest;
 ///
 /// [pcdas]: https://eprint.iacr.org/2020/499
 /// [marlin]: https://eprint.iacr.org/2019/1047
-pub struct InnerProductArgPC<
-    G: AffineRepr,
-    D: Digest,
-    P: DenseUVPolynomial<G::ScalarField>,
-    S: CryptographicSponge,
-> {
+pub struct InnerProductArgPC<G: AffineRepr, D: Digest, P: DenseUVPolynomial<G::ScalarField>> {
     _projective: PhantomData<G>,
     _digest: PhantomData<D>,
     _poly: PhantomData<P>,
-    _sponge: PhantomData<S>,
 }
 
-impl<G, D, P, S> InnerProductArgPC<G, D, P, S>
+impl<G, D, P> InnerProductArgPC<G, D, P>
 where
     G: AffineRepr,
     G::Group: VariableBaseMSM<MulBase = G>,
     D: Digest,
     P: DenseUVPolynomial<G::ScalarField>,
-    S: CryptographicSponge,
 {
     /// `PROTOCOL_NAME` is used as a seed for the setup function.
     pub const PROTOCOL_NAME: &'static [u8] = b"PC-DL-2020";
@@ -104,7 +99,7 @@ where
         point: G::ScalarField,
         values: impl IntoIterator<Item = G::ScalarField>,
         proof: &Proof<G>,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
     ) -> Option<SuccinctCheckPolynomial<G::ScalarField>> {
         let check_time = start_timer!(|| "Succinct checking");
 
@@ -335,13 +330,12 @@ where
     }
 }
 
-impl<G, D, P, S> PolynomialCommitment<G::ScalarField, P, S> for InnerProductArgPC<G, D, P, S>
+impl<G, D, P> PolynomialCommitment<G::ScalarField, P> for InnerProductArgPC<G, D, P>
 where
     G: AffineRepr,
     G::Group: VariableBaseMSM<MulBase = G>,
     D: Digest,
     P: DenseUVPolynomial<G::ScalarField, Point = G::ScalarField>,
-    S: CryptographicSponge,
 {
     type UniversalParams = UniversalParams<G>;
     type CommitterKey = CommitterKey<G>;
@@ -488,7 +482,7 @@ where
         labeled_polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<G::ScalarField, P>>,
         commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
         point: &'a P::Point,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         states: impl IntoIterator<Item = &'a Self::CommitmentState>,
         rng: Option<&mut dyn RngCore>,
     ) -> Result<Self::Proof, Self::Error>
@@ -739,7 +733,7 @@ where
         point: &'a P::Point,
         values: impl IntoIterator<Item = G::ScalarField>,
         proof: &Self::Proof,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         _rng: Option<&mut dyn RngCore>,
     ) -> Result<bool, Self::Error>
     where
@@ -789,7 +783,7 @@ where
         query_set: &QuerySet<P::Point>,
         values: &Evaluations<G::ScalarField, P::Point>,
         proof: &Self::BatchProof,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         rng: &mut R,
     ) -> Result<bool, Self::Error>
     where
@@ -869,7 +863,7 @@ where
         polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<G::ScalarField, P>>,
         commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
         query_set: &QuerySet<P::Point>,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         states: impl IntoIterator<Item = &'a Self::CommitmentState>,
         rng: Option<&mut dyn RngCore>,
     ) -> Result<BatchLCProof<G::ScalarField, Self::BatchProof>, Self::Error>
@@ -980,7 +974,7 @@ where
         eqn_query_set: &QuerySet<P::Point>,
         eqn_evaluations: &Evaluations<P::Point, G::ScalarField>,
         proof: &BatchLCProof<G::ScalarField, Self::BatchProof>,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         rng: &mut R,
     ) -> Result<bool, Self::Error>
     where
@@ -1064,8 +1058,6 @@ mod tests {
     #![allow(non_camel_case_types)]
 
     use super::InnerProductArgPC;
-    use ark_crypto_primitives::sponge::poseidon::PoseidonSponge;
-    use ark_ec::AffineRepr;
     use ark_ed_on_bls12_381::{EdwardsAffine, Fr};
     use ark_ff::PrimeField;
     use ark_poly::{univariate::DensePolynomial as DensePoly, DenseUVPolynomial};
@@ -1073,9 +1065,8 @@ mod tests {
     use rand_chacha::ChaCha20Rng;
 
     type UniPoly = DensePoly<Fr>;
-    type Sponge = PoseidonSponge<<EdwardsAffine as AffineRepr>::ScalarField>;
-    type PC<E, D, P, S> = InnerProductArgPC<E, D, P, S>;
-    type PC_JJB2S = PC<EdwardsAffine, Blake2s256, UniPoly, Sponge>;
+    type PC<E, D, P> = InnerProductArgPC<E, D, P>;
+    type PC_JJB2S = PC<EdwardsAffine, Blake2s256, UniPoly>;
 
     fn rand_poly<F: PrimeField>(
         degree: usize,
@@ -1104,7 +1095,7 @@ mod tests {
             None,
             rand_poly::<Fr>,
             rand_point::<Fr>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<Fr>,
         )
         .expect("test failed for ed_on_bls12_381-blake2s");
     }
@@ -1116,7 +1107,7 @@ mod tests {
             None,
             constant_poly::<Fr>,
             rand_point::<Fr>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<Fr>,
         )
         .expect("test failed for ed_on_bls12_381-blake2s");
     }
@@ -1127,7 +1118,7 @@ mod tests {
         quadratic_poly_degree_bound_multiple_queries_test::<_, _, PC_JJB2S, _>(
             rand_poly::<Fr>,
             rand_point::<Fr>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<Fr>,
         )
         .expect("test failed for ed_on_bls12_381-blake2s");
     }
@@ -1138,7 +1129,7 @@ mod tests {
         linear_poly_degree_bound_test::<_, _, PC_JJB2S, _>(
             rand_poly::<Fr>,
             rand_point::<Fr>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<Fr>,
         )
         .expect("test failed for ed_on_bls12_381-blake2s");
     }
@@ -1149,7 +1140,7 @@ mod tests {
         single_poly_degree_bound_test::<_, _, PC_JJB2S, _>(
             rand_poly::<Fr>,
             rand_point::<Fr>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<Fr>,
         )
         .expect("test failed for ed_on_bls12_381-blake2s");
     }
@@ -1160,7 +1151,7 @@ mod tests {
         single_poly_degree_bound_multiple_queries_test::<_, _, PC_JJB2S, _>(
             rand_poly::<Fr>,
             rand_point::<Fr>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<Fr>,
         )
         .expect("test failed for ed_on_bls12_381-blake2s");
     }
@@ -1171,7 +1162,7 @@ mod tests {
         two_polys_degree_bound_single_query_test::<_, _, PC_JJB2S, _>(
             rand_poly::<Fr>,
             rand_point::<Fr>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<Fr>,
         )
         .expect("test failed for ed_on_bls12_381-blake2s");
     }
@@ -1183,7 +1174,7 @@ mod tests {
             None,
             rand_poly::<Fr>,
             rand_point::<Fr>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<Fr>,
         )
         .expect("test failed for ed_on_bls12_381-blake2s");
         println!("Finished ed_on_bls12_381-blake2s");
@@ -1196,7 +1187,7 @@ mod tests {
             None,
             rand_poly::<Fr>,
             rand_point::<Fr>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<Fr>,
         )
         .expect("test failed for ed_on_bls12_381-blake2s");
         println!("Finished ed_on_bls12_381-blake2s");
@@ -1209,7 +1200,7 @@ mod tests {
             None,
             rand_poly::<Fr>,
             rand_point::<Fr>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<Fr>,
         )
         .expect("test failed for ed_on_bls12_381-blake2s");
         println!("Finished ed_on_bls12_381-blake2s");
@@ -1221,7 +1212,7 @@ mod tests {
         two_equation_degree_bound_test::<_, _, PC_JJB2S, _>(
             rand_poly::<Fr>,
             rand_point::<Fr>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<Fr>,
         )
         .expect("test failed for ed_on_bls12_381-blake2s");
         println!("Finished ed_on_bls12_381-blake2s");
@@ -1234,7 +1225,7 @@ mod tests {
             None,
             rand_poly::<Fr>,
             rand_point::<Fr>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<Fr>,
         )
         .expect("test failed for ed_on_bls12_381-blake2s");
         println!("Finished ed_on_bls12_381-blake2s");
@@ -1247,7 +1238,7 @@ mod tests {
         bad_degree_bound_test::<_, _, PC_JJB2S, _>(
             rand_poly::<Fr>,
             rand_point::<Fr>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<Fr>,
         )
         .expect("test failed for ed_on_bls12_381-blake2s");
         println!("Finished ed_on_bls12_381-blake2s");
diff --git a/poly-commit/src/kzg10/data_structures.rs b/poly-commit/src/kzg10/data_structures.rs
index d648f19f..f781465c 100644
--- a/poly-commit/src/kzg10/data_structures.rs
+++ b/poly-commit/src/kzg10/data_structures.rs
@@ -1,8 +1,6 @@
 use crate::*;
-use ark_ec::pairing::Pairing;
-use ark_ec::AdditiveGroup;
-use ark_ec::AffineRepr;
-use ark_ff::{PrimeField, ToConstraintField};
+use ark_ec::{pairing::Pairing, AdditiveGroup, AffineRepr};
+use ark_ff::ToConstraintField;
 use ark_serialize::{
     CanonicalDeserialize, CanonicalSerialize, Compress, SerializationError, Valid, Validate,
 };
diff --git a/poly-commit/src/kzg10/mod.rs b/poly-commit/src/kzg10/mod.rs
index 508db2cb..48861963 100644
--- a/poly-commit/src/kzg10/mod.rs
+++ b/poly-commit/src/kzg10/mod.rs
@@ -5,15 +5,13 @@
 //! proposed by Kate, Zaverucha, and Goldberg ([KZG10](http://cacr.uwaterloo.ca/techreports/2010/cacr2010-10.pdf)).
 //! This construction achieves extractability in the algebraic group model (AGM).
 
-use crate::{BTreeMap, Error, LabeledPolynomial, PCCommitmentState, ToString, Vec};
-use ark_ec::AffineRepr;
-use ark_ec::{pairing::Pairing, CurveGroup};
-use ark_ec::{scalar_mul::ScalarMul, VariableBaseMSM};
+use crate::{BTreeMap, Error, LabeledPolynomial, PCCommitmentState};
+use ark_ec::{pairing::Pairing, scalar_mul::ScalarMul, AffineRepr, CurveGroup, VariableBaseMSM};
 use ark_ff::{One, PrimeField, UniformRand, Zero};
 use ark_poly::DenseUVPolynomial;
-use ark_std::{format, marker::PhantomData, ops::Div, ops::Mul, vec};
-
-use ark_std::rand::RngCore;
+use ark_std::{format, marker::PhantomData, ops::Div, ops::Mul, rand::RngCore};
+#[cfg(not(feature = "std"))]
+use ark_std::{string::ToString, vec::Vec};
 #[cfg(feature = "parallel")]
 use rayon::prelude::*;
 
@@ -479,7 +477,6 @@ mod tests {
     use ark_bls12_377::Bls12_377;
     use ark_bls12_381::Bls12_381;
     use ark_bls12_381::Fr;
-    use ark_ec::pairing::Pairing;
     use ark_poly::univariate::DensePolynomial as DensePoly;
     use ark_std::test_rng;
 
diff --git a/poly-commit/src/lib.rs b/poly-commit/src/lib.rs
index 8ebb9710..9dc26cba 100644
--- a/poly-commit/src/lib.rs
+++ b/poly-commit/src/lib.rs
@@ -19,13 +19,15 @@ extern crate ark_std;
 
 use ark_ff::{Field, PrimeField};
 pub use ark_poly::{DenseUVPolynomial, Polynomial};
-use ark_std::rand::RngCore;
-
 use ark_std::{
     collections::{BTreeMap, BTreeSet},
     fmt::Debug,
     hash::Hash,
     iter::FromIterator,
+    rand::RngCore,
+};
+#[cfg(not(feature = "std"))]
+use ark_std::{
     string::{String, ToString},
     vec::Vec,
 };
@@ -140,9 +142,7 @@ pub type Evaluations<T, F> = BTreeMap<(String, T), F>;
 /// a sender to commit to multiple polynomials and later provide a succinct proof
 /// of evaluation for the corresponding commitments at a query set `Q`, while
 /// enforcing per-polynomial degree bounds.
-pub trait PolynomialCommitment<F: PrimeField, P: Polynomial<F>, S: CryptographicSponge>:
-    Sized
-{
+pub trait PolynomialCommitment<F: PrimeField, P: Polynomial<F>>: Sized {
     /// The universal parameters for the commitment scheme. These are "trimmed"
     /// down to `Self::CommitterKey` and `Self::VerifierKey` by `Self::trim`.
     type UniversalParams: PCUniversalParams;
@@ -216,7 +216,7 @@ pub trait PolynomialCommitment<F: PrimeField, P: Polynomial<F>, S: Cryptographic
         labeled_polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<F, P>>,
         commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
         point: &'a P::Point,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         states: impl IntoIterator<Item = &'a Self::CommitmentState>,
         rng: Option<&mut dyn RngCore>,
     ) -> Result<Self::Proof, Self::Error>
@@ -232,7 +232,7 @@ pub trait PolynomialCommitment<F: PrimeField, P: Polynomial<F>, S: Cryptographic
         point: &'a P::Point,
         values: impl IntoIterator<Item = F>,
         proof: &Self::Proof,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         rng: Option<&mut dyn RngCore>,
     ) -> Result<bool, Self::Error>
     where
@@ -252,7 +252,7 @@ pub trait PolynomialCommitment<F: PrimeField, P: Polynomial<F>, S: Cryptographic
         labeled_polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<F, P>>,
         commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
         query_set: &QuerySet<P::Point>,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         states: impl IntoIterator<Item = &'a Self::CommitmentState>,
         rng: Option<&mut dyn RngCore>,
     ) -> Result<Self::BatchProof, Self::Error>
@@ -265,7 +265,7 @@ pub trait PolynomialCommitment<F: PrimeField, P: Polynomial<F>, S: Cryptographic
         // order to gather (i.e. batch) all polynomials that should be queried at
         // the same point, then opening their commitments simultaneously with a
         // single call to `open` (per point)
-        let rng = &mut crate::optional_rng::OptionalRng(rng);
+        let rng = &mut optional_rng::OptionalRng(rng);
         let poly_st_comm: BTreeMap<_, _> = labeled_polynomials
             .into_iter()
             .zip(states)
@@ -357,7 +357,7 @@ pub trait PolynomialCommitment<F: PrimeField, P: Polynomial<F>, S: Cryptographic
         query_set: &QuerySet<P::Point>,
         evaluations: &Evaluations<P::Point, F>,
         proof: &Self::BatchProof,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         rng: &mut R,
     ) -> Result<bool, Self::Error>
     where
@@ -429,7 +429,7 @@ pub trait PolynomialCommitment<F: PrimeField, P: Polynomial<F>, S: Cryptographic
         polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<F, P>>,
         commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
         query_set: &QuerySet<P::Point>,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         states: impl IntoIterator<Item = &'a Self::CommitmentState>,
         rng: Option<&mut dyn RngCore>,
     ) -> Result<BatchLCProof<F, Self::BatchProof>, Self::Error>
@@ -474,7 +474,7 @@ pub trait PolynomialCommitment<F: PrimeField, P: Polynomial<F>, S: Cryptographic
         eqn_query_set: &QuerySet<P::Point>,
         eqn_evaluations: &Evaluations<P::Point, F>,
         proof: &BatchLCProof<F, Self::BatchProof>,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         rng: &mut R,
     ) -> Result<bool, Self::Error>
     where
@@ -622,9 +622,9 @@ fn lc_query_set_to_poly_query_set<'a, F: Field, T: Clone + Ord>(
 
 #[cfg(test)]
 pub mod tests {
+    #![allow(missing_docs)]
     use crate::*;
     use ark_crypto_primitives::sponge::poseidon::{PoseidonConfig, PoseidonSponge};
-    use ark_poly::Polynomial;
     use ark_std::rand::{
         distributions::{Distribution, Uniform},
         Rng, SeedableRng,
@@ -654,7 +654,7 @@ pub mod tests {
     where
         F: PrimeField,
         P: Polynomial<F>,
-        PC: PolynomialCommitment<F, P, S>,
+        PC: PolynomialCommitment<F, P>,
         S: CryptographicSponge,
     {
         let sponge = sponge();
@@ -743,7 +743,7 @@ pub mod tests {
     where
         F: PrimeField,
         P: Polynomial<F>,
-        PC: PolynomialCommitment<F, P, S>,
+        PC: PolynomialCommitment<F, P>,
         S: CryptographicSponge,
     {
         let TestInfo {
@@ -884,7 +884,7 @@ pub mod tests {
     where
         F: PrimeField,
         P: Polynomial<F>,
-        PC: PolynomialCommitment<F, P, S>,
+        PC: PolynomialCommitment<F, P>,
         S: CryptographicSponge,
     {
         let TestInfo {
@@ -1070,7 +1070,7 @@ pub mod tests {
     where
         F: PrimeField,
         P: Polynomial<F>,
-        PC: PolynomialCommitment<F, P, S>,
+        PC: PolynomialCommitment<F, P>,
         S: CryptographicSponge,
     {
         let info = TestInfo {
@@ -1097,7 +1097,7 @@ pub mod tests {
     where
         F: PrimeField,
         P: Polynomial<F>,
-        PC: PolynomialCommitment<F, P, S>,
+        PC: PolynomialCommitment<F, P>,
         S: CryptographicSponge,
     {
         let info = TestInfo {
@@ -1124,7 +1124,7 @@ pub mod tests {
     where
         F: PrimeField,
         P: Polynomial<F>,
-        PC: PolynomialCommitment<F, P, S>,
+        PC: PolynomialCommitment<F, P>,
         S: CryptographicSponge,
     {
         let info = TestInfo {
@@ -1151,7 +1151,7 @@ pub mod tests {
     where
         F: PrimeField,
         P: Polynomial<F>,
-        PC: PolynomialCommitment<F, P, S>,
+        PC: PolynomialCommitment<F, P>,
         S: CryptographicSponge,
     {
         let info = TestInfo {
@@ -1178,7 +1178,7 @@ pub mod tests {
     where
         F: PrimeField,
         P: Polynomial<F>,
-        PC: PolynomialCommitment<F, P, S>,
+        PC: PolynomialCommitment<F, P>,
         S: CryptographicSponge,
     {
         let info = TestInfo {
@@ -1205,7 +1205,7 @@ pub mod tests {
     where
         F: PrimeField,
         P: Polynomial<F>,
-        PC: PolynomialCommitment<F, P, S>,
+        PC: PolynomialCommitment<F, P>,
         S: CryptographicSponge,
     {
         let info = TestInfo {
@@ -1233,7 +1233,7 @@ pub mod tests {
     where
         F: PrimeField,
         P: Polynomial<F>,
-        PC: PolynomialCommitment<F, P, S>,
+        PC: PolynomialCommitment<F, P>,
         S: CryptographicSponge,
     {
         let info = TestInfo {
@@ -1261,7 +1261,7 @@ pub mod tests {
     where
         F: PrimeField,
         P: Polynomial<F>,
-        PC: PolynomialCommitment<F, P, S>,
+        PC: PolynomialCommitment<F, P>,
         S: CryptographicSponge,
     {
         let info = TestInfo {
@@ -1289,7 +1289,7 @@ pub mod tests {
     where
         F: PrimeField,
         P: Polynomial<F>,
-        PC: PolynomialCommitment<F, P, S>,
+        PC: PolynomialCommitment<F, P>,
         S: CryptographicSponge,
     {
         let info = TestInfo {
@@ -1317,7 +1317,7 @@ pub mod tests {
     where
         F: PrimeField,
         P: Polynomial<F>,
-        PC: PolynomialCommitment<F, P, S>,
+        PC: PolynomialCommitment<F, P>,
         S: CryptographicSponge,
     {
         let info = TestInfo {
@@ -1344,7 +1344,7 @@ pub mod tests {
     where
         F: PrimeField,
         P: Polynomial<F>,
-        PC: PolynomialCommitment<F, P, S>,
+        PC: PolynomialCommitment<F, P>,
         S: CryptographicSponge,
     {
         let info = TestInfo {
diff --git a/poly-commit/src/marlin/marlin_pc/data_structures.rs b/poly-commit/src/marlin/marlin_pc/data_structures.rs
index 203e3201..f01f67ab 100644
--- a/poly-commit/src/marlin/marlin_pc/data_structures.rs
+++ b/poly-commit/src/marlin/marlin_pc/data_structures.rs
@@ -1,15 +1,16 @@
 use crate::{
-    DenseUVPolynomial, PCCommitment, PCCommitmentState, PCCommitterKey, PCPreparedCommitment,
-    PCPreparedVerifierKey, PCVerifierKey, Vec,
+    kzg10, DenseUVPolynomial, PCCommitment, PCCommitmentState, PCCommitterKey,
+    PCPreparedCommitment, PCPreparedVerifierKey, PCVerifierKey,
 };
-use ark_ec::pairing::Pairing;
-use ark_ec::AdditiveGroup;
+use ark_ec::{pairing::Pairing, AdditiveGroup};
 use ark_ff::{Field, PrimeField, ToConstraintField};
 use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
-use ark_std::ops::{Add, AddAssign};
-use ark_std::rand::RngCore;
-
-use crate::kzg10;
+#[cfg(not(feature = "std"))]
+use ark_std::vec::Vec;
+use ark_std::{
+    ops::{Add, AddAssign},
+    rand::RngCore,
+};
 /// `UniversalParams` are the universal parameters for the KZG10 scheme.
 pub type UniversalParams<E> = kzg10::UniversalParams<E>;
 
diff --git a/poly-commit/src/marlin/marlin_pc/mod.rs b/poly-commit/src/marlin/marlin_pc/mod.rs
index 7fbfba07..52f56354 100644
--- a/poly-commit/src/marlin/marlin_pc/mod.rs
+++ b/poly-commit/src/marlin/marlin_pc/mod.rs
@@ -1,18 +1,17 @@
-use crate::{kzg10, marlin::Marlin, PCCommitterKey, CHALLENGE_SIZE};
-use crate::{BTreeMap, BTreeSet, ToString, Vec};
-use crate::{BatchLCProof, Error, Evaluations, QuerySet};
-use crate::{LabeledCommitment, LabeledPolynomial, LinearCombination};
-use crate::{PCCommitmentState, PCUniversalParams, PolynomialCommitment};
-use ark_ec::pairing::Pairing;
-use ark_ec::AffineRepr;
-use ark_ec::CurveGroup;
+use crate::{
+    kzg10, marlin::Marlin, BTreeMap, BTreeSet, BatchLCProof, Error, Evaluations, LabeledCommitment,
+    LabeledPolynomial, LinearCombination, PCCommitmentState, PCCommitterKey, PCUniversalParams,
+    PolynomialCommitment, QuerySet, CHALLENGE_SIZE,
+};
+use ark_crypto_primitives::sponge::CryptographicSponge;
+use ark_ec::{pairing::Pairing, AffineRepr, CurveGroup};
 use ark_ff::Zero;
 use ark_poly::DenseUVPolynomial;
-use ark_std::rand::RngCore;
-use ark_std::{marker::PhantomData, ops::Div, vec};
+use ark_std::{marker::PhantomData, ops::Div, rand::RngCore};
+#[cfg(not(feature = "std"))]
+use ark_std::{string::ToString, vec::Vec};
 
 mod data_structures;
-use ark_crypto_primitives::sponge::CryptographicSponge;
 pub use data_structures::*;
 
 /// Polynomial commitment based on [[KZG10]][kzg], with degree enforcement, batching,
@@ -27,10 +26,9 @@ pub use data_structures::*;
 ///
 /// [kzg]: http://cacr.uwaterloo.ca/techreports/2010/cacr2010-10.pdf
 /// [marlin]: https://eprint.iacr.org/2019/1047
-pub struct MarlinKZG10<E: Pairing, P: DenseUVPolynomial<E::ScalarField>, S: CryptographicSponge> {
+pub struct MarlinKZG10<E: Pairing, P: DenseUVPolynomial<E::ScalarField>> {
     _engine: PhantomData<E>,
     _poly: PhantomData<P>,
-    _sponge: PhantomData<S>,
 }
 
 pub(crate) fn shift_polynomial<E: Pairing, P: DenseUVPolynomial<E::ScalarField>>(
@@ -54,11 +52,10 @@ pub(crate) fn shift_polynomial<E: Pairing, P: DenseUVPolynomial<E::ScalarField>>
     }
 }
 
-impl<E, P, S> PolynomialCommitment<E::ScalarField, P, S> for MarlinKZG10<E, P, S>
+impl<E, P> PolynomialCommitment<E::ScalarField, P> for MarlinKZG10<E, P>
 where
     E: Pairing,
     P: DenseUVPolynomial<E::ScalarField, Point = E::ScalarField>,
-    S: CryptographicSponge,
     for<'a, 'b> &'a P: Div<&'b P, Output = P>,
 {
     type UniversalParams = UniversalParams<E>;
@@ -250,7 +247,7 @@ where
         labeled_polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<E::ScalarField, P>>,
         _commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
         point: &'a P::Point,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         states: impl IntoIterator<Item = &'a Self::CommitmentState>,
         _rng: Option<&mut dyn RngCore>,
     ) -> Result<Self::Proof, Self::Error>
@@ -346,7 +343,7 @@ where
         point: &'a P::Point,
         values: impl IntoIterator<Item = E::ScalarField>,
         proof: &Self::Proof,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         _rng: Option<&mut dyn RngCore>,
     ) -> Result<bool, Self::Error>
     where
@@ -354,7 +351,7 @@ where
     {
         let check_time = start_timer!(|| "Checking evaluations");
         let (combined_comm, combined_value) =
-            Marlin::<E, S, P, Self>::accumulate_commitments_and_values(
+            Marlin::<E, P, Self>::accumulate_commitments_and_values(
                 commitments,
                 values,
                 sponge,
@@ -372,14 +369,14 @@ where
         query_set: &QuerySet<P::Point>,
         values: &Evaluations<E::ScalarField, P::Point>,
         proof: &Self::BatchProof,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         rng: &mut R,
     ) -> Result<bool, Self::Error>
     where
         Self::Commitment: 'a,
     {
         let (combined_comms, combined_queries, combined_evals) =
-            Marlin::<E, S, P, Self>::combine_and_normalize(
+            Marlin::<E, P, Self>::combine_and_normalize(
                 commitments,
                 query_set,
                 values,
@@ -406,7 +403,7 @@ where
         polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<E::ScalarField, P>>,
         commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
         query_set: &QuerySet<P::Point>,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         states: impl IntoIterator<Item = &'a Self::CommitmentState>,
         rng: Option<&mut dyn RngCore>,
     ) -> Result<BatchLCProof<E::ScalarField, Self::BatchProof>, Self::Error>
@@ -415,7 +412,7 @@ where
         Self::CommitmentState: 'a,
         Self::Commitment: 'a,
     {
-        Marlin::<E, S, P, Self>::open_combinations(
+        Marlin::<E, P, Self>::open_combinations(
             ck,
             lc_s,
             polynomials,
@@ -436,13 +433,13 @@ where
         query_set: &QuerySet<P::Point>,
         evaluations: &Evaluations<E::ScalarField, P::Point>,
         proof: &BatchLCProof<E::ScalarField, Self::BatchProof>,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         rng: &mut R,
     ) -> Result<bool, Self::Error>
     where
         Self::Commitment: 'a,
     {
-        Marlin::<E, S, P, Self>::check_combinations(
+        Marlin::<E, P, Self>::check_combinations(
             vk,
             lc_s,
             commitments,
@@ -461,7 +458,7 @@ where
         labeled_polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<E::ScalarField, P>>,
         commitments: impl IntoIterator<Item = &'a LabeledCommitment<Commitment<E>>>,
         query_set: &QuerySet<P::Point>,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         states: impl IntoIterator<Item = &'a Self::CommitmentState>,
         rng: Option<&mut dyn RngCore>,
     ) -> Result<Vec<kzg10::Proof<E>>, Error>
@@ -537,7 +534,6 @@ mod tests {
     use super::MarlinKZG10;
     use ark_bls12_377::Bls12_377;
     use ark_bls12_381::Bls12_381;
-    use ark_crypto_primitives::sponge::poseidon::PoseidonSponge;
     use ark_ec::pairing::Pairing;
     use ark_ff::UniformRand;
     use ark_poly::{univariate::DensePolynomial as DensePoly, DenseUVPolynomial};
@@ -546,13 +542,10 @@ mod tests {
     type UniPoly_381 = DensePoly<<Bls12_381 as Pairing>::ScalarField>;
     type UniPoly_377 = DensePoly<<Bls12_377 as Pairing>::ScalarField>;
 
-    type PC<E, P, S> = MarlinKZG10<E, P, S>;
-
-    type Sponge_Bls12_381 = PoseidonSponge<<Bls12_381 as Pairing>::ScalarField>;
-    type Sponge_Bls12_377 = PoseidonSponge<<Bls12_377 as Pairing>::ScalarField>;
+    type PC<E, P> = MarlinKZG10<E, P>;
 
-    type PC_Bls12_381 = PC<Bls12_381, UniPoly_381, Sponge_Bls12_381>;
-    type PC_Bls12_377 = PC<Bls12_377, UniPoly_377, Sponge_Bls12_377>;
+    type PC_Bls12_381 = PC<Bls12_381, UniPoly_381>;
+    type PC_Bls12_377 = PC<Bls12_377, UniPoly_377>;
 
     fn rand_poly<E: Pairing>(
         degree: usize,
@@ -581,14 +574,14 @@ mod tests {
             None,
             rand_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         single_poly_test::<_, _, PC_Bls12_381, _>(
             None,
             rand_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
     }
@@ -600,14 +593,14 @@ mod tests {
             None,
             constant_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         single_poly_test::<_, _, PC_Bls12_381, _>(
             None,
             constant_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
     }
@@ -618,13 +611,13 @@ mod tests {
         quadratic_poly_degree_bound_multiple_queries_test::<_, _, PC_Bls12_377, _>(
             rand_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         quadratic_poly_degree_bound_multiple_queries_test::<_, _, PC_Bls12_381, _>(
             rand_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
     }
@@ -635,13 +628,13 @@ mod tests {
         linear_poly_degree_bound_test::<_, _, PC_Bls12_377, _>(
             rand_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         linear_poly_degree_bound_test::<_, _, PC_Bls12_381, _>(
             rand_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
     }
@@ -652,13 +645,13 @@ mod tests {
         single_poly_degree_bound_test::<_, _, PC_Bls12_377, _>(
             rand_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         single_poly_degree_bound_test::<_, _, PC_Bls12_381, _>(
             rand_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
     }
@@ -669,13 +662,13 @@ mod tests {
         single_poly_degree_bound_multiple_queries_test::<_, _, PC_Bls12_377, _>(
             rand_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         single_poly_degree_bound_multiple_queries_test::<_, _, PC_Bls12_381, _>(
             rand_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
     }
@@ -686,13 +679,13 @@ mod tests {
         two_polys_degree_bound_single_query_test::<_, _, PC_Bls12_377, _>(
             rand_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         two_polys_degree_bound_single_query_test::<_, _, PC_Bls12_381, _>(
             rand_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
     }
@@ -704,7 +697,7 @@ mod tests {
             None,
             rand_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         println!("Finished bls12-377");
@@ -712,7 +705,7 @@ mod tests {
             None,
             rand_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
         println!("Finished bls12-381");
@@ -725,7 +718,7 @@ mod tests {
             None,
             rand_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         println!("Finished bls12-377");
@@ -733,7 +726,7 @@ mod tests {
             None,
             rand_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
         println!("Finished bls12-381");
@@ -746,7 +739,7 @@ mod tests {
             None,
             rand_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         println!("Finished bls12-377");
@@ -754,7 +747,7 @@ mod tests {
             None,
             rand_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
         println!("Finished bls12-381");
@@ -766,14 +759,14 @@ mod tests {
         two_equation_degree_bound_test::<_, _, PC_Bls12_377, _>(
             rand_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         println!("Finished bls12-377");
         two_equation_degree_bound_test::<_, _, PC_Bls12_381, _>(
             rand_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
         println!("Finished bls12-381");
@@ -786,7 +779,7 @@ mod tests {
             None,
             rand_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         println!("Finished bls12-377");
@@ -794,7 +787,7 @@ mod tests {
             None,
             rand_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
         println!("Finished bls12-381");
@@ -807,14 +800,14 @@ mod tests {
         bad_degree_bound_test::<_, _, PC_Bls12_377, _>(
             rand_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         println!("Finished bls12-377");
         bad_degree_bound_test::<_, _, PC_Bls12_381, _>(
             rand_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
         println!("Finished bls12-381");
diff --git a/poly-commit/src/marlin/marlin_pst13_pc/combinations.rs b/poly-commit/src/marlin/marlin_pst13_pc/combinations.rs
index dd1aaf14..bc76ea99 100644
--- a/poly-commit/src/marlin/marlin_pst13_pc/combinations.rs
+++ b/poly-commit/src/marlin/marlin_pst13_pc/combinations.rs
@@ -1,7 +1,7 @@
 //! Compute all combinations of values in a given list
 //! Credit: https://github.com/meltinglava/uniquecombinations/
-use crate::Vec;
-
+#[cfg(not(feature = "std"))]
+use ark_std::vec::Vec;
 /// Compute all combinations of values in a given list.
 pub(crate) struct Combinations<T>
 where
diff --git a/poly-commit/src/marlin/marlin_pst13_pc/data_structures.rs b/poly-commit/src/marlin/marlin_pst13_pc/data_structures.rs
index 9cc8d73b..22377b9d 100644
--- a/poly-commit/src/marlin/marlin_pst13_pc/data_structures.rs
+++ b/poly-commit/src/marlin/marlin_pst13_pc/data_structures.rs
@@ -1,20 +1,21 @@
-use crate::{BTreeMap, Vec};
 use crate::{
-    PCCommitmentState, PCCommitterKey, PCPreparedVerifierKey, PCUniversalParams, PCVerifierKey,
+    BTreeMap, PCCommitmentState, PCCommitterKey, PCPreparedVerifierKey, PCUniversalParams,
+    PCVerifierKey,
 };
 use ark_ec::pairing::Pairing;
 use ark_poly::DenseMVPolynomial;
+use ark_serialize::{
+    CanonicalDeserialize, CanonicalSerialize, Compress, SerializationError, Valid, Validate,
+};
+#[cfg(not(feature = "std"))]
+use ark_std::vec::Vec;
 use ark_std::{
     io::{Read, Write},
     marker::PhantomData,
     ops::{Add, AddAssign, Index},
+    rand::RngCore,
 };
 
-use ark_serialize::{
-    CanonicalDeserialize, CanonicalSerialize, Compress, SerializationError, Valid, Validate,
-};
-use ark_std::rand::RngCore;
-
 /// `UniversalParams` are the universal parameters for the MarlinPST13 scheme.
 #[derive(Derivative)]
 #[derivative(Default(bound = ""), Clone(bound = ""), Debug(bound = ""))]
diff --git a/poly-commit/src/marlin/marlin_pst13_pc/mod.rs b/poly-commit/src/marlin/marlin_pst13_pc/mod.rs
index eee026d7..b0f7114a 100644
--- a/poly-commit/src/marlin/marlin_pst13_pc/mod.rs
+++ b/poly-commit/src/marlin/marlin_pst13_pc/mod.rs
@@ -1,22 +1,22 @@
 use crate::{
     kzg10,
     marlin::{marlin_pc, Marlin},
-    CHALLENGE_SIZE,
+    BatchLCProof, Error, Evaluations, LabeledCommitment, LabeledPolynomial, LinearCombination,
+    PCCommitmentState, PCUniversalParams, PolynomialCommitment, QuerySet, CHALLENGE_SIZE,
 };
-use crate::{BatchLCProof, Error, Evaluations, QuerySet};
-use crate::{LabeledCommitment, LabeledPolynomial, LinearCombination};
-use crate::{PCCommitmentState, PCUniversalParams, PolynomialCommitment};
-use crate::{ToString, Vec};
-use ark_ec::AffineRepr;
+use ark_crypto_primitives::sponge::CryptographicSponge;
 use ark_ec::{
     pairing::Pairing,
     scalar_mul::{BatchMulPreprocessing, ScalarMul},
-    CurveGroup, VariableBaseMSM,
+    AffineRepr, CurveGroup, VariableBaseMSM,
 };
 use ark_ff::{One, PrimeField, UniformRand, Zero};
 use ark_poly::{multivariate::Term, DenseMVPolynomial};
-use ark_std::rand::RngCore;
-use ark_std::{marker::PhantomData, ops::Index, ops::Mul, vec};
+use ark_std::{marker::PhantomData, ops::Index, ops::Mul, rand::RngCore};
+#[cfg(not(feature = "std"))]
+use ark_std::{string::ToString, vec::Vec};
+#[cfg(feature = "parallel")]
+use rayon::prelude::*;
 
 mod data_structures;
 pub use data_structures::*;
@@ -24,25 +24,18 @@ pub use data_structures::*;
 mod combinations;
 use combinations::*;
 
-use ark_crypto_primitives::sponge::CryptographicSponge;
-#[cfg(feature = "parallel")]
-use rayon::prelude::*;
-
 /// Multivariate polynomial commitment based on the construction in [[PST13]][pst]
 /// with batching and (optional) hiding property inspired by the univariate scheme
 /// in [[CHMMVW20, "Marlin"]][marlin]
 ///
 /// [pst]: https://eprint.iacr.org/2011/587
 /// [marlin]: https://eprint.iacr.org/2019/1047
-pub struct MarlinPST13<E: Pairing, P: DenseMVPolynomial<E::ScalarField>, S: CryptographicSponge> {
+pub struct MarlinPST13<E: Pairing, P: DenseMVPolynomial<E::ScalarField>> {
     _engine: PhantomData<E>,
     _poly: PhantomData<P>,
-    _sponge: PhantomData<S>,
 }
 
-impl<E: Pairing, P: DenseMVPolynomial<E::ScalarField>, S: CryptographicSponge>
-    MarlinPST13<E, P, S>
-{
+impl<E: Pairing, P: DenseMVPolynomial<E::ScalarField>> MarlinPST13<E, P> {
     /// Given some point `z`, compute the quotients `w_i(X)` s.t
     ///
     /// `p(X) - p(z) = (X_1-z_1)*w_1(X) + (X_2-z_2)*w_2(X) + ... + (X_l-z_l)*w_l(X)`
@@ -143,11 +136,10 @@ impl<E: Pairing, P: DenseMVPolynomial<E::ScalarField>, S: CryptographicSponge>
     }
 }
 
-impl<E, P, S> PolynomialCommitment<E::ScalarField, P, S> for MarlinPST13<E, P, S>
+impl<E, P> PolynomialCommitment<E::ScalarField, P> for MarlinPST13<E, P>
 where
     E: Pairing,
     P: DenseMVPolynomial<E::ScalarField> + Sync,
-    S: CryptographicSponge,
     P::Point: Index<usize, Output = E::ScalarField>,
 {
     type UniversalParams = UniversalParams<E, P>;
@@ -429,7 +421,7 @@ where
         labeled_polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<E::ScalarField, P>>,
         _commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
         point: &P::Point,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         states: impl IntoIterator<Item = &'a Self::CommitmentState>,
         _rng: Option<&mut dyn RngCore>,
     ) -> Result<Self::Proof, Self::Error>
@@ -527,7 +519,7 @@ where
         point: &'a P::Point,
         values: impl IntoIterator<Item = E::ScalarField>,
         proof: &Self::Proof,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         _rng: Option<&mut dyn RngCore>,
     ) -> Result<bool, Self::Error>
     where
@@ -536,7 +528,7 @@ where
         let check_time = start_timer!(|| "Checking evaluations");
         // Accumulate commitments and values
         let (combined_comm, combined_value) =
-            Marlin::<E, S, P, Self>::accumulate_commitments_and_values(
+            Marlin::<E, P, Self>::accumulate_commitments_and_values(
                 commitments,
                 values,
                 sponge,
@@ -571,14 +563,14 @@ where
         query_set: &QuerySet<P::Point>,
         values: &Evaluations<P::Point, E::ScalarField>,
         proof: &Self::BatchProof,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         rng: &mut R,
     ) -> Result<bool, Self::Error>
     where
         Self::Commitment: 'a,
     {
         let (combined_comms, combined_queries, combined_evals) =
-            Marlin::<E, S, P, Self>::combine_and_normalize(
+            Marlin::<E, P, Self>::combine_and_normalize(
                 commitments,
                 query_set,
                 values,
@@ -649,7 +641,7 @@ where
         polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<E::ScalarField, P>>,
         commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
         query_set: &QuerySet<P::Point>,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         states: impl IntoIterator<Item = &'a Self::CommitmentState>,
         rng: Option<&mut dyn RngCore>,
     ) -> Result<BatchLCProof<E::ScalarField, Self::BatchProof>, Self::Error>
@@ -658,7 +650,7 @@ where
         Self::CommitmentState: 'a,
         Self::Commitment: 'a,
     {
-        Marlin::<E, S, P, Self>::open_combinations(
+        Marlin::<E, P, Self>::open_combinations(
             ck,
             linear_combinations,
             polynomials,
@@ -679,13 +671,13 @@ where
         eqn_query_set: &QuerySet<P::Point>,
         eqn_evaluations: &Evaluations<P::Point, E::ScalarField>,
         proof: &BatchLCProof<E::ScalarField, Self::BatchProof>,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         rng: &mut R,
     ) -> Result<bool, Self::Error>
     where
         Self::Commitment: 'a,
     {
-        Marlin::<E, S, P, Self>::check_combinations(
+        Marlin::<E, P, Self>::check_combinations(
             vk,
             linear_combinations,
             commitments,
@@ -704,26 +696,23 @@ mod tests {
     use super::MarlinPST13;
     use ark_bls12_377::Bls12_377;
     use ark_bls12_381::Bls12_381;
-    use ark_crypto_primitives::sponge::poseidon::PoseidonSponge;
     use ark_ec::pairing::Pairing;
     use ark_ff::UniformRand;
     use ark_poly::{
         multivariate::{SparsePolynomial as SparsePoly, SparseTerm},
         DenseMVPolynomial,
     };
+    #[cfg(not(feature = "std"))]
     use ark_std::vec::Vec;
     use rand_chacha::ChaCha20Rng;
 
     type MVPoly_381 = SparsePoly<<Bls12_381 as Pairing>::ScalarField, SparseTerm>;
     type MVPoly_377 = SparsePoly<<Bls12_377 as Pairing>::ScalarField, SparseTerm>;
 
-    type PC<E, P, S> = MarlinPST13<E, P, S>;
-
-    type Sponge_bls12_381 = PoseidonSponge<<Bls12_381 as Pairing>::ScalarField>;
-    type Sponge_Bls12_377 = PoseidonSponge<<Bls12_377 as Pairing>::ScalarField>;
+    type PC<E, P> = MarlinPST13<E, P>;
 
-    type PC_Bls12_381 = PC<Bls12_381, MVPoly_381, Sponge_bls12_381>;
-    type PC_Bls12_377 = PC<Bls12_377, MVPoly_377, Sponge_Bls12_377>;
+    type PC_Bls12_381 = PC<Bls12_381, MVPoly_381>;
+    type PC_Bls12_377 = PC<Bls12_377, MVPoly_377>;
 
     fn rand_poly<E: Pairing>(
         degree: usize,
@@ -753,14 +742,14 @@ mod tests {
             num_vars,
             rand_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         single_poly_test::<_, _, PC_Bls12_381, _>(
             num_vars,
             rand_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
     }
@@ -773,7 +762,7 @@ mod tests {
             num_vars,
             rand_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         println!("Finished bls12-377");
@@ -781,7 +770,7 @@ mod tests {
             num_vars,
             rand_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
         println!("Finished bls12-381");
@@ -795,7 +784,7 @@ mod tests {
             num_vars,
             rand_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         println!("Finished bls12-377");
@@ -803,7 +792,7 @@ mod tests {
             num_vars,
             rand_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
         println!("Finished bls12-381");
@@ -817,7 +806,7 @@ mod tests {
             num_vars,
             rand_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         println!("Finished bls12-377");
@@ -825,7 +814,7 @@ mod tests {
             num_vars,
             rand_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
         println!("Finished bls12-381");
@@ -839,7 +828,7 @@ mod tests {
             num_vars,
             rand_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         println!("Finished bls12-377");
@@ -847,7 +836,7 @@ mod tests {
             num_vars,
             rand_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
         println!("Finished bls12-381");
diff --git a/poly-commit/src/marlin/mod.rs b/poly-commit/src/marlin/mod.rs
index d7e7f5a1..714ad727 100644
--- a/poly-commit/src/marlin/mod.rs
+++ b/poly-commit/src/marlin/mod.rs
@@ -1,15 +1,17 @@
-use crate::CHALLENGE_SIZE;
-use crate::{kzg10, Error};
-use crate::{BTreeMap, BTreeSet, Debug, RngCore, String, ToString, Vec};
-use crate::{BatchLCProof, LabeledPolynomial, LinearCombination};
-use crate::{Evaluations, LabeledCommitment, QuerySet};
-use crate::{PCCommitmentState, Polynomial, PolynomialCommitment};
+use crate::{
+    kzg10, BTreeMap, BTreeSet, BatchLCProof, Debug, Error, Evaluations, LabeledCommitment,
+    LabeledPolynomial, LinearCombination, PCCommitmentState, Polynomial, PolynomialCommitment,
+    QuerySet, RngCore, CHALLENGE_SIZE,
+};
 use ark_crypto_primitives::sponge::CryptographicSponge;
-use ark_ec::pairing::Pairing;
-use ark_ec::AffineRepr;
-use ark_ec::CurveGroup;
+use ark_ec::{pairing::Pairing, AffineRepr, CurveGroup};
 use ark_ff::{One, Zero};
 use ark_std::{convert::TryInto, hash::Hash, ops::AddAssign, ops::Mul};
+#[cfg(not(feature = "std"))]
+use ark_std::{
+    string::{String, ToString},
+    vec::Vec,
+};
 
 /// Polynomial commitment scheme from [[KZG10]][kzg] that enforces
 /// strict degree bounds and (optionally) enables hiding commitments by
@@ -28,25 +30,22 @@ pub mod marlin_pc;
 pub mod marlin_pst13_pc;
 
 /// Common functionalities between `marlin_pc` and `marlin_pst13_pc`
-struct Marlin<E, S, P, PC>
+struct Marlin<E, P, PC>
 where
     E: Pairing,
-    S: CryptographicSponge,
     P: Polynomial<E::ScalarField>,
-    PC: PolynomialCommitment<E::ScalarField, P, S>,
+    PC: PolynomialCommitment<E::ScalarField, P>,
 {
     _engine: core::marker::PhantomData<E>,
-    _sponge: core::marker::PhantomData<S>,
     _poly: core::marker::PhantomData<P>,
     _pc: core::marker::PhantomData<PC>,
 }
 
-impl<E, S, P, PC> Marlin<E, S, P, PC>
+impl<E, P, PC> Marlin<E, P, PC>
 where
     E: Pairing,
-    S: CryptographicSponge,
     P: Polynomial<E::ScalarField>,
-    PC: PolynomialCommitment<E::ScalarField, P, S>,
+    PC: PolynomialCommitment<E::ScalarField, P>,
 {
     /// MSM for `commitments` and `coeffs`
     fn combine_commitments<'a>(
@@ -110,7 +109,7 @@ where
     fn accumulate_commitments_and_values<'a>(
         commitments: impl IntoIterator<Item = &'a LabeledCommitment<marlin_pc::Commitment<E>>>,
         values: impl IntoIterator<Item = E::ScalarField>,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         vk: Option<&marlin_pc::VerifierKey<E>>,
     ) -> Result<(E::G1, E::ScalarField), Error> {
         let acc_time = start_timer!(|| "Accumulating commitments and values");
@@ -153,7 +152,7 @@ where
         commitments: impl IntoIterator<Item = &'a LabeledCommitment<marlin_pc::Commitment<E>>>,
         query_set: &QuerySet<D>,
         evaluations: &Evaluations<D, E::ScalarField>,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         vk: Option<&marlin_pc::VerifierKey<E>>,
     ) -> Result<(Vec<kzg10::Commitment<E>>, Vec<D>, Vec<E::ScalarField>), Error>
     where
@@ -228,7 +227,7 @@ where
         polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<E::ScalarField, P>>,
         commitments: impl IntoIterator<Item = &'a LabeledCommitment<PC::Commitment>>,
         query_set: &QuerySet<D>,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         states: impl IntoIterator<Item = &'a PC::CommitmentState>,
         rng: Option<&mut dyn RngCore>,
     ) -> Result<BatchLCProof<E::ScalarField, PC::BatchProof>, Error>
@@ -238,7 +237,6 @@ where
         PC: PolynomialCommitment<
             E::ScalarField,
             P,
-            S,
             Commitment = marlin_pc::Commitment<E>,
             Error = Error,
         >,
@@ -324,7 +322,7 @@ where
         query_set: &QuerySet<P::Point>,
         evaluations: &Evaluations<P::Point, E::ScalarField>,
         proof: &BatchLCProof<E::ScalarField, PC::BatchProof>,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         rng: &mut R,
     ) -> Result<bool, Error>
     where
@@ -334,7 +332,6 @@ where
         PC: PolynomialCommitment<
             E::ScalarField,
             P,
-            S,
             Commitment = marlin_pc::Commitment<E>,
             Error = Error,
         >,
diff --git a/poly-commit/src/multilinear_pc/data_structures.rs b/poly-commit/src/multilinear_pc/data_structures.rs
index 6920ece7..c70aae08 100644
--- a/poly-commit/src/multilinear_pc/data_structures.rs
+++ b/poly-commit/src/multilinear_pc/data_structures.rs
@@ -1,5 +1,6 @@
 use ark_ec::pairing::Pairing;
 use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
+#[cfg(not(feature = "std"))]
 use ark_std::vec::Vec;
 #[allow(type_alias_bounds)]
 /// Evaluations over {0,1}^n for G1
diff --git a/poly-commit/src/multilinear_pc/mod.rs b/poly-commit/src/multilinear_pc/mod.rs
index cff20eb5..55bd98ea 100644
--- a/poly-commit/src/multilinear_pc/mod.rs
+++ b/poly-commit/src/multilinear_pc/mod.rs
@@ -1,20 +1,19 @@
 use crate::multilinear_pc::data_structures::{
     Commitment, CommitterKey, Proof, UniversalParams, VerifierKey,
 };
-use ark_ec::scalar_mul::BatchMulPreprocessing;
-use ark_ec::AffineRepr;
-use ark_ec::{pairing::Pairing, CurveGroup};
-use ark_ec::{scalar_mul::ScalarMul, VariableBaseMSM};
-use ark_ff::{Field, PrimeField};
-use ark_ff::{One, Zero};
+use ark_ec::{
+    pairing::Pairing,
+    scalar_mul::{BatchMulPreprocessing, ScalarMul},
+    AffineRepr, CurveGroup, VariableBaseMSM,
+};
+use ark_ff::{Field, One, PrimeField, Zero};
 use ark_poly::{DenseMultilinearExtension, MultilinearExtension};
-use ark_std::collections::LinkedList;
-use ark_std::iter::FromIterator;
-use ark_std::marker::PhantomData;
-use ark_std::ops::Mul;
-use ark_std::rand::RngCore;
+#[cfg(not(feature = "std"))]
 use ark_std::vec::Vec;
-use ark_std::UniformRand;
+use ark_std::{
+    collections::LinkedList, iter::FromIterator, marker::PhantomData, ops::Mul, rand::RngCore,
+    UniformRand,
+};
 
 /// data structures used by multilinear extension commitment scheme
 pub mod data_structures;
@@ -236,15 +235,13 @@ fn eq_extension<F: Field>(t: &[F]) -> Vec<DenseMultilinearExtension<F>> {
 
 #[cfg(test)]
 mod tests {
-    use crate::ark_std::UniformRand;
-    use crate::multilinear_pc::data_structures::UniversalParams;
-    use crate::multilinear_pc::MultilinearPC;
+    use crate::multilinear_pc::{data_structures::UniversalParams, MultilinearPC};
     use ark_bls12_381::Bls12_381;
     use ark_ec::pairing::Pairing;
     use ark_poly::{DenseMultilinearExtension, MultilinearExtension, SparseMultilinearExtension};
-    use ark_std::rand::RngCore;
-    use ark_std::test_rng;
+    #[cfg(not(feature = "std"))]
     use ark_std::vec::Vec;
+    use ark_std::{rand::RngCore, test_rng, UniformRand};
     type E = Bls12_381;
     type Fr = <E as Pairing>::ScalarField;
 
diff --git a/poly-commit/src/sonic_pc/data_structures.rs b/poly-commit/src/sonic_pc/data_structures.rs
index 4e1cd309..4ed8e500 100644
--- a/poly-commit/src/sonic_pc/data_structures.rs
+++ b/poly-commit/src/sonic_pc/data_structures.rs
@@ -1,13 +1,13 @@
-use crate::kzg10;
 use crate::{
-    BTreeMap, PCCommitterKey, PCPreparedCommitment, PCPreparedVerifierKey, PCVerifierKey, Vec,
+    kzg10, BTreeMap, PCCommitterKey, PCPreparedCommitment, PCPreparedVerifierKey, PCVerifierKey,
 };
-use ark_ec::pairing::Pairing;
-use ark_ec::AdditiveGroup;
+use ark_ec::{pairing::Pairing, AdditiveGroup};
 use ark_serialize::{
     CanonicalDeserialize, CanonicalSerialize, Compress, SerializationError, Valid, Validate,
 };
 use ark_std::io::{Read, Write};
+#[cfg(not(feature = "std"))]
+use ark_std::vec::Vec;
 
 /// `UniversalParams` are the universal parameters for the KZG10 scheme.
 pub type UniversalParams<E> = kzg10::UniversalParams<E>;
diff --git a/poly-commit/src/sonic_pc/mod.rs b/poly-commit/src/sonic_pc/mod.rs
index caf9b79c..8af2496e 100644
--- a/poly-commit/src/sonic_pc/mod.rs
+++ b/poly-commit/src/sonic_pc/mod.rs
@@ -1,18 +1,19 @@
-use crate::{kzg10, PCCommitterKey, CHALLENGE_SIZE};
-use crate::{BTreeMap, BTreeSet, String, ToString, Vec};
-use crate::{BatchLCProof, DenseUVPolynomial, Error, Evaluations, QuerySet};
-use crate::{LabeledCommitment, LabeledPolynomial, LinearCombination};
-use crate::{PCCommitmentState, PCUniversalParams, PolynomialCommitment};
-use ark_ec::AffineRepr;
-use ark_ec::CurveGroup;
-
-use ark_ec::pairing::Pairing;
+use crate::{
+    kzg10, BTreeMap, BTreeSet, BatchLCProof, DenseUVPolynomial, Error, Evaluations,
+    LabeledCommitment, LabeledPolynomial, LinearCombination, PCCommitmentState, PCCommitterKey,
+    PCUniversalParams, PolynomialCommitment, QuerySet, CHALLENGE_SIZE,
+};
+use ark_crypto_primitives::sponge::CryptographicSponge;
+use ark_ec::{pairing::Pairing, AffineRepr, CurveGroup};
 use ark_ff::{One, UniformRand, Zero};
-use ark_std::rand::RngCore;
-use ark_std::{convert::TryInto, marker::PhantomData, ops::Div, ops::Mul, vec};
+use ark_std::{convert::TryInto, marker::PhantomData, ops::Div, ops::Mul, rand::RngCore};
+#[cfg(not(feature = "std"))]
+use ark_std::{
+    string::{String, ToString},
+    vec::Vec,
+};
 
 mod data_structures;
-use ark_crypto_primitives::sponge::CryptographicSponge;
 pub use data_structures::*;
 
 /// Polynomial commitment based on [[KZG10]][kzg], with degree enforcement and
@@ -25,17 +26,15 @@ pub use data_structures::*;
 /// [sonic]: https://eprint.iacr.org/2019/099
 /// [al]: https://eprint.iacr.org/2019/601
 /// [marlin]: https://eprint.iacr.org/2019/1047
-pub struct SonicKZG10<E: Pairing, P: DenseUVPolynomial<E::ScalarField>, S: CryptographicSponge> {
+pub struct SonicKZG10<E: Pairing, P: DenseUVPolynomial<E::ScalarField>> {
     _engine: PhantomData<E>,
     _poly: PhantomData<P>,
-    _sponge: PhantomData<S>,
 }
 
-impl<E, P, S> SonicKZG10<E, P, S>
+impl<E, P> SonicKZG10<E, P>
 where
     E: Pairing,
     P: DenseUVPolynomial<E::ScalarField>,
-    S: CryptographicSponge,
 {
     fn accumulate_elems<'a>(
         combined_comms: &mut BTreeMap<Option<usize>, E::G1>,
@@ -46,7 +45,7 @@ where
         point: P::Point,
         values: impl IntoIterator<Item = E::ScalarField>,
         proof: &kzg10::Proof<E>,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         randomizer: Option<E::ScalarField>,
     ) {
         let acc_time = start_timer!(|| "Accumulating elements");
@@ -134,11 +133,10 @@ where
     }
 }
 
-impl<E, P, S> PolynomialCommitment<E::ScalarField, P, S> for SonicKZG10<E, P, S>
+impl<E, P> PolynomialCommitment<E::ScalarField, P> for SonicKZG10<E, P>
 where
     E: Pairing,
     P: DenseUVPolynomial<E::ScalarField, Point = E::ScalarField>,
-    S: CryptographicSponge,
     for<'a, 'b> &'a P: Div<&'b P, Output = P>,
 {
     type UniversalParams = UniversalParams<E>;
@@ -344,7 +342,7 @@ where
         labeled_polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<E::ScalarField, P>>,
         _commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
         point: &'a P::Point,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         states: impl IntoIterator<Item = &'a Self::CommitmentState>,
         _rng: Option<&mut dyn RngCore>,
     ) -> Result<Self::Proof, Self::Error>
@@ -389,7 +387,7 @@ where
         point: &'a P::Point,
         values: impl IntoIterator<Item = E::ScalarField>,
         proof: &Self::Proof,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         _rng: Option<&mut dyn RngCore>,
     ) -> Result<bool, Self::Error>
     where
@@ -429,7 +427,7 @@ where
         query_set: &QuerySet<P::Point>,
         values: &Evaluations<E::ScalarField, P::Point>,
         proof: &Self::BatchProof,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         rng: &mut R,
     ) -> Result<bool, Self::Error>
     where
@@ -501,7 +499,7 @@ where
         polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<E::ScalarField, P>>,
         commitments: impl IntoIterator<Item = &'a LabeledCommitment<Self::Commitment>>,
         query_set: &QuerySet<P::Point>,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         states: impl IntoIterator<Item = &'a Self::CommitmentState>,
         rng: Option<&mut dyn RngCore>,
     ) -> Result<BatchLCProof<E::ScalarField, Self::BatchProof>, Self::Error>
@@ -596,7 +594,7 @@ where
         eqn_query_set: &QuerySet<P::Point>,
         eqn_evaluations: &Evaluations<P::Point, E::ScalarField>,
         proof: &BatchLCProof<E::ScalarField, Self::BatchProof>,
-        sponge: &mut S,
+        sponge: &mut impl CryptographicSponge,
         rng: &mut R,
     ) -> Result<bool, Self::Error>
     where
@@ -677,7 +675,6 @@ mod tests {
     use super::SonicKZG10;
     use ark_bls12_377::Bls12_377;
     use ark_bls12_381::Bls12_381;
-    use ark_crypto_primitives::sponge::poseidon::PoseidonSponge;
     use ark_ec::pairing::Pairing;
     use ark_ff::UniformRand;
     use ark_poly::{univariate::DensePolynomial as DensePoly, DenseUVPolynomial};
@@ -686,11 +683,9 @@ mod tests {
     type UniPoly_381 = DensePoly<<Bls12_381 as Pairing>::ScalarField>;
     type UniPoly_377 = DensePoly<<Bls12_377 as Pairing>::ScalarField>;
 
-    type PC<E, P, S> = SonicKZG10<E, P, S>;
-    type Sponge_Bls12_377 = PoseidonSponge<<Bls12_377 as Pairing>::ScalarField>;
-    type Sponge_Bls12_381 = PoseidonSponge<<Bls12_381 as Pairing>::ScalarField>;
-    type PC_Bls12_377 = PC<Bls12_377, UniPoly_377, Sponge_Bls12_377>;
-    type PC_Bls12_381 = PC<Bls12_381, UniPoly_381, Sponge_Bls12_381>;
+    type PC<E, P> = SonicKZG10<E, P>;
+    type PC_Bls12_377 = PC<Bls12_377, UniPoly_377>;
+    type PC_Bls12_381 = PC<Bls12_381, UniPoly_381>;
 
     fn rand_poly<E: Pairing>(
         degree: usize,
@@ -711,14 +706,14 @@ mod tests {
             None,
             rand_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         single_poly_test::<_, _, PC_Bls12_381, _>(
             None,
             rand_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
     }
@@ -729,13 +724,13 @@ mod tests {
         quadratic_poly_degree_bound_multiple_queries_test::<_, _, PC_Bls12_377, _>(
             rand_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         quadratic_poly_degree_bound_multiple_queries_test::<_, _, PC_Bls12_381, _>(
             rand_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
     }
@@ -746,13 +741,13 @@ mod tests {
         linear_poly_degree_bound_test::<_, _, PC_Bls12_377, _>(
             rand_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         linear_poly_degree_bound_test::<_, _, PC_Bls12_381, _>(
             rand_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
     }
@@ -763,13 +758,13 @@ mod tests {
         single_poly_degree_bound_test::<_, _, PC_Bls12_377, _>(
             rand_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         single_poly_degree_bound_test::<_, _, PC_Bls12_381, _>(
             rand_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
     }
@@ -780,13 +775,13 @@ mod tests {
         single_poly_degree_bound_multiple_queries_test::<_, _, PC_Bls12_377, _>(
             rand_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         single_poly_degree_bound_multiple_queries_test::<_, _, PC_Bls12_381, _>(
             rand_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
     }
@@ -797,13 +792,13 @@ mod tests {
         two_polys_degree_bound_single_query_test::<_, _, PC_Bls12_377, _>(
             rand_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         two_polys_degree_bound_single_query_test::<_, _, PC_Bls12_381, _>(
             rand_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
     }
@@ -815,7 +810,7 @@ mod tests {
             None,
             rand_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         println!("Finished bls12-377");
@@ -823,7 +818,7 @@ mod tests {
             None,
             rand_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
         println!("Finished bls12-381");
@@ -836,7 +831,7 @@ mod tests {
             None,
             rand_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         println!("Finished bls12-377");
@@ -844,7 +839,7 @@ mod tests {
             None,
             rand_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
         println!("Finished bls12-381");
@@ -857,7 +852,7 @@ mod tests {
             None,
             rand_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         println!("Finished bls12-377");
@@ -865,7 +860,7 @@ mod tests {
             None,
             rand_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
         println!("Finished bls12-381");
@@ -877,14 +872,14 @@ mod tests {
         two_equation_degree_bound_test::<_, _, PC_Bls12_377, _>(
             rand_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         println!("Finished bls12-377");
         two_equation_degree_bound_test::<_, _, PC_Bls12_381, _>(
             rand_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
         println!("Finished bls12-381");
@@ -897,7 +892,7 @@ mod tests {
             None,
             rand_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         println!("Finished bls12-377");
@@ -905,7 +900,7 @@ mod tests {
             None,
             rand_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
         println!("Finished bls12-381");
@@ -918,14 +913,14 @@ mod tests {
         bad_degree_bound_test::<_, _, PC_Bls12_377, _>(
             rand_poly::<Bls12_377>,
             rand_point::<Bls12_377>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_377 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-377");
         println!("Finished bls12-377");
         bad_degree_bound_test::<_, _, PC_Bls12_381, _>(
             rand_poly::<Bls12_381>,
             rand_point::<Bls12_381>,
-            poseidon_sponge_for_test,
+            poseidon_sponge_for_test::<<Bls12_381 as Pairing>::ScalarField>,
         )
         .expect("test failed for bls12-381");
         println!("Finished bls12-381");
diff --git a/poly-commit/src/streaming_kzg/data_structures.rs b/poly-commit/src/streaming_kzg/data_structures.rs
index 0dc68e87..b3910ce3 100644
--- a/poly-commit/src/streaming_kzg/data_structures.rs
+++ b/poly-commit/src/streaming_kzg/data_structures.rs
@@ -1,9 +1,8 @@
+use crate::streaming_kzg::ceil_div;
 use ark_ff::Field;
-use ark_std::borrow::Borrow;
+#[cfg(not(feature = "std"))]
 use ark_std::vec::Vec;
-
-use crate::streaming_kzg::ceil_div;
-use ark_std::iterable::Iterable;
+use ark_std::{borrow::Borrow, iterable::Iterable};
 
 /// A `Streamer` folding a vector of coefficients
 /// with the given challenges, and producing a stream of items
diff --git a/poly-commit/src/streaming_kzg/mod.rs b/poly-commit/src/streaming_kzg/mod.rs
index e3bdb2af..95ae6f7c 100644
--- a/poly-commit/src/streaming_kzg/mod.rs
+++ b/poly-commit/src/streaming_kzg/mod.rs
@@ -82,29 +82,29 @@
 //! assert!(vk.verify(&commitment, &alpha, &evaluation, &proof).is_ok())
 //! ```
 
+use ark_ec::{pairing::Pairing, AffineRepr, CurveGroup, VariableBaseMSM};
+use ark_ff::{Field, One, PrimeField, Zero};
+use ark_poly::{univariate::DensePolynomial, DenseUVPolynomial};
+use ark_serialize::{CanonicalSerialize, Compress};
+#[cfg(not(feature = "std"))]
+use ark_std::vec::Vec;
+use ark_std::{
+    borrow::Borrow,
+    fmt,
+    ops::{Add, Mul},
+};
+
 mod data_structures;
 mod space;
 mod time;
-
-use ark_ec::CurveGroup;
-use ark_serialize::{CanonicalSerialize, Compress};
-use ark_std::vec::Vec;
 pub use data_structures::*;
 pub use space::CommitterKeyStream;
 pub use time::CommitterKey;
 
+/// Dummy docs
 #[cfg(test)]
 pub mod tests;
 
-use ark_ff::{Field, One, PrimeField, Zero};
-use ark_poly::{univariate::DensePolynomial, DenseUVPolynomial};
-use ark_std::ops::{Add, Mul};
-
-use ark_std::borrow::Borrow;
-use ark_std::fmt;
-
-use ark_ec::{pairing::Pairing, AffineRepr, VariableBaseMSM};
-
 /// A Kate polynomial commitment over a bilinear group, represented as a single \\(\GG_1\\) element.
 #[derive(Debug, Copy, Clone, PartialEq, Eq)]
 pub struct Commitment<E: Pairing>(pub(crate) E::G1Affine);
diff --git a/poly-commit/src/streaming_kzg/space.rs b/poly-commit/src/streaming_kzg/space.rs
index ab50adfd..9d1cfa71 100644
--- a/poly-commit/src/streaming_kzg/space.rs
+++ b/poly-commit/src/streaming_kzg/space.rs
@@ -1,17 +1,22 @@
 //! Space-efficient implementation of the polynomial commitment of Kate et al.
-use ark_ec::{pairing::Pairing, CurveGroup};
+use crate::streaming_kzg::{
+    ceil_div, time::CommitterKey, vanishing_polynomial, Commitment, EvaluationProof,
+    FoldedPolynomialTree, VerifierKey,
+};
+use ark_ec::{
+    pairing::Pairing,
+    scalar_mul::variable_base::{ChunkedPippenger, HashMapPippenger, VariableBaseMSM},
+    CurveGroup,
+};
 use ark_ff::{PrimeField, Zero};
 use ark_poly::Polynomial;
-use ark_std::borrow::Borrow;
-use ark_std::collections::VecDeque;
+#[cfg(not(feature = "std"))]
 use ark_std::vec::Vec;
-
-use crate::streaming_kzg::{ceil_div, vanishing_polynomial, FoldedPolynomialTree};
-use ark_ec::scalar_mul::variable_base::{ChunkedPippenger, HashMapPippenger, VariableBaseMSM};
-use ark_std::iterable::{Iterable, Reverse};
-
-use super::{time::CommitterKey, VerifierKey};
-use super::{Commitment, EvaluationProof};
+use ark_std::{
+    borrow::Borrow,
+    collections::VecDeque,
+    iterable::{Iterable, Reverse},
+};
 
 const LENGTH_MISMATCH_MSG: &str = "Expecting at least one element in the committer key.";
 
diff --git a/poly-commit/src/streaming_kzg/tests.rs b/poly-commit/src/streaming_kzg/tests.rs
index bb2aa34e..c92dcb09 100644
--- a/poly-commit/src/streaming_kzg/tests.rs
+++ b/poly-commit/src/streaming_kzg/tests.rs
@@ -1,15 +1,16 @@
+use crate::streaming_kzg::{
+    space::CommitterKeyStream, time::CommitterKey, vanishing_polynomial, VerifierKey,
+};
 use ark_bls12_381::{Bls12_381, Fr};
-use ark_poly::univariate::DensePolynomial;
-use ark_poly::DenseUVPolynomial;
-use ark_std::vec::Vec;
-use ark_std::{UniformRand, Zero};
-
-use crate::streaming_kzg::space::CommitterKeyStream;
-use crate::streaming_kzg::time::CommitterKey;
-use crate::streaming_kzg::{vanishing_polynomial, VerifierKey};
 use ark_ff::Field;
-use ark_std::borrow::Borrow;
-use ark_std::iterable::{Iterable, Reverse};
+use ark_poly::{univariate::DensePolynomial, DenseUVPolynomial};
+#[cfg(not(feature = "std"))]
+use ark_std::vec::Vec;
+use ark_std::{
+    borrow::Borrow,
+    iterable::{Iterable, Reverse},
+    UniformRand, Zero,
+};
 
 /// Polynomial evaluation, assuming that the
 /// coefficients are in little-endian.
diff --git a/poly-commit/src/streaming_kzg/time.rs b/poly-commit/src/streaming_kzg/time.rs
index b8d52093..0d73c3c1 100644
--- a/poly-commit/src/streaming_kzg/time.rs
+++ b/poly-commit/src/streaming_kzg/time.rs
@@ -1,17 +1,14 @@
 //! An impementation of a time-efficient version of Kate et al's polynomial commitment,
 //! with optimization from [\[BDFG20\]](https://eprint.iacr.org/2020/081.pdf).
-use ark_ec::pairing::Pairing;
-use ark_ec::scalar_mul::ScalarMul;
-use ark_ec::CurveGroup;
-use ark_ff::Zero;
-use ark_poly::{univariate::DensePolynomial, DenseUVPolynomial};
-use ark_std::{borrow::Borrow, ops::Div, ops::Mul, rand::RngCore, vec::Vec, UniformRand};
-
 use crate::streaming_kzg::{
-    linear_combination, msm, powers, Commitment, EvaluationProof, VerifierKey,
+    linear_combination, msm, powers, vanishing_polynomial, Commitment, EvaluationProof, VerifierKey,
 };
-
-use super::vanishing_polynomial;
+use ark_ec::{pairing::Pairing, scalar_mul::ScalarMul, CurveGroup};
+use ark_ff::Zero;
+use ark_poly::{univariate::DensePolynomial, DenseUVPolynomial};
+#[cfg(not(feature = "std"))]
+use ark_std::vec::Vec;
+use ark_std::{borrow::Borrow, ops::Div, ops::Mul, rand::RngCore, UniformRand};
 
 /// The SRS for the polynomial commitment scheme for a max
 ///