<div dir="ltr"><div><div class="gmail_extra">For any given TRNG, if we understand it's theoretical operation, and can model the real devices well, we can accurately estimate the entropy coming from the device.  This is key for monitoring it's health.<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">There is no such thing as an unbiased TRNG.  Any TRNG that passes the Dieharder tests directly is cheating by "whitening" bits before you see them.  If the manufacturer does not specify how this is done, you should be worried!</div><div class="gmail_extra"><br></div><div class="gmail_extra">"Entropy" per bit is a term we abuse here, but unfortunately, it's widespread.  It simply means the log base 2 of one over the probability of being bit's value:<br></div></div><div><br></div><div>    E(bit) = log2(1/P(bit))</div><div><br></div><div>The entropy of a sequence is the sum of the entropies of the bit.  The outcome of a fair coin has probability 1/2.  For a coin flip, the entropy of heads is 1 bit, as is the entropy for tails, so it's always 1 bit.<div><div><br></div><div>Measuring bits of entropy of a sequence can be done accurately given an accurate model for the probability of the next bit given all the previous bits.  For a biased coin, we can do this easily.  For example, what do we get when a biased coin has probability of coming up heads P(H) = 1/4, and we see the sequence HH?<br></div><div><br></div><div>    P(H) = 1/4</div><div>    P(HH) = 1/4 * 1/4 = 1/16</div><div>    E(HH) = log2(1/(1/16)) = log2(16) = 4<br></div><div><br></div><div>The entropy in TT is lower:</div><div><br></div><div>    P(T) = 3/4</div><div>    P(TT) = 9/16</div><div>    E(TT) = log2(16/9) = 4 - 2*log2(3) = 0.839</div><div><br></div><div>We can add bits of entropy for independent outcomes.  So, E(HH) = E(H) + E(H).  For a fair coin, this is just 1 + 1 = 2.  For our biased coin above, it's 2 + 2 = 4.  For the biased coin, E(TT) = E(T) + E(T) = log2(4/3) + log2(4/3) = log2(4) - log2(3) + log2(4) - log2(3) = 2 - log2(3) 2 - log2(3) = 4 - 2*log2(3) = 0.839.</div><div><br></div><div>We can use this same mathematical model for entropy for correlated outcomes.  For example, if the probability of the next coin flip being the same as the previous is 1/4, and the probability of heads or tails is even for the first flip, then P(HH) = 1/2 * 1/4 = 1/8.  This would be 3 bits of entropy.</div></div><div><br></div><div>This model works _exactly_ for any sequence of bits from _any_ TRNG.  How cool is that?  All you need is the _exact_ model of operation that describes the probability of the next bit being 1, given all prior history of output bits.</div><div><br></div><div class="gmail_extra">For any given TRNG, if we understand it's theoretical operation well, and can model the real devices well, we can accurately estimate the entropy coming from the device.  For a TRNG which is a true coin flip, the answer is 1 bit per flip.  For an Infinite Noise Multiplier with a gain between 1 and 2, the entropy per bit is log2(gain).  This enables a simple way to monitor the health of the TRNG.  If the estimated entropy deviates significantly from the expected entropy per bit for a long sequence, then there's probably something wrong.</div><div class="gmail_extra"><br></div><div class="gmail_extra">A serious limitation of most other TRNGs is that the entropy per bit is highly dependent on process variation, temperature, and the cycle of the moon ;-)   However, with care, you can still do the health monitoring trick.  For example, with the OneRNG, which uses finicky zener avalanche noise, you get high correlation between outputs if they are measured with low time between samples, but if there should be little correlation if the time between samples is long.  We can model the output for long delays between samples as a biased coin, produce a bunch of bits with high delay, and estimate it's entropy using the biased coin model.  This number should not change rapidly over time, which is something we can monitor, and we can raise a red flag if there is a sudden change.</div><div class="gmail_extra"><br></div><div class="gmail_extra">As for post-process whitening, it's a very good thing.  For example, we can convert a sequence of highly biased coin flips, where the coin flips generate only 1/2 bit per flip, into a sequence of entirely random bits 1/2 the length.  Simply feed the sequence into a CPRNG, and wham - you get true random bits on the output, at 1/2 the rate.</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div></div></div>