7bba2bc3b5 secp256k1-sys: Remove custom implementations of Eq, Ord and friends (Tobin C. Harding)
a815272bfc secp256k1: Remove custom implementations of Eq, Ord and friends (Tobin C. Harding)
ee83c3a4f9 Bump MSRV to 1.48 (Tobin C. Harding)
0e2579fb96 Fix release date in changelogs (Tobin C. Harding)

Pull request description:

  As per ecosystem wide change, bump the MSRV of both crates to 1.48

  Patch 1 is a typo fix to the changelog, I don't see changelogs cached on crates.io in any way so this fix should be able to quietly go in.

  Note before this is applied there is no mention of the MSRV in secp256k1-sys, was that intentional? If not, with this applied, we have a mention in the readme.

  CI needs some more fixes (wasm job) but because patching CI often leads to me doing 300 pushes I'm leaving it to a separate PR.

ACKs for top commit:
  apoelstra:
    ACK 7bba2bc3b5

Tree-SHA512: 4e575c7e4f7d4a36e024eee407f8a757ad35be7225d8b8de71d57248c40801b05aeb12abf27ea9ce63215561527c8edb4d1807b09388b9d1dcdb52f453cd0981
This commit is contained in:
Andrew Poelstra 2023-03-31 00:18:28 +00:00
commit 1ad3107e80
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
13 changed files with 25 additions and 73 deletions

View File

@ -40,7 +40,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
rust: [stable, beta, nightly, 1.41.1] rust: [stable, beta, nightly, 1.48.0]
steps: steps:
- name: Checkout Crate - name: Checkout Crate
uses: actions/checkout@v2 uses: actions/checkout@v2

View File

@ -1,4 +1,10 @@
# 0.27.0 - 2023-13-15 # 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
* [Depend on newly release `bitcoin_hashes` v0.12](https://github.com/rust-bitcoin/rust-secp256k1/pull/588). * [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). * [Implement `Debug` trait for `Scalar` type](https://github.com/rust-bitcoin/rust-secp256k1/pull/578).

View File

@ -20,7 +20,7 @@ Contributions to this library are welcome. A few guidelines:
* Any breaking changes must have an accompanied entry in CHANGELOG.md * Any breaking changes must have an accompanied entry in CHANGELOG.md
* No new dependencies, please. * 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. * 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 ### Githooks

View File

@ -1 +1 @@
msrv = "1.41.1" msrv = "1.48.0"

View File

@ -13,11 +13,6 @@ if cargo --version | grep nightly; then
NIGHTLY=true NIGHTLY=true
fi 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) # 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\]" cargo test -- --ignored --exact 'tests::test_panic_raw_ctx_should_terminate_abnormally' 2>&1 | tee /dev/stderr | grep "SIGILL\\|panicked at '\[libsecp256k1\]"

View File

