Skip to content

Commit

Permalink
Merge #722: Truncate secret hash
Browse files Browse the repository at this point in the history
3d1ce0d Truncate secret hash using precision (Tobin C. Harding)
4b143d6 Remove bitcoin_hashes range dependency (Tobin C. Harding)

Pull request description:

  The `core::hash::Hasher` and `bitcoin_hashes` hash types implement formatting traits slightly differently

  - We default to displaying in hex but `core` defaults to using base 10
  - We truncate with precision not width parameter but core truncates with both

  Anywho, this PR fixes the secret display truncation.

ACKs for top commit:
  Kixunil:
    ACK 3d1ce0d
  apoelstra:
    ACK 3d1ce0d successfully ran local tests

Tree-SHA512: f4f15c084f33bf270eab7b578891b50aa743caac12eb0cc3f7ced8fce2df2af93fcca859a2bc0a50396434514fad63368cd81753b8634a41dc3da996d1b1996c
  • Loading branch information
apoelstra committed Aug 25, 2024
2 parents 789f384 + 3d1ce0d commit 5d2149f
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 18 deletions.
25 changes: 17 additions & 8 deletions Cargo-minimal.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
# It is not intended for manual editing.
version = 3

[[package]]
name = "arrayvec"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"

[[package]]
name = "base-x"
version = "0.2.0"
Expand All @@ -18,18 +24,18 @@ dependencies = [
]

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

[[package]]
name = "bitcoin_hashes"
version = "0.13.0"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1930a4dabfebb8d7d9992db18ebe3ae2876f0a305fab206fd168df931ede293b"
checksum = "bb18c03d0db0247e147a21a6faafd5a7eb851c743db062de72018b6b7e8e4d16"
dependencies = [
"bitcoin-internals",
"bitcoin-io",
"hex-conservative",
]

Expand Down Expand Up @@ -106,9 +112,12 @@ checksum = "ee6c0438de3ca4d8cac2eec62b228e2f8865cfe9ebefea720406774223fa2d2e"

[[package]]
name = "hex-conservative"
version = "0.1.1"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30ed443af458ccb6d81c1e7e661545f94d3176752fb1df2f543b902a1e0f51e2"
checksum = "5313b072ce3c597065a808dbf612c4c8e8590bdbf8b579508bf7a762c5eae6cd"
dependencies = [
"arrayvec",
]

[[package]]
name = "hex_lit"
Expand Down
25 changes: 17 additions & 8 deletions Cargo-recent.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
# It is not intended for manual editing.
version = 3

[[package]]
name = "arrayvec"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"

[[package]]
name = "bincode"
version = "1.3.3"
Expand All @@ -12,18 +18,18 @@ dependencies = [
]

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

[[package]]
name = "bitcoin_hashes"
version = "0.13.0"
version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1930a4dabfebb8d7d9992db18ebe3ae2876f0a305fab206fd168df931ede293b"
checksum = "bb18c03d0db0247e147a21a6faafd5a7eb851c743db062de72018b6b7e8e4d16"
dependencies = [
"bitcoin-internals",
"bitcoin-io",
"hex-conservative",
]

Expand Down Expand Up @@ -82,9 +88,12 @@ checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7"

[[package]]
name = "hex-conservative"
version = "0.1.1"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30ed443af458ccb6d81c1e7e661545f94d3176752fb1df2f543b902a1e0f51e2"
checksum = "5313b072ce3c597065a808dbf612c4c8e8590bdbf8b579508bf7a762c5eae6cd"
dependencies = [
"arrayvec",
]

[[package]]
name = "hex_lit"
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ global-context-less-secure = ["global-context"]
secp256k1-sys = { version = "0.10.0", default-features = false, path = "./secp256k1-sys" }
serde = { version = "1.0.103", default-features = false, optional = true }

hashes = { package = "bitcoin_hashes", version = ">= 0.12, <= 0.14", default-features = false, optional = true }
hashes = { package = "bitcoin_hashes", version = "0.14", default-features = false, optional = true }
rand = { version = "0.8", default-features = false, optional = true }

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion src/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,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!("#{:016x}", hash)).finish()
f.debug_tuple(stringify!($thing)).field(&format_args!("#{:.16}", hash)).finish()
}
}

Expand Down

0 comments on commit 5d2149f

Please sign in to comment.