Skip to content

Commit

Permalink
Further test
Browse files Browse the repository at this point in the history
  • Loading branch information
autquis committed Apr 7, 2024
1 parent 04cc8e7 commit 739345a
Show file tree
Hide file tree
Showing 22 changed files with 65 additions and 12 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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/" }
Expand Down
2 changes: 2 additions & 0 deletions poly-commit/src/constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ 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::{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.
Expand Down
2 changes: 2 additions & 0 deletions poly-commit/src/data_structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use ark_std::{
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;
Expand Down
3 changes: 3 additions & 0 deletions poly-commit/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#[cfg(not(feature = "std"))]
use ark_std::string::String;

/// The error type for `PolynomialCommitment`.
#[derive(Debug)]
pub enum Error {
Expand Down
5 changes: 5 additions & 0 deletions poly-commit/src/ipa_pc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ 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};
#[cfg(not(feature = "std"))]
use ark_std::{
string::{String, ToString},
vec::Vec,
};

mod data_structures;
pub use data_structures::*;
Expand Down
5 changes: 3 additions & 2 deletions poly-commit/src/kzg10/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +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::{format, marker::PhantomData, ops::Div, ops::Mul};

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::*;

Expand Down
5 changes: 5 additions & 0 deletions poly-commit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ use ark_std::{
hash::Hash,
iter::FromIterator,
};
#[cfg(not(feature = "std"))]
use ark_std::{
string::{String, ToString},
vec::Vec,
};

/// Data structures used by a polynomial commitment scheme.
pub mod data_structures;
Expand Down
6 changes: 3 additions & 3 deletions poly-commit/src/marlin/marlin_pc/data_structures.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::kzg10;
use crate::{
DenseUVPolynomial, PCCommitment, PCCommitmentState, PCCommitterKey, PCPreparedCommitment,
PCPreparedVerifierKey, PCVerifierKey,
Expand All @@ -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<E> = kzg10::UniversalParams<E>;

Expand Down
2 changes: 2 additions & 0 deletions poly-commit/src/marlin/marlin_pc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ use ark_ff::Zero;
use ark_poly::DenseUVPolynomial;
use ark_std::rand::RngCore;
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;
Expand Down
4 changes: 2 additions & 2 deletions poly-commit/src/marlin/marlin_pst13_pc/combinations.rs
Original file line number Diff line number Diff line change
@@ -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<T>
where
Expand Down
2 changes: 2 additions & 0 deletions poly-commit/src/marlin/marlin_pst13_pc/data_structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ 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,
Expand Down
12 changes: 7 additions & 5 deletions poly-commit/src/marlin/marlin_pst13_pc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -15,17 +16,17 @@ use ark_ec::{
use ark_ff::{One, PrimeField, UniformRand, Zero};
use ark_poly::{multivariate::Term, DenseMVPolynomial};
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::*;

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]
Expand Down Expand Up @@ -704,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<<Bls12_381 as Pairing>::ScalarField, SparseTerm>;
Expand Down
5 changes: 5 additions & 0 deletions poly-commit/src/marlin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ use ark_ec::AffineRepr;
use ark_ec::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
Expand Down
2 changes: 2 additions & 0 deletions poly-commit/src/multilinear_pc/data_structures.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
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
pub type EvaluationHyperCubeOnG1<E: Pairing> = Vec<E::G1Affine>;
Expand Down
4 changes: 4 additions & 0 deletions poly-commit/src/multilinear_pc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use ark_ec::{
};
use ark_ff::{Field, One, PrimeField, Zero};
use ark_poly::{DenseMultilinearExtension, MultilinearExtension};
#[cfg(not(feature = "std"))]
use ark_std::vec::Vec;
use ark_std::{
collections::LinkedList, iter::FromIterator, marker::PhantomData, ops::Mul, rand::RngCore,
UniformRand,
Expand Down Expand Up @@ -241,6 +243,8 @@ mod tests {
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;
type E = Bls12_381;
type Fr = <E as Pairing>::ScalarField;

Expand Down
2 changes: 2 additions & 0 deletions poly-commit/src/sonic_pc/data_structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ 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>;
Expand Down
5 changes: 5 additions & 0 deletions poly-commit/src/sonic_pc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ use ark_crypto_primitives::sponge::CryptographicSponge;
use ark_ec::{pairing::Pairing, AffineRepr, CurveGroup};
use ark_ff::{One, UniformRand, Zero};
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;
pub use data_structures::*;
Expand Down
2 changes: 2 additions & 0 deletions poly-commit/src/streaming_kzg/data_structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use crate::streaming_kzg::ceil_div;
use ark_ff::Field;
use ark_std::borrow::Borrow;
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
Expand Down
2 changes: 2 additions & 0 deletions poly-commit/src/streaming_kzg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ mod time;

use ark_ec::CurveGroup;
use ark_serialize::{CanonicalSerialize, Compress};
#[cfg(not(feature = "std"))]
use ark_std::vec::Vec;
pub use data_structures::*;
pub use space::CommitterKeyStream;
pub use time::CommitterKey;
Expand Down
2 changes: 2 additions & 0 deletions poly-commit/src/streaming_kzg/space.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use ark_std::collections::VecDeque;
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};
Expand Down
2 changes: 2 additions & 0 deletions poly-commit/src/streaming_kzg/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,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.
Expand Down
2 changes: 2 additions & 0 deletions poly-commit/src/streaming_kzg/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use ark_ec::scalar_mul::ScalarMul;
use ark_ec::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};

use crate::streaming_kzg::{
Expand Down

0 comments on commit 739345a

Please sign in to comment.