Use a do-while in multiexp, first to please a friend, and then to annoy them

It's also legitimately cleaner code.
This commit is contained in:
Luke Parker 2022-07-02 14:22:17 -04:00
parent a81a76da3b
commit 3acfb5b7d2
No known key found for this signature in database
GPG key ID: F9F1386DB1E119B6

View file

@ -22,11 +22,12 @@ impl<Id: Copy, G: Group> BatchVerifier<Id, G> where <G as Group>::Scalar: PrimeF
let u = if self.0.len() == 0 {
G::Scalar::one()
} else {
let mut weight = G::Scalar::random(&mut *rng);
let mut weight;
// Ensure it's non-zero, as a zero scalar would cause this item to pass no matter what
while weight.is_zero().into() {
while {
weight = G::Scalar::random(&mut *rng);
}
weight.is_zero().into()
} {}
weight
};
self.0.push((id, pairs.into_iter().map(|(scalar, point)| (scalar * u, point)).collect()));