From 9f3e355c5c1de65baa1e8975e10d949576110cda Mon Sep 17 00:00:00 2001 From: Tamas Blummer Date: Sat, 27 Jul 2019 09:28:51 +0200 Subject: [PATCH] upgrade to secp256k1 0.15 and bitcoinconsensus 0.17 --- Cargo.toml | 8 +++++--- src/util/merkleblock.rs | 6 +++--- src/util/misc.rs | 3 ++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4366f70e..afa5e795 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,15 +23,17 @@ use-serde = ["serde", "bitcoin_hashes/serde"] bech32 = "0.7.1" byteorder = "1.2" bitcoin_hashes = "0.7" -bitcoinconsensus = { version = "0.16", optional = true } -secp256k1 = "0.12" +bitcoinconsensus = { version = "0.17", optional = true } serde = { version = "1", optional = true } [dependencies.hex] version = "=0.3.2" +[dependencies.secp256k1] +version = "0.15" +features = [ "rand" ] + [dev-dependencies] serde_derive = "<1.0.99" serde_json = "1" serde_test = "1" -secp256k1 = { version = "0.12", features = [ "rand" ] } diff --git a/src/util/merkleblock.rs b/src/util/merkleblock.rs index 6ced63e7..9f56c8f0 100644 --- a/src/util/merkleblock.rs +++ b/src/util/merkleblock.rs @@ -497,7 +497,7 @@ mod tests { use hashes::hex::{FromHex, ToHex}; use hashes::{sha256d, Hash}; - use secp256k1::rand::{weak_rng, Rng, XorShiftRng}; + use secp256k1::rand::prelude::*; use consensus::encode::{deserialize, serialize}; use util::hash::{bitcoin_merkle_root, BitcoinHash}; @@ -506,7 +506,7 @@ mod tests { #[test] fn pmt_tests() { - let mut rng = weak_rng(); + let mut rng = thread_rng(); let tx_counts = vec![1, 4, 7, 17, 56, 100, 127, 256, 312, 513, 1000, 4095]; for num_tx in tx_counts { @@ -693,7 +693,7 @@ mod tests { impl PartialMerkleTree { /// Flip one bit in one of the hashes - this should break the authentication - fn damage(&mut self, rng: &mut XorShiftRng) { + fn damage(&mut self, rng: &mut ThreadRng) { let n = rng.gen_range(0, self.hashes.len()); let bit = rng.gen::(); let hashes = &mut self.hashes; diff --git a/src/util/misc.rs b/src/util/misc.rs index f8a3a459..784994e0 100644 --- a/src/util/misc.rs +++ b/src/util/misc.rs @@ -125,6 +125,7 @@ pub fn signed_msg_hash(msg: &str) -> sha256d::Hash { #[cfg(all(test, feature="unstable"))] mod benches { use secp256k1::rand::{Rng, thread_rng}; + use secp256k1::rand::distributions::Standard; use super::hex_bytes; use test::Bencher; @@ -138,7 +139,7 @@ mod benches { fn bench_from_hex(b: &mut Bencher, data_size: usize) { let data_bytes = thread_rng() - .gen_iter() + .sample_iter(&Standard) .take(data_size) .collect::>(); let data = join(data_bytes.iter().map(|x| format!("{:02x}", x)), data_size * 2);