Add PartialOrd, Ord to ecdsa::Signature
What changed, and why it matters
This commit simply adds standard sorting traits (PartialOrd and Ord) to an ECDSA signature type and its associated sighash type, matching what already exists for similar types. There is no indication this fixes or introduces a security problem.
No security action required; review as normal API consistency change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change derives PartialOrd and Ord for EcdsaSighashType and ecdsa::Signature in rust-bitcoin. The ordering is the standard derived lexicographic ordering over the struct/enum fields. This is a consistency/API ergonomics change; it does not alter signature parsing, validation, serialization, or cryptographic behavior.
Changed components
crypto/src/ecdsa.rscrypto/src/sighash.rsInspect captured patch +2 / −2
diff --git a/crypto/src/ecdsa.rs b/crypto/src/ecdsa.rs
index 58ad265d..4ca2a9c6 100644
--- a/crypto/src/ecdsa.rs
+++ b/crypto/src/ecdsa.rs
@@ -40,7 +40,7 @@ pub use self::error::ParseSignatureError;
const MAX_SIG_LEN: usize = 73;
/// An ECDSA signature with the corresponding hash type.
-#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Signature {
/// The underlying ECDSA Signature.
diff --git a/crypto/src/sighash.rs b/crypto/src/sighash.rs
index 1398c262..e92ae526 100644
--- a/crypto/src/sighash.rs
+++ b/crypto/src/sighash.rs
@@ -102,7 +102,7 @@ impl TapSighashType {
///
/// Fixed values so they can be cast as integer types for encoding (see also
/// [`TapSighashType`]).
-#[derive(PartialEq, Eq, Debug, Copy, Clone, Hash)]
+#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
pub enum EcdsaSighashType {
/// 0x1: Sign all outputs.
All = 0x01,
Why this scored 16/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.