Merge rust-bitcoin/rust-secp256k1#510: Fix incorrect method call

cd7a6b316b Fix incorrect method call (Tobin C. Harding)

Pull request description:

  We have the following method on `SecretKey`

  ```
      pub fn sign_ecdsa(&self, msg: Message) -> ecdsa::Signature {
          SECP256K1.sign_ecdsa(&msg, self)
      }
  ```

  But we have a method call in rustdocs
  ```
  //! let (secret_key, public_key) = generate_keypair(&mut thread_rng());
  //! let message = Message::from_hashed_data::<sha256::Hash>("Hello World!".as_bytes());
  //!
  //! let sig = secret_key.sign_ecdsa(&message, &secret_key);
  ```

  This is incorrect, I have no idea why this code builds.

  (Also see https://github.com/rust-bitcoin/rust-secp256k1/issues/508.)

ACKs for top commit:
  apoelstra:
    ACK cd7a6b316b

Tree-SHA512: 5f22157798a4e4a21fff946dd930c62c7d82100a8e729309f6383709cb3fefdd935df1b7954fc545f1c2283a46b8c22f61e1c6d4534cb750eb7ab3b5036eedf5
This commit is contained in:
Andrew Poelstra 2022-11-16 18:09:00 +00:00
commit ab9fdf006c
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 2 additions and 2 deletions

View File

@ -58,7 +58,7 @@
//! If the "global-context" feature is enabled you have access to an alternate API. //! If the "global-context" feature is enabled you have access to an alternate API.
//! //!
//! ```rust //! ```rust
//! # #[cfg(all(feature="global-context", feature = "std", feature="rand-std", features = "bitcoin-hashes-std"))] { //! # #[cfg(all(feature = "global-context", feature = "std", feature = "rand-std", feature = "bitcoin-hashes-std"))] {
//! use secp256k1::rand::thread_rng; //! use secp256k1::rand::thread_rng;
//! use secp256k1::{generate_keypair, Message}; //! use secp256k1::{generate_keypair, Message};
//! use secp256k1::hashes::sha256; //! use secp256k1::hashes::sha256;
@ -66,7 +66,7 @@
//! let (secret_key, public_key) = generate_keypair(&mut thread_rng()); //! let (secret_key, public_key) = generate_keypair(&mut thread_rng());
//! let message = Message::from_hashed_data::<sha256::Hash>("Hello World!".as_bytes()); //! let message = Message::from_hashed_data::<sha256::Hash>("Hello World!".as_bytes());
//! //!
//! let sig = secret_key.sign_ecdsa(&message, &secret_key); //! let sig = secret_key.sign_ecdsa(message);
//! assert!(sig.verify(&message, &public_key).is_ok()); //! assert!(sig.verify(&message, &public_key).is_ok());
//! # } //! # }
//! ``` //! ```