Using Lehmer Codes to Generate Uniform Pseudo-Random Number Sequences

Although pseudo-random number generators (e.g. LCGs and Xorshift) are fast they are also statistically flawed. Conversely secure generators can be prohibitively slow. Here, a novel permutation based 'whitening' technique termed 'Lehmerizing' is introduced. Lehmer codes and the factorial number system facilitate translation between a window of output data produced by a base cheap PRNG and its corresponding permutation. We specify a rejection sampling algorithm, and hardware informed cost function T(w, R), for designing generators that can be tuned for arbitrary output domains that are free of modulo bias. A total of 328 trials are performed to validate the optimal window function. Using non-overlapping windows (delta = w = 14), both XOR_LH and LCG_LH pass all 160 TestU01 Big Crush statistical tests with no errors. This while running roughly 7.8 times faster than Python's default Mersenne Twister loop in Cython. It can be confirmed both theoretically and experimentally that Lehmerizing can convert any continuous, independent and identically distributed (i.i.d.) non-uniform probability distribution into an i.i.d. uniform sequence. Furthermore, Lehmerizing's limitations are analyzed when applied to highly autocorrelated chaotic mappings like the logistic map. Cryptanalysis demonstrates that neither XOR_LH nor a single-round ARX variant (CryptoLehmer) is secure. Both suffer from polynomial time F2 linear inversion of their seeds, and insufficient Shannon entropy diffusion. However, we exploit these poor diffusion properties and the invariance of Lehmerizing to monotonic functions to construct a proof-of-concept Locality Sensitive Hashing (LSH) framework for image recognition. This surpasses a basic spatial MinHash in the presence of non-linear brightness warping and sensor noise (89.94% vs. 0.15% and 70.52% vs. 0.01% respectively).

Authors

Institutions

Publication Details

Journal
Zenodo (CERN European Organization for Nuclear Research)
Published
2026-11-26
DOI
https://doi.org/10.5281/zenodo.24549562
Primary Topic
Cryptographic Implementations and Security
Type
preprint
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
NOV
preprint

Using Lehmer Codes to Generate Uniform Pseudo-Random Number Sequences

Oscar Jimenez Rodriguez
Zenodo (CERN European Organization for Nuclear Research)
Cryptographic Implementations and Security
preprint

Using Lehmer Codes to Generate Uniform Pseudo-Random Number Sequences

Oscar Jimenez Rodriguez
preprint en

Abstract

Although pseudo-random number generators (e.g. LCGs and Xorshift) are fast they are also statistically flawed. Conversely secure generators can be prohibitively slow. Here, a novel permutation based 'whitening' technique termed 'Lehmerizing' is introduced. Lehmer codes and the factorial number system facilitate translation between a window of output data produced by a base cheap PRNG and its corresponding permutation. We specify a rejection sampling algorithm, and hardware informed cost function T(w, R), for designing generators that can be tuned for arbitrary output domains that are free of modulo bias. A total of 328 trials are performed to validate the optimal window function. Using non-overlapping windows (delta = w = 14), both XOR_LH and LCG_LH pass all 160 TestU01 Big Crush statistical tests with no errors. This while running roughly 7.8 times faster than Python's default Mersenne Twister loop in Cython. It can be confirmed both theoretically and experimentally that Lehmerizing can convert any continuous, independent and identically distributed (i.i.d.) non-uniform probability distribution into an i.i.d. uniform sequence. Furthermore, Lehmerizing's limitations are analyzed when applied to highly autocorrelated chaotic mappings like the logistic map. Cryptanalysis demonstrates that neither XOR_LH nor a single-round ARX variant (CryptoLehmer) is secure. Both suffer from polynomial time F2 linear inversion of their seeds, and insufficient Shannon entropy diffusion. However, we exploit these poor diffusion properties and the invariance of Lehmerizing to monotonic functions to construct a proof-of-concept Locality Sensitive Hashing (LSH) framework for image recognition. This surpasses a basic spatial MinHash in the presence of non-linear brightness warping and sensor noise (89.94% vs. 0.15% and 70.52% vs. 0.01% respectively).

Zenodo (CERN European Organization for Nuclear Research)
Ithaca College (US)
Cryptographic Implementations and Security
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Laika access coming soon