Add equality impls to ecdsa::SerializedSignature
What changed, and why it matters
This commit adds standard Rust comparison traits (equality and ordering) to a type that wraps a raw ECDSA signature byte array. It simply lets programmers compare these signature objects more conveniently; it does not change signature validation or introduce a security vulnerability.
No security action required; routine API-harmonization change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch implements PartialEq, PartialOrd, Ord, and Hash-related comparisons for ecdsa::SerializedSignature, mirroring the existing API of taproot::SerializedSignature. The implementations delegate to the underlying byte slice via the type’s Deref to [u8]. No cryptographic checks, parsing, or consensus behavior is altered.
Changed components
bitcoin/src/crypto/ecdsa.rsecdsa::SerializedSignatureInspect captured patch +32 / −0
diff --git a/bitcoin/src/crypto/ecdsa.rs b/bitcoin/src/crypto/ecdsa.rs
index 61990170..82202ba7 100644
--- a/bitcoin/src/crypto/ecdsa.rs
+++ b/bitcoin/src/crypto/ecdsa.rs
@@ -152,6 +152,38 @@ impl PartialEq for SerializedSignature {
fn eq(&self, other: &Self) -> bool { **self == **other }
}
+impl PartialEq<[u8]> for SerializedSignature {
+ #[inline]
+ fn eq(&self, other: &[u8]) -> bool { **self == *other }
+}
+
+impl PartialEq<SerializedSignature> for [u8] {
+ #[inline]
+ fn eq(&self, other: &SerializedSignature) -> bool { *self == **other }
+}
+
+impl PartialOrd for SerializedSignature {
+ fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
+ Some(self.cmp(other))
+ }
+}
+
+impl Ord for SerializedSignature {
+ fn cmp(&self, other: &Self) -> core::cmp::Ordering { (**self).cmp(&**other) }
+}
+
+impl PartialOrd<[u8]> for SerializedSignature {
+ fn partial_cmp(&self, other: &[u8]) -> Option<core::cmp::Ordering> {
+ (**self).partial_cmp(other)
+ }
+}
+
+impl PartialOrd<SerializedSignature> for [u8] {
+ fn partial_cmp(&self, other: &SerializedSignature) -> Option<core::cmp::Ordering> {
+ self.partial_cmp(&**other)
+ }
+}
+
impl Eq for SerializedSignature {}
impl core::hash::Hash for SerializedSignature {
Why this scored 15/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.