hashes: capitalize hash algorithm names
What changed, and why it matters
This commit only changes the capitalization of hash algorithm names in comments and documentation strings (for example, 'sha256' becomes 'SHA256' and 'sha256d' becomes 'SHA256d'). No program logic, code behavior, or security properties were modified.
No action required; this is a non-functional documentation/style change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff is a documentation-only style change across 14 files in the rust-bitcoin repository. It capitalizes references to hash algorithms in doc comments, inline comments, and string literals. There are no changes to function implementations, APIs, constants, cryptographic operations, or control flow. No security vulnerability is introduced or fixed.
Changed components
base58/src/lib.rsbitcoin/src/blockdata/constants.rsbitcoin/src/crypto/sighash.rsbitcoin/src/hash_types.rshashes/src/sha256/crypto/arm_sha2.rshashes/src/sha256/crypto/x86_shani.rshashes/src/sha256/mod.rshashes/src/sha256/tests.rshashes/src/sha256d/mod.rshashes/src/sha256t/mod.rshashes/src/sha384/mod.rshashes/src/sha3_256/mod.rshashes/src/sha512_256/mod.rshashes/tests/api.rsInspect captured patch +31 / −31
diff --git a/base58/src/lib.rs b/base58/src/lib.rs
index e4a56659..c9697723 100644
--- a/base58/src/lib.rs
+++ b/base58/src/lib.rs
@@ -173,7 +173,7 @@ pub fn encode(data: &[u8]) -> String {
/// Encodes `data` as a base58 string including the checksum.
///
-/// The checksum is the first four bytes of the sha256d of the data, concatenated onto the end.
+/// The checksum is the first four bytes of the `SHA256d` of the data, concatenated onto the end.
#[allow(clippy::missing_panics_doc)] // fmt::Write returns Result but String is infallible.
#[cfg(feature = "alloc")]
pub fn encode_check(data: &[u8]) -> String {
@@ -184,7 +184,7 @@ pub fn encode_check(data: &[u8]) -> String {
/// Encodes a slice as base58, including the checksum, into a formatter.
///
-/// The checksum is the first four bytes of the sha256d of the data, concatenated onto the end.
+/// The checksum is the first four bytes of the `SHA256d` of the data, concatenated onto the end.
///
/// # Errors
///
diff --git a/bitcoin/src/blockdata/constants.rs b/bitcoin/src/blockdata/constants.rs
index 66e6a8e4..0e4bd410 100644
--- a/bitcoin/src/blockdata/constants.rs
+++ b/bitcoin/src/blockdata/constants.rs
@@ -390,9 +390,9 @@ mod test {
fn chain_hash_and_genesis_block(network: Network) {
use hashes::sha256;
- // The genesis block hash is a double-sha256 and it is displayed backwards.
+ // The genesis block hash is a double-SHA256 and it is displayed backwards.
let genesis_hash = genesis_block(network).block_hash();
- // We abuse the sha256 hash here so we get a LowerHex impl that does not print the hex backwards.
+ // We abuse the SHA256 hash here so we get a LowerHex impl that does not print the hex backwards.
let hash = sha256::Hash::from_byte_array(genesis_hash.to_byte_array());
let want = format!("{:02x}", hash);
diff --git a/bitcoin/src/crypto/sighash.rs b/bitcoin/src/crypto/sighash.rs
index 9d1976e6..b49eb0f0 100644
--- a/bitcoin/src/crypto/sighash.rs
+++ b/bitcoin/src/crypto/sighash.rs
@@ -113,7 +113,7 @@ pub struct SighashCache<T: Borrow<Transaction>> {
/// Common cache for Taproot and SegWit inputs, `None` for legacy inputs.
common_cache: Option<CommonCache>,
- /// Cache for SegWit v0 inputs (the result of another round of sha256 on `common_cache`).
+ /// Cache for SegWit v0 inputs (the result of another round of SHA256 on `common_cache`).
segwit_cache: Option<SegwitCache>,
/// Cache for Taproot v1 inputs.
@@ -131,7 +131,7 @@ struct CommonCache {
outputs: sha256::Hash,
}
-/// Values cached for SegWit inputs, equivalent to [`CommonCache`] plus another round of `sha256`.
+/// Values cached for SegWit inputs, equivalent to [`CommonCache`] plus another round of SHA256.
#[derive(Debug, Clone)]
struct SegwitCache {
prevouts: sha256d::Hash,
diff --git a/bitcoin/src/hash_types.rs b/bitcoin/src/hash_types.rs
index cf754dff..e62c5d4d 100644
--- a/bitcoin/src/hash_types.rs
+++ b/bitcoin/src/hash_types.rs
@@ -17,14 +17,14 @@ mod tests {
use crate::{LegacySighash, SegwitV0Sighash, TapSighash, XKeyIdentifier};
#[rustfmt::skip]
- /// sha256d of the empty string
+ /// SHA256d of the empty string
const DUMMY32: [u8; 32] = [
0x5d, 0xf6, 0xe0, 0xe2, 0x76, 0x13, 0x59, 0xd3,
0x0a, 0x82, 0x75, 0x05, 0x8e, 0x29, 0x9f, 0xcc,
0x03, 0x81, 0x53, 0x45, 0x45, 0xf5, 0x5c, 0xf4,
0x3e, 0x41, 0x98, 0x3f, 0x5d, 0x4c, 0x94, 0x56,
];
- /// hash160 of the empty string
+ /// HASH160 of the empty string
#[rustfmt::skip]
const DUMMY20: [u8; 20] = [
0xb4, 0x72, 0xa2, 0x66, 0xd0, 0xbd, 0x89, 0xc1, 0x37, 0x06,
diff --git a/hashes/src/sha256/crypto/arm_sha2.rs b/hashes/src/sha256/crypto/arm_sha2.rs
index 81b57ddb..21bc67ee 100644
--- a/hashes/src/sha256/crypto/arm_sha2.rs
+++ b/hashes/src/sha256/crypto/arm_sha2.rs
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: CC0-1.0
-//! ARM sha2 intrinsics for sha256.
+//! ARM SHA2 intrinsics for SHA256.
#![allow(clippy::unreadable_literal)]
#![allow(clippy::cast_ptr_alignment)]
@@ -12,7 +12,7 @@ use core::arch::aarch64::{
vsha256hq_u32, vsha256su0q_u32, vsha256su1q_u32, vst1q_u32,
};
-/// Processes sha256 blocks using ARM SHA2 intrinsics.
+/// Processes SHA256 blocks using ARM SHA2 intrinsics.
#[target_feature(enable = "sha2")]
pub(super) unsafe fn process_blocks(state: &mut [u32; 8], blocks: &[u8]) {
// Code translated and based on from
diff --git a/hashes/src/sha256/crypto/x86_shani.rs b/hashes/src/sha256/crypto/x86_shani.rs
index 3bb25ced..137193a7 100644
--- a/hashes/src/sha256/crypto/x86_shani.rs
+++ b/hashes/src/sha256/crypto/x86_shani.rs
@@ -17,7 +17,7 @@ use core::arch::x86_64::{
_mm_shuffle_epi8, _mm_storeu_si128,
};
-/// Processes sha256 blocks using x86 SHA-NI intrinsics.
+/// Processes SHA256 blocks using x86 SHA-NI intrinsics.
#[target_feature(enable = "sha,sse2,ssse3,sse4.1")]
pub(super) unsafe fn process_blocks(state: &mut [u32; 8], blocks: &[u8]) {
// Code translated and based on from
diff --git a/hashes/src/sha256/mod.rs b/hashes/src/sha256/mod.rs
index c5687714..75c7f29f 100644
--- a/hashes/src/sha256/mod.rs
+++ b/hashes/src/sha256/mod.rs
@@ -55,14 +55,14 @@ impl Hash {
pub fn from_engine(e: HashEngine) -> Self {
let mut hash = e.midstate_unchecked().bytes;
if hash == [0; 32] {
- // Assume sha256 is secure and never generate 0-hashes (which represent invalid
+ // Assume SHA256 is secure and never generate 0-hashes (which represent invalid
// secp256k1 secret keys, causing downstream application breakage).
hash[0] = 1;
}
Hash(hash)
}
- /// Iterate the sha256 algorithm to turn a sha256 hash into a sha256d hash.
+ /// Iterate the SHA256 algorithm to turn a SHA256 hash into a `SHA256d` hash.
#[must_use]
pub fn hash_again(&self) -> sha256d::Hash { sha256d::Hash::from_byte_array(hash(&self.0).0) }
diff --git a/hashes/src/sha256/tests.rs b/hashes/src/sha256/tests.rs
index e31f3852..961b827b 100644
--- a/hashes/src/sha256/tests.rs
+++ b/hashes/src/sha256/tests.rs
@@ -114,7 +114,7 @@ fn midstate() {
#[test]
fn engine_with_state() {
// Test that a specific midstate results in a specific hash. Midstate was
- // obtained by applying sha256 to sha256("MuSig coefficient")||sha256("MuSig
+ // obtained by applying SHA256 to SHA256("MuSig coefficient")||SHA256("MuSig
// coefficient").
#[rustfmt::skip]
static MIDSTATE: [u8; 32] = [
diff --git a/hashes/src/sha256d/mod.rs b/hashes/src/sha256d/mod.rs
index cb36f5c7..8d864a9b 100644
--- a/hashes/src/sha256d/mod.rs
+++ b/hashes/src/sha256d/mod.rs
@@ -105,7 +105,7 @@ mod tests {
let manual_hash = sha256d::Hash::from_engine(engine);
assert_eq!(hash, manual_hash);
- // Hash by computing a sha256 then `hash_again`ing it
+ // Hash by computing a SHA256 then `hash_again`ing it
let sha2_hash = sha256::Hash::hash(test.input.as_bytes());
let sha2d_hash = sha2_hash.hash_again();
assert_eq!(hash, sha2d_hash);
diff --git a/hashes/src/sha256t/mod.rs b/hashes/src/sha256t/mod.rs
index 8b88e89f..f32ea591 100644
--- a/hashes/src/sha256t/mod.rs
+++ b/hashes/src/sha256t/mod.rs
@@ -203,7 +203,7 @@ mod tests {
108, 71, 99, 110, 96, 125, 179, 62, 234, 221, 198, 240, 201,
];
- // The digest created by sha256 hashing `&[0]` starting with `TEST_MIDSTATE`.
+ // The digest created by SHA256 hashing `&[0]` starting with `TEST_MIDSTATE`.
#[cfg(feature = "alloc")]
#[cfg(feature = "hex")]
const HASH_ZERO_BACKWARD: &str =
diff --git a/hashes/src/sha384/mod.rs b/hashes/src/sha384/mod.rs
index 5a5b0d72..712f1bf1 100644
--- a/hashes/src/sha384/mod.rs
+++ b/hashes/src/sha384/mod.rs
@@ -62,7 +62,7 @@ mod tests {
#[rustfmt::skip]
let tests = [
- // Examples from go sha384 tests.
+ // Examples from go SHA384 tests.
Test {
input: "",
output: [
diff --git a/hashes/src/sha3_256/mod.rs b/hashes/src/sha3_256/mod.rs
index 3328ddca..17ca3815 100644
--- a/hashes/src/sha3_256/mod.rs
+++ b/hashes/src/sha3_256/mod.rs
@@ -171,7 +171,7 @@ fn keccakf1600(state: &mut KeccakState) {
}
}
-/// Engine to compute the Sha3-256 hash function.
+/// Engine to compute the SHA3-256 hash function.
#[derive(Debug, Clone)]
pub struct HashEngine {
h: KeccakState,
@@ -184,7 +184,7 @@ impl Default for HashEngine {
}
impl HashEngine {
- /// Construct a new Sha3-256 hash engine.
+ /// Constructs a new SHA3-256 hash engine.
pub const fn new() -> Self {
Self { h: KeccakState::new(), bytes_hashed: 0, buffer: [0; RATE] }
}
diff --git a/hashes/src/sha512_256/mod.rs b/hashes/src/sha512_256/mod.rs
index 7854326e..fc70cfee 100644
--- a/hashes/src/sha512_256/mod.rs
+++ b/hashes/src/sha512_256/mod.rs
@@ -2,18 +2,18 @@
//! `SHA512_256` implementation.
//!
-//! SHA512/256 is a hash function that uses the sha512 algorithm but it truncates the output to 256
-//! bits. It has different initial constants than sha512 so it produces an entirely different hash
-//! compared to sha512. More information at <https://eprint.iacr.org/2010/548.pdf>.
+//! SHA512/256 is a hash function that uses the SHA512 algorithm but it truncates the output to 256
+//! bits. It has different initial constants than SHA512 so it produces an entirely different hash
+//! compared to SHA512. More information at <https://eprint.iacr.org/2010/548.pdf>.
use crate::sha512;
crate::internal_macros::general_hash_type! {
/// Output of the SHA512/256 hash function.
///
- /// SHA512/256 is a hash function that uses the sha512 algorithm but it truncates the output to
- /// 256 bits. It has different initial constants than sha512 so it produces an entirely
- /// different hash compared to sha512. More information at
+ /// SHA512/256 is a hash function that uses the SHA512 algorithm but it truncates the output to
+ /// 256 bits. It has different initial constants than SHA512 so it produces an entirely
+ /// different hash compared to SHA512. More information at
/// <https://eprint.iacr.org/2010/548.pdf>.
pub struct Hash([u8; 32]);
@@ -31,9 +31,9 @@ impl Hash {
/// Engine to compute SHA512/256 hash function.
///
-/// SHA512/256 is a hash function that uses the sha512 algorithm but it truncates the output to 256
-/// bits. It has different initial constants than sha512 so it produces an entirely different hash
-/// compared to sha512. More information at <https://eprint.iacr.org/2010/548.pdf>.
+/// SHA512/256 is a hash function that uses the SHA512 algorithm but it truncates the output to 256
+/// bits. It has different initial constants than SHA512 so it produces an entirely different hash
+/// compared to SHA512. More information at <https://eprint.iacr.org/2010/548.pdf>.
#[derive(Debug, Clone)]
pub struct HashEngine(sha512::HashEngine);
@@ -75,7 +75,7 @@ mod tests {
#[rustfmt::skip]
let tests = [
- // Examples from go sha512/256 tests.
+ // Examples from go SHA512/256 tests.
Test {
input: "",
output: [
diff --git a/hashes/tests/api.rs b/hashes/tests/api.rs
index eca69322..cd7ea484 100644
--- a/hashes/tests/api.rs
+++ b/hashes/tests/api.rs
@@ -22,7 +22,7 @@ use bitcoin_hashes::{
Sha512, Sha512_256, Siphash24,
};
-// Arbitrary midstate value; taken from as sha256t unit tests.
+// Arbitrary midstate value; taken from as SHA256t unit tests.
const TEST_MIDSTATE: [u8; 32] = [
156, 224, 228, 230, 124, 17, 108, 57, 56, 179, 202, 242, 195, 15, 80, 137, 211, 243, 147, 108,
71, 99, 110, 96, 125, 179, 62, 234, 221, 198, 240, 201,
@@ -34,7 +34,7 @@ sha256t_tag! {
struct Tag = raw(TEST_MIDSTATE, 64);
}
hash_newtype! {
- /// A concrete sha256t hash type so we don't have to use generics.
+ /// A concrete SHA256t hash type so we don't have to use generics.
#[derive(Debug)]
struct TaggedHash(sha256t::Hash<Tag>);
}
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.