fix(bls): fix is_infinity when aggregating onto empty AggregateSignature (#8496)

Co-Authored-By: figtracer <1gusredo@gmail.com>

Co-Authored-By: Michael Sproul <michaelsproul@users.noreply.github.com>
This commit is contained in:
gustavo
2025-12-15 01:47:04 +00:00
committed by GitHub
parent 556e917092
commit cd0b1ef648
2 changed files with 21 additions and 6 deletions

View File

@@ -124,13 +124,15 @@ where
/// Aggregates a signature onto `self`.
pub fn add_assign(&mut self, other: &GenericSignature<Pub, Sig>) {
if let Some(other_point) = other.point() {
self.is_infinity = self.is_infinity && other.is_infinity;
if let Some(self_point) = &mut self.point {
self_point.add_assign(other_point)
self_point.add_assign(other_point);
self.is_infinity = self.is_infinity && other.is_infinity;
} else {
let mut self_point = AggSig::infinity();
self_point.add_assign(other_point);
self.point = Some(self_point)
self.point = Some(self_point);
// the result is infinity, if `other` is
self.is_infinity = other.is_infinity;
}
}
}
@@ -138,13 +140,15 @@ where
/// Aggregates an aggregate signature onto `self`.
pub fn add_assign_aggregate(&mut self, other: &Self) {
if let Some(other_point) = other.point() {
self.is_infinity = self.is_infinity && other.is_infinity;
if let Some(self_point) = &mut self.point {
self_point.add_assign_aggregate(other_point)
self_point.add_assign_aggregate(other_point);
self.is_infinity = self.is_infinity && other.is_infinity;
} else {
let mut self_point = AggSig::infinity();
self_point.add_assign_aggregate(other_point);
self.point = Some(self_point)
self.point = Some(self_point);
// the result is infinity, if `other` is
self.is_infinity = other.is_infinity;
}
}
}