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
- Oscar Jimenez Rodriguez (ORCID: https://orcid.org/0009-0001-7971-8159)
Institutions
- Ithaca College (US)
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