Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions poly-commit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ark-crypto-primitives = {version = "^0.4.0", default-features = false, features
ark-std = { version = "^0.4.0", default-features = false }
blake2 = { version = "0.10", default-features = false }
merlin = { version = "3.0.0", default-features = false }

rand = { version = "0.8.0", optional = true }
ark-relations = { version = "^0.4.0", default-features = false, optional = true }
ark-r1cs-std = { version = "^0.4.0", default-features = false, optional = true }

Expand Down Expand Up @@ -55,4 +55,4 @@ 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"]
r1cs = [ "ark-relations", "ark-r1cs-std", "hashbrown", "ark-crypto-primitives/r1cs"]
print-trace = [ "ark-std/print-trace" ]
parallel = [ "std", "ark-ff/parallel", "ark-ec/parallel", "ark-poly/parallel", "ark-std/parallel", "rayon" ]
parallel = [ "std", "ark-ff/parallel", "ark-ec/parallel", "ark-poly/parallel", "ark-std/parallel", "rayon", "rand" ]
17 changes: 9 additions & 8 deletions poly-commit/src/hyrax/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ impl<G: AffineRepr, P: MultilinearExtension<G::ScalarField>>
///
/// Panics if `rng` is None, since Hyrax requires randomness in order to
/// commit to a polynomial
#[allow(unused_variables)]
fn commit<'a>(
ck: &Self::CommitterKey,
polynomials: impl IntoIterator<Item = &'a LabeledPolynomial<G::ScalarField, P>>,
Expand All @@ -248,11 +249,10 @@ impl<G: AffineRepr, P: MultilinearExtension<G::ScalarField>>
let mut coms = Vec::new();
let mut rands = Vec::new();

#[cfg(not(feature = "parallel"))]
let rng_inner = rng.expect("Committing to polynomials requires a random generator");

for l_poly in polynomials {
let mut com_rands = Vec::new();

let label = l_poly.label();
let poly = l_poly.polynomial();

Expand All @@ -272,15 +272,16 @@ impl<G: AffineRepr, P: MultilinearExtension<G::ScalarField>>
let m = flat_to_matrix_column_major(&poly.to_evaluations(), dim, dim);

// Commiting to the matrix with one multi-commitment per row
let row_coms = m
.iter()
let (row_coms, com_rands): (Vec<_>, Vec<_>) = cfg_iter!(m)
.map(|row| {
#[cfg(not(feature = "parallel"))]
let (c, r) = Self::pedersen_commit(ck, row, None, Some(rng_inner));
// Storing the randomness used in the commitment
com_rands.push(r);
c
#[cfg(feature = "parallel")]
let (c, r) =
Self::pedersen_commit(ck, row, None, Some(&mut rand::thread_rng()));
Comment thread
mmagician marked this conversation as resolved.
(c, r)
})
.collect();
.unzip();

let com = HyraxCommitment { row_coms };
let l_comm = LabeledCommitment::new(label.to_string(), com, Some(1));
Expand Down