mirror of
https://github.com/serai-dex/serai.git
synced 2025-03-22 15:19:06 +00:00
Ensure multiexp never uses a zero-weight in its batch verifier
This commit is contained in:
parent
daadb43875
commit
a81a76da3b
1 changed files with 6 additions and 1 deletions
|
@ -22,7 +22,12 @@ impl<Id: Copy, G: Group> BatchVerifier<Id, G> where <G as Group>::Scalar: PrimeF
|
||||||
let u = if self.0.len() == 0 {
|
let u = if self.0.len() == 0 {
|
||||||
G::Scalar::one()
|
G::Scalar::one()
|
||||||
} else {
|
} 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()));
|
self.0.push((id, pairs.into_iter().map(|(scalar, point)| (scalar * u, point)).collect()));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue