File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change 1111#include "libsecp256k1-config.h"
1212#endif
1313
14- /** Seed the pseudorandom number generator. */
14+ /* A non-cryptographic RNG used only for test infrastructure. */
15+
16+ /** Seed the pseudorandom number generator for testing. */
1517SECP256K1_INLINE static void secp256k1_rand_seed (uint64_t v );
1618
1719/** Generate a pseudorandom 32-bit number. */
Original file line number Diff line number Diff line change @@ -18,15 +18,19 @@ SECP256K1_INLINE static void secp256k1_rand_seed(uint64_t v) {
1818 secp256k1_Rz = v >> 32 ;
1919 secp256k1_Rw = v ;
2020
21+ /* There are two seeds with short (length 1) cycles for the Rz PRNG. */
2122 if (secp256k1_Rz == 0 || secp256k1_Rz == 0x9068ffffU ) {
2223 secp256k1_Rz = 111 ;
2324 }
24- if (secp256k1_Rw == 0 || secp256k1_Rw == 0x464fffffU ) {
25+ /* There are four seeds with short (length 1) cycles for the Rw PRNG. */
26+ if (secp256k1_Rw == 0 || secp256k1_Rw == 0x464fffffU ||
27+ secp256k1_Rw == 0x8c9ffffeU || secp256k1_Rw == 0xd2effffdU ) {
2528 secp256k1_Rw = 111 ;
2629 }
2730}
2831
2932SECP256K1_INLINE static uint32_t secp256k1_rand32 (void ) {
33+ /* MWC PRNG for tests. */
3034 secp256k1_Rz = 36969 * (secp256k1_Rz & 0xFFFF ) + (secp256k1_Rz >> 16 );
3135 secp256k1_Rw = 18000 * (secp256k1_Rw & 0xFFFF ) + (secp256k1_Rw >> 16 );
3236 return (secp256k1_Rw << 16 ) + (secp256k1_Rw >> 16 ) + secp256k1_Rz ;
You can’t perform that action at this time.
0 commit comments