What changed, and why it matters
This is a small API ergonomics change in a Rust Bitcoin library. A function called tap_tweak is changed so callers pass a reference to the key instead of giving up ownership of the key. It does not fix a bug or vulnerability; it makes the library easier to use in code that holds key references.
No security action required. Treat as a normal API improvement. Review downstream code only if the signature change affects custom trait implementations or borrow-checker expectations.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The TapTweak trait’s tap_tweak method signature is changed from taking self by value to taking &self. Implementations for UntweakedPublicKey and UntweakedKeypair are updated to dereference or reference self as needed. The cryptographic computation is unchanged. This is a non-breaking source change for most callers and is purely an API usability improvement.
Changed components
bitcoin/src/crypto/key.rsTapTweak traitUntweakedPublicKey::tap_tweakUntweakedKeypair::tap_tweakInspect captured patch +5 / −5
diff --git a/bitcoin/src/crypto/key.rs b/bitcoin/src/crypto/key.rs
index 4d7a7ee3..de717466 100644
--- a/bitcoin/src/crypto/key.rs
+++ b/bitcoin/src/crypto/key.rs
@@ -118,7 +118,7 @@ pub trait TapTweak {
/// # Returns
///
/// The tweaked key, with the required parity.
- fn tap_tweak(self, merkle_root: Option<TapNodeHash>) -> Self::TweakedAux;
+ fn tap_tweak(&self, merkle_root: Option<TapNodeHash>) -> Self::TweakedAux;
/// Directly converts an [`UntweakedPublicKey`] to a [`TweakedPublicKey`].
///
@@ -144,8 +144,8 @@ impl TapTweak for UntweakedPublicKey {
/// # Returns
///
/// The tweaked key and its parity.
- fn tap_tweak(self, merkle_root: Option<TapNodeHash>) -> TweakedPublicKey {
- let tweak = TapTweakHash::from_key_and_merkle_root(self, merkle_root).to_scalar();
+ fn tap_tweak(&self, merkle_root: Option<TapNodeHash>) -> TweakedPublicKey {
+ let tweak = TapTweakHash::from_key_and_merkle_root(*self, merkle_root).to_scalar();
let output_key = self.add_tweak(&tweak).expect("Tap tweak failed");
debug_assert!(self.tweak_add_check(&output_key, tweak));
@@ -171,8 +171,8 @@ impl TapTweak for UntweakedKeypair {
/// # Returns
///
/// The tweaked keypair.
- fn tap_tweak(self, merkle_root: Option<TapNodeHash>) -> TweakedKeypair {
- let pubkey = XOnlyPublicKey::from_keypair(&self);
+ fn tap_tweak(&self, merkle_root: Option<TapNodeHash>) -> TweakedKeypair {
+ let pubkey = XOnlyPublicKey::from_keypair(self);
let tweak = TapTweakHash::from_key_and_merkle_root(pubkey, merkle_root).to_scalar();
let tweaked = self.as_inner().add_xonly_tweak(&tweak).expect("Tap tweak failed");
TweakedKeypair::dangerous_assume_tweaked(Self::from(tweaked))
Why this scored 19/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.