From 0e2579fb9679e4a93dc757d46cb8af2c6fd22b0b Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 31 Mar 2023 09:42:33 +1100 Subject: [PATCH 1/4] Fix release date in changelogs We have a typo in the release date of the cahngelogs, release was in March not in the mythical 13th month. --- CHANGELOG.md | 2 +- secp256k1-sys/CHANGELOG.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d82f419..189422b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -# 0.27.0 - 2023-13-15 +# 0.27.0 - 2023-03-15 * [Depend on newly release `bitcoin_hashes` v0.12](https://github.com/rust-bitcoin/rust-secp256k1/pull/588). * [Implement `Debug` trait for `Scalar` type](https://github.com/rust-bitcoin/rust-secp256k1/pull/578). diff --git a/secp256k1-sys/CHANGELOG.md b/secp256k1-sys/CHANGELOG.md index f2b318a..0899675 100644 --- a/secp256k1-sys/CHANGELOG.md +++ b/secp256k1-sys/CHANGELOG.md @@ -1,4 +1,4 @@ -# 0.8.1 - 2023-13-16 +# 0.8.1 - 2023-03-16 * [Implement `insecure-erase`](https://github.com/rust-bitcoin/rust-secp256k1/pull/582). From ee83c3a4f97da65197231cecc86eed8213234f51 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 31 Mar 2023 09:18:02 +1100 Subject: [PATCH 2/4] Bump MSRV to 1.48 We are upgrading the MSRV across the whole Rust Bitcoin ecosystem. Update the README, clippy config file, and CI to use the new MSRV. Changes to use the new MSRV will be done later. Add mention of MSRV to `secp256k1-sys`, add unreleased section to both changelogs. --- .github/workflows/rust.yml | 2 +- CHANGELOG.md | 4 ++++ README.md | 2 +- clippy.toml | 2 +- contrib/test.sh | 5 ----- secp256k1-sys/CHANGELOG.md | 4 ++++ secp256k1-sys/README.md | 3 +++ 7 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index d44c005..459f63c 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -40,7 +40,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - rust: [stable, beta, nightly, 1.41.1] + rust: [stable, beta, nightly, 1.48.0] steps: - name: Checkout Crate uses: actions/checkout@v2 diff --git a/CHANGELOG.md b/CHANGELOG.md index 189422b..b9337ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# Unreleased + +* Bump MSRV to 1.48 + # 0.27.0 - 2023-03-15 * [Depend on newly release `bitcoin_hashes` v0.12](https://github.com/rust-bitcoin/rust-secp256k1/pull/588). diff --git a/README.md b/README.md index 6b854bb..a910125 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Contributions to this library are welcome. A few guidelines: * Any breaking changes must have an accompanied entry in CHANGELOG.md * No new dependencies, please. * No crypto should be implemented in Rust, with the possible exception of hash functions. Cryptographic contributions should be directed upstream to libsecp256k1. -* This library should always compile with any combination of features on **Rust 1.41.1**. +* This library should always compile with any combination of features on **Rust 1.48.0**. ### Githooks diff --git a/clippy.toml b/clippy.toml index 799264e..11d46a7 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1 +1 @@ -msrv = "1.41.1" +msrv = "1.48.0" diff --git a/contrib/test.sh b/contrib/test.sh index 2675a15..bccfd5e 100755 --- a/contrib/test.sh +++ b/contrib/test.sh @@ -13,11 +13,6 @@ if cargo --version | grep nightly; then NIGHTLY=true fi -if cargo --version | grep "1\.41"; then - # 1.8.x uses constfns which aren't supported in 1.41 - cargo update -p half --precise 1.7.0 -fi - # Test if panic in C code aborts the process (either with a real panic or with SIGILL) cargo test -- --ignored --exact 'tests::test_panic_raw_ctx_should_terminate_abnormally' 2>&1 | tee /dev/stderr | grep "SIGILL\\|panicked at '\[libsecp256k1\]" diff --git a/secp256k1-sys/CHANGELOG.md b/secp256k1-sys/CHANGELOG.md index 0899675..c6a1789 100644 --- a/secp256k1-sys/CHANGELOG.md +++ b/secp256k1-sys/CHANGELOG.md @@ -1,3 +1,7 @@ +# Unreleased + +* Bump MSRV to 1.48 + # 0.8.1 - 2023-03-16 * [Implement `insecure-erase`](https://github.com/rust-bitcoin/rust-secp256k1/pull/582). diff --git a/secp256k1-sys/README.md b/secp256k1-sys/README.md index 2684d4c..0872ebc 100644 --- a/secp256k1-sys/README.md +++ b/secp256k1-sys/README.md @@ -33,3 +33,6 @@ If you want to compile this library without using the bundled symbols (which may be required for integration into other build systems), you can do so by adding `--cfg=rust_secp_no_symbol_renaming'` to your `RUSTFLAGS` variable. +## Minimum Supported Rust Version + +This library should always compile with any combination of features on **Rust 1.48.0**. From a815272bfca8fec019c4fe77e86aa6ea2dfc3b8b Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 31 Mar 2023 09:23:49 +1100 Subject: [PATCH 3/4] secp256k1: Remove custom implementations of Eq, Ord and friends Now that we have Rust 1.48 as the MSRV we no longer need the custom implementations of `PartialEq`, `Eq`, `PartialOrd`, `Ord`, and `Hash`. We can just let users of the `impl_array_newtype` macro derive these traits if they want them. Remove the custom implementations and add derives to our two users of the macro. --- CHANGELOG.md | 2 ++ src/lib.rs | 2 +- src/macros.rs | 25 ------------------------- src/schnorr.rs | 2 +- 4 files changed, 4 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9337ba..703b45b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Unreleased * Bump MSRV to 1.48 +* Remove implementations of `PartialEq`, `Eq`, `PartialOrd`, `Ord`, and `Hash` from the + `impl_array_newtype` macro. Users will now need to derive these traits if they are wanted. # 0.27.0 - 2023-03-15 diff --git a/src/lib.rs b/src/lib.rs index 9abcf39..ea72ae1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -232,7 +232,7 @@ impl ThirtyTwoByteHash for hashes::sha256t::Hash { } /// A (hashed) message input to an ECDSA signature. -#[derive(Copy, Clone)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Message([u8; constants::MESSAGE_SIZE]); impl_array_newtype!(Message, u8, constants::MESSAGE_SIZE); impl_pretty_debug!(Message); diff --git a/src/macros.rs b/src/macros.rs index 16672da..d5b78e9 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -17,31 +17,6 @@ #[macro_export] macro_rules! impl_array_newtype { ($thing:ident, $ty:ty, $len:expr) => { - // We cannot derive these traits because Rust 1.41.1 requires `std::array::LengthAtMost32`. - - impl PartialEq for $thing { - #[inline] - fn eq(&self, other: &$thing) -> bool { &self[..] == &other[..] } - } - - impl Eq for $thing {} - - impl core::hash::Hash for $thing { - fn hash(&self, state: &mut H) { (&self[..]).hash(state) } - } - - impl PartialOrd for $thing { - #[inline] - fn partial_cmp(&self, other: &$thing) -> Option { - self[..].partial_cmp(&other[..]) - } - } - - impl Ord for $thing { - #[inline] - fn cmp(&self, other: &$thing) -> core::cmp::Ordering { self[..].cmp(&other[..]) } - } - impl AsRef<[$ty; $len]> for $thing { #[inline] /// Gets a reference to the underlying array diff --git a/src/schnorr.rs b/src/schnorr.rs index 1a79893..6aed26b 100644 --- a/src/schnorr.rs +++ b/src/schnorr.rs @@ -15,7 +15,7 @@ use crate::{ }; /// Represents a schnorr signature. -#[derive(Copy, Clone)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Signature([u8; constants::SCHNORR_SIGNATURE_SIZE]); impl_array_newtype!(Signature, u8, constants::SCHNORR_SIGNATURE_SIZE); impl_pretty_debug!(Signature); From 7bba2bc3b5f54e506bf815413660c7d0533dd5e7 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 31 Mar 2023 09:31:35 +1100 Subject: [PATCH 4/4] secp256k1-sys: Remove custom implementations of Eq, Ord and friends Note: Only effects code when fuzzing is enabled, as such does not include a mention in the changelog. Now that we have Rust 1.48 as the MSRV we no longer need the custom implementations of `PartialEq`, `Eq`, `PartialOrd`, `Ord`, and `Hash`. We can just let users of the `impl_array_newtype` macro derive these traits if they want them. Remove the custom implementations and add derives to our two users of the macro. --- secp256k1-sys/src/lib.rs | 4 ++++ secp256k1-sys/src/macros.rs | 36 ----------------------------------- secp256k1-sys/src/recovery.rs | 1 + 3 files changed, 5 insertions(+), 36 deletions(-) diff --git a/secp256k1-sys/src/lib.rs b/secp256k1-sys/src/lib.rs index bbe30eb..b4b1cf9 100644 --- a/secp256k1-sys/src/lib.rs +++ b/secp256k1-sys/src/lib.rs @@ -133,6 +133,7 @@ impl SchnorrSigExtraParams { /// Library-internal representation of a Secp256k1 public key #[repr(C)] #[derive(Copy, Clone)] +#[cfg_attr(fuzzing, derive(PartialEq, Eq, PartialOrd, Ord, Hash))] pub struct PublicKey([c_uchar; 64]); impl_array_newtype!(PublicKey, c_uchar, 64); impl_raw_debug!(PublicKey); @@ -227,6 +228,7 @@ impl core::hash::Hash for PublicKey { /// Library-internal representation of a Secp256k1 signature #[repr(C)] #[derive(Copy, Clone)] +#[cfg_attr(fuzzing, derive(PartialEq, Eq, PartialOrd, Ord, Hash))] pub struct Signature([c_uchar; 64]); impl_array_newtype!(Signature, c_uchar, 64); impl_raw_debug!(Signature); @@ -315,6 +317,7 @@ impl core::hash::Hash for Signature { #[repr(C)] #[derive(Copy, Clone)] +#[cfg_attr(fuzzing, derive(PartialEq, Eq, PartialOrd, Ord, Hash))] pub struct XOnlyPublicKey([c_uchar; 64]); impl_array_newtype!(XOnlyPublicKey, c_uchar, 64); impl_raw_debug!(XOnlyPublicKey); @@ -404,6 +407,7 @@ impl core::hash::Hash for XOnlyPublicKey { #[repr(C)] #[derive(Copy, Clone)] +#[cfg_attr(fuzzing, derive(PartialEq, Eq, PartialOrd, Ord, Hash))] pub struct KeyPair([c_uchar; 96]); impl_array_newtype!(KeyPair, c_uchar, 96); impl_raw_debug!(KeyPair); diff --git a/secp256k1-sys/src/macros.rs b/secp256k1-sys/src/macros.rs index 35734fc..3f97245 100644 --- a/secp256k1-sys/src/macros.rs +++ b/secp256k1-sys/src/macros.rs @@ -45,42 +45,6 @@ macro_rules! impl_array_newtype { } } - // We cannot derive these traits because Rust 1.41.1 requires `std::array::LengthAtMost32`. - - #[cfg(fuzzing)] - impl PartialEq for $thing { - #[inline] - fn eq(&self, other: &$thing) -> bool { - &self[..] == &other[..] - } - } - - #[cfg(fuzzing)] - impl Eq for $thing {} - - #[cfg(fuzzing)] - impl core::hash::Hash for $thing { - fn hash(&self, state: &mut H) { - (&self[..]).hash(state) - } - } - - #[cfg(fuzzing)] - impl PartialOrd for $thing { - #[inline] - fn partial_cmp(&self, other: &$thing) -> Option { - self[..].partial_cmp(&other[..]) - } - } - - #[cfg(fuzzing)] - impl Ord for $thing { - #[inline] - fn cmp(&self, other: &$thing) -> core::cmp::Ordering { - self[..].cmp(&other[..]) - } - } - impl AsRef<[$ty; $len]> for $thing { #[inline] /// Gets a reference to the underlying array diff --git a/secp256k1-sys/src/recovery.rs b/secp256k1-sys/src/recovery.rs index 606c3b1..637cbe5 100644 --- a/secp256k1-sys/src/recovery.rs +++ b/secp256k1-sys/src/recovery.rs @@ -22,6 +22,7 @@ use core::fmt; /// Library-internal representation of a Secp256k1 signature + recovery ID #[repr(C)] #[derive(Copy, Clone)] +#[cfg_attr(fuzzing, derive(PartialEq, Eq, PartialOrd, Ord, Hash))] pub struct RecoverableSignature([c_uchar; 65]); impl_array_newtype!(RecoverableSignature, c_uchar, 65);