What changed, and why it matters
This commit updates the rust-bitcoin library to use a new beta version of its underlying secp256k1 cryptographic library (0.32.0-beta.2). It is a routine dependency upgrade that adjusts many internal calls to match the new library's simpler API. There is no direct evidence in the commit that this fixes a known security vulnerability, but it does remove an old, separately-patched version of a hashing dependency and moves to a newer cryptographic release. The main risk is that any upgrade of core crypto code could introduce subtle bugs or break downstream users who rely on the old API.
Treat as a normal dependency/API migration commit. Review the secp256k1 0.32.0-beta.2 release notes and changelog for any security-relevant fixes or breaking changes. Run the full test suite, especially cryptographic signing, PSBT Taproot signing, BIP32 derivation, and message signing tests. Verify that removing the bitcoin_hashes workspace patch does not cause version resolution issues for downstream crates. If this beta dependency is used in production, consider waiting for the stable 0.32.0 release.
Security signals we found
Dependency upgrade of core cryptographic library (secp256k1)
Removal of local workspace patch for bitcoin_hashes
API migration removing Secp256k1 context from key derivation/tweaking calls
No explicit security fix, CVE, or vulnerability description in commit or supplied references
Evidence from the diff
The commit bumps the secp256k1 dependency from 0.31.1 to 0.32.0-beta.2 and removes the workspace patch that forced bitcoin_hashes to be sourced from the local path for secp256k1’s benefit. The new secp256k1 API no longer requires a Secp256k1 context argument for many key operations (e.g., PublicKey::from_secret_key, Keypair::from_secret_key, add_tweak, add_exp_tweak), so the diff mechanically removes the secp parameter from those calls across examples, library code, and tests. It also updates Cargo.lock files to drop the older bitcoin_hashes 0.14.0 and bitcoin-io 0.1.x transitive dependencies that secp256k1 0.31.1 pulled in. The CHANGELOG is updated to reflect newer dependency versions. No security advisory, CVE, or bug fix is mentioned in the commit message or diff.
Changed components
bitcoin/Cargo.tomlbitcoin/src/bip32.rsbitcoin/src/crypto/key.rsbitcoin/src/crypto/sighash.rsbitcoin/src/psbt/mod.rsbitcoin/src/sign_message.rsbitcoin/examples/sign-tx-segwit-v0.rsbitcoin/examples/sign-tx-taproot.rsbitcoin/examples/taproot-psbt.rsbitcoin/tests/psbt-sign-taproot.rsCargo.toml workspace patchCargo-minimal.lock / Cargo-recent.lockInspect captured patch +59 / −107
diff --git a/Cargo-minimal.lock b/Cargo-minimal.lock
index d453e459..b0421946 100644
--- a/Cargo-minimal.lock
+++ b/Cargo-minimal.lock
@@ -19,7 +19,7 @@ name = "base58ck"
version = "0.2.0"
dependencies = [
"bitcoin-internals",
- "bitcoin_hashes 0.17.0",
+ "bitcoin_hashes",
"hex_lit",
]
@@ -55,10 +55,10 @@ dependencies = [
"bech32",
"bincode",
"bitcoin-internals",
- "bitcoin-io 0.2.0",
+ "bitcoin-io",
"bitcoin-primitives",
"bitcoin-units",
- "bitcoin_hashes 0.17.0",
+ "bitcoin_hashes",
"bitcoinconsensus",
"hex-conservative 0.3.0",
"hex_lit",
@@ -102,19 +102,13 @@ dependencies = [
"serde_json",
]
-[[package]]
-name = "bitcoin-io"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "17e5b76b88667412087beea1882980ad843b660490bbf6cce0a6cfc999c5b989"
-
[[package]]
name = "bitcoin-io"
version = "0.2.0"
dependencies = [
"bitcoin-consensus-encoding",
"bitcoin-internals",
- "bitcoin_hashes 0.17.0",
+ "bitcoin_hashes",
]
[[package]]
@@ -124,9 +118,9 @@ dependencies = [
"arbitrary",
"bitcoin",
"bitcoin-internals",
- "bitcoin-io 0.2.0",
+ "bitcoin-io",
"bitcoin-units",
- "bitcoin_hashes 0.17.0",
+ "bitcoin_hashes",
"hex-conservative 0.3.0",
"hex_lit",
]
@@ -141,7 +135,7 @@ dependencies = [
"bitcoin-consensus-encoding",
"bitcoin-internals",
"bitcoin-units",
- "bitcoin_hashes 0.17.0",
+ "bitcoin_hashes",
"hex-conservative 0.3.0",
"hex-conservative 1.0.0",
"hex_lit",
@@ -162,16 +156,6 @@ dependencies = [
"serde_test",
]
-[[package]]
-name = "bitcoin_hashes"
-version = "0.14.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bb18c03d0db0247e147a21a6faafd5a7eb851c743db062de72018b6b7e8e4d16"
-dependencies = [
- "bitcoin-io 0.1.1",
- "hex-conservative 0.2.0",
-]
-
[[package]]
name = "bitcoin_hashes"
version = "0.17.0"
@@ -235,15 +219,6 @@ dependencies = [
"windows-targets",
]
-[[package]]
-name = "hex-conservative"
-version = "0.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e1aa273bf451e37ed35ced41c71a5e2a4e29064afb104158f2514bcd71c2c986"
-dependencies = [
- "arrayvec",
-]
-
[[package]]
name = "hex-conservative"
version = "0.3.0"
@@ -376,11 +351,10 @@ checksum = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997"
[[package]]
name = "secp256k1"
-version = "0.31.1"
+version = "0.32.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2c3c81b43dc2d8877c216a3fccf76677ee1ebccd429566d3e67447290d0c42b2"
+checksum = "3c5fdc7d6e800869d3fd60ff857c479bf0a83ea7bf44b389e64461e844204994"
dependencies = [
- "bitcoin_hashes 0.14.0",
"rand",
"secp256k1-sys",
"serde",
@@ -388,9 +362,9 @@ dependencies = [
[[package]]
name = "secp256k1-sys"
-version = "0.11.0"
+version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dcb913707158fadaf0d8702c2db0e857de66eb003ccfdda5924b5f5ac98efb38"
+checksum = "6d3be00697c88c00fe102af8dc316038cc2062eab8da646e7463f4c0e70ca9fd"
dependencies = [
"cc",
]
diff --git a/Cargo-recent.lock b/Cargo-recent.lock
index 3a92d0ae..010038e2 100644
--- a/Cargo-recent.lock
+++ b/Cargo-recent.lock
@@ -19,7 +19,7 @@ name = "base58ck"
version = "0.2.0"
dependencies = [
"bitcoin-internals",
- "bitcoin_hashes 0.17.0",
+ "bitcoin_hashes",
"hex_lit",
]
@@ -54,10 +54,10 @@ dependencies = [
"bech32",
"bincode",
"bitcoin-internals",
- "bitcoin-io 0.2.0",
+ "bitcoin-io",
"bitcoin-primitives",
"bitcoin-units",
- "bitcoin_hashes 0.17.0",
+ "bitcoin_hashes",
"bitcoinconsensus",
"hex-conservative 0.3.0",
"hex_lit",
@@ -101,19 +101,13 @@ dependencies = [
"serde_json",
]
-[[package]]
-name = "bitcoin-io"
-version = "0.1.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0b47c4ab7a93edb0c7198c5535ed9b52b63095f4e9b45279c6736cec4b856baf"
-
[[package]]
name = "bitcoin-io"
version = "0.2.0"
dependencies = [
"bitcoin-consensus-encoding",
"bitcoin-internals",
- "bitcoin_hashes 0.17.0",
+ "bitcoin_hashes",
]
[[package]]
@@ -123,9 +117,9 @@ dependencies = [
"arbitrary",
"bitcoin",
"bitcoin-internals",
- "bitcoin-io 0.2.0",
+ "bitcoin-io",
"bitcoin-units",
- "bitcoin_hashes 0.17.0",
+ "bitcoin_hashes",
"hex-conservative 0.3.0",
"hex_lit",
]
@@ -140,7 +134,7 @@ dependencies = [
"bitcoin-consensus-encoding",
"bitcoin-internals",
"bitcoin-units",
- "bitcoin_hashes 0.17.0",
+ "bitcoin_hashes",
"hex-conservative 0.3.0",
"hex-conservative 1.0.0",
"hex_lit",
@@ -161,16 +155,6 @@ dependencies = [
"serde_test",
]
-[[package]]
-name = "bitcoin_hashes"
-version = "0.14.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bb18c03d0db0247e147a21a6faafd5a7eb851c743db062de72018b6b7e8e4d16"
-dependencies = [
- "bitcoin-io 0.1.3",
- "hex-conservative 0.2.1",
-]
-
[[package]]
name = "bitcoin_hashes"
version = "0.17.0"
@@ -231,15 +215,6 @@ dependencies = [
"wasip2",
]
-[[package]]
-name = "hex-conservative"
-version = "0.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5313b072ce3c597065a808dbf612c4c8e8590bdbf8b579508bf7a762c5eae6cd"
-dependencies = [
- "arrayvec",
-]
-
[[package]]
name = "hex-conservative"
version = "0.3.0"
@@ -385,11 +360,10 @@ checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
[[package]]
name = "secp256k1"
-version = "0.31.1"
+version = "0.32.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2c3c81b43dc2d8877c216a3fccf76677ee1ebccd429566d3e67447290d0c42b2"
+checksum = "3c5fdc7d6e800869d3fd60ff857c479bf0a83ea7bf44b389e64461e844204994"
dependencies = [
- "bitcoin_hashes 0.14.0",
"rand",
"secp256k1-sys",
"serde",
@@ -397,9 +371,9 @@ dependencies = [
[[package]]
name = "secp256k1-sys"
-version = "0.11.0"
+version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dcb913707158fadaf0d8702c2db0e857de66eb003ccfdda5924b5f5ac98efb38"
+checksum = "6d3be00697c88c00fe102af8dc316038cc2062eab8da646e7463f4c0e70ca9fd"
dependencies = [
"cc",
]
diff --git a/Cargo.toml b/Cargo.toml
index eabacff1..a022d60f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,9 +2,3 @@
members = ["addresses", "base58", "bitcoin", "chacha20_poly1305", "consensus_encoding", "fuzz", "hashes", "internals", "io", "p2p", "primitives", "units"]
exclude = ["benches"]
resolver = "2"
-
-# Keep this patch for hashes because secp256k1 depends on bitcoin-hashes via crates.io
-# This allows testing changes to hashes with secp256k1
-# See https://github.com/rust-bitcoin/rust-bitcoin/pull/4284#pullrequestreview-2714442229
-[patch.crates-io.bitcoin_hashes]
-path = "hashes"
diff --git a/bitcoin/CHANGELOG.md b/bitcoin/CHANGELOG.md
index 1a5fba48..a1523f7f 100644
--- a/bitcoin/CHANGELOG.md
+++ b/bitcoin/CHANGELOG.md
@@ -29,15 +29,25 @@ We do not currently intend on releasing `bitcoin 0.33.0` until the `1.0` release
For changes to our dependencies included in this release see:
-- `bitcoin_hashes 0.15`: [changelog](https://github.com/rust-bitcoin/rust-bitcoin/blob/master/hashes/CHANGELOG.md)
+- `bitcoin_hashes 0.17`: [changelog](https://github.com/rust-bitcoin/rust-bitcoin/blob/master/hashes/CHANGELOG.md)
- `hex-conservative 0.3`: [changelog](https://github.com/rust-bitcoin/hex-conservative/blob/master/CHANGELOG.md)
- `bitcoin-io 0.2`: [changelog](https://github.com/rust-bitcoin/rust-bitcoin/blob/master/io/CHANGELOG.md)
-- `bitcoin-primitives: 0.101`: [changelog](https://github.com/rust-bitcoin/rust-bitcoin/blob/master/primitives/CHANGELOG.md)
-- `bitcoin-units 0.2`: [changelog](https://github.com/rust-bitcoin/rust-bitcoin/blob/master/units/CHANGELOG.md)
+- `bitcoin-primitives: 1.0.0-rc.0`: [changelog](https://github.com/rust-bitcoin/rust-bitcoin/blob/master/primitives/CHANGELOG.md)
+- `bitcoin-units 1.0.0-rc.2`: [changelog](https://github.com/rust-bitcoin/rust-bitcoin/blob/master/units/CHANGELOG.md)
- `bitcoinconsensus: 0.106.0+26`: [changelog](https://github.com/rust-bitcoin/rust-bitcoinconsensus/blob/master/CHANGELOG.md)
## Changes
+- Deprecate unchecked `amount` ops [#3759](https://github.com/rust-bitcoin/rust-bitcoin/pull/3759)
+- Change paramater type used for whole bitcoin amounts [#3744](https://github.com/rust-bitcoin/rust-bitcoin/pull/3744)
+- Add `Weight::to_kwu_ceil` [#3740](https://github.com/rust-bitcoin/rust-bitcoin/pull/3740)
+- Remove `Weight::from_wu_usize` function [#3738](https://github.com/rust-bitcoin/rust-bitcoin/pull/3738)
+- Move script hash types to `primitives` [#3734](https://github.com/rust-bitcoin/rust-bitcoin/pull/3734)
+- units: Unify and flesh out ops impls [#3728](https://github.com/rust-bitcoin/rust-bitcoin/pull/3728)
+- units: Seal the `Integer` trait [#3724](https://github.com/rust-bitcoin/rust-bitcoin/pull/3724)
+- base58ck: Bump version to `0.2.0` [#3717](https://github.com/rust-bitcoin/rust-bitcoin/pull/3717)
+- Explicitly define `Ord` for `NodeInfo` [#3699](https://github.com/rust-bitcoin/rust-bitcoin/pull/3699)
+- Change `Amount::MAX` from `u64::MAX` to `Amount::MAX_MONEY` [#3693](https://github.com/rust-bitcoin/rust-bitcoin/pull/3693)
- Fix psbt fuzz crash [#3667](https://github.com/rust-bitcoin/rust-bitcoin/pull/3667)
- Update `from_next_work_required` to take an `i64` for timespan [#3660](https://github.com/rust-bitcoin/rust-bitcoin/pull/3660)
- Account for data pushing opcodes in `is_standard_op_return` [#3643](https://github.com/rust-bitcoin/rust-bitcoin/pull/3643)
diff --git a/bitcoin/Cargo.toml b/bitcoin/Cargo.toml
index 06f0eed2..1f00feb4 100644
--- a/bitcoin/Cargo.toml
+++ b/bitcoin/Cargo.toml
@@ -33,7 +33,7 @@ hex = { package = "hex-conservative", version = "0.3.0", default-features = fals
internals = { package = "bitcoin-internals", path = "../internals", version = "0.4.1", features = ["alloc", "hex"] }
io = { package = "bitcoin-io", path = "../io", version = "0.2.0", default-features = false, features = ["alloc", "hashes"] }
primitives = { package = "bitcoin-primitives", path = "../primitives", version = "1.0.0-rc.0", default-features = false, features = ["alloc", "hex"] }
-secp256k1 = { version = "0.31.1", default-features = false, features = ["hashes", "alloc"] }
+secp256k1 = { version = "0.32.0-beta.2", default-features = false, features = ["alloc"] }
units = { package = "bitcoin-units", path = "../units", version = "1.0.0-rc.2", default-features = false, features = ["alloc"] }
arbitrary = { version = "1.4.1", optional = true }
diff --git a/bitcoin/examples/sign-tx-segwit-v0.rs b/bitcoin/examples/sign-tx-segwit-v0.rs
index e0379aa2..e28601f5 100644
--- a/bitcoin/examples/sign-tx-segwit-v0.rs
+++ b/bitcoin/examples/sign-tx-segwit-v0.rs
@@ -74,7 +74,7 @@ fn main() {
// Update the witness stack.
let signature = bitcoin::ecdsa::Signature { signature, sighash_type };
- let pk = sk.public_key(&secp);
+ let pk = sk.public_key();
*sighasher.witness_mut(input_index).unwrap() = Witness::p2wpkh(signature, pk);
// Get the signed transaction.
@@ -89,7 +89,7 @@ fn main() {
/// In a real application these would be actual secrets.
fn senders_keys<C: Signing>(secp: &Secp256k1<C>) -> (SecretKey, WPubkeyHash) {
let sk = SecretKey::new(&mut rand::rng());
- let pk = bitcoin::PublicKey::new(sk.public_key(secp));
+ let pk = bitcoin::PublicKey::new(sk.public_key());
let wpkh = pk.wpubkey_hash().expect("key is compressed");
(sk, wpkh)
diff --git a/bitcoin/examples/sign-tx-taproot.rs b/bitcoin/examples/sign-tx-taproot.rs
index 53f4b80a..2ecfcb36 100644
--- a/bitcoin/examples/sign-tx-taproot.rs
+++ b/bitcoin/examples/sign-tx-taproot.rs
@@ -87,7 +87,7 @@ fn main() {
/// In a real application these would be actual secrets.
fn senders_keys<C: Signing>(secp: &Secp256k1<C>) -> Keypair {
let sk = SecretKey::new(&mut rand::rng());
- Keypair::from_secret_key(secp, &sk)
+ Keypair::from_secret_key(&sk)
}
/// A dummy address for the receiver.
diff --git a/bitcoin/examples/taproot-psbt.rs b/bitcoin/examples/taproot-psbt.rs
index 32f6a17b..079e6640 100644
--- a/bitcoin/examples/taproot-psbt.rs
+++ b/bitcoin/examples/taproot-psbt.rs
@@ -748,7 +748,7 @@ fn sign_psbt_taproot(
sighash_type: TapSighashType,
secp: &Secp256k1<secp256k1::All>,
) {
- let keypair = secp256k1::Keypair::from_seckey_byte_array(secp, secret_key.secret_bytes()).unwrap();
+ let keypair = secp256k1::Keypair::from_seckey_byte_array(secret_key.secret_bytes()).unwrap();
let keypair = match leaf_hash {
None => keypair.tap_tweak(secp, psbt_input.tap_merkle_root).to_keypair(),
Some(_) => keypair, // no tweak for script spend
diff --git a/bitcoin/src/bip32.rs b/bitcoin/src/bip32.rs
index 4f0797d4..bb349af9 100644
--- a/bitcoin/src/bip32.rs
+++ b/bitcoin/src/bip32.rs
@@ -745,7 +745,7 @@ impl Xpriv {
/// Constructs a new BIP-0340 keypair for Schnorr signatures and Taproot use matching the internal
/// secret key representation.
pub fn to_keypair<C: secp256k1::Signing>(self, secp: &Secp256k1<C>) -> Keypair {
- Keypair::from_seckey_byte_array(secp, self.private_key.secret_bytes())
+ Keypair::from_seckey_byte_array(self.private_key.secret_bytes())
.expect("BIP-0032 internal private key representation is broken")
}
@@ -787,7 +787,7 @@ impl Xpriv {
ChildNumber::Normal { .. } => {
// Non-hardened key: compute public data and use that
engine.input(
- &secp256k1::PublicKey::from_secret_key(secp, &self.private_key).serialize()[..],
+ &secp256k1::PublicKey::from_secret_key(&self.private_key).serialize()[..],
);
}
ChildNumber::Hardened { .. } => {
@@ -882,7 +882,7 @@ impl Xpub {
depth: xpriv.depth,
parent_fingerprint: xpriv.parent_fingerprint,
child_number: xpriv.child_number,
- public_key: secp256k1::PublicKey::from_secret_key(secp, &xpriv.private_key),
+ public_key: secp256k1::PublicKey::from_secret_key(&xpriv.private_key),
chain_code: xpriv.chain_code,
}
}
@@ -961,7 +961,7 @@ impl Xpub {
) -> Result<Self, DerivationError> {
let (sk, chain_code) = self.ckd_pub_tweak(i)?;
let tweaked =
- self.public_key.add_exp_tweak(secp, &sk.into()).expect("cryptographically unreachable");
+ self.public_key.add_exp_tweak(&sk.into()).expect("cryptographically unreachable");
Ok(Self {
network: self.network,
diff --git a/bitcoin/src/crypto/key.rs b/bitcoin/src/crypto/key.rs
index eafe5637..957d9d98 100644
--- a/bitcoin/src/crypto/key.rs
+++ b/bitcoin/src/crypto/key.rs
@@ -84,7 +84,7 @@ impl XOnlyPublicKey {
tweaked_parity: Parity,
tweak: secp256k1::Scalar,
) -> bool {
- self.0.tweak_add_check(secp, &tweaked_key.0, tweaked_parity, tweak)
+ self.0.tweak_add_check(&tweaked_key.0, tweaked_parity, tweak)
}
/// Tweaks an [`XOnlyPublicKey`] by adding the generator multiplied with the given tweak to it.
@@ -104,7 +104,7 @@ impl XOnlyPublicKey {
secp: &Secp256k1<V>,
tweak: &secp256k1::Scalar,
) -> Result<(Self, Parity), TweakXOnlyPublicKeyError> {
- match self.0.add_tweak(secp, tweak) {
+ match self.0.add_tweak(tweak) {
Ok((xonly, parity)) => Ok((Self(xonly), parity)),
Err(secp256k1::Error::InvalidTweak) => Err(TweakXOnlyPublicKeyError::BadTweak),
Err(secp256k1::Error::InvalidParityValue(_)) =>
@@ -562,7 +562,7 @@ impl PrivateKey {
pub fn public_key<C: secp256k1::Signing>(&self, secp: &Secp256k1<C>) -> PublicKey {
PublicKey {
compressed: self.compressed,
- inner: secp256k1::PublicKey::from_secret_key(secp, &self.inner),
+ inner: secp256k1::PublicKey::from_secret_key(&self.inner),
}
}
@@ -873,7 +873,7 @@ pub type UntweakedKeypair = Keypair;
/// # use bitcoin::key::{Keypair, TweakedKeypair, TweakedPublicKey};
/// # use bitcoin::secp256k1::{rand, Secp256k1};
/// # let secp = Secp256k1::new();
-/// # let keypair = TweakedKeypair::dangerous_assume_tweaked(Keypair::new(&secp, &mut rand::rng()));
+/// # let keypair = TweakedKeypair::dangerous_assume_tweaked(Keypair::new(&mut rand::rng()));
/// // There are various conversion methods available to get a tweaked pubkey from a tweaked keypair.
/// let (_pk, _parity) = keypair.public_parts();
/// let _pk = TweakedPublicKey::from_keypair(keypair);
@@ -971,7 +971,7 @@ impl TapTweak for UntweakedKeypair {
) -> TweakedKeypair {
let (pubkey, _parity) = XOnlyPublicKey::from_keypair(&self);
let tweak = TapTweakHash::from_key_and_merkle_root(pubkey, merkle_root).to_scalar();
- let tweaked = self.add_xonly_tweak(secp, &tweak).expect("Tap tweak failed");
+ let tweaked = self.add_xonly_tweak(&tweak).expect("Tap tweak failed");
TweakedKeypair(tweaked)
}
@@ -1745,7 +1745,7 @@ mod tests {
use secp256k1::rand;
let secp = Secp256k1::new();
- let kp = Keypair::new(&secp, &mut rand::rng());
+ let kp = Keypair::new(&mut rand::rng());
let _ = PublicKey::new(kp);
let _ = PublicKey::new_uncompressed(kp);
diff --git a/bitcoin/src/crypto/sighash.rs b/bitcoin/src/crypto/sighash.rs
index 550c34db..1938b959 100644
--- a/bitcoin/src/crypto/sighash.rs
+++ b/bitcoin/src/crypto/sighash.rs
@@ -2013,10 +2013,10 @@ mod tests {
};
// tests
- let keypair = secp256k1::Keypair::from_secret_key(secp, &internal_priv_key);
+ let keypair = secp256k1::Keypair::from_secret_key(&internal_priv_key);
let (internal_key, _parity) = XOnlyPublicKey::from_keypair(&keypair);
let tweak = TapTweakHash::from_key_and_merkle_root(internal_key, merkle_root);
- let tweaked_keypair = keypair.add_xonly_tweak(secp, &tweak.to_scalar()).unwrap();
+ let tweaked_keypair = keypair.add_xonly_tweak(&tweak.to_scalar()).unwrap();
let mut sig_msg = Vec::new();
cache
.taproot_encode_signing_data_to(
diff --git a/bitcoin/src/psbt/mod.rs b/bitcoin/src/psbt/mod.rs
index ccfcbbf5..adc2daaa 100644
--- a/bitcoin/src/psbt/mod.rs
+++ b/bitcoin/src/psbt/mod.rs
@@ -440,7 +440,7 @@ impl Psbt {
// According to BIP-0371, we also need to consider the condition leaf_hashes.is_empty() for a more accurate determination.
if internal_key == xonly && leaf_hashes.is_empty() && input.tap_key_sig.is_none() {
let (sighash, sighash_type) = self.sighash_taproot(input_index, cache, None)?;
- let key_pair = Keypair::from_secret_key(secp, &sk.inner)
+ let key_pair = Keypair::from_secret_key(&sk.inner)
.tap_tweak(secp, input.tap_merkle_root)
.to_keypair();
@@ -466,7 +466,7 @@ impl Psbt {
.collect::<Vec<_>>();
if !leaf_hashes.is_empty() {
- let key_pair = Keypair::from_secret_key(secp, &sk.inner);
+ let key_pair = Keypair::from_secret_key(&sk.inner);
for lh in leaf_hashes {
let (sighash, sighash_type) =
diff --git a/bitcoin/src/sign_message.rs b/bitcoin/src/sign_message.rs
index d3903485..9c8feff0 100644
--- a/bitcoin/src/sign_message.rs
+++ b/bitcoin/src/sign_message.rs
@@ -104,7 +104,7 @@ mod message_signing {
pub fn serialize(&self) -> [u8; 65] {
let (recid, raw) = self.signature.serialize_compact();
let mut serialized = [0u8; 65];
- serialized[0] = i32::from(recid) as u8 + if self.compressed { 31 } else { 27 };
+ serialized[0] = recid.to_u8() + if self.compressed { 31 } else { 27 };
serialized[1..].copy_from_slice(&raw[..]);
serialized
}
@@ -278,7 +278,7 @@ mod tests {
let p2pkh = Address::p2pkh(pubkey, Network::Bitcoin);
assert_eq!(signature2.is_signed_by_address(&secp, &p2pkh, msg_hash), Ok(true));
- assert_eq!(pubkey.0, secp256k1::PublicKey::from_secret_key(&secp, &privkey));
+ assert_eq!(pubkey.0, secp256k1::PublicKey::from_secret_key(&privkey));
let signature_base64 = signature.to_base64();
let signature_round_trip =
super::MessageSignature::from_base64(&signature_base64).expect("message signature");
diff --git a/bitcoin/tests/psbt-sign-taproot.rs b/bitcoin/tests/psbt-sign-taproot.rs
index f882eb41..3b126227 100644
--- a/bitcoin/tests/psbt-sign-taproot.rs
+++ b/bitcoin/tests/psbt-sign-taproot.rs
@@ -60,7 +60,7 @@ fn psbt_sign_taproot() {
let script3 = create_basic_single_sig_script(secp, sk_path[2].0); // m/86'/1'/0'/0/2
// Just use one of the secret keys for the key path spend.
- let kp = Keypair::from_seckey_str(secp, sk_path[2].0).expect("failed to create keypair");
+ let kp = Keypair::from_seckey_str(sk_path[2].0).expect("failed to create keypair");
let internal_key = kp.x_only_public_key().0; // Ignore the parity.
@@ -114,7 +114,7 @@ fn psbt_sign_taproot() {
// script path spend
{
// use private key of path "m/86'/1'/0'/0/1" as signing key
- let kp = Keypair::from_seckey_str(secp, sk_path[1].0).expect("failed to create keypair");
+ let kp = Keypair::from_seckey_str(sk_path[1].0).expect("failed to create keypair");
let x_only_pubkey = kp.x_only_public_key().0;
let signing_key_path = sk_path[1].1;
@@ -167,7 +167,7 @@ fn psbt_sign_taproot() {
}
fn create_basic_single_sig_script(secp: &Secp256k1<secp256k1::All>, sk: &str) -> TapScriptBuf {
- let kp = Keypair::from_seckey_str(secp, sk).expect("failed to create keypair");
+ let kp = Keypair::from_seckey_str(sk).expect("failed to create keypair");
let x_only_pubkey = kp.x_only_public_key().0;
script::Builder::new()
.push_slice(x_only_pubkey.serialize())
Why this scored 32/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.