|
22 | 22 | //!
|
23 | 23 | //! # Synopsis
|
24 | 24 | //! ```
|
25 |
| -//! use schnorr_fun::{blind, Blinder, Message, Schnorr}; |
26 |
| -//! use secp256kfun::{g, marker::Public, Scalar, G, nonce::Deterministic,}; |
| 25 | +//! use schnorr_fun::{blind, Blinder, Message, Schnorr, nonce}; |
| 26 | +//! use secp256kfun::{g, marker::Public, Scalar, G, derive_nonce, nonce::Deterministic}; |
| 27 | +//! use rand::rngs::ThreadRng; |
27 | 28 | //! use sha2::Sha256;
|
28 | 29 | //!
|
29 |
| -//! let schnorr = Schnorr::<Sha256, Deterministic<Sha256>>::new(Deterministic::<Sha256>::default()); |
30 |
| -//! // Generate a secret & public key for the party that will blindly sign a message |
| 30 | +//! let nonce_gen = nonce::Synthetic::<Sha256, nonce::GlobalRng<ThreadRng>>::default(); |
| 31 | +//! let schnorr = Schnorr::<Sha256, _>::new(nonce_gen); |
| 32 | +//! // Generate a secret & public key for the blind signing server |
31 | 33 | //! let mut secret = Scalar::random(&mut rand::thread_rng());
|
32 | 34 | //! let (public_key, secret_needs_negation) = g!(secret * G).normalize().into_point_with_even_y();
|
33 | 35 | //! secret.conditional_negate(secret_needs_negation);
|
|
37 | 39 | //! // Here we request two nonces corresponding to two sessions, such that we will retrieve one signature.
|
38 | 40 | //! let n_sessions = 2;
|
39 | 41 | //!
|
40 |
| -//! // The blind signing server replies with N public nonces to the user and remembers this number of sessions. |
| 42 | +//! // The blind signing server sends out N public nonces to the user and remembers this number of sessions. |
41 | 43 | //! let mut nonces = vec![];
|
42 | 44 | //! let mut pub_nonces = vec![];
|
43 | 45 | //! for _ in 0..n_sessions {
|
44 |
| -//! let mut nonce = Scalar::random(&mut rand::thread_rng()); |
45 |
| -//! // TODO: Probably want to reintroduce a singular nonce struct? And move musig/frost to "binonce" |
| 46 | +//! let mut nonce = derive_nonce!( |
| 47 | +//! nonce_gen => schnorr.nonce_gen(), |
| 48 | +//! secret => secret, |
| 49 | +//! public => [public_key] |
| 50 | +//! ); |
46 | 51 | //! let (pub_nonce, nonce_negated) = g!(nonce * G).normalize().into_point_with_even_y();
|
47 | 52 | //! nonce.conditional_negate(nonce_negated);
|
48 | 53 | //! nonces.push(nonce);
|
|
99 | 104 | //! }
|
100 | 105 | //! ```
|
101 | 106 |
|
102 |
| -use crate::fun::rand_core::{CryptoRng, RngCore}; |
103 |
| -use crate::{Message, Schnorr, Signature}; |
| 107 | +use crate::{ |
| 108 | + fun::rand_core::{CryptoRng, RngCore}, |
| 109 | + Message, Schnorr, Signature, Vec, |
| 110 | +}; |
104 | 111 | use rand::Rng;
|
105 |
| -use secp256kfun::nonce::{AddTag, NonceGen}; |
106 | 112 | use secp256kfun::{
|
107 | 113 | digest::{generic_array::typenum::U32, Digest},
|
108 | 114 | g,
|
109 | 115 | marker::*,
|
| 116 | + nonce::{AddTag, NonceGen}, |
110 | 117 | s, Point, Scalar, G,
|
111 | 118 | };
|
112 |
| -use std::vec::Vec; |
113 | 119 |
|
114 | 120 | /// Use [`BlindingTweaks`] to create the blinded public key, challenge, and nonce needed for a blinded signature
|
115 | 121 | ///
|
|
0 commit comments