5

Are values hashed using KECCAK - 256 uniformly distributed? If I use a KECCAK - 256 hash and then convert it to a number in a range 0 - N using the modulo operation, would the probability of obtaining any of the numbers in this range be equal to 1/N, or would there be a deviation from the ideal distribution?

6

I came across this paper that looks at using Keccak-256 (the original one that Ethereum uses, not SHA3) as a PRNG. It subjects the output of the hash to a large number of tests of randomness and it passes them all.

Conclusion:

The experimental results show the KECCAK hash function has excellent pseudo randomness, and its security shows that it can be utilized to generate pseudorandom bit sequences.

According to the test results, the sequence of bits generated by applying Keccak-256 to successive integers is indistinguishable from random, and thus your modulo approach ought to be fine - i.e. uniformly distributed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.