Skip to content

Commit c4c029f

Browse files
committed
Merge #709: Bump MSRV to 1.63
55c2efc Bump MSRV to 1.63 (Martin Habovstiak) Pull request description: The version 1.63 satisfies our requirements for MSRV and provides significant benefits so this commit bumps it. This commit also starts using weak dependencies. ACKs for top commit: tcharding: ACK 55c2efc Tree-SHA512: 565fd46768384e7c026c3aa8873e321a20425a6526bcd379ba442cf2504517a435c6c14e21186b36c99185d0a8439f4de2d3ba097b91119483d1a83ab05010ba
2 parents 135c938 + 55c2efc commit c4c029f

File tree

14 files changed

+108
-104
lines changed

14 files changed

+108
-104
lines changed

.github/workflows/rust.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ jobs:
5757
run: ./contrib/test.sh
5858

5959
MSRV:
60-
name: Test - 1.56.1 toolchain
60+
name: Test - MSRV toolchain
6161
runs-on: ubuntu-latest
6262
strategy:
6363
fail-fast: false
6464
steps:
6565
- name: Checkout Crate
6666
uses: actions/checkout@v3
6767
- name: Checkout Toolchain
68-
uses: dtolnay/rust-toolchain@1.56.1
68+
uses: dtolnay/rust-toolchain@1.63.0
6969
- name: Running test script
7070
env:
7171
DO_FEATURE_MATRIX: true

Cargo.toml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,24 @@ description = "Rust wrapper library for Pieter Wuille's `libsecp256k1`. Implemen
1111
keywords = [ "crypto", "ECDSA", "secp256k1", "libsecp256k1", "bitcoin" ]
1212
readme = "README.md"
1313
edition = "2021"
14-
rust-version = "1.56.1"
14+
rust-version = "1.63.0"
1515

1616
[package.metadata.docs.rs]
1717
all-features = true
1818
rustdoc-args = ["--cfg", "docsrs"]
1919

2020
[features]
2121
default = ["std"]
22-
std = ["alloc", "secp256k1-sys/std"]
22+
std = ["alloc", "secp256k1-sys/std", "rand?/std", "rand?/std_rng", "hashes?/std"]
2323
# allow use of Secp256k1::new and related API that requires an allocator
2424
alloc = ["secp256k1-sys/alloc"]
25-
hashes-std = ["std", "hashes/std"]
26-
rand-std = ["std", "rand", "rand/std", "rand/std_rng"]
2725
recovery = ["secp256k1-sys/recovery"]
2826
lowmemory = ["secp256k1-sys/lowmemory"]
2927
global-context = ["std"]
3028
# disable re-randomization of the global context, which provides some
3129
# defense-in-depth against sidechannel attacks. You should only use
3230
# this feature if you expect the `rand` crate's thread_rng to panic.
33-
# (If you are sure the `rand-std` feature will not be enabled, e.g.
31+
# (If you are sure the `rand` and `std` features will not be enabled, e.g.
3432
# if you are doing a no-std build, then this feature does nothing
3533
# and is not necessary.)
3634
global-context-less-secure = ["global-context"]
@@ -39,8 +37,6 @@ global-context-less-secure = ["global-context"]
3937
secp256k1-sys = { version = "0.10.0", default-features = false, path = "./secp256k1-sys" }
4038
serde = { version = "1.0.103", default-features = false, optional = true }
4139

42-
# You likely only want to enable these if you explicitly do not want to use "std", otherwise enable
43-
# the respective -std feature e.g., hashes-std
4440
hashes = { package = "bitcoin_hashes", version = ">= 0.12, <= 0.14", default-features = false, optional = true }
4541
rand = { version = "0.8", default-features = false, optional = true }
4642

