@@ -248,18 +248,35 @@ impl<C: Verification> Secp256k1<C> {
248248}
249249
250250impl < C : Signing > Secp256k1 < C > {
251-
252- /// Generates a random Schnorr KeyPair and its associated Schnorr PublicKey.
253- /// Convenience function for `schnorrsig ::KeyPair::new` and
254- /// `schnorrsig::PublicKey::from_keypair`; call those functions directly for
255- /// batch key generation. Requires a signing-capable context. Requires compilation
256- /// with the "rand" feature.
251+ /// Generates a random Schnorr `KeyPair` and its associated Schnorr `XOnlyPublicKey`.
252+ ///
253+ /// Convenience function for `key ::KeyPair::new` and `key::XOnlyPublicKey::from_keypair`; call
254+ /// those functions directly for batch key generation.
255+ ///
256+ /// Requires a signing-capable context and requires compilation with the "rand" feature.
257257 #[ inline]
258258 #[ cfg( any( test, feature = "rand" ) ) ]
259259 #[ cfg_attr( docsrs, doc( cfg( feature = "rand" ) ) ) ]
260+ #[ deprecated( since = "0.21.0" , note = "Use generate_keypair_xonly instead." ) ]
260261 pub fn generate_schnorrsig_keypair < R : Rng + ?Sized > (
261262 & self ,
262263 rng : & mut R ,
264+ ) -> ( KeyPair , XOnlyPublicKey ) {
265+ self . generate_keypair_xonly ( rng)
266+ }
267+
268+ /// Generates a random Schnorr `KeyPair` and its associated Schnorr `XOnlyPublicKey`.
269+ ///
270+ /// Convenience function for `key::KeyPair::new` and `key::XOnlyPublicKey::from_keypair`; call
271+ /// those functions directly for batch key generation.
272+ ///
273+ /// Requires a signing-capable context and requires compilation with the "rand" feature.
274+ #[ inline]
275+ #[ cfg( any( test, feature = "rand" ) ) ]
276+ #[ cfg_attr( docsrs, doc( cfg( feature = "rand" ) ) ) ]
277+ pub fn generate_keypair_xonly < R : Rng + ?Sized > (
278+ & self ,
279+ rng : & mut R ,
263280 ) -> ( KeyPair , XOnlyPublicKey ) {
264281 let sk = KeyPair :: new ( self , rng) ;
265282 let pubkey = XOnlyPublicKey :: from_keypair ( & sk) ;
@@ -325,7 +342,7 @@ mod tests {
325342 let secp = Secp256k1 :: new ( ) ;
326343
327344 let mut rng = thread_rng ( ) ;
328- let ( seckey, pubkey) = secp. generate_schnorrsig_keypair ( & mut rng) ;
345+ let ( seckey, pubkey) = secp. generate_keypair_xonly ( & mut rng) ;
329346 let mut msg = [ 0u8 ; 32 ] ;
330347
331348 for _ in 0 ..100 {
@@ -390,7 +407,7 @@ mod tests {
390407 #[ test]
391408 fn test_pubkey_serialize_roundtrip ( ) {
392409 let secp = Secp256k1 :: new ( ) ;
393- let ( _, pubkey) = secp. generate_schnorrsig_keypair ( & mut thread_rng ( ) ) ;
410+ let ( _, pubkey) = secp. generate_keypair_xonly ( & mut thread_rng ( ) ) ;
394411 let ser = pubkey. serialize ( ) ;
395412 let pubkey2 = XOnlyPublicKey :: from_slice ( & ser) . unwrap ( ) ;
396413 assert_eq ! ( pubkey, pubkey2) ;
@@ -513,7 +530,7 @@ mod tests {
513530 }
514531
515532 let s = Secp256k1 :: new ( ) ;
516- let ( _, pubkey) = s. generate_schnorrsig_keypair ( & mut DumbRng ( 0 ) ) ;
533+ let ( _, pubkey) = s. generate_keypair_xonly ( & mut DumbRng ( 0 ) ) ;
517534 assert_eq ! (
518535 & pubkey. serialize( ) [ ..] ,
519536 & [
0 commit comments