Move ecdsa::SerializedSignature impls
What changed, and why it matters
This commit is purely a code cleanup: it moves some trait implementation blocks for the ECDSA SerializedSignature type to a different location in the same file and reorders the Taproot Eq impl to sit next to PartialEq. No logic, behavior, or signatures changed.
No action needed; this is a non-functional refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff shows only reordering of existing impl blocks for SerializedSignature in bitcoin/src/crypto/ecdsa.rs and a relocation of impl Eq for SerializedSignature in bitcoin/src/crypto/taproot.rs. No trait implementations were added, removed, or modified; function bodies are identical. The commit message explicitly states the goal is to make the ecdsa and taproot modules look the same for easier comparison.
Changed components
bitcoin/src/crypto/ecdsa.rsbitcoin/src/crypto/taproot.rsInspect captured patch +39 / −39
diff --git a/bitcoin/src/crypto/ecdsa.rs b/bitcoin/src/crypto/ecdsa.rs
index 0b5a1462..61990170 100644
--- a/bitcoin/src/crypto/ecdsa.rs
+++ b/bitcoin/src/crypto/ecdsa.rs
@@ -121,43 +121,6 @@ impl SerializedSignature {
}
}
-impl core::ops::Deref for SerializedSignature {
- type Target = [u8];
-
- #[inline]
- fn deref(&self) -> &Self::Target { &self.data[..self.len] }
-}
-
-impl core::ops::DerefMut for SerializedSignature {
- #[inline]
- fn deref_mut(&mut self) -> &mut Self::Target { &mut self.data[..self.len] }
-}
-
-impl AsRef<[u8]> for SerializedSignature {
- #[inline]
- fn as_ref(&self) -> &[u8] { self }
-}
-
-impl AsMut<[u8]> for SerializedSignature {
- #[inline]
- fn as_mut(&mut self) -> &mut [u8] { self }
-}
-
-impl AsRef<PushBytes> for SerializedSignature {
- #[inline]
- fn as_ref(&self) -> &PushBytes { &<&PushBytes>::from(&self.data)[..self.len()] }
-}
-
-impl core::borrow::Borrow<[u8]> for SerializedSignature {
- #[inline]
- fn borrow(&self) -> &[u8] { self }
-}
-
-impl core::borrow::BorrowMut<[u8]> for SerializedSignature {
- #[inline]
- fn borrow_mut(&mut self) -> &mut [u8] { self }
-}
-
impl fmt::Debug for SerializedSignature {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(self, f) }
@@ -195,6 +158,43 @@ impl core::hash::Hash for SerializedSignature {
fn hash<H: core::hash::Hasher>(&self, state: &mut H) { core::hash::Hash::hash(&**self, state) }
}
+impl AsRef<[u8]> for SerializedSignature {
+ #[inline]
+ fn as_ref(&self) -> &[u8] { self }
+}
+
+impl AsMut<[u8]> for SerializedSignature {
+ #[inline]
+ fn as_mut(&mut self) -> &mut [u8] { self }
+}
+
+impl core::ops::Deref for SerializedSignature {
+ type Target = [u8];
+
+ #[inline]
+ fn deref(&self) -> &Self::Target { &self.data[..self.len] }
+}
+
+impl core::ops::DerefMut for SerializedSignature {
+ #[inline]
+ fn deref_mut(&mut self) -> &mut Self::Target { &mut self.data[..self.len] }
+}
+
+impl AsRef<PushBytes> for SerializedSignature {
+ #[inline]
+ fn as_ref(&self) -> &PushBytes { &<&PushBytes>::from(&self.data)[..self.len()] }
+}
+
+impl core::borrow::Borrow<[u8]> for SerializedSignature {
+ #[inline]
+ fn borrow(&self) -> &[u8] { self }
+}
+
+impl core::borrow::BorrowMut<[u8]> for SerializedSignature {
+ #[inline]
+ fn borrow_mut(&mut self) -> &mut [u8] { self }
+}
+
impl<'a> IntoIterator for &'a SerializedSignature {
type IntoIter = core::slice::Iter<'a, u8>;
type Item = &'a u8;
diff --git a/bitcoin/src/crypto/taproot.rs b/bitcoin/src/crypto/taproot.rs
index 2f7dd85d..30f69356 100644
--- a/bitcoin/src/crypto/taproot.rs
+++ b/bitcoin/src/crypto/taproot.rs
@@ -185,6 +185,8 @@ impl PartialOrd<SerializedSignature> for [u8] {
}
}
+impl Eq for SerializedSignature {}
+
impl core::hash::Hash for SerializedSignature {
fn hash<H: core::hash::Hasher>(&self, state: &mut H) { (**self).hash(state) }
}
@@ -206,8 +208,6 @@ impl ops::Deref for SerializedSignature {
fn deref(&self) -> &[u8] { &self.data[..self.len] }
}
-impl Eq for SerializedSignature {}
-
impl IntoIterator for SerializedSignature {
type IntoIter = IntoIter;
type Item = u8;
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.