@@ -13,7 +13,7 @@ use core::{fmt, ptr, str};
1313pub use self :: recovery:: { RecoverableSignature , RecoveryId } ;
1414pub use self :: serialized_signature:: SerializedSignature ;
1515use crate :: ffi:: CPtr ;
16- use crate :: { ecdsa, ffi, from_hex, Error , Message , PublicKey , Secp256k1 , SecretKey } ;
16+ use crate :: { ecdsa, ffi, from_hex, Error , Message , PublicKey , Secp256k1 , SecretKey , Signing , Verification } ;
1717
1818/// An ECDSA signature
1919#[ derive( Copy , Clone , PartialOrd , Ord , PartialEq , Eq , Hash ) ]
@@ -341,6 +341,91 @@ pub fn sign_low_r(msg: impl Into<Message>, sk: &SecretKey) -> Signature {
341341 sign_grind_with_check ( msg, sk, compact_sig_has_zero_first_bit)
342342}
343343
344+ impl < C : Signing > Secp256k1 < C > {
345+ /// Constructs a signature for `msg` using the secret key `sk` and RFC6979 nonce
346+ /// Requires a signing-capable context.
347+ #[ deprecated( since = "0.32" , note = "use ecdsa::sign instead" ) ]
348+ pub fn sign_ecdsa ( & self , msg : impl Into < Message > , sk : & SecretKey ) -> Signature {
349+ self :: sign ( msg, sk)
350+ }
351+
352+ /// Constructs a signature for `msg` using the secret key `sk` and RFC6979 nonce
353+ /// and includes 32 bytes of noncedata in the nonce generation via inclusion in
354+ /// one of the hash operations during nonce generation. This is useful when multiple
355+ /// signatures are needed for the same Message and SecretKey while still using RFC6979.
356+ /// Requires a signing-capable context.
357+ #[ deprecated( since = "0.32" , note = "use ecdsa::sign_with_noncedata instead" ) ]
358+ pub fn sign_ecdsa_with_noncedata (
359+ & self ,
360+ msg : impl Into < Message > ,
361+ sk : & SecretKey ,
362+ noncedata : & [ u8 ; 32 ] ,
363+ ) -> Signature {
364+ self :: sign_with_noncedata ( msg, sk, noncedata)
365+ }
366+
367+ /// Constructs a signature for `msg` using the secret key `sk`, RFC6979 nonce
368+ /// and "grinds" the nonce by passing extra entropy if necessary to produce
369+ /// a signature that is less than 71 - `bytes_to_grind` bytes. The number
370+ /// of signing operation performed by this function is exponential in the
371+ /// number of bytes grinded.
372+ /// Requires a signing capable context.
373+ #[ deprecated( since = "0.32" , note = "use ecdsa::sign_grind_r instead" ) ]
374+ pub fn sign_ecdsa_grind_r (
375+ & self ,
376+ msg : impl Into < Message > ,
377+ sk : & SecretKey ,
378+ bytes_to_grind : usize ,
379+ ) -> Signature {
380+ self :: sign_grind_r ( msg, sk, bytes_to_grind)
381+ }
382+
383+ /// Constructs a signature for `msg` using the secret key `sk`, RFC6979 nonce
384+ /// and "grinds" the nonce by passing extra entropy if necessary to produce
385+ /// a signature that is less than 71 bytes and compatible with the low r
386+ /// signature implementation of bitcoin core. In average, this function
387+ /// will perform two signing operations.
388+ /// Requires a signing capable context.
389+ #[ deprecated( since = "0.32" , note = "use ecdsa::sign_low_r instead" ) ]
390+ pub fn sign_ecdsa_low_r ( & self , msg : impl Into < Message > , sk : & SecretKey ) -> Signature {
391+ self :: sign_low_r ( msg, sk)
392+ }
393+ }
394+
395+ impl < C : Verification > Secp256k1 < C > {
396+ /// Checks that `sig` is a valid ECDSA signature for `msg` using the public
397+ /// key `pubkey`. Returns `Ok(())` on success. Note that this function cannot
398+ /// be used for Bitcoin consensus checking since there may exist signatures
399+ /// which OpenSSL would verify but not libsecp256k1, or vice-versa. Requires a
400+ /// verify-capable context.
401+ ///
402+ /// ```rust
403+ /// # #[cfg(all(feature = "rand", feature = "std"))] {
404+ /// # use secp256k1::{rand, Secp256k1, Message, Error};
405+ /// #
406+ /// # let secp = Secp256k1::new();
407+ /// # let (secret_key, public_key) = secp.generate_keypair(&mut rand::rng());
408+ /// #
409+ /// let message = Message::from_digest_slice(&[0xab; 32]).expect("32 bytes");
410+ /// let sig = secp.sign_ecdsa(message, &secret_key);
411+ /// assert_eq!(secp.verify_ecdsa(&sig, message, &public_key), Ok(()));
412+ ///
413+ /// let message = Message::from_digest_slice(&[0xcd; 32]).expect("32 bytes");
414+ /// assert_eq!(secp.verify_ecdsa(&sig, message, &public_key), Err(Error::IncorrectSignature));
415+ /// # }
416+ /// ```
417+ #[ inline]
418+ #[ deprecated( since = "0.32" , note = "use ecdsa::verify instead" ) ]
419+ pub fn verify_ecdsa (
420+ & self ,
421+ sig : & Signature ,
422+ msg : impl Into < Message > ,
423+ pk : & PublicKey ,
424+ ) -> Result < ( ) , Error > {
425+ self :: verify ( sig, msg, pk)
426+ }
427+ }
428+
344429/// Checks that `sig` is a valid ECDSA signature for `msg` using the public
345430/// key `pubkey`. Returns `Ok(())` on success. Note that this function cannot
346431/// be used for Bitcoin consensus checking since there may exist signatures
0 commit comments