What changed, and why it matters
This commit seals a Rust trait called PushBytesErrorReport so that only two specific internal types can implement it. Sealing prevents outside code from implementing the trait, which reduces the chance that a future change accidentally breaks compatibility or introduces unexpected behavior. It is a defensive hardening change, not a fix for an active security bug.
No urgent action needed. Treat as routine maintenance/hardening. Reviewers may want to confirm that downstream crates do not already implement PushBytesErrorReport, since sealing would be a breaking change for any such crate.
Security signals we found
Trait sealing to prevent external implementations
Defensive API-hardening pattern
No memory-safety or cryptographic logic changed
Evidence from the diff
The PushBytesErrorReport trait gains a sealed::Sealed supertrait and a private sealed module that implements Sealed only for PushBytesError and core::convert::Infallible. This is a standard Rust API-stability pattern: it stops downstream crates from implementing the trait, giving the library freedom to evolve the trait without breaking external implementers. The diff shows no logic change, only trait sealing.
Changed components
primitives/src/script/push_bytes.rsPushBytesErrorReport traitInspect captured patch +7 / −1
diff --git a/primitives/src/script/push_bytes.rs b/primitives/src/script/push_bytes.rs
index 48dc940e..6f4b24ed 100644
--- a/primitives/src/script/push_bytes.rs
+++ b/primitives/src/script/push_bytes.rs
@@ -358,7 +358,7 @@ crate::impl_asref_push_bytes! {
///
/// This should not be needed by general public, except as an additional bound on `TryFrom` when
/// converting to `WitnessProgram`.
-pub trait PushBytesErrorReport {
+pub trait PushBytesErrorReport: sealed::Sealed {
/// How many bytes the input had.
fn input_len(&self) -> usize;
}
@@ -368,6 +368,12 @@ impl PushBytesErrorReport for core::convert::Infallible {
fn input_len(&self) -> usize { match *self {} }
}
+mod sealed {
+ pub trait Sealed {}
+ impl Sealed for super::PushBytesError {}
+ impl Sealed for core::convert::Infallible {}
+}
+
#[doc(no_inline)]
pub use error::PushBytesError;
Why this scored 18/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.