X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 09 Mar 2015 02:49 PM by  anon
Hardware Random Number Generator
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
09 Mar 2015 02:49 PM
    Hello-- I've recently purchased and set up a hardware random number generator (the TrueRNG2 from ubld.it) which generates random numbers for the entropy pool on a linux machine. The random number functions in IDL (e.g. randomu(seed)) can only generate pseudo-random numbers from IDL's hard-coded algorithm, correct? How can I have IDL (i.e. what function should I use to) construct random numbers from the computer's entropy pool or even from pre-existing random number generators built into linux? --Carter Chamberlain Astrophysics Graduate Student at Virginia Tech

    Deleted User



    New Member


    Posts:21
    New Member


    --
    10 Mar 2015 10:23 AM
    Hi Carter, The easiest approach would be to write a simple C-code wrapper that calls out to either your hardware or your other random number generators. Just as an aside - since IDL now uses the Mersenne twister algorithm for its random numbers, you probably won't need to use any of the Linux pre-existing generators since they won't necessarily be any "better". But of course your hardware generator will be the best. I would check out the API for the TrueRNG2 and see how to call it from C code. It's fairly straightforward to write an IDL wrapper to C code. Worse case, if that's too complicated, you could just use SPAWN to call out to the TrueRNG2 program and cache the random numbers in a file to be retrieved by IDL. Either approach will work fine. Cheers, Chris

    Deleted User



    New Member


    Posts:
    New Member


    --
    10 Mar 2015 01:43 PM
    Thanks for the suggestion, Chris, but I solved my problem an even simpler way: Apparently, Linux created a "file" (and I use that term loosely) in /dev/urandom for this very purpose. It technically has a size of zero bytes, but reading from it produces binary data directly from the machine's entropy pool which is fed by the TrueRNG2 device as well as other processes built into Linux. Essentially, you can acquire true random numbers (if you have a hardware RNG) in IDL by reading from this file. I initially tried using read_binary(1,data_type=1,data_dims=4) to read four bytes from the file and convert them into an unsigned float between 0 and 1, but I immediately got the message: % READ_BINARY: The file to be read has zero length. IDL was a little too smart for its own good, not realizing that the "file" is a link to the machine's entropy pool, and that the filesize is practially infinite since the pool replenishes itself as it is used. Unfortunately, IDL sees that the filesize is zero and doesn't even try to read it. Java and C don't seem to have this problem, though. The second thing I tried was readu,1,randomBytes, which worked fine. File I/O is usually the least efficient part of a program, but I think reading from /dev/urandom is the best option. --Carter
    You are not authorized to post a reply.