Skip to content

Commit 54bf6ca

Browse files
committed
Upgrade secp to 0.31.1
Upgrade to the latest released version of `rust-secp256k1`. Do just the build errors. Note one deprecated call to `thread_rng()` is added, I'm not sure why this line was building before but anyways the `rand` stuff will be done next.
1 parent e81a4c2 commit 54bf6ca

File tree

7 files changed

+17
-15
lines changed

7 files changed

+17
-15
lines changed

bitcoin/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ hex = { package = "hex-conservative", version = "0.3.0", default-features = fals
3333
internals = { package = "bitcoin-internals", path = "../internals", features = ["alloc", "hex"] }
3434
io = { package = "bitcoin-io", path = "../io", default-features = false, features = ["alloc", "hashes"] }
3535
primitives = { package = "bitcoin-primitives", path = "../primitives", default-features = false, features = ["alloc", "hex"] }
36+
<<<<<<< Side #1 (Conflict 1 of 1)
3637
secp256k1 = { version = "0.30.0", default-features = false, features = ["hashes", "alloc"] }
38+
secp256k1 = { version = "0.31.1", default-features = false, features = ["hashes", "alloc", "rand"] }
3739
units = { package = "bitcoin-units", path = "../units", default-features = false, features = ["alloc"] }
3840

3941
arbitrary = { version = "1.4.1", optional = true }

bitcoin/examples/sign-tx-segwit-v0.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ fn main() {
7070

7171
// Sign the sighash using the secp256k1 library (exported by rust-bitcoin).
7272
let msg = Message::from(sighash);
73-
let signature = secp.sign_ecdsa(&msg, &sk);
73+
let signature = secp.sign_ecdsa(msg, &sk);
7474

7575
// Update the witness stack.
7676
let signature = bitcoin::ecdsa::Signature { signature, sighash_type };

bitcoin/src/bip32.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ impl Xpriv {
721721
parent_fingerprint: Default::default(),
722722
child_number: ChildNumber::ZERO_NORMAL,
723723
private_key: secp256k1::SecretKey::from_byte_array(
724-
hmac.as_byte_array().split_array::<32, 32>().0,
724+
*hmac.as_byte_array().split_array::<32, 32>().0,
725725
)
726726
.expect("cryptographically unreachable"),
727727
chain_code: ChainCode::from_hmac(hmac),
@@ -800,7 +800,7 @@ impl Xpriv {
800800
engine.input(&u32::from(i).to_be_bytes());
801801
let hmac: Hmac<sha512::Hash> = engine.finalize();
802802
let sk =
803-
secp256k1::SecretKey::from_byte_array(hmac.as_byte_array().split_array::<32, 32>().0)
803+
secp256k1::SecretKey::from_byte_array(*hmac.as_byte_array().split_array::<32, 32>().0)
804804
.expect("statistically impossible to hit");
805805
let tweaked =
806806
sk.add_tweak(&self.private_key.into()).expect("statistically impossible to hit");
@@ -837,7 +837,7 @@ impl Xpriv {
837837
parent_fingerprint,
838838
child_number,
839839
chain_code,
840-
private_key: secp256k1::SecretKey::from_byte_array(private_key)?,
840+
private_key: secp256k1::SecretKey::from_byte_array(*private_key)?,
841841
})
842842
}
843843

@@ -944,7 +944,7 @@ impl Xpub {
944944

945945
let hmac = engine.finalize();
946946
let private_key = secp256k1::SecretKey::from_byte_array(
947-
hmac.as_byte_array().split_array::<32, 32>().0,
947+
*hmac.as_byte_array().split_array::<32, 32>().0,
948948
)
949949
.expect("cryptographically unreachable");
950950
let chain_code = ChainCode::from_hmac(hmac);

bitcoin/src/crypto/key.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl XOnlyPublicKey {
5757
pub fn from_byte_array(
5858
data: &[u8; constants::SCHNORR_PUBLIC_KEY_SIZE],
5959
) -> Result<XOnlyPublicKey, ParseXOnlyPublicKeyError> {
60-
secp256k1::XOnlyPublicKey::from_byte_array(data)
60+
secp256k1::XOnlyPublicKey::from_byte_array(*data)
6161
.map(XOnlyPublicKey::new)
6262
.map_err(|_| ParseXOnlyPublicKeyError::InvalidXCoordinate)
6363
}
@@ -326,7 +326,7 @@ impl PublicKey {
326326
msg: secp256k1::Message,
327327
sig: ecdsa::Signature,
328328
) -> Result<(), secp256k1::Error> {
329-
secp.verify_ecdsa(&msg, &sig.signature, &self.inner)
329+
secp.verify_ecdsa(msg, &sig.signature, &self.inner)
330330
}
331331
}
332332

@@ -468,7 +468,7 @@ impl CompressedPublicKey {
468468
msg: secp256k1::Message,
469469
sig: ecdsa::Signature,
470470
) -> Result<(), secp256k1::Error> {
471-
Ok(secp.verify_ecdsa(&msg, &sig.signature, &self.0)?)
471+
Ok(secp.verify_ecdsa(msg, &sig.signature, &self.0)?)
472472
}
473473
}
474474

@@ -582,7 +582,7 @@ impl PrivateKey {
582582
data: [u8; 32],
583583
network: impl Into<NetworkKind>,
584584
) -> Result<PrivateKey, secp256k1::Error> {
585-
Ok(PrivateKey::new(secp256k1::SecretKey::from_byte_array(&data)?, network))
585+
Ok(PrivateKey::new(secp256k1::SecretKey::from_byte_array(data)?, network))
586586
}
587587

588588
/// Deserializes a private key from a slice.
@@ -644,7 +644,7 @@ impl PrivateKey {
644644
}
645645
};
646646

647-
Ok(PrivateKey { compressed, network, inner: secp256k1::SecretKey::from_byte_array(key)? })
647+
Ok(PrivateKey { compressed, network, inner: secp256k1::SecretKey::from_byte_array(*key)? })
648648
}
649649

