Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

bcd32: Just another very simple non-cryptographical secure PRNG

35 views
Skip to first unread message

Karl-Uwe Frank

unread,
Oct 20, 2015, 5:58:38 AM10/20/15
to
On 2nd of October 2015 I have published a "CISPRNG" on sci.crypt-random.
It can be seeded with any arbitrary 128bit value and produce a 32bit output.

It also uses only cheap arithmetic operations, like bitwise shift,
additions and XOR. The internal state of 160 bit does not need any
predefined constant values.

It is released under the free BSD license.

It passes all statistical tests without failure. The formulae below
passes Qualcomms's bias test, John Walker's ENT, Maurer's Universal test
for random bits, show a well uniform distribution regarding Winston
Rayburn's bit analysis and pass all tests off Pierre L'Ecuyer's
testsuite TestU01, which are SmallCrush, Crush and BigCrush. Even a
reduced to 16bit version of bcd32 passed the before mentioned tests.


This is the formulae as ANSI-C snippet.
Please be aware that it should not be seeded with all vars equals 0.



static uint32_t a, b, c, d, t;

// The Seeding Function
void seed_bcd32(uint32_t seed[]) {
// check for a potential a==0
if (seed[0] > 0xfffffffe)) seed[0] = 1;

a = seed[0] ^ 0xffffffff;
b = seed[1];
c = seed[2];
d = seed[3];

t = a + b + c + d;
}

// The PRNG Function
uint32_t bcd32() {
a = a + (d >> 5);
b = a + (b ^ c);
c = a + (b << 13);
d = a + (d ^ t);
t = a + t;

return (b ^ c ^ d);
}



Some test results of bcd32


a = 1, b = 2, c = 3, d = 4

# Testsize 2**30 bit (128 MB)

../bcd32_BitStat 30 0 | BitStatistic/ent
Entropy = 8.000000 bits per byte.

Optimum compression would reduce the size
of this 536870912 byte file by 0 percent.

Chi square distribution for 536870912 samples is 270.82, and randomly
would exceed this value 23.70 percent of the times.

Arithmetic mean value of data bytes is 127.5036 (127.5 = random).
Monte Carlo value for Pi is 3.141336781 (error 0.01 percent).
Serial correlation coefficient is -0.000000 (totally uncorrelated = 0.0).

-----------------------------------------------------------------------------------

a = 219324720, b = 1108630788, c = 1189532544, d = 1548197085

# Testsize 2**30 bit (128 MB)

../bcd32_BitStat 30 65432912 | BitStatistic/ent
Entropy = 8.000000 bits per byte.

Optimum compression would reduce the size
of this 536870912 byte file by 0 percent.

Chi square distribution for 536870912 samples is 245.69, and randomly
would exceed this value 65.08 percent of the times.

Arithmetic mean value of data bytes is 127.5015 (127.5 = random).
Monte Carlo value for Pi is 3.141296860 (error 0.01 percent).
Serial correlation coefficient is -0.000033 (totally uncorrelated = 0.0).

-----------------------------------------------------------------------------------

# Seed = 3674308604 | a = 1064954296, b = 1558138774, c = 1222783100, d
= 2044543557

nice -n 19 ./TestU01_bcd32 -c 3674308604 3>&1 2>&3- | tee Crush.txt

========= Summary results of Crush =========

Version: TestU01 1.2.3
Generator: bcd32 32-bit
Number of statistics: 144
Total CPU time: 01:17:23.18

All tests were passed



# Seed = 167813656 | a = 798087881, b = 280156805, c = 1311267411, d
= 994191163
nice -n 19 ./TestU01_bcd32 -c 167813656 3>&1 2>&3- | tee Crush.txt

========= Summary results of Crush =========

Version: TestU01 1.2.3
Generator: bcd32 32-bit
Number of statistics: 144
Total CPU time: 01:13:08.81

All tests were passed



# Seed = 2028375283 | a = 1747968903, b = 537061761, c = 523248786, d
= 296811837

nice -n 19 ./TestU01_bcd32 -c 2028375283 3>&1 2>&3- | tee Crush.txt

========= Summary results of Crush =========

Version: TestU01 1.2.3
Generator: bcd32 32-bit
Number of statistics: 144
Total CPU time: 01:12:32.73

All tests were passed



nice -n 19 ./TestU01_bcd32 -b 2028375283 3>&1 2>&3- | tee BigCrush.txt

========= Summary results of BigCrush =========

Version: TestU01 1.2.3
Generator: bcd32 32-bit
Number of statistics: 160
Total CPU time: 08:26:48.66

All tests were passed



The source code for these tests can be found here
http://www.freecx.co.uk/bcd32/

Cheers,
Karl-Uwe

--- news://freenews.netfront.net/ - complaints: ne...@netfront.net ---

menti...@gmail.com

unread,
Nov 7, 2015, 8:59:04 PM11/7/15
to
On Tuesday, October 20, 2015 at 2:58:38 AM UTC-7, Karl-Uwe Frank wrote:
> On 2nd of October 2015 I have published
> a "CISPRNG" on sci.crypt-random. [...]

>
> The source code for these tests can be found here
> http://www.freecx.co.uk/bcd32/
>
> Cheers,
> Karl-Uwe
>
Thank you for posting the above information.

Meanwhile, message for underground agents in China:

16830 88370 38469 50310 93290 27030 47303
83341 71413 19647 45881 88991 25492 09531
86710 46463 09969 54288 81077 49231 57932
29053 91599 19798 85697 19810 52347 15118

For previous comms decipher
http://bbs.progrider.org/prog/read/1446811379/3

Mentifex against IV VI Massacre << http://ai.neocities.org/GIX.html
--
Major goal in life: Trigger a Technological Singularity;
Minor goal: Overthrow the unelected government of China;
Minor goal: Win a Nobel Prize in Physiology or Medicine;
Minor goal: [X] Reunification of East and West Germany.

Karl-Uwe Frank

unread,
Nov 8, 2015, 5:14:35 AM11/8/15
to
On 08.11.15 02:58, menti...@gmail.com wrote:
> On Tuesday, October 20, 2015 at 2:58:38 AM UTC-7, Karl-Uwe Frank wrote:
>> On 2nd of October 2015 I have published
>> a "CISPRNG" on sci.crypt-random. [...]
>
>>
>> The source code for these tests can be found here
>> http://www.freecx.co.uk/bcd32/
>>
>> Cheers,
>> Karl-Uwe
>>
> Thank you for posting the above information.
>
> Meanwhile, message for underground agents in China:
>
> 16830 88370 38469 50310 93290 27030 47303
> 83341 71413 19647 45881 88991 25492 09531
> 86710 46463 09969 54288 81077 49231 57932
> 29053 91599 19798 85697 19810 52347 15118
>
> For previous comms decipher
> http://bbs.progrider.org/prog/read/1446811379/3
>
> Mentifex against IV VI Massacre<< http://ai.neocities.org/GIX.html
Nice rubish try, idiot, your thread has been meanwhile removed :-)
0 new messages