I have just published a new library that uses the jitter associated with the watch dog timer and timer one on an arduino to generate truly random numbers. Preliminary testing indicates that this library generates random sequences with far greater entropy and uniformity than either the randomSeed(analogRead(0)) method or the TrueRandom library which demonstrably does not generate true random numbers.

I would like folks to download and test the software for defects. While I have tested the software and the algorithms used on all current arduino hardware, UNO (dip and smd), MEGA (R3), and the 32u4 used in the leonardo, I would like to obtain test data from as many different examples of these chips as possible. To that end I would appreciate any an all folks emailing me (at wandrson01 at gmail.com) with screen captures of the following sketch, along with the type of arduino used (UNO, MEGA, LEONARDO, etc... along with indication if the chip is a smd or dip version). To be statistically significant the samples need to contain at least 25,000 lines of capture (a few hours run time), but 250,000 (a day and a half) would be even better. I will collect the results from these samples and publish the statistical performance on the libraries web site.

While it appears that the library is producing cryptographically useful random numbers, the test data needs to be from a much larger sample to verify that. Here is the test script I need run to collect these samples:

// Generate_Random_Numbers - This sketch makes use of the Entropy library// to produce a serial of random 8 bit integers (bytes) that are streamed// to the serial port of the arduino//// Copyright 2012 by Walter Anderson//// This file is part of Entropy, an Arduino library.// Entropy is free software: you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation, either version 3 of the License, or// (at your option) any later version.//// Entropy is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with Entropy. If not, see <http://www.gnu.org/licenses/>.

#include <Entropy.h>

void setup(){ Serial.begin(115200);

// This routine sets up the watch dog timer with interrupt handler to maintain a // pool of real entropy for use in sketches. This mechanism is relatively slow // since it will only produce a little less than two 32-bit random values per // second. Entropy.Initialize();

}

void loop(){ // When the random method is called with a single integer parameter it will return // a random integer that is in the range: 0 <= random_value < integer parameter Serial.println(Entropy.random());}

Thank you. I chose the ascii data format for two reasons. One, it avoided any issues with platform specific binary storage formats, which shouldn't matter if the data is truly random, but if not could introduce bias. And secondly, I wanted it easy for everyone to see what data they were providing me, so it was clear that it wasn't a virus or such.

Feel free to use a zip or other archiving program to compress the ascii file when you email it. Thanks!

New true random number library available at: http://code.google.com/p/avr-hardware-random-number-generation/

I've got a clone mega 2560 I'll set up soon. But before I do I might try and find a standalone serial app, don't want to use the IDE serial monitor.

EDIT: Is running now, I have at least 48 hours I can donate to this.

I use minicom on my linux boxes to perform the screen captures. On windows, older versions will have hyper terminal which would work, new versions of windows could make use of bray's terminal to perform that function. Also bray's is very useful for other arduino related communication

It looks like the initialization code for the library will need some device specific modifcations. The errors I received when I tried to load it to the one ATtiny85 I have indicate that some of the registers I use for the library have different names for the tiny85, WDTCSR -> WDTCR and TCNT1L -> TCNT1

I will try and get the library modified to take that into account this weekend.

New true random number library available at: http://code.google.com/p/avr-hardware-random-number-generation/

Thank you for the information on the WDT device independent information. Would you provide some more information on why you would suggest using TMR0 on the ATtiny85? I haven't run any of my raw WDT tests on that chip, but noticed that it does have an 8-bit timer1. Since TMR0 on the standard Arduino's showed some potential bias problems, which as we have discussed, is probably due to TMR0 being used for an interrupt to maintain micros, etc.. I assumed that would be a similar problem on your ATtiny85 core (I haven't looked at your core code in any detail).

Also, I posted this question in the Programming forum, but I had some difficulty getting my #ifdef to recognize the ATtiny85 was being compiled for... I would appreciate advice on how to address that issue.

Walt

New true random number library available at: http://code.google.com/p/avr-hardware-random-number-generation/

Well with CodingBadly's assistance I have compiled the library and am testing it on an ATTiny85, specifically, I had a Sparkfun AVR Stick (http://www.sparkfun.com/products/9147) which I am running the same test sketch as above on. The stick and an FTDI cable was all I needed. In 36-48 hours I should have a sample dataset from the ATtiny, using CodingBadly's core for that machine.

If someone wants to try this with the ATtiny85, I am attaching the one library file that needed to change. The file is also on the google code page, but I haven't updated the zip file there yet.