|
28 | 28 | //! trigger any assertion failures in the upstream library.
|
29 | 29 | //!
|
30 | 30 | //! ```rust
|
31 |
| -//! # #[cfg(all(feature = "rand", feature = "hashes", feature = "std"))] { |
| 31 | +//! # #[cfg(all(feature = "rand", feature = "std"))] { |
32 | 32 | //! use secp256k1::rand;
|
33 | 33 | //! use secp256k1::{Secp256k1, Message};
|
34 |
| -//! use secp256k1::hashes::{sha256, Hash}; |
| 34 | +//! |
| 35 | +//! // Our message to sign. We explicitly obtain a hash and convert it to a |
| 36 | +//! // `Message`. In a real application, we would produce a signature hash |
| 37 | +//! // type, e.g. `bitcoin::LegacySigHash`, which is convertible to `Message` |
| 38 | +//! // and can be passed directly to `sign_ecdsa`. |
| 39 | +//! const HELLO_WORLD_SHA2: [u8; 32] = [ |
| 40 | +//! 0x31, 0x5f, 0x5b, 0xdb, 0x76, 0xd0, 0x78, 0xc4, 0x3b, 0x8a, 0xc0, 0x06, 0x4e, 0x4a, 0x01, 0x64, |
| 41 | +//! 0x61, 0x2b, 0x1f, 0xce, 0x77, 0xc8, 0x69, 0x34, 0x5b, 0xfc, 0x94, 0xc7, 0x58, 0x94, 0xed, 0xd3, |
| 42 | +//! ]; |
35 | 43 | //!
|
36 | 44 | //! let secp = Secp256k1::new();
|
37 | 45 | //! let (secret_key, public_key) = secp.generate_keypair(&mut rand::rng());
|
38 |
| -//! let digest = sha256::Hash::hash("Hello World!".as_bytes()); |
39 |
| -//! let message = Message::from_digest(digest.to_byte_array()); |
| 46 | +//! let message = Message::from_digest(HELLO_WORLD_SHA2); |
40 | 47 | //!
|
41 | 48 | //! let sig = secp.sign_ecdsa(message, &secret_key);
|
42 | 49 | //! assert!(secp.verify_ecdsa(&sig, message, &public_key).is_ok());
|
|
46 | 53 | //! If the "global-context" feature is enabled you have access to an alternate API.
|
47 | 54 | //!
|
48 | 55 | //! ```rust
|
49 |
| -//! # #[cfg(all(feature = "global-context", feature = "hashes", feature = "rand", feature = "std"))] { |
| 56 | +//! # #[cfg(all(feature = "global-context", feature = "rand", feature = "std"))] { |
50 | 57 | //! use secp256k1::{rand, generate_keypair, Message};
|
51 |
| -//! use secp256k1::hashes::{sha256, Hash}; |
| 58 | +//! |
| 59 | +//! // See previous example regarding this constant. |
| 60 | +//! const HELLO_WORLD_SHA2: [u8; 32] = [ |
| 61 | +//! 0x31, 0x5f, 0x5b, 0xdb, 0x76, 0xd0, 0x78, 0xc4, 0x3b, 0x8a, 0xc0, 0x06, 0x4e, 0x4a, 0x01, 0x64, |
| 62 | +//! 0x61, 0x2b, 0x1f, 0xce, 0x77, 0xc8, 0x69, 0x34, 0x5b, 0xfc, 0x94, 0xc7, 0x58, 0x94, 0xed, 0xd3, |
| 63 | +//! ]; |
52 | 64 | //!
|
53 | 65 | //! let (secret_key, public_key) = generate_keypair(&mut rand::rng());
|
54 |
| -//! let digest = sha256::Hash::hash("Hello World!".as_bytes()); |
55 |
| -//! let message = Message::from_digest(digest.to_byte_array()); |
| 66 | +//! let message = Message::from_digest(HELLO_WORLD_SHA2); |
56 | 67 | //!
|
57 | 68 | //! let sig = secret_key.sign_ecdsa(message);
|
58 | 69 | //! assert!(sig.verify(message, &public_key).is_ok());
|
@@ -152,9 +163,6 @@ extern crate core;
|
152 | 163 | #[cfg(bench)]
|
153 | 164 | extern crate test;
|
154 | 165 |
|
155 |
| -#[cfg(feature = "hashes")] |
156 |
| -pub extern crate hashes; |
157 |
| - |
158 | 166 | #[macro_use]
|
159 | 167 | mod macros;
|
160 | 168 | #[macro_use]
|
|
0 commit comments