[Cryptography] An interesting little pseudorandom number generator

Ray Dillinger bear at sonic.net
Sun Aug 1 00:12:23 EDT 2021



On 8/1/21 1:12 AM, Ray Dillinger wrote:
> Aw crap, the "fix" I proposed by complementing the first element was stupid.
> Now the generator produces zero one time in 256.

Another correction.  Mixing combiner functions (now add, multiply, XOR,
add) for more nonlinearity and correcting (in a non-stupid way this
time) for autocorrelation bias.  I think this addresses the things we've
noticed so far. 

Thanks to everyone who's taken time to look at it and think about it.

                Bear



uint64_t A[256];
uint32_t N;

uint64_t pseudorandom(){
    N--;
    A[N%256] = A[(N+5)%256] + A[(N+17)%256];
    A[(N+17)%256] = A[(N+41)%256] ^ A[(N+72)%256];   //<- Now XOR as
combiner
    A[(N+72)%256] = A[(N+120)%256] * A[(N+161)%256];  //<- Now * as combiner
    A[(N+161)%256] = A[(N+163)%256] + A[(N+254)%256];
    int idx1 = A[N%256]; int idx2=(A[(N+17)%256]+A[(N+72)%256])%256;
    return(idx1==idx2 ? A[idx1] :  A[idx1]+A[idx2]  ); // <- fix
autocorrelation bias.
}




More information about the cryptography mailing list