Skip to content

Commit

Permalink
Fix no-std
Browse files Browse the repository at this point in the history
Co-authored-by: Marcin Gorny <[email protected]>
  • Loading branch information
Pratyush and mmagician committed Feb 15, 2023
1 parent 3391417 commit 5fb2d44
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 26 deletions.
17 changes: 6 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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/"
Expand All @@ -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]
Expand All @@ -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"]
Expand Down
4 changes: 2 additions & 2 deletions src/ipa_pc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Fr>;
type Sponge = PoseidonSponge<<EdwardsAffine as AffineRepr>::ScalarField>;
type PC<E, D, P, S> = InnerProductArgPC<E, D, P, S>;
type PC_JJB2S = PC<EdwardsAffine, Blake2s, UniPoly, Sponge>;
type PC_JJB2S = PC<EdwardsAffine, Blake2s256, UniPoly, Sponge>;

fn rand_poly<F: PrimeField>(
degree: usize,
Expand Down
5 changes: 2 additions & 3 deletions src/kzg10/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ macro_rules! eprintln {
() => {};
($($arg: tt)*) => {};
}
#[cfg(not(feature = "std"))]
#[cfg(all(test, not(feature = "std")))]
macro_rules! println {
() => {};
($($arg: tt)*) => {};
Expand Down
6 changes: 3 additions & 3 deletions src/marlin/marlin_pst13_pc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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<<Bls12_381 as Pairing>::ScalarField, SparseTerm>;
Expand Down
7 changes: 1 addition & 6 deletions src/streaming_kzg/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 5fb2d44

Please sign in to comment.