I’m not entierly sure how rngs currently work, but I know they use time as a seed… So, why not just use a different prime number every time? As far as I know, primes are the only actual random thing known to us, so for example, every time a program asks for a random number you give him the nth prime and increase n by one. Wouldn’t this be purely random? Because differences between nth and n+1th are!
Share
Good idea, but there are 2 problems with this approach to building a Pseudo random number generator.
1] The security of RNGs depends in part on the inability of the attacker to know the seed that was used. While the distance between one prime and the next is random, the sequence of primes is not random. In other words 3 is prime, and I can’t predict what the next prime will be based on the fact that 3 is prime. But I already know that 5 is the next prime (as all low number primes are known). Based on your algorithm, if I determine that the seeds for the last random numbers were 3, and then 5, I can guess that the next seed you will use will be 7. So this won’t work for low primes. The list of primes from 1 to 10,006,721 is well known and published.
2] Finding primes is hard (computationally expensive). While it is less expensive for low numbers, it becomes very expensive for large primes. Most of the code that uses random numbers assumes that the number will be returned by the system very quickly, so it is used in tight loops for games, for example. This algorithm would break those use cases.
So this would not be a good way to build a random number generator.