@ -1,4 +1,8 @@
# 0.8.1 - 2023-13-16 # Unreleased
* Bump MSRV to 1.48
# 0.8.1 - 2023-03-16
* [Implement `insecure-erase`](https://github.com/rust-bitcoin/rust-secp256k1/pull/582). * [Implement `insecure-erase`](https://github.com/rust-bitcoin/rust-secp256k1/pull/582).

View File

@ -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 be required for integration into other build systems), you can do so by adding
`--cfg=rust_secp_no_symbol_renaming'` to your `RUSTFLAGS` variable. `--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**.

View File

@ -133,6 +133,7 @@ impl SchnorrSigExtraParams {
/// Library-internal representation of a Secp256k1 public key /// Library-internal representation of a Secp256k1 public key
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
#[cfg_attr(fuzzing, derive(PartialEq, Eq, PartialOrd, Ord, Hash))]
pub struct PublicKey([c_uchar; 64]); pub struct PublicKey([c_uchar; 64]);
impl_array_newtype!(PublicKey, c_uchar, 64); impl_array_newtype!(PublicKey, c_uchar, 64);
impl_raw_debug!(PublicKey); impl_raw_debug!(PublicKey);
@ -227,6 +228,7 @@ impl core::hash::Hash for PublicKey {
/// Library-internal representation of a Secp256k1 signature /// Library-internal representation of a Secp256k1 signature
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
#[cfg_attr(fuzzing, derive(PartialEq, Eq, PartialOrd, Ord, Hash))]
pub struct Signature([c_uchar; 64]); pub struct Signature([c_uchar; 64]);
impl_array_newtype!(Signature, c_uchar, 64); impl_array_newtype!(Signature, c_uchar, 64);
impl_raw_debug!(Signature); impl_raw_debug!(Signature);
@ -315,6 +317,7 @@ impl core::hash::Hash for Signature {
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
#[cfg_attr(fuzzing, derive(PartialEq, Eq, PartialOrd, Ord, Hash))]
pub struct XOnlyPublicKey([c_uchar; 64]); pub struct XOnlyPublicKey([c_uchar; 64]);
impl_array_newtype!(XOnlyPublicKey, c_uchar, 64); impl_array_newtype!(XOnlyPublicKey, c_uchar, 64);
impl_raw_debug!(XOnlyPublicKey); impl_raw_debug!(XOnlyPublicKey);
@ -404,6 +407,7 @@ impl core::hash::Hash for XOnlyPublicKey {
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
#[cfg_attr(fuzzing, derive(PartialEq, Eq, PartialOrd, Ord, Hash))]
pub struct KeyPair([c_uchar; 96]); pub struct KeyPair([c_uchar; 96]);
impl_array_newtype!(KeyPair, c_uchar, 96); impl_array_newtype!(KeyPair, c_uchar, 96);
impl_raw_debug!(KeyPair); impl_raw_debug!(KeyPair);

View File

@ -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<H: core::hash::Hasher>(&self, state: &mut H) {
(&self[..]).hash(state)
}
}
#[cfg(fuzzing)]
impl PartialOrd for $thing {
#[inline]
fn partial_cmp(&self, other: &$thing) -> Option<core::cmp::Ordering> {
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 { impl AsRef<[$ty; $len]> for $thing {
#[inline] #[inline]
/// Gets a reference to the underlying array /// Gets a reference to the underlying array

View File

@ -22,6 +22,7 @@ use core::fmt;
/// Library-internal representation of a Secp256k1 signature + recovery ID /// Library-internal representation of a Secp256k1 signature + recovery ID
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
#[cfg_attr(fuzzing, derive(PartialEq, Eq, PartialOrd, Ord, Hash))]
pub struct RecoverableSignature([c_uchar; 65]); pub struct RecoverableSignature([c_uchar; 65]);
impl_array_newtype!(RecoverableSignature, c_uchar, 65); impl_array_newtype!(RecoverableSignature, c_uchar, 65);

View File

@ -232,7 +232,7 @@ impl<T: hashes::sha256t::Tag> ThirtyTwoByteHash for hashes::sha256t::Hash<T> {
} }
/// A (hashed) message input to an ECDSA signature. /// 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]); pub struct Message([u8; constants::MESSAGE_SIZE]);
impl_array_newtype!(Message, u8, constants::MESSAGE_SIZE); impl_array_newtype!(Message, u8, constants::MESSAGE_SIZE);
impl_pretty_debug!(Message); impl_pretty_debug!(Message);

View File

@ -17,31 +17,6 @@
#[macro_export] #[macro_export]
macro_rules! impl_array_newtype { macro_rules! impl_array_newtype {
($thing:ident, $ty:ty, $len:expr) => { ($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<H: core::hash::Hasher>(&self, state: &mut H) { (&self[..]).hash(state) }
}
impl PartialOrd for $thing {
#[inline]
fn partial_cmp(&self, other: &$thing) -> Option<core::cmp::Ordering> {
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 { impl AsRef<[$ty; $len]> for $thing {
#[inline] #[inline]
/// Gets a reference to the underlying array /// Gets a reference to the underlying array

View File

@ -15,7 +15,7 @@ use crate::{
}; };
/// Represents a schnorr signature. /// Represents a schnorr signature.
#[derive(Copy, Clone)] #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Signature([u8; constants::SCHNORR_SIGNATURE_SIZE]); pub struct Signature([u8; constants::SCHNORR_SIGNATURE_SIZE]);
impl_array_newtype!(Signature, u8, constants::SCHNORR_SIGNATURE_SIZE); impl_array_newtype!(Signature, u8, constants::SCHNORR_SIGNATURE_SIZE);
impl_pretty_debug!(Signature); impl_pretty_debug!(Signature);