From 75a28aee6bf0becba5da78b08d08a8f5b1228868 Mon Sep 17 00:00:00 2001 From: Pratyush Mishra Date: Tue, 14 Feb 2023 18:10:21 -0800 Subject: [PATCH] Fix no-std --- Cargo.toml | 17 ++++++----------- src/ipa_pc/mod.rs | 4 ++-- src/kzg10/mod.rs | 5 ++--- src/lib.rs | 2 +- src/marlin/marlin_pst13_pc/mod.rs | 6 +++--- src/streaming_kzg/time.rs | 7 +------ 6 files changed, 15 insertions(+), 26 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0c71527f..aec77249 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,6 @@ [package] name = "ark-poly-commit" version = "0.4.0" -authors = [ - "arkworks contributors" -] description = "A library for constructing polynomial commitment schemes for use in zkSNARKs" repository = "https://github.com/arkworks-rs/poly-commit" documentation = "https://docs.rs/ark-poly-commit/" @@ -18,22 +15,22 @@ ark-serialize = { version = "^0.4.0", default-features = false, features = [ "de ark-ff = { version = "^0.4.0", default-features = false } ark-ec = { version = "^0.4.0", default-features = false } ark-poly = {version = "^0.4.0", default-features = false } -ark-crypto-primitives = {version = "^0.4.0", features = ["sponge"] } - +ark-crypto-primitives = {version = "^0.4.0", default-features = false, features = ["sponge"] } ark-std = { version = "^0.4.0", default-features = false } + 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.9", optional = true } +hashbrown = { version = "0.13", default-features = false, optional = true } -digest = "0.9" -rayon = { version = "1", optional = true } +digest = "0.10" derivative = { version = "2", features = [ "use_core" ] } +rayon = { version = "1", optional = true } [dev-dependencies] ark-ed-on-bls12-381 = { version = "^0.4.0", default-features = false } ark-bls12-381 = { version = "^0.4.0", default-features = false, features = [ "curve" ] } ark-bls12-377 = { version = "^0.4.0", default-features = false, features = [ "curve" ] } -blake2 = { version = "0.9", default-features = false } +blake2 = { version = "0.10", default-features = false } rand_chacha = { version = "0.3.0", default-features = false } [profile.release] @@ -48,8 +45,6 @@ debug-assertions = true incremental = true debug = true -# To be removed in the new release. - [features] default = [ "std", "parallel" ] std = [ "ark-ff/std", "ark-ec/std", "ark-poly/std", "ark-std/std", "ark-relations/std", "ark-serialize/std", "ark-crypto-primitives/std"] diff --git a/src/ipa_pc/mod.rs b/src/ipa_pc/mod.rs index eff7143b..53326e5d 100644 --- a/src/ipa_pc/mod.rs +++ b/src/ipa_pc/mod.rs @@ -1078,13 +1078,13 @@ mod tests { use ark_ed_on_bls12_381::{EdwardsAffine, Fr}; use ark_ff::PrimeField; use ark_poly::{univariate::DensePolynomial as DensePoly, DenseUVPolynomial}; - use blake2::Blake2s; + use blake2::Blake2s256; use rand_chacha::ChaCha20Rng; type UniPoly = DensePoly; type Sponge = PoseidonSponge<::ScalarField>; type PC = InnerProductArgPC; - type PC_JJB2S = PC; + type PC_JJB2S = PC; fn rand_poly( degree: usize, diff --git a/src/kzg10/mod.rs b/src/kzg10/mod.rs index e5dd0879..4c52390a 100644 --- a/src/kzg10/mod.rs +++ b/src/kzg10/mod.rs @@ -12,7 +12,6 @@ use ark_ec::{scalar_mul::fixed_base::FixedBase, VariableBaseMSM}; use ark_ff::{One, PrimeField, UniformRand, Zero}; use ark_poly::DenseUVPolynomial; use ark_std::{format, marker::PhantomData, ops::Div, ops::Mul, vec}; -use std::ops::AddAssign; use ark_std::rand::RngCore; #[cfg(feature = "parallel")] @@ -180,7 +179,7 @@ where .into_affine(); end_timer!(msm_time); - commitment.add_assign(&random_commitment); + commitment += &random_commitment; end_timer!(commit_time); Ok((Commitment(commitment.into()), randomness)) @@ -333,7 +332,7 @@ where for (((c, z), v), proof) in commitments.iter().zip(points).zip(values).zip(proofs) { let w = proof.w; let mut temp = w.mul(*z); - temp.add_assign(&c.0); + temp += &c.0; let c = temp; g_multiplier += &(randomizer * v); if let Some(random_v) = proof.random_v { diff --git a/src/lib.rs b/src/lib.rs index 2138d492..fdbd8f05 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -60,7 +60,7 @@ macro_rules! eprintln { () => {}; ($($arg: tt)*) => {}; } -#[cfg(not(feature = "std"))] +#[cfg(all(test, not(feature = "std")))] macro_rules! println { () => {}; ($($arg: tt)*) => {}; diff --git a/src/marlin/marlin_pst13_pc/mod.rs b/src/marlin/marlin_pst13_pc/mod.rs index db29d7f6..eaa5eeea 100644 --- a/src/marlin/marlin_pst13_pc/mod.rs +++ b/src/marlin/marlin_pst13_pc/mod.rs @@ -13,7 +13,6 @@ 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 std::ops::AddAssign; mod data_structures; pub use data_structures::*; @@ -422,7 +421,7 @@ where end_timer!(msm_time); // Mask commitment with random poly - commitment.add_assign(&random_commitment); + commitment += &random_commitment; let comm = Self::Commitment { comm: kzg10::Commitment(commitment.into()), @@ -622,7 +621,7 @@ where .enumerate() .map(|(j, w_j)| w_j.mul(z[j])) .sum(); - temp.add_assign(&c.0); + temp += &c.0; let c = temp; g_multiplier += &(randomizer * &v); if let Some(random_v) = proof.random_v { @@ -725,6 +724,7 @@ mod tests { multivariate::{SparsePolynomial as SparsePoly, SparseTerm}, DenseMVPolynomial, }; + use ark_std::vec::Vec; use rand_chacha::ChaCha20Rng; type MVPoly_381 = SparsePoly<::ScalarField, SparseTerm>; diff --git a/src/streaming_kzg/time.rs b/src/streaming_kzg/time.rs index 5885495f..8c7fa2f8 100644 --- a/src/streaming_kzg/time.rs +++ b/src/streaming_kzg/time.rs @@ -5,12 +5,7 @@ use ark_ec::scalar_mul::fixed_base::FixedBase; use ark_ec::CurveGroup; use ark_ff::{PrimeField, Zero}; use ark_poly::{univariate::DensePolynomial, DenseUVPolynomial}; -use ark_std::borrow::Borrow; -use ark_std::ops::Div; -use ark_std::rand::RngCore; -use ark_std::vec::Vec; -use ark_std::UniformRand; -use std::ops::Mul; +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,