Skip to content

Commit ec66003

Browse files
committed
musig: remove SessionSecretRand::new constructor
This is just a convenience wrapper around SessionSecretRand::from_rng(&mut rng()). The name `new` disguises the fact that this is an impure function and actually calls a RNG every time it is called. It is also unused, in the docs or in the tests. Finally, clippy complains about it because it feels that a `new` method should always be accompanied by a `Default` impl...which is fair, but the impurity is veen more surprising for `default` than for `new`. Since `rand` renamed `thread_rng` to just `rng` the keystroke-saving value of this method is less. So just delete it.
1 parent 6d938d3 commit ec66003

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/musig.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ impl fmt::Display for ParseError {
4242
pub struct SessionSecretRand([u8; 32]);
4343

4444
impl SessionSecretRand {
45-
/// Generates a new session ID using thread RNG.
46-
#[cfg(all(feature = "rand", feature = "std"))]
47-
pub fn new() -> Self { Self::from_rng(&mut rand::rng()) }
48-
4945
/// Creates a new [`SessionSecretRand`] with random bytes from the given rng
5046
#[cfg(feature = "rand")]
5147
pub fn from_rng<R: rand::Rng + ?Sized>(rng: &mut R) -> Self {
@@ -59,8 +55,8 @@ impl SessionSecretRand {
5955
/// [`KeyAggCache::nonce_gen`] or [`new_nonce_pair`]. The simplest
6056
/// recommendation is to use a cryptographicaly random 32-byte value.
6157
///
62-
/// In rand-std environment, [`SessionSecretRand::new`] can be used to generate a random
63-
/// session id using thread rng.
58+
/// If the **rand** feature is enabled, [`SessionSecretRand::from_rng`] can be used to generate a
59+
/// random session id.
6460
pub fn assume_unique_per_nonce_gen(inner: [u8; 32]) -> Self { SessionSecretRand(inner) }
6561

6662
/// Obtains the inner bytes of the [`SessionSecretRand`].

0 commit comments

Comments
 (0)