Refactor and clean up the SHA256 x86 SHANI implementation to improve code safety, readability, and consistency without any functional or behavioral changes.
Motivation
This patch improves long-term maintainability and compiler compatibility of the SHANI-optimized SHA256 implementation used in Bitcoin Core. It replaces C-style casts with reinterpret_cast to enforce type safety, ensures consistent use of static ALWAYS_INLINE linkage for internal helper functions, and converts static constants to constexpr for guaranteed compile-time initialization.
Benefits
Improves type safety and avoids undefined behavior across compilers.
Makes the code consistent with modern C++ conventions used elsewhere in the crypto module.
Ensures that constants are resolved at compile time, reducing startup cost.
No changes to hashing logic or results — verified against existing SHA256 test vectors.
Testing
All SHA256 and SHA256D64 test vectors in src/test/crypto_tests.cpp were re-run. Results are bit-for-bit identical with the pre-refactor implementation.
Scope
This PR is limited to code cleanup and refactor only. No logic, algorithm, or performance behavior has been altered.