Skip to content

Commit 40a8b65

Browse files
committed
musig: explicitly panic when given an empty slice of pubkeys to aggregate
The existing code panics somewhere in ffi.rs trying to do pointer alignment stuff, and is only not UB by accident. Guard this with an explicit panic.
1 parent ebdaec7 commit 40a8b65

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/musig.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,10 @@ impl KeyAggCache {
314314
///
315315
/// Panics if an empty slice of pubkeys is provided.
316316
pub fn new<C: Verification>(secp: &Secp256k1<C>, pubkeys: &[&PublicKey]) -> Self {
317+
if pubkeys.is_empty() {
318+
panic!("Cannot aggregate an empty slice of pubkeys");
319+
}
320+
317321
let cx = secp.ctx().as_ptr();
318322

319323
let mut key_agg_cache = MaybeUninit::<ffi::MusigKeyAggCache>::uninit();

0 commit comments

Comments
 (0)