test: rename k1/k2 to k0/k1 in `SipHash` consistency tests
What changed, and why it matters
This is a minor cleanup of a test file. It renames local variables from k1/k2 to k0/k1 to match how the rest of the codebase labels SipHash key halves, and slightly reorders the test code for readability. There is no change to production code or to what the test actually checks.
No security action needed. This is a non-functional test refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies only src/test/hash_tests.cpp in the siphash BOOST_AUTO_TEST_CASE. It renames two local uint64_t variables from k1/k2 to k0/k1, matching the parameter names used by CSipHasher, SipHashUint256, and SipHashUint256Extra. It also splits the single-parameter SipHashUint256 check from the extra-nonce SipHashUint256Extra check and adds a TODO comment noting a follow-up commit will modify these lines. No functional behavior changes; the same random keys and data are fed to the same functions and the same BOOST_CHECK_EQUAL assertions are performed.
Changed components
src/test/hash_tests.cppInspect captured patch +8 / −6
diff --git a/src/test/hash_tests.cpp b/src/test/hash_tests.cpp
index 2fe44960..46901893 100644
--- a/src/test/hash_tests.cpp
+++ b/src/test/hash_tests.cpp
@@ -133,18 +133,20 @@ BOOST_AUTO_TEST_CASE(siphash)
// Check consistency between CSipHasher and SipHashUint256[Extra].
FastRandomContext ctx;
for (int i = 0; i < 16; ++i) {
+ uint64_t k0 = ctx.rand64();
uint64_t k1 = ctx.rand64();
- uint64_t k2 = ctx.rand64();
uint256 x = m_rng.rand256();
+
+ CSipHasher sip256(k0, k1);
+ sip256.Write(x);
+ BOOST_CHECK_EQUAL(SipHashUint256(k0, k1, x), sip256.Finalize()); // TODO modified in follow-up commit
+
+ CSipHasher sip288 = sip256;
uint32_t n = ctx.rand32();
uint8_t nb[4];
WriteLE32(nb, n);
- CSipHasher sip256(k1, k2);
- sip256.Write(x);
- CSipHasher sip288 = sip256;
sip288.Write(nb);
- BOOST_CHECK_EQUAL(SipHashUint256(k1, k2, x), sip256.Finalize());
- BOOST_CHECK_EQUAL(SipHashUint256Extra(k1, k2, x, n), sip288.Finalize());
+ BOOST_CHECK_EQUAL(SipHashUint256Extra(k0, k1, x, n), sip288.Finalize()); // TODO modified in follow-up commit
}
}
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.