Clean up comments and usages of to_x_only_public_key
What changed, and why it matters
This is a minor code cleanup commit. It removes an unnecessary intermediate variable, updates a doc comment to match a previous API change, and removes an outdated comment in a test. There is no functional change and no security impact.
No action required. This is a non-functional cleanup commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors TweakedPublicKey::from_keypair to inline a variable and updates the doc comment for Keypair::to_x_only_public_key to remove the mention of Parity, which is no longer returned. A test comment ‘// Ignore the parity.’ is also removed because it no longer applies. The diff shows only comment and stylistic changes with no logic or API behavior modifications.
Changed components
bitcoin/src/crypto/key.rsbitcoin/tests/psbt-sign-taproot.rsInspect captured patch +3 / −4
diff --git a/bitcoin/src/crypto/key.rs b/bitcoin/src/crypto/key.rs
index 3124057e..7714ba8c 100644
--- a/bitcoin/src/crypto/key.rs
+++ b/bitcoin/src/crypto/key.rs
@@ -190,8 +190,7 @@ mod encapsulate {
/// Returns the [`TweakedPublicKey`] for `keypair`.
#[inline]
pub fn from_keypair(keypair: TweakedKeypair) -> Self {
- let xonly = keypair.to_keypair().to_x_only_public_key();
- Self(xonly)
+ Self(keypair.to_keypair().to_x_only_public_key())
}
/// Constructs a new [`TweakedPublicKey`] from a [`XOnlyPublicKey`]. No tweak is applied, consider
@@ -441,7 +440,7 @@ impl Keypair {
#[inline]
pub fn to_public_key(self) -> PublicKey { PublicKey::from_keypair(&self) }
- /// Returns the [`XOnlyPublicKey`] (and its [`Parity`]) for this [`Keypair`].
+ /// Returns the [`XOnlyPublicKey`] for this [`Keypair`].
///
/// This is equivalent to using [`XOnlyPublicKey::from_keypair`].
#[inline]
diff --git a/bitcoin/tests/psbt-sign-taproot.rs b/bitcoin/tests/psbt-sign-taproot.rs
index f18ef978..06e6f34c 100644
--- a/bitcoin/tests/psbt-sign-taproot.rs
+++ b/bitcoin/tests/psbt-sign-taproot.rs
@@ -57,7 +57,7 @@ fn psbt_sign_taproot() {
// Just use one of the secret keys for the key path spend.
let kp = sk_path[2].0.parse::<Keypair>().expect("failed to create keypair");
- let internal_key = kp.to_x_only_public_key(); // Ignore the parity.
+ let internal_key = kp.to_x_only_public_key();
let tree = create_taproot_tree(script1, script2.clone(), script3, internal_key);
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.