# Fast & good RNG

This topic is 4996 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Basically this is an RNG idea i've had in a nutshell. You have a finite space, (like that hash function that nobody replied to :( And a pointer to where you are in it. You also have an array of numbers (which form the state). Per iteration, you move backwards and forwards on the finite space, by using the array of numbers in an ISAACish manner. You then output a hash of the pointer the array of numbers would be about 255bits long, and the finite space would probably only be about 260 bits long, so that even if you can partially reverse the hash function (which although it would have many, many collisions (about 2^(260 - 32) collisions) it helps keep the state safe.). I was also wondering, if this allows us to quickly add more entropy into the rng, for eg. you can add extra entries into the main picking array (which will reset the piriod of the function, as well as making the piriod longer), or you can upset where the pointer is, by mangling it with the new numbers. So basically you have an array of numbers. You go and you have Four numbers, i, j,k,l and the pointer. The pointer is where you are in the field. all the rest is self-ish explanitory for each iteration needed,
i = (((array * array[j]) + (i << 1) + j) % arraylength
j = ((array[(i + j) % arraylength] + array[(i * j) % arraylength]) << 1) % arraylength
pointer += array * array[j]
pointer %= fieldsize
k = (((array[k] * array[l]) + (k << 1) + l) % arraylength
l = ((array[(k + l) % arraylength] + array[(k * l) % arraylength]) << 1) % arraylength
pointer -= array[k] * array[l]
if pointer < 0 {pointer = fieldsize - pointer}


Or something similar. For the hash, i would like a few sugestions :). Also, i was thinking about making the array a power of two, so that all of those pesky %'s are replaced with friendlier ands. What would the piriod be for something like this? Would it be incredibly hevily biased? Would it be usuably fast? From, Nice coder

##### Share on other sites
I have seen the mt.
It is impressive, but it is not cryptographically secure.
I also want to have some fun and build my own :).

I was also thinking about adding a stage, where you input some data, and it goes and compresses the entropy until it can be used in the generator. How would i do that?

From,
Nice coder

##### Share on other sites
Quote:
 Original post by Nice CoderIt is impressive, but it is not cryptographically secure.

No pseudo random number generator is, since they generate "random" numbers based on a known algorithm. If you are doing cryptography, you'll want a hardware true random number generator, not a PRNG algorithm.

Neither you nor I have the background to establish the suitability of a PRNG for numerical methods (e.g. monte-carlo integration). So, stick with the tried-and-true solutions (e.g, MT), or take an appropriate math course. [smile]

##### Share on other sites
Of course, there's always CryptGenRandom, or there's also RtlGenRandom, but that one's not gauranteed to be around in all versions of Windows (in fact, RtlGenRandom is only in Windows XP / Server 2003, while CryptGenRandom is available all the way back to Windows 95).

##### Share on other sites
I just thought I'd point it out because it sounded like what you described, and it looked like you were on the verge of reinventing the wheel.

That said, I know very little about writing a RNG, let alone one that is to be used for cryptography.

Here is a silly idea, though:

#include <iostream>template <int depth> class RNG {  protected:   RNG<depth-1> a, b;   RNG<depth-1> selector;    public:   int getNumber(int min, int max)    {     if(selector.getNumber(0, 1)==1)      return a.getNumber(min, max);     else      return b.getNumber(min, max);    } };template <> class RNG<0> {  protected:   // TODO: Important state keeping stuff.    public:   int getNumber(int min, int max)    {     return 0; // TODO: Return a random number.    } };int main() {  RNG<5> rng;// Warning: Creates several hundred generators.    for(int c = 1; c <= 4*8; ++c)   std::cout << rng.getNumber(0, 10) << (c%8?'\t':'\n');    std::flush(std::cout);    return 0; }

Trying to guess the ouput of one generator is difficult, trying to guess the output of 364 generators should be at the very least interesting.

##### Share on other sites
I would like to reinvent the wheel. Then smash the wheel, then make a harder wheel.

Basically, this would be (eventually) a small random number server.
You can open up a tcp connection with your own computer, on a port that is blocked on your firewall, and you ask it for a set of random numbers, specify how you want them, then it sends you the numbers.

It also takes user/disk input and uses that to generate an entropy pool, so that the rng has a neverending supply of entropy, so that it can go with an extreamly long piriod.

I'm not too good at this tho, so i'm just taking the things that makes other generators resistant to cryptanalisis, and sticking them together with a few extras onto my own generator :)

From,
Nice coder

##### Share on other sites
If you're doing this to learn, excellent! If you're going to be using this in an actual product, I for one will not trust it to be cryptographically safe until there has been some thorough examination from several cryptanalysists.

##### Share on other sites
I always build new things to learn how they work. And how they fail. (when they do, and sometimes thaey do).

You simply cannot understand how something works, until you've built one from the ground up.

So, i've got a schematic for a (probably mainly working) processor, a massivelly parellel cache (which is completelly new, and i haven't seen any like it), likweise an amplifier which dissipates a few watts, at 10KW output.

I wouldn't say that my algo is crypograpgically secure until i can find a few crypto experts which tel me that it isn't crackable. or if i give out a few thousand dollars in reward money, for cracking it. (and a smaller prize for theoretical hacks).

From,
Nice coder.

##### Share on other sites
Quote:
 Original post by Nice CoderI wouldn't say that my algo is crypograpgically secure until i can find a few crypto experts which tel me that it isn't crackable. or if i give out a few thousand dollars in reward money, for cracking it. (and a smaller prize for theoretical hacks).

If you're going to have a competition, offer the full prize to the analyst that can provide the best attack on the system, whether it is complete or not. Everything else would be a marketing sham.

1. 1
Rutin
27
2. 2
3. 3
4. 4
5. 5

• 11
• 11
• 10
• 13
• 20
• ### Forum Statistics

• Total Topics
632948
• Total Posts
3009401
• ### Who's Online (See full list)

There are no registered users currently online

×