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

I don't know what your original tutorial said. There's many ways to do this problem.

> maybe you know the word I need to search for, it was something like using every two or three bits and anding or xoring them or whatever to magically erase any bias present in the shot noise, yielding a perfectly uniform distribution of 1s and 0s.

I forgot the name of this technique as well. Its rather simple: take the bitstream and look at it pairwise, you have 4 options:

* 00 -- Throw away

* 11 -- Throw away

* 01 -- output 1

* 10 -- output 0

That's it. This always removes bias and returns a random 0 or 1 bit regardless of how biased the RNG is. 50% of outputs will be 0, and 50% of outputs will be 1.

However, you're being "too smart for your own good" if you go down this route. A perfectly unbiased input would still have 50% of its inputs rejected, and already you've dropped the speed of the RNG by 50%.

IMO: Signal processing is more obviously clean. Ultimately, you need to use analog techniques to finesse the white noise if you wanted to have assurances to the reliability of your RNG. You need to "clean up" the signal if you want the ADC / Input Pins to reliably read the data anyway, so making the analog circuitry a little bit more difficult (and maybe $1 more expensive) isn't a big deal.

---------

I'd take the white-noise as a voltage-signal, and send it into a bandpass filter or a simple "notch" filter, lets say with 10MHz to 11MHz (named: filterA).

filterA is then averaged across the last 100kHz (aka: 10 microseconds), which is just a simple low-pass filter (named: filterB).

Finally: you compare filterA vs filterB (simple voltage comparator): filterA > filterB == 1, and filterA < filterB == 0.

You'd safely be able to sample the data at 10MHz, or generate one bit every 100 nanoseconds. It'd be as simple as digitalRead(inPin) in Arduino (as long as the comparator outputs the voltage that's compatible with Arduino. You may need a level converter depending on how your comparator works).

Bandpass filters are a complex subject of op-amps in of themselves, but are necessary parts of circuit design. The sooner you (and your students) are familiar with filter designs, the better.

------------

There might be some slight bias still (ex: if temperature is rising over time, or reducing over time), but I don't think there would be major amounts of bias. So bias-removal is still going to be useful. But don't use the technique described earlier: instead just AES-encrypt the input bits and then xor-it.



> However, you're being "too smart for your own good" if you go down this route. A perfectly unbiased input would still have 50% of its inputs rejected, and already you've dropped the speed of the RNG by 50%.

To improve this situation you can use an additional trick: keep track of the sequence of thrown-away pairs, and look at them again in consecutive pairs, and generate some more random bits:

* 00 00 -- throw away

* 11 11 -- throw away

* 00 11 -- output 1

* 11 00 -- output 0

and so on..

see the paper "Iterating Von Neumann's Procedure for Extracting Random Bits" for details.




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

Search: