Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Take the biased source and run it through a cryptographic hash. As long as the input contains more bits of entropy than the length of the output, the result will be essentially 100% random.


Cool, I think this explains it. What crytographic hashes are available that take a limited stream of bits over time and generate an arbitrary number of bits when requested?


Real CSPRNG designs are a bit more complex, having at least a state (like a hash function) but also an output mechanism to let it generate more bits.

One way to do that is to “compress” all your input entropy into a single state, and then use that as the key for a stream cipher, like AESCTR or Salsa20.


Hashes always generate a fixed-size output (that's the definition of a hash). So if you have a hash with an n-bit output, you run it on an input of m>=n bits to get n random bits, then repeat that process as necessary. You choose m so that it contains >= n bits of entropy. When it doubt, overestimate m.

You can also "seed" subsequent round of the has with the output from the previous round. That helps protect against certain kinds of failures. It's not really necessary, but it's not hard to do either so you might as well do it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: