Skip to content

Commit e845b6c

Browse files
committed
fix doc tests
Signed-off-by: nickfarrow <[email protected]>
1 parent 345bdde commit e845b6c

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

schnorr_fun/src/musig.rs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! ## Synopsis
44
//!
55
//! ```
6-
//! use schnorr_fun::{musig::{MuSig, Party}, Schnorr, Message, nonce::Deterministic};
6+
//! use schnorr_fun::{musig::MuSig, Schnorr, Message, nonce::Deterministic};
77
//! use sha2::Sha256;
88
//! // use sha256 with deterministic nonce generation
99
//! let musig = MuSig::<Sha256, Schnorr<Sha256, Deterministic<Sha256>>>::default();
@@ -17,32 +17,35 @@
1717
//! # let public_key3 = kp3.public_key();
1818
//! // recieve the public keys of all other participants to form the aggregate key.
1919
//! let keylist = musig.new_keylist(vec![
20-
//! p1_public_key,
21-
//! p2_public_key,
22-
//! p3_public_key,
20+
//! public_key1,
21+
//! public_key2,
22+
//! public_key3,
2323
//! ]);
2424
//! let agg_key = keylist.agg_public_key();
2525
//!
26-
//! // create unique nonce, and send public nonce to other parties
27-
//! let p1_nonce = musig.gen_nonces(&keypair.sk, &keylist, b"session-id-1337");
28-
//! let p1_public_nonce = p1_nonce.public;
29-
//! # let p2_nonce = musig.gen_nonces(&keypair.sk, &keylist, b"session-id-1337");
30-
//! # let p3_nonce = musig.gen_nonces(&keypair.sk, &keylist, b"session-id-1337");
26+
//! // create unique nonce, and send public nonce to other parties.
27+
//! let p1_nonce = musig.gen_nonces(kp1.secret_key(), &keylist, b"session-id-1337");
28+
//! let p1_public_nonce = p1_nonce.public();
29+
//! # let p2_nonce = musig.gen_nonces(kp2.secret_key(), &keylist, b"session-id-1337");
30+
//! # let p2_public_nonce = p2_nonce.public();
31+
//! # let p3_nonce = musig.gen_nonces(kp3.secret_key(), &keylist, b"session-id-1337");
32+
//! # let p3_public_nonce = p3_nonce.public();
33+
//! // collect the public nonces from the other two parties
3134
//! let nonces = vec![p1_public_nonce, p2_public_nonce, p3_public_nonce];
32-
//! // Once you've got the nonces from the other two (p2_nonce and p3_nonce) you can start the signing session.
3335
//! let message = Message::plain("my-app", b"chancellor on brink of second bailout for banks");
36+
//! // start the signing session
3437
//! let mut session = musig.start_sign_session(&keylist, nonces, message).unwrap();
3538
//! // sign with our (single) local keypair
36-
//! let p1_sig = musig.sign(&keylist, 0, kp1.sk, p1_nonce, &session);
37-
//! # let p2_sig = musig.sign(&keylist, 1, kp2.sk, p2_nonce, &session);
38-
//! # let p3_sig = musig.sign(&keylist, 2, kp3.sk, p3_nonce, &session);
39+
//! let p1_sig = musig.sign(&keylist, 0, kp1.secret_key(), p1_nonce, &session);
40+
//! # let p2_sig = musig.sign(&keylist, 1, kp2.secret_key(), p2_nonce, &session);
41+
//! # let p3_sig = musig.sign(&keylist, 2, kp3.secret_key(), p3_nonce, &session);
3942
//! // receive p1_sig and p3_sig from somewhere and check they're valid
4043
//! assert!(musig.verify_partial_signature(&keylist, &session, 1, p2_sig));
4144
//! assert!(musig.verify_partial_signature(&keylist, &session, 2, p3_sig));
4245
//! // combine them with ours into the final signature
4346
//! let sig = musig.combine_partial_signatures(&keylist, &session, [p1_sig, p2_sig, p3_sig]);
4447
//! // check it's a valid normal Schnorr signature
45-
//! musig.schnorr.verify(&agg_key, message, &sig);
48+
//! musig.schnorr.verify(&keylist.agg_verification_key(), message, &sig);
4649
//! ```
4750
//!
4851
//! ## Description
@@ -196,7 +199,7 @@ impl<H: Digest<OutputSize = U32> + Clone, S> MuSig<H, S> {
196199
/// ```
197200
/// use schnorr_fun::{
198201
/// fun::{Point, Scalar, XOnly},
199-
/// musig::{MuSig, Party},
202+
/// musig::MuSig,
200203
/// nonce::Deterministic,
201204
/// Schnorr,
202205
/// };

0 commit comments

Comments
 (0)