What changed, and why it matters
This commit seals a small helper trait called WorkExt so that outside users of the library can no longer implement it themselves. Before the change, enabling the optional `std` feature silently added a new method (log2) to the trait without a fallback, which could break any downstream code that had implemented the trait. The fix prevents that breakage and makes the library's feature setup more predictable, but it is a breaking API change rather than a traditional security vulnerability.
Treat this as a normal API-compatibility / semver change. Downstream projects that implemented WorkExt will need to remove that implementation. No urgent security patch is required, but maintainers should document the breaking change in release notes.
Security signals we found
API-level breaking change under feature gates
Non-additive feature hazard removed by sealing trait
No unsafe code, no cryptographic operations, no input parsing changes
Evidence from the diff
The public trait WorkExt in bitcoin/src/pow.rs was unsealed and conditionally gained a method fn log2(self) -> f64 only when the std feature was enabled. Because the trait had no default implementation for that method, turning on std would break any external implementation of WorkExt. The patch adds sealed::Sealed as a supertrait and implements Sealed for Work, which stops downstream crates from implementing WorkExt and therefore removes the non-additive feature hazard. The change is API-breaking but defensive; there is no evidence of memory corruption, cryptographic weakness, or exploitability in the diff.
Changed components
bitcoin/src/pow.rsWorkExt traitWork typeInspect captured patch +2 / −1
diff --git a/bitcoin/src/pow.rs b/bitcoin/src/pow.rs
index c1489067..d59a434a 100644
--- a/bitcoin/src/pow.rs
+++ b/bitcoin/src/pow.rs
@@ -24,7 +24,7 @@ pub use self::error::CompactTargetDecoderError;
/// Extension functionality for the [`Work`] type.
// This can't be defined with the extension trait macro because it ignores the feature gate.
-pub trait WorkExt {
+pub trait WorkExt: sealed::Sealed {
/// Returns log2 of this work.
///
/// The result inherently suffers from a loss of precision and is, therefore, meant to be
@@ -37,6 +37,7 @@ pub trait WorkExt {
#[deprecated(since = "0.33.0", note = "use `format!(\"{var:x}\")` instead")]
fn to_hex(&self) -> String;
}
+
impl WorkExt for Work {
#[cfg(feature = "std")]
fn log2(self) -> f64 { self.to_inner().to_f64().log2() }
Why this scored 20/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.