Introduction
Cryptographically Secure Pseudorandom Numbers (CSRPNs) are the bedrock of modern security protocols, utilized in everything from the Skein hash function to the ChaCha20 cipher. A common, yet often unexamined, assumption in cryptographic engineering is that performing standard mathematical or logical operations on these numbers preserves their security properties. If an operation introduces bias or collapses the entropy of the output, it creates statistical regularities that attackers can exploit. This review systematically examines which operations maintain CSRPN status and which inadvertently leak information.
Methodology
The study employs a dual-track validation approach to assess the impact of various operations on randomness:
- Theoretical Analysis: The authors utilize Shannon Entropy to provide mathematical proofs for each operation. An operation is deemed secure if the probability distribution of the output remains uniform ($2^{-n}$ for an $n$-bit number), thereby maintaining an entropy of $n$.
- Experimental Verification: To ground the theory, the researchers used the NIST Randomness Test Suite (SP 800-22). High-quality random bits were sourced from a hardware-accelerated generator (
/dev/randomon an Apple M1 chip). These bits were processed into 64-bit or 128-bit integers, subjected to the operations in question, and then evaluated against 15 different statistical tests.
Analysis of Operations
The "Safe" Zone: Bijective Operations
Operations that function as bijections—mapping every input to exactly one unique output—are inherently secure. XOR and NOT fall into this category. Because they do not "collapse" the possibility space, they preserve 100% of the source entropy. Similarly, Splitting and Bit Selection are secure, as they simply isolate portions of an already random bitstream.
The Nuance of Addition and Subtraction
Addition and Subtraction (both signed and unsigned) are secure provided the result is truncated to the original bit-length. If the operation allows for bit-growth (e.g., an overflow bit in BigInteger addition), the $n+1$ bit is not truly random, which technically makes the entire resulting number non-random by cryptographic standards.
The "Danger" Zone: Entropy Loss
Bitwise AND and OR operations are highly destructive to randomness. An AND operation biases bits toward 0 (only a 25% chance of a bit being 1), while OR biases them toward 1. This results in a significant drop in entropy from $n$ to approximately $0.811n$.
Multiplication, Division, and Modulo are identified as the most insecure operations. Multiplication biases results toward smaller values and numbers with more factors. Division is particularly problematic; dividing two random numbers $r_1 / r_2$ results in 0 nearly 50% of the time (whenever $r_1 < r_2$), creating a massive statistical spike that is easily detectable.
Key Results
The findings demonstrate a clear divide between operations that preserve CSRPN status and those that do not. In NIST testing, insecure operations like AND, OR, and Division failed nearly every test, yielding P-values of 0.0, indicating they are statistically distinguishable from random noise almost immediately.
Conclusion and Future Work
This research highlights the risks of "tacit assumptions" in cryptographic implementation. While XOR and truncated addition are safe for mixing entropy, operations like multiplication or bitwise AND/OR require additional "whitening" steps to restore randomness. The authors suggest that these findings should be a mandatory consideration for anyone designing new random number generators or hashing algorithms. Future research should explore the composition of multiple operations and the security of more complex functions in both classical and quantum contexts.
Summary updated