Fix lint errors in taproot-primitives
What changed, and why it matters
This is a routine code cleanup commit that fixes two Rust lint warnings in the taproot-primitives crate. It adds a Clippy suppression annotation and replaces an integer cast with a safer conversion. There is no security-relevant behavior change.
No security action needed. Treat as normal maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit addresses two Clippy lint issues in taproot-primitives/src/lib.rs: (1) adds #[allow(clippy::missing_panics_doc)] to TapTweakHash::to_scalar, which already documents the panic possibility in a comment; and (2) changes value as u64 to u64::from(value) in a serde Deserialize implementation for LeafVersion. Neither change alters runtime semantics or fixes a vulnerability.
Changed components
taproot-primitives/src/lib.rsInspect captured patch +2 / −1
diff --git a/taproot-primitives/src/lib.rs b/taproot-primitives/src/lib.rs
index 179a3c3f..41085662 100644
--- a/taproot-primitives/src/lib.rs
+++ b/taproot-primitives/src/lib.rs
@@ -128,6 +128,7 @@ impl TapTweakHash {
}
/// Converts a `TapTweakHash` into a `Scalar` ready for use with key tweaking API.
+ #[allow(clippy::missing_panics_doc)]
pub fn to_scalar(self) -> Scalar {
// This is statistically extremely unlikely to panic.
Scalar::from_be_bytes(self.to_byte_array()).expect("hash value greater than curve order")
@@ -230,7 +231,7 @@ impl<'de> serde::Deserialize<'de> for LeafVersion {
})?;
LeafVersion::from_consensus(value).map_err(|_| {
E::invalid_value(
- ::serde::de::Unexpected::Unsigned(value as u64),
+ ::serde::de::Unexpected::Unsigned(u64::from(value)),
&"consensus-encoded leaf version as 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.