650650
/// Returns a new private key with the negated secret value.

bitcoin/src/merkle_tree/block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ mod tests {
576576

577577
#[cfg(feature = "rand-std")]
578578
fn pmt_test(tx_count: usize) {
579-
let mut rng = thread_rng();
579+
let mut rng = secp256k1::rand::thread_rng();
580580
// Create some fake tx ids
581581
let tx_ids = (1..=tx_count)
582582
.map(|i| format!("{:064x}", i).parse::<Txid>().unwrap())

bitcoin/src/psbt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ impl Psbt {
379379
};
380380

381381
let sig = ecdsa::Signature {
382-
signature: secp.sign_ecdsa(&msg, &sk.inner),
382+
signature: secp.sign_ecdsa(msg, &sk.inner),
383383
sighash_type: sighash_ty,
384384
};
385385

bitcoin/src/sign_message.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ mod message_signing {
139139
msg_hash: sha256d::Hash,
140140
) -> Result<PublicKey, MessageSignatureError> {
141141
let msg = secp256k1::Message::from_digest(msg_hash.to_byte_array());
142-
let pubkey = secp_ctx.recover_ecdsa(&msg, &self.signature)?;
142+
let pubkey = secp_ctx.recover_ecdsa(msg, &self.signature)?;
143143
Ok(PublicKey { inner: pubkey, compressed: self.compressed })
144144
}
145145

@@ -224,7 +224,7 @@ pub fn sign<C: secp256k1::Signing>(
224224
) -> MessageSignature {
225225
let msg_hash = signed_msg_hash(msg);
226226
let msg_to_sign = secp256k1::Message::from_digest(msg_hash.to_byte_array());
227-
let secp_sig = secp_ctx.sign_ecdsa_recoverable(&msg_to_sign, &privkey);
227+
let secp_sig = secp_ctx.sign_ecdsa_recoverable(msg_to_sign, &privkey);
228228
MessageSignature { signature: secp_sig, compressed: true }
229229
}
230230

@@ -253,7 +253,7 @@ mod tests {
253253
let msg_hash = super::signed_msg_hash(message);
254254
let msg = secp256k1::Message::from_digest(msg_hash.to_byte_array());
255255
let privkey = secp256k1::SecretKey::new(&mut secp256k1::rand::thread_rng());
256-
let secp_sig = secp.sign_ecdsa_recoverable(&msg, &privkey);
256+
let secp_sig = secp.sign_ecdsa_recoverable(msg, &privkey);
257257
let signature = super::MessageSignature { signature: secp_sig, compressed: true };
258258

259259
assert_eq!(signature.to_string(), super::sign(&secp, message, privkey).to_string());

0 commit comments

Comments
 (0)