Although typicalRandomConstant has // DO NOT MODIFY comment, it should have extra comments about how it is used to prevent users from modifying it without understanding the implications.
Finding ID: NCC-E003763-27A
Details:
We only store 64-bit seed to reduce storage.
CircleHash64f only supports 64-bit seed and is the default noncryptographic hash, so it isn't affected by this issue.
CircleHash64fx and Siphash supports 128-bit seed and are not currently used by Atree.
typicalRandomConst can be used by hashes with 128-bit seeds if they don't use 64bit->128-bit seed expansion function or a different const.
Suggested Solution
Before:
// typicalRandomConstant is a 64-bit value that has qualities
// of a typical random value (e.g. hamming weight, number of
// consecutive groups of 1-bits, etc.) so it can be useful as
// a const part of a seed, round constant inside a permutation, etc.
typicalRandomConstant = uint64(0x1BD11BDAA9FC1A22) // DO NOT MODIFY
After:
// typicalRandomConstant is a 64-bit value that has qualities
// of a typical random value (e.g. hamming weight, number of
// consecutive groups of 1-bits, etc.) so it can be useful as
// a const part of a seed, round constant inside a permutation, etc.
// CAUTION: We only store 64-bit seed, so some hashes with 64-bit seed like
// CircleHash64f don't use this const. However, other hashes such as
// CircleHash64fx and SipHash might use this const as part of their
// 128-bit seed (when they don't use 64-bit -> 128-bit seed expansion func).
typicalRandomConstant = uint64(0x1BD11BDAA9FC1A22) // DO NOT MODIFY
Issue To Be Solved
Although
typicalRandomConstant
has// DO NOT MODIFY
comment, it should have extra comments about how it is used to prevent users from modifying it without understanding the implications.Finding ID: NCC-E003763-27A
Details:
typicalRandomConst
can be used by hashes with 128-bit seeds if they don't use64bit->128-bit
seed expansion function or a different const.Suggested Solution
Before:
After: