onflow / atree

Atree provides scalable arrays and scalable ordered maps.
https://onflow.org
Apache License 2.0
40 stars 16 forks source link

Add extra comment for typicalRandomConstant (NCC-E003763-27A) #258

Closed fxamacker closed 2 years ago

fxamacker commented 2 years ago

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:

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