|
49 | 49 | //! # } |
50 | 50 | //! ``` |
51 | 51 | //! |
52 | | -//! If the "global-context" feature is enabled you have access to an alternate API. |
53 | | -//! |
54 | | -//! ```rust |
55 | | -//! # #[cfg(all(feature = "global-context", feature = "rand", feature = "std"))] { |
56 | | -//! use secp256k1::{rand, Message}; |
57 | | -//! |
58 | | -//! // See previous example regarding this constant. |
59 | | -//! const HELLO_WORLD_SHA2: [u8; 32] = [ |
60 | | -//! 0x31, 0x5f, 0x5b, 0xdb, 0x76, 0xd0, 0x78, 0xc4, 0x3b, 0x8a, 0xc0, 0x06, 0x4e, 0x4a, 0x01, 0x64, |
61 | | -//! 0x61, 0x2b, 0x1f, 0xce, 0x77, 0xc8, 0x69, 0x34, 0x5b, 0xfc, 0x94, 0xc7, 0x58, 0x94, 0xed, 0xd3, |
62 | | -//! ]; |
63 | | -//! |
64 | | -//! let (secret_key, public_key) = secp256k1::generate_keypair(&mut rand::rng()); |
65 | | -//! let message = Message::from_digest(HELLO_WORLD_SHA2); |
66 | | -//! |
67 | | -//! let sig = secret_key.sign_ecdsa(message); |
68 | | -//! assert!(sig.verify(message, &public_key).is_ok()); |
69 | | -//! # } |
70 | | -//! ``` |
71 | | -//! |
72 | 52 | //! The above code requires `rust-secp256k1` to be compiled with the `rand`, `hashes`, and `std` |
73 | 53 | //! feature enabled, to get access to [`generate_keypair`](struct.Secp256k1.html#method.generate_keypair) |
74 | 54 | //! Alternately, keys and messages can be parsed from slices, like |
|
139 | 119 | //! * `hashes` - use the `hashes` library. |
140 | 120 | //! * `recovery` - enable functions that can compute the public key from signature. |
141 | 121 | //! * `lowmemory` - optimize the library for low-memory environments. |
142 | | -//! * `global-context` - enable use of global secp256k1 context (implies `std`). |
143 | 122 | //! * `serde` - implements serialization and deserialization for types in this crate using `serde`. |
144 | 123 | //! **Important**: `serde` encoding is **not** the same as consensus encoding! |
145 | 124 | //! |
@@ -422,12 +401,12 @@ pub fn generate_keypair<R: rand::Rng + ?Sized>(rng: &mut R) -> (key::SecretKey, |
422 | 401 | /// Constructor for unit testing. (Calls `generate_keypair` if all |
423 | 402 | /// the relevant features are on to get coverage of that functoin.) |
424 | 403 | #[cfg(test)] |
425 | | -#[cfg(all(feature = "global-context", feature = "rand", feature = "std"))] |
| 404 | +#[cfg(all(feature = "rand", feature = "std"))] |
426 | 405 | fn test_random_keypair() -> (key::SecretKey, key::PublicKey) { generate_keypair(&mut rand::rng()) } |
427 | 406 |
|
428 | 407 | /// Constructor for unit testing. |
429 | 408 | #[cfg(test)] |
430 | | -#[cfg(not(all(feature = "global-context", feature = "rand", feature = "std")))] |
| 409 | +#[cfg(not(all(feature = "rand", feature = "std")))] |
431 | 410 | fn test_random_keypair() -> (key::SecretKey, key::PublicKey) { |
432 | 411 | let sk = SecretKey::test_random(); |
433 | 412 | let pk = key::PublicKey::from_secret_key(&sk); |
@@ -963,7 +942,6 @@ mod tests { |
963 | 942 | assert_tokens(&sig.readable(), &[Token::String(SIG_STR)]); |
964 | 943 | } |
965 | 944 |
|
966 | | - #[cfg(feature = "global-context")] |
967 | 945 | #[test] |
968 | 946 | fn test_global_context() { |
969 | 947 | let sk_data = hex!("e6dd32f8761625f105c39a39f19370b3521d845a12456d60ce44debd0a362641"); |
|
0 commit comments