Hawkynt

Squares

Fast counter-based PRNG using multiple rounds of squaring, modernizing von Neumann’s middle-square method. Trivially parallelizable with competitive performance, passing BigCrush and PractRand statistical tests.

Properties

Property Value
Category Random Number Generators
Sub-category Counter-Based PRNG
Security status πŸŽ“ Educational Only
Complexity Intermediate
Inventor Bernard Widynski
Year 2020
Origin Not specified
Source algorithms/random/squares.js

Parameters

Parameter Supported values
Key sizes 8 bytes (64 bits)

Capabilities

Flag Value
IsDeterministic Yes
IsCryptographicallySecure No
IsCounterBased Yes

Security

Status: πŸŽ“ Educational Only

No vulnerabilities are recorded for this implementation.

Documentation

References

Test vectors

6 vectors ship with this algorithm and run in the test suite. Byte values are hexadecimal.

Vector 1 β€” Squares 3-round: counter=0, key=0xea3742c76bf95d47 - FlorisSteenkamp reference

Field Value
key 475df96bc74237ea
outputSize 4
input 0000000000000000
expected 63b29228

Vector 2 β€” Squares 3-round: counter=1, key=0xea3742c76bf95d47

Field Value
key 475df96bc74237ea
outputSize 4
input 0100000000000000
expected 42e3a3d8

Vector 3 β€” Squares 3-round: counter=100, key=0xea3742c76bf95d47 - Known test vector

Field Value
key 475df96bc74237ea
outputSize 4
input 6400000000000000
expected 7b2c9b40

Vector 4 β€” Squares 3-round: counter=42, key=0xea3742c76bf95d47

Field Value
key 475df96bc74237ea
outputSize 4
input 2a00000000000000
expected 79a8cc24

Vector 5 β€” Squares 3-round: counter=0xFFFFFFFF, key=0xea3742c76bf95d47 - Max 32-bit counter

Field Value
key 475df96bc74237ea
outputSize 4
input ffffffff00000000
expected c9604e43

Vector 6 β€” Squares 3-round: counter=12345, key=0xea3742c76bf95d47

Field Value
key 475df96bc74237ea
outputSize 4
input 3930000000000000
expected 907d8ec2

← All algorithms