What changed, and why it matters
This commit is a straightforward code cleanup in the rust-bitcoin library. It removes top-level imports of serde serialization traits and replaces them with explicit `serde::` prefixes in the key module. There is no functional change to how keys are serialized or deserialized, and no security issue is introduced or fixed.
No security action required. Treat as a normal refactoring commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change modifies crypto/src/key.rs to remove use serde::{Deserialize, Deserializer, Serialize, Serializer}; and qualify all serde trait references with serde::. The implementations for XOnlyPublicKey remain behaviorally identical: Serialize still delegates to the inner secp256k1::XOnlyPublicKey, and Deserialize still reconstructs via from_secp with Parity::Even. The commit message explicitly frames this as a stylistic simplification to avoid namespace clutter and awkward (*self).serialize() syntax.
Changed components
crypto/src/key.rsInspect captured patch +5 / −7
diff --git a/crypto/src/key.rs b/crypto/src/key.rs
index 69455019..6221f132 100644
--- a/crypto/src/key.rs
+++ b/crypto/src/key.rs
@@ -26,8 +26,6 @@ use network::NetworkKind;
#[cfg(feature = "rand")]
#[cfg(feature = "std")]
pub use secp256k1::rand;
-#[cfg(feature = "serde")]
-use serde::{Deserialize, Deserializer, Serialize, Serializer};
use crate::ecdsa;
use crate::hex::{self, DecodeFixedLengthBytesError};
@@ -1282,22 +1280,22 @@ impl<'de> serde::Deserialize<'de> for WifKey {
// XOnlyPublicKey should serialize/deserialize identically to the inner type.
#[cfg(feature = "serde")]
-impl Serialize for XOnlyPublicKey {
+impl serde::Serialize for XOnlyPublicKey {
#[inline]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
- S: Serializer,
+ S: serde::Serializer,
{
- <secp256k1::XOnlyPublicKey as Serialize>::serialize(&self.to_inner(), serializer)
+ <secp256k1::XOnlyPublicKey as serde::Serialize>::serialize(&self.to_inner(), serializer)
}
}
#[cfg(feature = "serde")]
-impl<'de> Deserialize<'de> for XOnlyPublicKey {
+impl<'de> serde::Deserialize<'de> for XOnlyPublicKey {
#[inline]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
- D: Deserializer<'de>,
+ D: serde::Deserializer<'de>,
{
Ok(Self::from_secp(secp256k1::XOnlyPublicKey::deserialize(deserializer)?, Parity::Even))
}
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.