Reliable random numbers for online lottery

I need to generate random numbers for playing the lottery, the front lottery will work in Flash AS3, the idea is to run a script that generates 10 random numbers (winners) and stores them in the SQL database

What is a reliable way to create random numbers? Is js Math.rand () function reliable enough for lottery?

On wikipedia, I found Fortuna a “cryptographically robust pseudo random number generator” that is included in the Javascript Crypto Library.

Another option is http://www.random.org , it offers a free API for random numbers, but what guarantees can it offer?

+4
source share
3 answers

Random.org seems to base its numbers on static noise, which is rather random, and more random than the random javascript library, which probably bases its randomness on some timing algorithm.

+2
source

Javascript Math.rand () is unlikely to be good enough for the lottery, since the specification does not require cryptographic protection. For example, there are known flaws in the generator used in some versions of Chrome.

You will need a cryptographically secure pseudo-random number generator (for example, blum-blum-shub) and a method for sowing it. You need a good way to sow it, because if someone can figure out which seed you used, they can generate all the lottery numbers. You will probably want to plant a pseudo-random generator with a truly random rather than random pesudo number. This will require a random number generator. Random.org supposedly provides a source of truly random numbers, however, if someone eavesdrops on your connection with random.org, they can still detect your random seed. You may prefer to invest in your own equipment rather than relying on someone else.

Infact, if you did not need a lot of random numbers (much more than 10), it would make little sense to use a pseudo-random number generator in general. You can also get all your random numbers from a real, random, random number generator.

+2
source

If the lottery includes money (buying "tickets" and paying prizes), you may need to demonstrate that you are using "real" random numbers. In this case, you can invest in your own equipment for generating random numbers. A quick search shows several, for example this one .

Otherwise, any of the two pseudo-random sources will seem adequate to me.

+1
source

Source: https://habr.com/ru/post/1345848/


All Articles