Operation pool: add attestation support

This commit is contained in:
Michael Sproul
2019-03-19 19:15:33 +11:00
parent c2e5d3c45a
commit 1fca8a063c
3 changed files with 146 additions and 6 deletions

View File

@@ -28,6 +28,25 @@ pub struct Attestation {
pub aggregate_signature: AggregateSignature,
}
impl Attestation {
/// Are the aggregation bitfields of these attestations disjoint?
pub fn signers_disjoint_from(&self, other: &Attestation) -> bool {
self.aggregation_bitfield.intersection(&other.aggregation_bitfield).is_zero()
}
/// Aggregate another Attestation into this one.
///
/// The aggregation bitfields must be disjoint, and the data must be the same.
pub fn aggregate(&mut self, other: &Attestation) {
debug_assert_eq!(self.data, other.data);
debug_assert!(self.signers_disjoint_from(other));
self.aggregation_bitfield.union_inplace(&other.aggregation_bitfield);
self.custody_bitfield.union_inplace(&other.custody_bitfield);
// FIXME: signature aggregation once our BLS library wraps it
}
}
#[cfg(test)]
mod tests {
use super::*;