Skip to content

Commit

Permalink
Verify signature in aggregation
Browse files Browse the repository at this point in the history
  • Loading branch information
survived committed Apr 19, 2024
1 parent 916380b commit 1a788de
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions givre/src/signing/aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,14 @@ pub fn aggregate<C: Ciphersuite>(
.map(|(_j, _comm, sig_share)| sig_share.0)
.sum();

Ok(Signature {
let sig = Signature {
r: C::normalize_point(group_commitment),
z,
})
};
sig.verify(&C::normalize_point(key_info.shared_public_key), msg)
.map_err(|_| Reason::InvalidSig)?;

Ok(sig)
}

/// Aggregation error
Expand All @@ -144,6 +148,7 @@ pub struct AggregateError(Reason);
enum Reason {
UnknownSigner(SignerIndex),
SameSignerTwice,
InvalidSig,
}

impl From<Reason> for AggregateError {
Expand All @@ -159,6 +164,7 @@ impl fmt::Display for AggregateError {
Reason::SameSignerTwice => {
f.write_str("same signer appears more than once in the list")
}
Reason::InvalidSig => f.write_str("invalid signature"),
}
}
}
Expand All @@ -167,7 +173,7 @@ impl fmt::Display for AggregateError {
impl std::error::Error for AggregateError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match &self.0 {
Reason::UnknownSigner(_) | Reason::SameSignerTwice => None,
Reason::UnknownSigner(_) | Reason::SameSignerTwice | Reason::InvalidSig => None,
}
}
}
Expand Down

0 comments on commit 1a788de

Please sign in to comment.