mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-12 21:52:53 +02:00
test: add shared SipHash vectors
Lock SipHash-2-4 behavior into shared vectors before refactoring its round and finalization code. Store inputs as ordered hex byte blocks so `CSipHasher` and the independent Python implementation hash the same byte sequence, with applicable `PresaltedSipHasher` overloads checked against the same vectors. Add the 64 official SipHash-2-4 vectors alongside block-partition and empty-block cases for the generic path. Move randomized generic/fixed comparisons to the integer fuzzer. SipHash-1-3-UJ coverage can add expected outputs for compatible 8- and 32-byte block sequences. The Python test reads a build-tree copy so functional-test staging behaves consistently when files are symlinked or copied. Co-authored-by: Pieter Wuille <pieter@wuille.net>
This commit is contained in:
@@ -67,6 +67,7 @@ FUZZ_TARGET(integer, .init = initialize_integer)
|
||||
// ConsumeIntegral<char>() instead of casting from {u,}int8_t.
|
||||
const char ch = fuzzed_data_provider.ConsumeIntegral<char>();
|
||||
const bool b = fuzzed_data_provider.ConsumeBool();
|
||||
const uint64_t u64_2{fuzzed_data_provider.ConsumeIntegral<uint64_t>()};
|
||||
|
||||
const Consensus::Params& consensus_params = Params().GetConsensus();
|
||||
(void)CheckProofOfWorkImpl(u256, u32, consensus_params);
|
||||
@@ -118,8 +119,16 @@ FUZZ_TARGET(integer, .init = initialize_integer)
|
||||
}
|
||||
(void)MillisToTimeval(i64);
|
||||
(void)SighashToStr(uch);
|
||||
(void)PresaltedSipHasher(u64, u64)(u256);
|
||||
(void)PresaltedSipHasher(u64, u64)(u256, u32);
|
||||
{
|
||||
CSipHasher hasher{u64, u64_2};
|
||||
const PresaltedSipHasher presalted_hasher{u64, u64_2};
|
||||
hasher.Write(u256);
|
||||
assert(presalted_hasher(u256) == hasher.Finalize());
|
||||
uint8_t extra[4]{};
|
||||
WriteLE32(extra, u32);
|
||||
hasher.Write(extra);
|
||||
assert(presalted_hasher(u256, u32) == hasher.Finalize());
|
||||
}
|
||||
(void)ToLower(ch);
|
||||
(void)ToUpper(ch);
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user