Merge rust-bitcoin/rust-secp256k1#389: On key-generation example (documentation), "rand" should be "rand-std" instead

2732891359 Change rand to rand-std in lib.rs documentation (Vincent Liao)

Pull request description:

  I copy-pasted the key-generation example written on the documentation, but it didn't work. It only worked when I used the feature `rand-std` instead of `rand`.

  To reproduce, boot up a new Rust project, and add this to main.rs:

  ```
  use secp256k1::rand::rngs::OsRng;
  use secp256k1::{Secp256k1, Message};
  use secp256k1::hashes::sha256;

  let secp = Secp256k1::new();
  let mut rng = OsRng::new().expect("OsRng");
  let (secret_key, public_key) = secp.generate_keypair(&mut rng);
  let message = Message::from_hashed_data::<sha256::Hash>("Hello World!".as_bytes());

  let sig = secp.sign_ecdsa(&message, &secret_key);
  assert!(secp.verify_ecdsa(&message, &sig, &public_key).is_ok());
  ```

  Using this dependencies causes error: `secp256k1 = {version="0.21.2", features=["rand", "bitcoin_hashes"]}`. After replacing `rand` with `rand-std`, it works.

ACKs for top commit:
  apoelstra:
    ACK 2732891
  tcharding:
    tACK 2732891359

Tree-SHA512: 6b5436bc71bab7535e432e119679bc6bcb11d2575b609e039cc25c122ae92b528f95a673e9c643a6cfa2ee3a663f7efdd61731b6084261c52a220448b6f72d12
This commit is contained in:
Andrew Poelstra 2022-02-03 15:10:24 +00:00
commit 7a3736a0f9
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 1 additions and 1 deletions

View File

@ -53,7 +53,7 @@
//! # }
//! ```
//!
//! The above code requires `rust-secp256k1` to be compiled with the `rand` and `bitcoin_hashes`
//! The above code requires `rust-secp256k1` to be compiled with the `rand-std` and `bitcoin_hashes`
//! feature enabled, to get access to [`generate_keypair`](struct.Secp256k1.html#method.generate_keypair)
//! Alternately, keys and messages can be parsed from slices, like
//!