diff --git a/crypto/multiexp/src/batch.rs b/crypto/multiexp/src/batch.rs index 5b5d65fb..81765563 100644 --- a/crypto/multiexp/src/batch.rs +++ b/crypto/multiexp/src/batch.rs @@ -22,7 +22,12 @@ impl BatchVerifier where ::Scalar: PrimeF let u = if self.0.len() == 0 { G::Scalar::one() } else { - G::Scalar::random(rng) + let mut weight = G::Scalar::random(&mut *rng); + // Ensure it's non-zero, as a zero scalar would cause this item to pass no matter what + while weight.is_zero().into() { + weight = G::Scalar::random(&mut *rng); + } + weight }; self.0.push((id, pairs.into_iter().map(|(scalar, point)| (scalar * u, point)).collect())); }