Electronics > Projects, Designs, and Technical Stuff

TRNG Tinkering

(1/2) > >>

Dabbot:
Here's my try at a TRNG. Note this is not for any larger endeavor. I'm merely pulling at the threads of entropy for further understanding.

The majority of the circuit (attached) is an LM324 amplifying it's own noise, which is fed into a basic PIC micro for packaging and shipping. Initially I was simply collecting the LSB from each ADC sample, but it produced a fair amount of bias. I tried a chip with a 10 bit ADC and got similar results.

So I wrote a program which generates each random bit by comparing the ADC sample to a pre-calculated threshold, effectively using the ADC as a comparator. But this on its own is not enough. So the program also keeps track of bias and adjusts a PWM accordingly, giving the noise circuit's virtual ground a very slight nudge until it's about balanced.

The result is a bit stream which still has small localised bias, but tends toward a perfect 50/50 as more is collected. It's also important to note there is no post processing done on the bit stream (whitening / von Neumann etc.). I use a couple of Python scripts to do some very basic analysis on the output (tally bits & hex characters, basic patterns). Nothing approaching the diehard tests, which requires a few GB of sample data and me knowing where to start with them.

magic:

--- Quote from: Dabbot on July 08, 2020, 05:10:52 am ---effectively using the ADC as a comparator

--- End quote ---
Use one opamp as comparator, lowpass-filter its output to drive the threshold, throw the PIC to trash :P

RoGeorge:
If you need digital noise and have a microcontroller, you can use Von Neumann debiasing algorithm (Von Neumann Extractor) to make sure the ratio between the 0s and 1s is kept 50/50.

From there, by integration you can get any shape you want for a custom probability distribution.

Dabbot:

--- Quote from: magic on July 08, 2020, 06:18:35 am ---Use one opamp as comparator, lowpass-filter its output to drive the threshold, throw the PIC to trash :P

--- End quote ---

I like your thinking. I'm going to try this.  :D

Edit: No good. The circuit oscillates. Decreasing the gain only causes it to oscillate less vigorously.

magic:
Well, an analog solution has the further disadvantage that you will never get it to output 50/50 unless you get offset voltages perfectly right.

If you want to play with it, be sure to include some hysteresis (positive feedback) in the comparator. The threshold regulator will react immediately to every bit from the comparator (with a slew rate dependent on the RC filter, but with zero delay). To avoid oscillation, the comparator needs to be prevented from reacting to that threshold correction before the analog input signal has a chance of toggling it a few times.

At least that's how I feel about it.

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod