Shop OBEX P1 Docs P2 Docs Learn Events
Have any of the Propeller-based True Random Number generators been tested? — Parallax Forums

Have any of the Propeller-based True Random Number generators been tested?

ElectricAyeElectricAye Posts: 4,561
edited 2013-09-30 14:46 in Propeller 1
Have any of the Propeller-based True Random Number generators been tested and shown to be truly random? I've been googling for answers to that question, and though I've found lots of discussion about true random number generation using the Propeller with various objects, I haven't seen anyone mention that the outputs have been tested against any standards.

I've seen circuits on the internet that use transistors in avalanche mode, etc. and they seem fairly simple, and then their outputs are run through a PIC or Arduino to clean up any drifts, bias, etc., so it seems this would be easy for the Propeller, but I also read that the Propeller's internal circuits could provide randomness that could be filtered via software in a similar manner. I just haven't found any mention of these outputs actually passing any randomness tests.

Anyone know?

Thanks.

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-09-30 09:03
    I believe that RealRandom uses Von Neumann bias correction, which is known to be rock-solid (albeit with non-deterministic wait times), assuming the physical samples are independent. Beyond that, I don't know if any more rigorous testing has been done. The few times I've used it, it's just been to generate a random seed for the pseudo-random number generator.

    -Phil
  • ElectricAyeElectricAye Posts: 4,561
    edited 2013-09-30 09:27
    ...The few times I've used it, it's just been to generate a random seed for the pseudo-random number generator.

    -Phil

    Thanks, Phil.

    Hey, that reminds me of another question. Is there any danger of a truly random seed inserted into a pseudo-random number generator resulting in a non-random output? Or are you somehow guaranteed that the pseudo-random number generator can't possibly add order to a completely disordered input?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-09-30 09:37
    The only reason for using a random seed is so the program doesn't generate the same results every time it's run. From that point on, the output is only as good (or bad) as the pseudo-random number generator itself. The one used by Spin is invariant as to starting point, as it cycles through all 232 - 1 longs anyway before starting over.

    -Phil
  • Heater.Heater. Posts: 21,230
    edited 2013-09-30 10:39
    ElectricAye,

    This is a fascinating subject, let's see what we can do...
    Have any of the Propeller-based True Random Number generators been tested and shown to be truly random?
    First of all it is impossible to prove conclusively that any set of numbers was produced randomly. That is to say, you can analyse the output of of a Propeller random number generator, or any other, until you are blue in the face and never be really sure it was randomly generated.

    What you can do is apply a bunch of tests to your set of "random" numbers that show that they have a similar statistical distribution of various properties as you would expect from "real" randomness. For example: You might check that there is an equal number of zeros and ones in a binary output. You might check that the numer of consequtive ones (or zeros) follows the expected pattern. And many other things.

    One such set of tests is quite famous and was developed by the mathematician George Marsaglia, the "Diehard" test suite. http://www.stat.fsu.edu/pub/diehard/ This has since been built upon to the "dieharder" tests by Robert Brown http://www.phy.duke.edu/~rgb/General/dieharder.php.

    Now, if you search the Parallax forums back a few years ago you will find a discussion of the Prop's real random number generator where I subjected it's output to these tests. The tests declared that it may well be random!

    Then there was forum member Cessnapilot who was also into testing this and came up with his "BUST" tests that could be run on the Propeller itself: http://forums.parallax.com/showthread.php/115936-How-to-check-the-TRUE-randomness-(of-Prop-for-example)-with-BUST-in-SPIN

    My conclusion was that the Propeller real random number generator was as good as the transistors in avalanche circuits. According to the tests I mentioned above.

    Note: The Spin random operator fails the above tests badly.
    Is there any danger of a truly random seed inserted into a pseudo-random number generator resulting in a non-random output?
    Never mind danger, it's certain, the pseudo-random number generator will always fail the above tests of randomness very badly. As I just mentioned above.

    Pseudo random number generators are called "pseudo" for a reason. They are totally deterministic logic circuits or algorithms that produce a sequence of numbers with some statistical properties of randomness. With the same seed they always produce the same sequence. They are never in anyway random.
  • ElectricAyeElectricAye Posts: 4,561
    edited 2013-09-30 10:53
    Heater. wrote: »
    ....
    Now, if you search the Parallax forums back a few years ago you will find a discussion of the Prop's real random number generator where I subjected it's output to these tests. The tests declared that it may well be random!... My conclusion was that the Propeller real random number generator was as good as the transistors in avalanche circuits. According to the tests I mentioned above.
    ....

    Heater,
    that's great to hear. I was hoping one of them had been tested and passed. But do you recall exactly which object it was you tested?

    Heater. wrote: »
    ......... the pseudo-random number generator will always fail the above tests of randomness very badly. ... With the same seed they always produce the same sequence. They are never in anyway random.

    Yes, I know that pseudo-random number generators by themselves can not produce true randomness. What I was wondering about in my side question was whether pseudo-random number generators could take a random input and somehow inflict non-randomness into it. For example, I know analog random number/event generators can suffer from the harmonics of their detector thresholds inserting a non-random component into otherwise random inputs, so I was wondering if a digitally-based pseudo-random number generator might do the same. I was merely curious about that case, since it makes no practical sense to take a signal you know is random and cram it through a pseudo-random number generator you're not quite sure about.

    Thanks for your insights on this. I really know very little about RNGs, etc.
  • KeithEKeithE Posts: 957
    edited 2013-09-30 11:11
    >it makes no practical sense to take a signal you know is random and cram it through a pseudo-random number generator you're not quite sure about

    I think that Intel's RdRand runs the numbers through AES to "whiten" them. You might find a search for RdRand interesting given all of the recent news. Also NIST has some test suites and papers about them on their site.
  • Heater.Heater. Posts: 21,230
    edited 2013-09-30 11:29
    ElectricAye,
    But do you recall exactly which object it was you tested?
    I would not worry about it. I gave you the links to the Diehard, Dieharder and BUST tests. Download them and get them running. Then get those Propeller objects you have in mind and test them for yourself. It's a fascinating thing to do for yourself. And you should never take anyones word for such things.
    What I was wondering about in my side question was whether pseudo-random number generators could take a random input and somehow inflict non-randomness into it.
    But that's exactly what they do! Starting from a seed they produce a sequence. Always the same sequence for the same seed. It's interesting to run the output of pseudo-random number generators through the tests mentioned above. They can fail really badly.

    KeithE,
    Yes, Intel's RdRand is compromised by the NSA: http://blog.jim.com/crypto/rdrand.html

    Actually that may or may not be true. It does not matter. When it comes down to cryptography you can trust no one. So why trust Intel?
  • jazzedjazzed Posts: 11,803
    edited 2013-09-30 11:39
    Heater you should trust Microsoft ;)
  • Heater.Heater. Posts: 21,230
    edited 2013-09-30 12:01
    Jazzed,
    Heater you should trust Microsoft
    Oh but I do. I trust Microsoft to try and screw me over at every possible opportunity:)
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-09-30 12:01
    What I was wondering about in my side question was whether pseudo-random number generators could take a random input and somehow inflict non-randomness into it.
    Of course it could. Take this obviously-flawed PRNG for example: Rand(x) = 1, where x is the real random input. :)

    -Phil
  • Heater.Heater. Posts: 21,230
    edited 2013-09-30 12:06
    But Phil, ElecticAye's question was about taking a random input and making it non-random. Easy:
    output N0 = Some really, really random number input.
    output N1 = N0 + 1
    output N2 = N1 + 1
    output N3 = N2 + 1

    and so on.

    Like I said, "that's what pseudo random number generators do"
  • Heater.Heater. Posts: 21,230
    edited 2013-09-30 12:08
    Ok Phil, yeah, your example is the same.
  • KeithEKeithE Posts: 957
    edited 2013-09-30 12:13
    >taking a random input and making it non-random

    The concern about RdRand was the opposite - taking a non-random input, and making it look random ;-)
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-09-30 12:22
    heater wrote:
    Ok Phil, yeah, your example is the same.
    Just more degenerate. :)

    -Phil
  • Heater.Heater. Posts: 21,230
    edited 2013-09-30 12:27
    KeithE,
    The concern about RdRand was the opposite - taking a non-random input, and making it look random
    True. My point was you should not trust it when it comes to cryptography.

    Imagine:
    You want to send a secret message to your friend that no one else can read. So you invent a scheme to scramble that message so that only your friend can unscramble it.
    But, because you are lazy you ask me to help you scramble it.
    Well, guess what? Even if I don't see your original message I might help you scramble it in such a way that I can also unscramble it.
    You should not trust me!

    Similarly, having someone like Intel as an input to your scrambling scheme is a bad idea.
  • KeithEKeithE Posts: 957
    edited 2013-09-30 13:36
    Heater - I understand. (I'm not an expert in this area though.) It's an interesting problem because running the numbers through AES is great if they are really random, but makes it very difficult to run integrity checks. Even if the random number generator were severely compromised (e.g. see the Stealthy Dopant-Level Hardware Trojans paper) how could you tell?
  • Heater.Heater. Posts: 21,230
    edited 2013-09-30 13:46
    Good question.
    Not being a crypto expert I have no idea.
    Which of course bugs me like hell. Above I mentioned being lazy with respect to random number generation. Well, of course, the truth is if I want to use crypto I will be lazy and use whatever algorithm the "experts" tell me is good and strong. I am putting my trust in other people to scramble my messages, WTF?

    And trust is what it all comes down to unless you have the savy to make the whole thing for yourself or at least fully understand what you are using.
  • davidsaundersdavidsaunders Posts: 1,559
    edited 2013-09-30 14:28
    LOL Cryptography an art, math and science of imperfect perfection.

    Now as to pseudo random number algorithms, most are very crude, many are little more than a copy of the algorithm from The C Programming Language 2nd ED.
    Also most Pseudo random number algorithms are either convergent or divergent, making for very poor distribution.
  • Heater.Heater. Posts: 21,230
    edited 2013-09-30 14:46
    davidsaunders,
    "...most are very crude...also most Pseudo random number algorithms are either convergent or divergent, making for very poor distribution."
    Perhaps. But many people have been working on this. For example the late great George Marsaglia. See threads:
    http://forums.parallax.com/showthread.php/136975-JKISS32-High-quality-PRNG-with-RealRandom-seed-save-a-COG.
    and:
    http://forums.parallax.com/showthread.php/137118-MWC256-Very-high-quality-PRNG-with-RealRandom-seed-save-a-COG.
    That's even before we get onto cryptographically secure PRNGs.
Sign In or Register to comment.