Skip to content

Commit 5af93eb

Browse files
Merge rust-bitcoin/rust-secp256k1#802: musig: Take references to pub nonce and part sig in partial_verify
6c8b1b81c2c52ca4e6c66dd0402a66fd923c439f run cargo fmt (Andrew Poelstra) cd6ecb11760e8219119da5b0be3f655bac9e6f1e musig: Take references to pub nonce and part sig in partial_verify (Steven Roose) Pull request description: We've been building on sanket's old branch for quite a while and I noticed the unnecessary taking by value there. These types are quite big (132 bytes for the pub nonce), so since they're just ref'd internally as well, it makes sense to do this. I assume the musig API is still not released yet, so this can be changed without breaking? ACKs for top commit: apoelstra: On 6c8b1b81c2c52ca4e6c66dd0402a66fd923c439f successfully ran local tests; would ACK but I am the last pusher and Github will not let me Tree-SHA512: d3af93f20fce3a8863b3681a942d3186ca59523d7e0e90464bf24c563185e8ec14d8a129c797336fe9d8b5ad6166313fb8932d397f7aeee0526819be9ce128f0
2 parents c6ddc53 + 997e611 commit 5af93eb

File tree

2 files changed

+41
-11
lines changed

2 files changed

+41
-11
lines changed

examples/musig.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ fn main() {
8484
let partial_sign2 = session.partial_sign(&secp, sec_nonce2, &keypair2, &musig_key_agg_cache);
8585

8686
let is_partial_signature_valid =
87-
session.partial_verify(&secp, &musig_key_agg_cache, partial_sign1, pub_nonce1, pubkey1);
87+
session.partial_verify(&secp, &musig_key_agg_cache, &partial_sign1, &pub_nonce1, pubkey1);
8888
assert!(is_partial_signature_valid);
8989

9090
let is_partial_signature_valid =
91-
session.partial_verify(&secp, &musig_key_agg_cache, partial_sign2, pub_nonce2, pubkey2);
91+
session.partial_verify(&secp, &musig_key_agg_cache, &partial_sign2, &pub_nonce2, pubkey2);
9292
assert!(is_partial_signature_valid);
9393

9494
let partial_sigs = [partial_sign1, partial_sign2];

src/musig.rs

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,8 +1226,8 @@ impl Session {
12261226
/// assert!(session.partial_verify(
12271227
/// &secp,
12281228
/// &key_agg_cache,
1229-
/// partial_sig1,
1230-
/// pub_nonce1,
1229+
/// &partial_sig1,
1230+
/// &pub_nonce1,
12311231
/// pub_key1,
12321232
/// ));
12331233
/// # }
@@ -1236,8 +1236,8 @@ impl Session {
12361236
&self,
12371237
secp: &Secp256k1<C>,
12381238
key_agg_cache: &KeyAggCache,
1239-
partial_sig: PartialSignature,
1240-
pub_nonce: PublicNonce,
1239+
partial_sig: &PartialSignature,
1240+
pub_nonce: &PublicNonce,
12411241
pub_key: PublicKey,
12421242
) -> bool {
12431243
let cx = secp.ctx().as_ptr();
@@ -1591,12 +1591,42 @@ mod tests {
15911591
let partial_sign2 = session.partial_sign(&secp, sec_nonce2, &keypair2, &key_agg_cache);
15921592

15931593
// Test partial signature verification
1594-
assert!(session.partial_verify(&secp, &key_agg_cache, partial_sign1, pub_nonce1, pubkey1));
1595-
assert!(session.partial_verify(&secp, &key_agg_cache, partial_sign2, pub_nonce2, pubkey2));
1594+
assert!(session.partial_verify(
1595+
&secp,
1596+
&key_agg_cache,
1597+
&partial_sign1,
1598+
&pub_nonce1,
1599+
pubkey1
1600+
));
1601+
assert!(session.partial_verify(
1602+
&secp,
1603+
&key_agg_cache,
1604+
&partial_sign2,
1605+
&pub_nonce2,
1606+
pubkey2
1607+
));
15961608
// Test that they are invalid if you switch keys
1597-
assert!(!session.partial_verify(&secp, &key_agg_cache, partial_sign2, pub_nonce2, pubkey1));
1598-
assert!(!session.partial_verify(&secp, &key_agg_cache, partial_sign2, pub_nonce1, pubkey2));
1599-
assert!(!session.partial_verify(&secp, &key_agg_cache, partial_sign2, pub_nonce1, pubkey1));
1609+
assert!(!session.partial_verify(
1610+
&secp,
1611+
&key_agg_cache,
1612+
&partial_sign2,
1613+
&pub_nonce2,
1614+
pubkey1
1615+
));
1616+
assert!(!session.partial_verify(
1617+
&secp,
1618+
&key_agg_cache,
1619+
&partial_sign2,
1620+
&pub_nonce1,
1621+
pubkey2
1622+
));
1623+
assert!(!session.partial_verify(
1624+
&secp,
1625+
&key_agg_cache,
1626+
&partial_sign2,
1627+
&pub_nonce1,
1628+
pubkey1
1629+
));
16001630

16011631
// Test PartialSignature serialization/deserialization
16021632
let serialized_partial_sig = partial_sign1.serialize();

0 commit comments

Comments
 (0)