@@ -59,15 +55,15 @@ unexpected_cfgs = { level = "deny", check-cfg = ['cfg(bench)', 'cfg(secp256k1_fu
5955

6056
[[example]]
6157
name = "sign_verify_recovery"
62-
required-features = ["recovery", "hashes-std"]
58+
required-features = ["recovery", "hashes", "std"]
6359

6460
[[example]]
6561
name = "sign_verify"
66-
required-features = ["hashes-std"]
62+
required-features = ["hashes", "std"]
6763

6864
[[example]]
6965
name = "generate_keys"
70-
required-features = ["rand-std"]
66+
required-features = ["rand", "std"]
7167

7268
[workspace]
7369
members = ["secp256k1-sys"]

clippy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
msrv = "1.56.1"
1+
msrv = "1.63.0"

contrib/_test.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -ex
44

55
REPO_DIR=$(git rev-parse --show-toplevel)
6-
FEATURES="hashes global-context lowmemory rand recovery serde std alloc hashes-std rand-std"
6+
FEATURES="hashes global-context lowmemory rand recovery serde std alloc"
77

88
cargo --version
99
rustc --version
@@ -62,17 +62,17 @@ if [ "$DO_FEATURE_MATRIX" = true ]; then
6262
fi
6363

6464
# Examples
65-
cargo run --locked --example sign_verify --features=hashes-std
66-
cargo run --locked --example sign_verify_recovery --features=recovery,hashes-std
67-
cargo run --locked --example generate_keys --features=rand-std
65+
cargo run --locked --example sign_verify --features=hashes,std
66+
cargo run --locked --example sign_verify_recovery --features=recovery,hashes,std
67+
cargo run --locked --example generate_keys --features=rand,std
6868
fi
6969

7070
if [ "$DO_LINT" = true ]
7171
then
7272
cargo clippy --locked --all-features --all-targets -- -D warnings
73-
cargo clippy --locked --example sign_verify --features=hashes-std -- -D warnings
74-
cargo clippy --locked --example sign_verify_recovery --features=recovery,hashes-std -- -D warnings
75-
cargo clippy --locked --example generate_keys --features=rand-std -- -D warnings
73+
cargo clippy --locked --example sign_verify --features=hashes,std -- -D warnings
74+
cargo clippy --locked --example sign_verify_recovery --features=recovery,hashes,std -- -D warnings
75+
cargo clippy --locked --example generate_keys --features=rand,std -- -D warnings
7676
fi
7777

7878
# Build the docs if told to (this only works with the nightly toolchain)
@@ -120,7 +120,7 @@ fi
120120
# Bench if told to, only works with non-stable toolchain (nightly, beta).
121121
if [ "$DO_BENCH" = true ]
122122
then
123-
RUSTFLAGS='--cfg=bench' cargo bench --features=recovery,rand-std
123+
RUSTFLAGS='--cfg=bench' cargo bench --features=recovery,rand,std
124124
fi
125125

126126
exit 0

githooks/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fi
4747
git diff-index --check --cached $against -- || exit 1
4848

4949
# Check that code lints cleanly.
50-
cargo clippy --features=rand-std,recovery,lowmemory,global-context --all-targets -- -D warnings || exit 1
50+
cargo clippy --features=rand,std,recovery,lowmemory,global-context --all-targets -- -D warnings || exit 1
5151

5252
# Check that there are no formatting issues.
5353
cargo +nightly fmt --check || exit 1

secp256k1-sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ readme = "README.md"
1414
build = "build.rs"
1515
links = "rustsecp256k1_v0_10_0"
1616
edition = "2021"
17-
rust-version = "1.56.1"
17+
rust-version = "1.63.0"
1818

1919
[package.metadata.docs.rs]
2020
all-features = true

src/context.rs

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ pub mod global {
2727

2828
/// A global static context to avoid repeatedly creating contexts.
2929
///
30-
/// If `rand-std` feature is enabled, context will have been randomized using `thread_rng`.
30+
/// If `rand` and `std` feature is enabled, context will have been randomized using
31+
/// `thread_rng`.
3132
///
3233
/// ```
33-
/// # #[cfg(all(feature = "global-context", feature = "rand-std"))] {
34+
/// # #[cfg(all(feature = "global-context", feature = "rand", feature = "std"))] {
3435
/// use secp256k1::{PublicKey, SECP256K1};
3536
/// let _ = SECP256K1.generate_keypair(&mut rand::thread_rng());
3637
/// # }
@@ -40,15 +41,16 @@ pub mod global {
4041
impl Deref for GlobalContext {
4142
type Target = Secp256k1<All>;
4243

43-
#[allow(unused_mut)] // Unused when `rand-std` is not enabled.
44+
#[allow(unused_mut)] // Unused when `rand` + `std` is not enabled.
4445
fn deref(&self) -> &Self::Target {
4546
static ONCE: Once = Once::new();
4647
static mut CONTEXT: Option<Secp256k1<All>> = None;
4748
ONCE.call_once(|| unsafe {
4849
let mut ctx = Secp256k1::new();
4950
#[cfg(all(
5051
not(target_arch = "wasm32"),
51-
feature = "rand-std",
52+
feature = "rand",
53+
feature = "std",
5254
not(feature = "global-context-less-secure")
5355
))]
5456
{
@@ -181,10 +183,12 @@ mod alloc_only {
181183
impl<C: Context> Secp256k1<C> {
182184
/// Lets you create a context in a generic manner (sign/verify/all).
183185
///
184-
/// If `rand-std` feature is enabled, context will have been randomized using `thread_rng`.
185-
/// If `rand-std` feature is not enabled please consider randomizing the context as follows:
186+
/// If `rand` and `std` feature is enabled, context will have been randomized using
187+
/// `thread_rng`.
188+
/// If `rand` or `std` feature is not enabled please consider randomizing the context as
189+
/// follows:
186190
/// ```
187-
/// # #[cfg(feature = "rand-std")] {
191+
/// # #[cfg(all(feature = "rand", feature = "std"))] {
188192
/// # use secp256k1::Secp256k1;
189193
/// # use secp256k1::rand::{thread_rng, RngCore};
190194
/// let mut ctx = Secp256k1::new();
@@ -195,7 +199,10 @@ mod alloc_only {
195199
/// ctx.seeded_randomize(&seed);
196200
/// # }
197201
/// ```
198-
#[cfg_attr(not(feature = "rand-std"), allow(clippy::let_and_return, unused_mut))]
202+
#[cfg_attr(
203+
not(all(feature = "rand", feature = "std")),
204+
allow(clippy::let_and_return, unused_mut)
205+
)]
199206
pub fn gen_new() -> Secp256k1<C> {
200207
#[cfg(target_arch = "wasm32")]
201208
ffi::types::sanity_checks_for_wasm();
@@ -214,7 +221,8 @@ mod alloc_only {
214221

215222
#[cfg(all(
216223
not(target_arch = "wasm32"),
217-
feature = "rand-std",
224+
feature = "rand",
225+
feature = "std",
218226
not(feature = "global-context-less-secure")
219227
))]
220228
{
@@ -229,27 +237,30 @@ mod alloc_only {
229237
impl Secp256k1<All> {
230238
/// Creates a new Secp256k1 context with all capabilities.
231239
///
232-
/// If `rand-std` feature is enabled, context will have been randomized using `thread_rng`.
233-
/// If `rand-std` feature is not enabled please consider randomizing the context (see docs
234-
/// for `Secp256k1::gen_new()`).
240+
/// If `rand` and `std` feature is enabled, context will have been randomized using
241+
/// `thread_rng`.
242+
/// If `rand` or `std` feature is not enabled please consider randomizing the context (see
243+
/// docs for `Secp256k1::gen_new()`).
235244
pub fn new() -> Secp256k1<All> { Secp256k1::gen_new() }
236245
}
237246

238247
impl Secp256k1<SignOnly> {
239248
/// Creates a new Secp256k1 context that can only be used for signing.
240249
///
241-
/// If `rand-std` feature is enabled, context will have been randomized using `thread_rng`.
242-
/// If `rand-std` feature is not enabled please consider randomizing the context (see docs
243-
/// for `Secp256k1::gen_new()`).
250+
/// If `rand` and `std` feature is enabled, context will have been randomized using
251+
/// `thread_rng`.
252+
/// If `rand` or `std` feature is not enabled please consider randomizing the context (see
253+
/// docs for `Secp256k1::gen_new()`).
244254
pub fn signing_only() -> Secp256k1<SignOnly> { Secp256k1::gen_new() }
245255
}
246256

247257
impl Secp256k1<VerifyOnly> {
248258
/// Creates a new Secp256k1 context that can only be used for verification.
249259
///
250-
/// * If `rand-std` feature is enabled, context will have been randomized using `thread_rng`.
251-
/// * If `rand-std` feature is not enabled please consider randomizing the context (see docs
252-
/// for `Secp256k1::gen_new()`).
260+
/// If `rand` and `std` feature is enabled, context will have been randomized using
261+
/// `thread_rng`.
262+
/// If `rand` or `std` feature is not enabled please consider randomizing the context (see
263+
/// docs for `Secp256k1::gen_new()`).
253264
pub fn verification_only() -> Secp256k1<VerifyOnly> { Secp256k1::gen_new() }
254265
}
255266

src/ecdh.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const SHARED_SECRET_SIZE: usize = constants::SECRET_KEY_SIZE;
2020
/// # Examples
2121
///
2222
/// ```
23-
/// # #[cfg(feature = "rand-std")] {
23+
/// # #[cfg(all(feature = "rand", feature = "std"))] {
2424
/// # use secp256k1::{rand, Secp256k1};
2525
/// # use secp256k1::ecdh::SharedSecret;
2626
/// let s = Secp256k1::new();
@@ -110,7 +110,7 @@ impl AsRef<[u8]> for SharedSecret {
110110
///
111111
/// # Examples
112112
/// ```
113-
/// # #[cfg(all(feature = "hashes-std", feature = "rand-std"))] {
113+
/// # #[cfg(all(feature = "hashes", feature = "rand", feature = "std"))] {
114114
/// # use secp256k1::{ecdh, rand, Secp256k1, PublicKey, SecretKey};
115115
/// # use secp256k1::hashes::{Hash, sha512};
116116
///
@@ -193,7 +193,7 @@ mod tests {
193193
use crate::Secp256k1;
194194

195195
#[test]
196-
#[cfg(feature = "rand-std")]
196+
#[cfg(all(feature = "rand", feature = "std"))]
197197
fn ecdh() {
198198
let s = Secp256k1::signing_only();
199199
let (sk1, pk1) = s.generate_keypair(&mut rand::thread_rng());
@@ -225,7 +225,7 @@ mod tests {
225225

226226
#[test]
227227
#[cfg(not(secp256k1_fuzz))]
228-
#[cfg(all(feature = "hashes-std", feature = "rand-std"))]
228+
#[cfg(all(feature = "hashes", feature = "rand", feature = "std"))]
229229
fn hashes_and_sys_generate_same_secret() {
230230
use hashes::{sha256, Hash, HashEngine};
231231

@@ -275,7 +275,7 @@ mod tests {
275275
}
276276

277277
#[cfg(bench)]
278-
#[cfg(feature = "rand-std")] // Currently only a single bench that requires "rand-std".
278+
#[cfg(all(feature = "rand", feature = "std"))] // Currently only a single bench that requires "rand" + "std".
279279
mod benches {
280280
use test::{black_box, Bencher};
281281

src/ecdsa/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ impl<C: Verification> Secp256k1<C> {
365365
/// verify-capable context.
366366
///
367367
/// ```rust
368-
/// # #[cfg(feature = "rand-std")] {
368+
/// # #[cfg(all(feature = "rand", feature = "std"))] {
369369
/// # use secp256k1::{rand, Secp256k1, Message, Error};
370370
/// #
371371
/// # let secp = Secp256k1::new();

src/ecdsa/recovery.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ mod tests {
219219
use crate::{Error, Message, Secp256k1, SecretKey};
220220

221221
#[test]
222-
#[cfg(feature = "rand-std")]
222+
#[cfg(all(feature = "rand", feature = "std"))]
223223
fn capabilities() {
224224
let sign = Secp256k1::signing_only();
225225
let vrfy = Secp256k1::verification_only();
@@ -251,7 +251,7 @@ mod tests {
251251

252252
#[test]
253253
#[cfg(not(secp256k1_fuzz))] // fixed sig vectors can't work with fuzz-sigs
254-
#[cfg(feature = "rand-std")]
254+
#[cfg(all(feature = "rand", feature = "std"))]
255255
#[rustfmt::skip]
256256
fn sign() {
257257
let mut s = Secp256k1::new();
@@ -276,7 +276,7 @@ mod tests {
276276

277277
#[test]
278278
#[cfg(not(secp256k1_fuzz))] // fixed sig vectors can't work with fuzz-sigs
279-
#[cfg(feature = "rand-std")]
279+
#[cfg(all(feature = "rand", feature = "std"))]
280280
#[rustfmt::skip]
281281
fn sign_with_noncedata() {
282282
let mut s = Secp256k1::new();
@@ -301,7 +301,7 @@ mod tests {
301301
}
302302

303303
#[test]
304-
#[cfg(feature = "rand-std")]
304+
#[cfg(all(feature = "rand", feature = "std"))]
305305
fn sign_and_verify_fail() {
306306
let mut s = Secp256k1::new();
307307
s.randomize(&mut rand::thread_rng());
@@ -323,7 +323,7 @@ mod tests {
323323
}
324324

325325
#[test]
326-
#[cfg(feature = "rand-std")]
326+
#[cfg(all(feature = "rand", feature = "std"))]
327327
fn sign_with_recovery() {
328328
let mut s = Secp256k1::new();
329329
s.randomize(&mut rand::thread_rng());
@@ -339,7 +339,7 @@ mod tests {
339339
}
340340

341341
#[test]
342-
#[cfg(feature = "rand-std")]
342+
#[cfg(all(feature = "rand", feature = "std"))]
343343
fn sign_with_recovery_and_noncedata() {
344344
let mut s = Secp256k1::new();
345345
s.randomize(&mut rand::thread_rng());
@@ -357,7 +357,7 @@ mod tests {
357357
}
358358

359359
#[test]
360-
#[cfg(feature = "rand-std")]
360+
#[cfg(all(feature = "rand", feature = "std"))]
361361
fn bad_recovery() {
362362
let mut s = Secp256k1::new();
363363
s.randomize(&mut rand::thread_rng());
@@ -423,7 +423,7 @@ mod tests {
423423
}
424424

425425
#[cfg(bench)]
426-
#[cfg(feature = "rand-std")] // Currently only a single bench that requires "rand-std".
426+
#[cfg(all(feature = "rand", feature = "std"))] // Currently only a single bench that requires "rand" + "std".
427427
mod benches {
428428
use test::{black_box, Bencher};
429429

0 commit comments

Comments
 (0)