@@ -13,7 +13,7 @@ use core::{
1313 str,
1414} ;
1515use ff:: { Field , PrimeField } ;
16- use rand_core:: TryCryptoRng ;
16+ use rand_core:: { CryptoRng , TryCryptoRng } ;
1717use subtle:: { Choice , ConditionallySelectable , ConstantTimeEq , CtOption } ;
1818use zeroize:: Zeroize ;
1919
@@ -50,7 +50,11 @@ impl<C> NonZeroScalar<C>
5050where
5151 C : CurveArithmetic ,
5252{
53- /// Generate a random `NonZeroScalar`.
53+ /// Generate a random [`NonZeroScalar`].
54+ ///
55+ /// # Panics
56+ ///
57+ /// If the system's cryptographically secure RNG has an internal error.
5458 #[ cfg( feature = "getrandom" ) ]
5559 pub fn generate ( ) -> Self {
5660 // Use rejection sampling to eliminate invalid values
6569 }
6670 }
6771
68- /// Generate a random `NonZeroScalar`.
72+ /// Generate a random [ `NonZeroScalar`] .
6973 pub fn try_from_rng < R : TryCryptoRng + ?Sized > ( rng : & mut R ) -> Result < Self , R :: Error > {
7074 // Use rejection sampling to eliminate zero values.
7175 // While this method isn't constant-time, the attacker shouldn't learn
7781 }
7882 }
7983
84+ /// Deprecated: Generate a random [`NonZeroScalar`].
85+ #[ cfg( feature = "arithmetic" ) ]
86+ #[ deprecated( since = "0.14.0" , note = "use `generate` or `try_from_rng` instead" ) ]
87+ pub fn random < R : CryptoRng + ?Sized > ( rng : & mut R ) -> Self {
88+ let Ok ( ret) = Self :: try_from_rng ( rng) ;
89+ ret
90+ }
91+
8092 /// Create a [`NonZeroScalar`] from a scalar.
8193 pub fn new ( scalar : Scalar < C > ) -> CtOption < Self > {
8294 CtOption :: new ( Self { scalar } , !scalar. is_zero ( ) )
0 commit comments