4
$\begingroup$

I am testing a theoretical hash function, $f()$, which produces n-bits of output.

By the pigeon hole principle, if I run $f(x)$ over a search space of $1+2^n$ values, I will get at least one collision. According to the birthday problem I should get many more collisions than that.

Is there a similar principle that I can determine how many values of $x$ will be needed to ensure with high probability that I have produced all possible $2^n$ values of $f(x)$?

I'm relatively certain that there is no 100% guarantee of obtaining all values, but at least an approximation within a degree of confidence should be possible. Are these approximations only practical when considering specific hashing algorithms?

$\endgroup$
  • 3
    $\begingroup$ Belongs on Crypto SE? $\endgroup$ – Bryan Field Nov 21 '16 at 15:29
  • 1
    $\begingroup$ Uhm, why are you testing a theoretical hash function? Are you a security researcher? If not, it might be prudent to stick to existing hash functions. $\endgroup$ – Pascal Nov 21 '16 at 15:29
  • $\begingroup$ Related: security.stackexchange.com/questions/107081/… $\endgroup$ – Wumpus Q. Wumbley Nov 21 '16 at 16:45
  • $\begingroup$ en.wikipedia.org/wiki/… ​ ​ $\endgroup$ – user991 Nov 21 '16 at 16:58
5
$\begingroup$

If $f()$ can be modeled as a random function (that is, if each output for a distinct input is independent of all other outputs), then this is a well studied problem in probability theory, known as the Coupon Collector's Problem.

The link I gave you gives more details; the bottom line is that you start getting good probability of seeing all possible sequences after around $C n 2^n$, for a constant $C$ not too far from 1 (and whose actual value depends on what "good probability" actually is).

Of course, if your theoretical hash function doesn't act randomly (for example, there are pairs of inputs $A \ne B$ where we're guarranteed that $f(A) \ne f(B)$), this analysis does not apply.

$\endgroup$

Your Answer

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