What changed, and why it matters
This commit only adds a new performance benchmark for the SHA256d hashing function. It does not change any production code, cryptographic logic, or user-facing behavior. There is no security issue.
No action required; the commit is benign benchmark infrastructure.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change registers a new Criterion benchmark target in benches/Cargo.toml and adds benches/hashes/sha256d.rs, which measures sha256d::Hash::engine() throughput for 10, 64, 1024, and 65536 byte inputs. It is purely test/benchmark infrastructure.
Changed components
benches/Cargo.tomlbenches/hashes/sha256d.rsInspect captured patch +32 / −0
diff --git a/benches/Cargo.toml b/benches/Cargo.toml
index b1de4d98..ba7ff442 100644
--- a/benches/Cargo.toml
+++ b/benches/Cargo.toml
@@ -84,6 +84,11 @@ name = "sha256"
path = "hashes/sha256.rs"
harness = false
+[[bench]]
+name = "sha256d"
+path = "hashes/sha256d.rs"
+harness = false
+
[[bench]]
name = "sha384"
path = "hashes/sha384.rs"
diff --git a/benches/hashes/sha256d.rs b/benches/hashes/sha256d.rs
new file mode 100644
index 00000000..54f0924a
--- /dev/null
+++ b/benches/hashes/sha256d.rs
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: CC0-1.0
+
+use std::hint::black_box;
+
+use bitcoin_hashes::{sha256d, HashEngine};
+use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
+
+fn bench_sha256d(c: &mut Criterion) {
+ let mut g = c.benchmark_group("sha256d");
+
+ for &size in &[10usize, 64, 1024, 65536] {
+ let bytes = vec![1u8; size];
+ g.throughput(Throughput::Bytes(size as u64));
+ g.bench_function(BenchmarkId::new("engine_input", size), |b| {
+ b.iter(|| {
+ let mut engine = sha256d::Hash::engine();
+ engine.input(black_box(&bytes));
+ black_box(engine.finalize());
+ });
+ });
+ }
+
+ g.finish();
+}
+
+criterion_group!(benches, bench_sha256d);
+criterion_main!(benches);
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.