Skip to content

Commit 9bf8dfc

Browse files
committed
Update secp256k1 dependency to use PR rust-bitcoin/rust-secp256k1#721
1 parent c061d93 commit 9bf8dfc

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

bitcoin/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ exclude = ["tests", "contrib"]
1717
[features]
1818
default = [ "std", "secp-recovery" ]
1919
std = ["base58/std", "bech32/std", "hashes/std", "hex/std", "internals/std", "io/std", "primitives/std", "secp256k1/std", "units/std", "bitcoinconsensus?/std"]
20-
rand-std = ["secp256k1/rand-std", "std"]
20+
rand-std = ["secp256k1/std", "secp256k1/rand", "std"]
2121
rand = ["secp256k1/rand"]
2222
serde = ["dep:serde", "hashes/serde", "internals/serde", "primitives/serde", "secp256k1/serde", "units/serde"]
2323
secp-lowmemory = ["secp256k1/lowmemory"]
@@ -31,7 +31,7 @@ hex = { package = "hex-conservative", version = "0.2.0", default-features = fals
3131
internals = { package = "bitcoin-internals", version = "0.3.0", features = ["alloc"] }
3232
io = { package = "bitcoin-io", version = "0.1.1", default-features = false, features = ["alloc"] }
3333
primitives = { package = "bitcoin-primitives", version = "0.100.0", default-features = false, features = ["alloc"] }
34-
secp256k1 = { version = "0.29.0", default-features = false, features = ["hashes", "alloc"] }
34+
secp256k1 = { git = "https://github.com/rust-bitcoin/rust-secp256k1.git", rev = "refs/pull/721/head", default-features = false, features = ["alloc", "hashes", "rand", "std"] }
3535
units = { package = "bitcoin-units", version = "0.1.0", default-features = false, features = ["alloc"] }
3636

3737
base64 = { version = "0.22.0", optional = true }

bitcoin/examples/sign-tx-taproot.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::str::FromStr;
77
use bitcoin::address::script_pubkey::ScriptBufExt as _;
88
use bitcoin::key::{Keypair, TapTweak, TweakedKeypair, UntweakedPublicKey};
99
use bitcoin::locktime::absolute;
10-
use bitcoin::secp256k1::{rand, Message, Secp256k1, SecretKey, Signing, Verification};
10+
use bitcoin::secp256k1::{rand, Secp256k1, SecretKey, Signing, Verification};
1111
use bitcoin::sighash::{Prevouts, SighashCache, TapSighashType};
1212
use bitcoin::{
1313
transaction, Address, Amount, Network, OutPoint, ScriptBuf, Sequence, Transaction, TxIn, TxOut,
@@ -71,7 +71,7 @@ fn main() {
7171

7272
// Sign the sighash using the secp256k1 library (exported by rust-bitcoin).
7373
let tweaked: TweakedKeypair = keypair.tap_tweak(&secp, None);
74-
let msg = Message::from(sighash);
74+
let msg = sighash.to_byte_array();
7575
let signature = secp.sign_schnorr(&msg, &tweaked.to_inner());
7676

7777
// Update the witness stack.

bitcoin/examples/taproot-psbt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ fn sign_psbt_taproot(
740740
Some(_) => keypair, // no tweak for script spend
741741
};
742742

743-
let msg = secp256k1::Message::from(hash);
743+
let msg = hash.to_byte_array();
744744
let signature = secp.sign_schnorr(&msg, &keypair);
745745

746746
let final_signature = taproot::Signature { signature, sighash_type };

bitcoin/src/psbt/mod.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use crate::prelude::{btree_map, BTreeMap, BTreeSet, Borrow, Box, Vec};
2828
use crate::script::ScriptExt as _;
2929
use crate::sighash::{self, EcdsaSighashType, Prevouts, SighashCache};
3030
use crate::transaction::{self, Transaction, TxOut};
31-
use crate::{Amount, FeeRate, TapLeafHash, TapSighashType};
31+
use crate::{Amount, FeeRate, TapLeafHash, TapSighash, TapSighashType};
3232

3333
#[rustfmt::skip] // Keep public re-exports separate.
3434
#[doc(inline)]
@@ -443,6 +443,8 @@ impl Psbt {
443443
.tap_tweak(secp, input.tap_merkle_root)
444444
.to_inner();
445445

446+
let msg = msg.to_byte_array();
447+
446448
#[cfg(feature = "rand-std")]
447449
let signature = secp.sign_schnorr(&msg, &key_pair);
448450
#[cfg(not(feature = "rand-std"))]
@@ -470,6 +472,8 @@ impl Psbt {
470472
let (msg, sighash_type) =
471473
self.sighash_taproot(input_index, cache, Some(lh))?;
472474

475+
let msg = msg.to_byte_array();
476+
473477
#[cfg(feature = "rand-std")]
474478
let signature = secp.sign_schnorr(&msg, &key_pair);
475479
#[cfg(not(feature = "rand-std"))]
@@ -560,7 +564,7 @@ impl Psbt {
560564
input_index: usize,
561565
cache: &mut SighashCache<T>,
562566
leaf_hash: Option<TapLeafHash>,
563-
) -> Result<(Message, TapSighashType), SignError> {
567+
) -> Result<(TapSighash, TapSighashType), SignError> {
564568
use OutputType::*;
565569

566570
if self.signing_algorithm(input_index)? != SigningAlgorithm::Schnorr {
@@ -605,7 +609,7 @@ impl Psbt {
605609
} else {
606610
cache.taproot_key_spend_signature_hash(input_index, &prev_outs, hash_ty)?
607611
};
608-
Ok((Message::from(sighash), hash_ty))
612+
Ok((sighash, hash_ty))
609613
}
610614
_ => Err(SignError::Unsupported),
611615
}

0 commit comments

Comments
 (0)