Add From/TryFrom for Signature/SerializedSignature
What changed, and why it matters
This commit adds standard Rust conversion traits (From/TryFrom) between an ECDSA signature and its serialized byte form. It is a small API-consistency change that mirrors traits already present on the Taproot signature type. There is no indication it fixes a security bug or introduces a vulnerability.
No security action required. Treat as routine API enhancement. Reviewers may optionally verify that the delegated methods (from_signature, to_signature) are unchanged and correctly handle signature parsing errors.
Security signals we found
No security-relevant keywords in commit title or message
No changes to cryptographic validation or parsing logic
Only adds convenience trait implementations delegating to existing methods
No incident, CVE, or vendor security disclosure referenced
Evidence from the diff
The patch implements From
Changed components
rust-bitcoin/crypto/src/ecdsa.rsECDSA Signature and SerializedSignature typesInspect captured patch +21 / −0
diff --git a/crypto/src/ecdsa.rs b/crypto/src/ecdsa.rs
index 4c52f6d7..cfb6e09c 100644
--- a/crypto/src/ecdsa.rs
+++ b/crypto/src/ecdsa.rs
@@ -292,6 +292,27 @@ impl<'a> IntoIterator for &'a SerializedSignature {
fn into_iter(self) -> Self::IntoIter { (**self).iter() }
}
+impl From<Signature> for SerializedSignature {
+ #[inline]
+ fn from(value: Signature) -> Self { Self::from_signature(value) }
+}
+
+impl TryFrom<SerializedSignature> for Signature {
+ type Error = DecodeError;
+
+ #[inline]
+ fn try_from(value: SerializedSignature) -> Result<Self, Self::Error> { value.to_signature() }
+}
+
+impl<'a> TryFrom<&'a SerializedSignature> for Signature {
+ type Error = DecodeError;
+
+ #[inline]
+ fn try_from(value: &'a SerializedSignature) -> Result<Self, Self::Error> {
+ value.to_signature()
+ }
+}
+
/// Error types for ECDSA
pub mod error {
use core::convert::Infallible;
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.