From acdbaaee8becb68db9430ca1b413e43ea26f6c25 Mon Sep 17 00:00:00 2001 From: autquis Date: Sun, 7 Apr 2024 15:47:37 +0200 Subject: [PATCH] Test to see --- Cargo.toml | 1 + poly-commit/src/constraints.rs | 4 +-- poly-commit/src/data_structures.rs | 4 +-- poly-commit/src/error.rs | 3 +- poly-commit/src/ipa_pc/mod.rs | 10 ++++--- poly-commit/src/kzg10/mod.rs | 7 ++--- poly-commit/src/lib.rs | 7 +++-- .../src/marlin/marlin_pc/data_structures.rs | 6 ++-- poly-commit/src/marlin/marlin_pc/mod.rs | 7 ++--- .../marlin/marlin_pst13_pc/combinations.rs | 4 +-- .../marlin/marlin_pst13_pc/data_structures.rs | 12 ++++---- poly-commit/src/marlin/marlin_pst13_pc/mod.rs | 17 ++++++----- poly-commit/src/marlin/mod.rs | 7 +++-- .../src/multilinear_pc/data_structures.rs | 3 +- poly-commit/src/multilinear_pc/mod.rs | 28 +++++++++---------- poly-commit/src/sonic_pc/data_structures.rs | 3 +- poly-commit/src/sonic_pc/mod.rs | 17 ++++++----- .../src/streaming_kzg/data_structures.rs | 6 ++-- poly-commit/src/streaming_kzg/mod.rs | 3 +- poly-commit/src/streaming_kzg/space.rs | 3 +- poly-commit/src/streaming_kzg/tests.rs | 3 +- poly-commit/src/streaming_kzg/time.rs | 3 +- 22 files changed, 85 insertions(+), 73 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bc7f3243..e215af57 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,6 +28,7 @@ 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/" } diff --git a/poly-commit/src/constraints.rs b/poly-commit/src/constraints.rs index a7e65e06..834b6a68 100644 --- a/poly-commit/src/constraints.rs +++ b/poly-commit/src/constraints.rs @@ -7,9 +7,9 @@ use ark_poly::Polynomial; use ark_r1cs_std::fields::emulated_fp::EmulatedFpVar; use ark_r1cs_std::{fields::fp::FpVar, prelude::*}; use ark_relations::r1cs::{ConstraintSystemRef, Namespace, Result as R1CSResult, SynthesisError}; -use ark_std::string::*; -use ark_std::vec::*; 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. diff --git a/poly-commit/src/data_structures.rs b/poly-commit/src/data_structures.rs index 46bfb4a7..1b25d693 100644 --- a/poly-commit/src/data_structures.rs +++ b/poly-commit/src/data_structures.rs @@ -2,13 +2,13 @@ use crate::Polynomial; use ark_ff::{Field, PrimeField, ToConstraintField}; use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; use ark_std::rand::RngCore; -use ark_std::string::*; -use ark_std::vec::*; use ark_std::{ borrow::Borrow, marker::PhantomData, ops::{AddAssign, MulAssign, SubAssign}, }; +#[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 2b5b7dcf..6534aaae 100644 --- a/poly-commit/src/error.rs +++ b/poly-commit/src/error.rs @@ -1,4 +1,5 @@ -use ark_std::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/mod.rs b/poly-commit/src/ipa_pc/mod.rs index 57305aae..a632eb7c 100644 --- a/poly-commit/src/ipa_pc/mod.rs +++ b/poly-commit/src/ipa_pc/mod.rs @@ -2,14 +2,16 @@ use crate::{BTreeMap, BTreeSet, CHALLENGE_SIZE}; use crate::{BatchLCProof, DenseUVPolynomial, Error, Evaluations, QuerySet}; use crate::{LabeledCommitment, LabeledPolynomial, LinearCombination}; use crate::{PCCommitmentState, PCCommitterKey, PCUniversalParams, PolynomialCommitment}; -use ark_std::string::*; -use ark_std::vec::*; - 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}; +use ark_std::{convert::TryInto, format, marker::PhantomData, ops::Mul}; +#[cfg(not(feature = "std"))] +use ark_std::{ + string::{String, ToString}, + vec::Vec, +}; mod data_structures; pub use data_structures::*; diff --git a/poly-commit/src/kzg10/mod.rs b/poly-commit/src/kzg10/mod.rs index cbdfdd9f..ad1675aa 100644 --- a/poly-commit/src/kzg10/mod.rs +++ b/poly-commit/src/kzg10/mod.rs @@ -11,11 +11,10 @@ use ark_ec::{pairing::Pairing, CurveGroup}; use ark_ec::{scalar_mul::ScalarMul, VariableBaseMSM}; use ark_ff::{One, PrimeField, UniformRand, Zero}; use ark_poly::DenseUVPolynomial; -use ark_std::string::*; -use ark_std::vec::*; -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}; +#[cfg(not(feature = "std"))] +use ark_std::{string::ToString, vec::Vec}; #[cfg(feature = "parallel")] use rayon::prelude::*; diff --git a/poly-commit/src/lib.rs b/poly-commit/src/lib.rs index 31729133..cc024164 100644 --- a/poly-commit/src/lib.rs +++ b/poly-commit/src/lib.rs @@ -26,8 +26,11 @@ use ark_std::{ fmt::Debug, hash::Hash, iter::FromIterator, - string::*, - vec::*, +}; +#[cfg(not(feature = "std"))] +use ark_std::{ + string::{String, ToString}, + vec::Vec, }; /// Data structures used by a polynomial commitment scheme. diff --git a/poly-commit/src/marlin/marlin_pc/data_structures.rs b/poly-commit/src/marlin/marlin_pc/data_structures.rs index 398eeceb..3ed690ca 100644 --- a/poly-commit/src/marlin/marlin_pc/data_structures.rs +++ b/poly-commit/src/marlin/marlin_pc/data_structures.rs @@ -1,3 +1,4 @@ +use crate::kzg10; use crate::{ DenseUVPolynomial, PCCommitment, PCCommitmentState, PCCommitterKey, PCPreparedCommitment, PCPreparedVerifierKey, PCVerifierKey, @@ -8,9 +9,8 @@ use ark_ff::{Field, PrimeField, ToConstraintField}; use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; use ark_std::ops::{Add, AddAssign}; use ark_std::rand::RngCore; -use ark_std::vec::*; - -use crate::kzg10; +#[cfg(not(feature = "std"))] +use ark_std::vec::Vec; /// `UniversalParams` are the universal parameters for the KZG10 scheme. pub type UniversalParams = kzg10::UniversalParams; diff --git a/poly-commit/src/marlin/marlin_pc/mod.rs b/poly-commit/src/marlin/marlin_pc/mod.rs index befb8d1f..04293e7f 100644 --- a/poly-commit/src/marlin/marlin_pc/mod.rs +++ b/poly-commit/src/marlin/marlin_pc/mod.rs @@ -1,8 +1,5 @@ use crate::{kzg10, marlin::Marlin, PCCommitterKey, CHALLENGE_SIZE}; use crate::{BTreeMap, BTreeSet}; -use ark_std::string::*; -use ark_std::vec::*; - use crate::{BatchLCProof, Error, Evaluations, QuerySet}; use crate::{LabeledCommitment, LabeledPolynomial, LinearCombination}; use crate::{PCCommitmentState, PCUniversalParams, PolynomialCommitment}; @@ -12,7 +9,9 @@ use ark_ec::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}; +#[cfg(not(feature = "std"))] +use ark_std::{string::ToString, vec::Vec}; mod data_structures; use ark_crypto_primitives::sponge::CryptographicSponge; diff --git a/poly-commit/src/marlin/marlin_pst13_pc/combinations.rs b/poly-commit/src/marlin/marlin_pst13_pc/combinations.rs index 9c009a4f..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 ark_std::vec::*; - +#[cfg(not(feature = "std"))] +use ark_std::vec::Vec; /// Compute all combinations of values in a given list. pub(crate) struct Combinations 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 7b5d957a..389ce69d 100644 --- a/poly-commit/src/marlin/marlin_pst13_pc/data_structures.rs +++ b/poly-commit/src/marlin/marlin_pst13_pc/data_structures.rs @@ -4,18 +4,18 @@ use crate::{ }; 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; -use ark_std::vec::*; - /// `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 94abae1b..787cf0a5 100644 --- a/poly-commit/src/marlin/marlin_pst13_pc/mod.rs +++ b/poly-commit/src/marlin/marlin_pst13_pc/mod.rs @@ -6,6 +6,7 @@ use crate::{ use crate::{BatchLCProof, Error, Evaluations, QuerySet}; use crate::{LabeledCommitment, LabeledPolynomial, LinearCombination}; use crate::{PCCommitmentState, PCUniversalParams, PolynomialCommitment}; +use ark_crypto_primitives::sponge::CryptographicSponge; use ark_ec::AffineRepr; use ark_ec::{ pairing::Pairing, @@ -14,10 +15,11 @@ use ark_ec::{ }; use ark_ff::{One, PrimeField, UniformRand, Zero}; use ark_poly::{multivariate::Term, DenseMVPolynomial}; -use ark_std::rand::RngCore; -use ark_std::string::*; -use ark_std::vec::*; -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::*; @@ -25,10 +27,6 @@ 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] @@ -707,7 +705,8 @@ mod tests { multivariate::{SparsePolynomial as SparsePoly, SparseTerm}, DenseMVPolynomial, }; - use ark_std::vec::*; + #[cfg(not(feature = "std"))] + use ark_std::vec::Vec; use rand_chacha::ChaCha20Rng; type MVPoly_381 = SparsePoly<::ScalarField, SparseTerm>; diff --git a/poly-commit/src/marlin/mod.rs b/poly-commit/src/marlin/mod.rs index e7bd8bcc..403be0c6 100644 --- a/poly-commit/src/marlin/mod.rs +++ b/poly-commit/src/marlin/mod.rs @@ -9,9 +9,12 @@ use ark_ec::pairing::Pairing; use ark_ec::AffineRepr; use ark_ec::CurveGroup; use ark_ff::{One, Zero}; -use ark_std::string::*; -use ark_std::vec::*; 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 diff --git a/poly-commit/src/multilinear_pc/data_structures.rs b/poly-commit/src/multilinear_pc/data_structures.rs index f4fc6f67..c70aae08 100644 --- a/poly-commit/src/multilinear_pc/data_structures.rs +++ b/poly-commit/src/multilinear_pc/data_structures.rs @@ -1,6 +1,7 @@ use ark_ec::pairing::Pairing; use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; -use ark_std::vec::*; +#[cfg(not(feature = "std"))] +use ark_std::vec::Vec; #[allow(type_alias_bounds)] /// Evaluations over {0,1}^n for G1 pub type EvaluationHyperCubeOnG1 = Vec; diff --git a/poly-commit/src/multilinear_pc/mod.rs b/poly-commit/src/multilinear_pc/mod.rs index 0b5f494c..f75558a1 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; -use ark_std::vec::*; -use ark_std::UniformRand; +#[cfg(not(feature = "std"))] +use ark_std::vec::Vec; +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; @@ -244,7 +243,8 @@ mod tests { use ark_poly::{DenseMultilinearExtension, MultilinearExtension, SparseMultilinearExtension}; use ark_std::rand::RngCore; use ark_std::test_rng; - use ark_std::vec::*; + #[cfg(not(feature = "std"))] + use ark_std::vec::Vec; type E = Bls12_381; type Fr = ::ScalarField; diff --git a/poly-commit/src/sonic_pc/data_structures.rs b/poly-commit/src/sonic_pc/data_structures.rs index ac066f1b..92049b04 100644 --- a/poly-commit/src/sonic_pc/data_structures.rs +++ b/poly-commit/src/sonic_pc/data_structures.rs @@ -6,7 +6,8 @@ use ark_serialize::{ CanonicalDeserialize, CanonicalSerialize, Compress, SerializationError, Valid, Validate, }; use ark_std::io::{Read, Write}; -use ark_std::vec::*; +#[cfg(not(feature = "std"))] +use ark_std::vec::Vec; /// `UniversalParams` are the universal parameters for the KZG10 scheme. pub type UniversalParams = kzg10::UniversalParams; diff --git a/poly-commit/src/sonic_pc/mod.rs b/poly-commit/src/sonic_pc/mod.rs index c10d7ac4..f408fe97 100644 --- a/poly-commit/src/sonic_pc/mod.rs +++ b/poly-commit/src/sonic_pc/mod.rs @@ -3,18 +3,17 @@ use crate::{BTreeMap, BTreeSet}; 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_std::string::*; -use ark_std::vec::*; - -use ark_ec::pairing::Pairing; +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 diff --git a/poly-commit/src/streaming_kzg/data_structures.rs b/poly-commit/src/streaming_kzg/data_structures.rs index c6fb2a77..7a09141a 100644 --- a/poly-commit/src/streaming_kzg/data_structures.rs +++ b/poly-commit/src/streaming_kzg/data_structures.rs @@ -1,9 +1,9 @@ +use crate::streaming_kzg::ceil_div; use ark_ff::Field; use ark_std::borrow::Borrow; -use ark_std::vec::*; - -use crate::streaming_kzg::ceil_div; use ark_std::iterable::Iterable; +#[cfg(not(feature = "std"))] +use ark_std::vec::Vec; /// 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 8abcfa08..14d686c2 100644 --- a/poly-commit/src/streaming_kzg/mod.rs +++ b/poly-commit/src/streaming_kzg/mod.rs @@ -88,7 +88,8 @@ mod time; use ark_ec::CurveGroup; use ark_serialize::{CanonicalSerialize, Compress}; -use ark_std::vec::*; +#[cfg(not(feature = "std"))] +use ark_std::vec::Vec; pub use data_structures::*; pub use space::CommitterKeyStream; pub use time::CommitterKey; diff --git a/poly-commit/src/streaming_kzg/space.rs b/poly-commit/src/streaming_kzg/space.rs index ad4ce521..4fa2a9eb 100644 --- a/poly-commit/src/streaming_kzg/space.rs +++ b/poly-commit/src/streaming_kzg/space.rs @@ -4,11 +4,12 @@ use ark_ff::{PrimeField, Zero}; use ark_poly::Polynomial; use ark_std::borrow::Borrow; use ark_std::collections::VecDeque; -use ark_std::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}; +#[cfg(not(feature = "std"))] +use ark_std::vec::Vec; use super::{time::CommitterKey, VerifierKey}; use super::{Commitment, EvaluationProof}; diff --git a/poly-commit/src/streaming_kzg/tests.rs b/poly-commit/src/streaming_kzg/tests.rs index 8ca1eb70..8d5da658 100644 --- a/poly-commit/src/streaming_kzg/tests.rs +++ b/poly-commit/src/streaming_kzg/tests.rs @@ -1,7 +1,6 @@ use ark_bls12_381::{Bls12_381, Fr}; use ark_poly::univariate::DensePolynomial; use ark_poly::DenseUVPolynomial; -use ark_std::vec::*; use ark_std::{UniformRand, Zero}; use crate::streaming_kzg::space::CommitterKeyStream; @@ -10,6 +9,8 @@ use crate::streaming_kzg::{vanishing_polynomial, VerifierKey}; use ark_ff::Field; use ark_std::borrow::Borrow; use ark_std::iterable::{Iterable, Reverse}; +#[cfg(not(feature = "std"))] +use ark_std::vec::Vec; /// 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 4a1110c7..ff14d6cd 100644 --- a/poly-commit/src/streaming_kzg/time.rs +++ b/poly-commit/src/streaming_kzg/time.rs @@ -5,7 +5,8 @@ use ark_ec::scalar_mul::ScalarMul; use ark_ec::CurveGroup; use ark_ff::Zero; use ark_poly::{univariate::DensePolynomial, DenseUVPolynomial}; -use ark_std::vec::*; +#[cfg(not(feature = "std"))] +use ark_std::vec::Vec; use ark_std::{borrow::Borrow, ops::Div, ops::Mul, rand::RngCore, UniformRand}; use crate::streaming_kzg::{