Skip to content

Update hashes to 0.16.0 #832

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions Cargo-minimal.lock
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,26 @@ dependencies = [
"serde",
]

[[package]]
name = "bitcoin-internals"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b854212e29b96c8f0fe04cab11d57586c8f3257de0d146c76cb3b42b3eb9118"

[[package]]
name = "bitcoin-io"
version = "0.1.2"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "340e09e8399c7bd8912f495af6aa58bea0c9214773417ffaa8f6460f93aaee56"
checksum = "26792cd2bf245069a1c5acb06aa7ad7abe1de69b507c90b490bca81e0665d0ee"
dependencies = [
"bitcoin-internals",
]

[[package]]
name = "bitcoin_hashes"
version = "0.14.0"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb18c03d0db0247e147a21a6faafd5a7eb851c743db062de72018b6b7e8e4d16"
checksum = "7e5d09f16329cd545d7e6008b2c6b2af3a90bc678cf41ac3d2f6755943301b16"
dependencies = [
"bitcoin-io",
"hex-conservative",
Expand Down Expand Up @@ -107,9 +116,9 @@ checksum = "ee6c0438de3ca4d8cac2eec62b228e2f8865cfe9ebefea720406774223fa2d2e"

[[package]]
name = "hex-conservative"
version = "0.2.1"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5313b072ce3c597065a808dbf612c4c8e8590bdbf8b579508bf7a762c5eae6cd"
checksum = "4afe881d0527571892c4034822e59bb10c6c991cce6abe8199b6f5cf10766f55"
dependencies = [
"arrayvec",
]
Expand Down
21 changes: 15 additions & 6 deletions Cargo-recent.lock
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,26 @@ dependencies = [
"serde",
]

[[package]]
name = "bitcoin-internals"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b854212e29b96c8f0fe04cab11d57586c8f3257de0d146c76cb3b42b3eb9118"

[[package]]
name = "bitcoin-io"
version = "0.1.2"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "340e09e8399c7bd8912f495af6aa58bea0c9214773417ffaa8f6460f93aaee56"
checksum = "26792cd2bf245069a1c5acb06aa7ad7abe1de69b507c90b490bca81e0665d0ee"
dependencies = [
"bitcoin-internals",
]

[[package]]
name = "bitcoin_hashes"
version = "0.14.0"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb18c03d0db0247e147a21a6faafd5a7eb851c743db062de72018b6b7e8e4d16"
checksum = "7e5d09f16329cd545d7e6008b2c6b2af3a90bc678cf41ac3d2f6755943301b16"
dependencies = [
"bitcoin-io",
"hex-conservative",
Expand Down Expand Up @@ -101,9 +110,9 @@ checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7"

[[package]]
name = "hex-conservative"
version = "0.2.1"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5313b072ce3c597065a808dbf612c4c8e8590bdbf8b579508bf7a762c5eae6cd"
checksum = "4afe881d0527571892c4034822e59bb10c6c991cce6abe8199b6f5cf10766f55"
dependencies = [
"arrayvec",
]
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ arbitrary = ["dep:arbitrary"]
secp256k1-sys = { version = "0.11.0", default-features = false, path = "./secp256k1-sys" }

arbitrary = { version = "1.4", optional = true }
hashes = { package = "bitcoin_hashes", version = "0.14", default-features = false, optional = true }
hashes = { package = "bitcoin_hashes", version = "0.16", default-features = false, optional = true }
rand = { version = "0.9", default-features = false, optional = true }
serde = { version = "1.0.103", default-features = false, optional = true }

Expand Down
2 changes: 1 addition & 1 deletion examples/sign_verify.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extern crate hashes;
extern crate secp256k1;

use hashes::{sha256, Hash};
use hashes::sha256;
use secp256k1::{ecdsa, Error, Message, PublicKey, Secp256k1, SecretKey, Signing, Verification};

fn verify<C: Verification>(
Expand Down
2 changes: 1 addition & 1 deletion examples/sign_verify_recovery.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extern crate hashes;
extern crate secp256k1;

use hashes::{sha256, Hash};
use hashes::sha256;
use secp256k1::{ecdsa, Error, Message, PublicKey, Secp256k1, SecretKey, Signing, Verification};

fn recover<C: Verification>(
Expand Down
4 changes: 2 additions & 2 deletions src/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ macro_rules! impl_display_secret {
#[cfg(feature = "hashes")]
impl ::core::fmt::Debug for $thing {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
use hashes::{sha256, Hash, HashEngine};
use hashes::{sha256, HashEngine};

let tag = "rust-secp256k1DEBUG";

Expand All @@ -25,7 +25,7 @@ macro_rules! impl_display_secret {
engine.input(&self.secret_bytes());
let hash = sha256::Hash::from_engine(engine);

f.debug_tuple(stringify!($thing)).field(&format_args!("#{:.16}", hash)).finish()
f.debug_tuple(stringify!($thing)).field(&format_args!("{:?}", hash)).finish()
Copy link
Member

@tcharding tcharding Aug 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That 16 width was so its a fingerprint not the whole hash. But I cannot find a test for it. Can you add this and make it pass?

#[cfg(test)]
mod test {
    use super::*;

    #[test]
    #[cfg(feature = "hashes")]
    fn debug_secret_hashes_feature_enabled() {
        let key = "0000000000000000000000000000000000000000000000000000000000000001".parse::<SecretKey>().unwrap();
        
        // Normal debug hides value (`Display` is not implemented for `SecretKey`).
        let want = "SecretKey(#2518682f7819fb2d)";
        let got = format!("{:?}", key);
        assert_eq!(got, want);
    }

    #[test]
    #[cfg(not(feature = "hashes"))]
    fn debug_secret_no_hashes() {
        let key = "0000000000000000000000000000000000000000000000000000000000000001".parse::<SecretKey>().unwrap();
        
        // With "hashes" feature we just output a message.
        let want = "<secret key; enable `hashes` feature of `secp256k1` to display fingerprint>";
        let got = format!("{:?}", key);
        assert_eq!(got, want);
    }
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the doc test was supposed to test it but it just includes a comment about it.

}
}

Expand Down
Loading