|
3 | 3 | //! ## Synopsis |
4 | 4 | //! |
5 | 5 | //! ``` |
6 | | -//! use schnorr_fun::{musig::{MuSig, Party}, Schnorr, Message, nonce::Deterministic}; |
| 6 | +//! use schnorr_fun::{musig::MuSig, Schnorr, Message, nonce::Deterministic}; |
7 | 7 | //! use sha2::Sha256; |
8 | 8 | //! // use sha256 with deterministic nonce generation |
9 | 9 | //! let musig = MuSig::<Sha256, Schnorr<Sha256, Deterministic<Sha256>>>::default(); |
|
17 | 17 | //! # let public_key3 = kp3.public_key(); |
18 | 18 | //! // recieve the public keys of all other participants to form the aggregate key. |
19 | 19 | //! 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, |
23 | 23 | //! ]); |
24 | 24 | //! let agg_key = keylist.agg_public_key(); |
25 | 25 | //! |
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 |
31 | 34 | //! 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. |
33 | 35 | //! let message = Message::plain("my-app", b"chancellor on brink of second bailout for banks"); |
| 36 | +//! // start the signing session |
34 | 37 | //! let mut session = musig.start_sign_session(&keylist, nonces, message).unwrap(); |
35 | 38 | //! // 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); |
39 | 42 | //! // receive p1_sig and p3_sig from somewhere and check they're valid |
40 | 43 | //! assert!(musig.verify_partial_signature(&keylist, &session, 1, p2_sig)); |
41 | 44 | //! assert!(musig.verify_partial_signature(&keylist, &session, 2, p3_sig)); |
42 | 45 | //! // combine them with ours into the final signature |
43 | 46 | //! let sig = musig.combine_partial_signatures(&keylist, &session, [p1_sig, p2_sig, p3_sig]); |
44 | 47 | //! // 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); |
46 | 49 | //! ``` |
47 | 50 | //! |
48 | 51 | //! ## Description |
@@ -196,7 +199,7 @@ impl<H: Digest<OutputSize = U32> + Clone, S> MuSig<H, S> { |
196 | 199 | /// ``` |
197 | 200 | /// use schnorr_fun::{ |
198 | 201 | /// fun::{Point, Scalar, XOnly}, |
199 | | - /// musig::{MuSig, Party}, |
| 202 | + /// musig::MuSig, |
200 | 203 | /// nonce::Deterministic, |
201 | 204 | /// Schnorr, |
202 | 205 | /// }; |
|
0 commit comments