martijnvanbrummelen / nwipe

nwipe secure disk eraser
GNU General Public License v2.0
631 stars 71 forks source link

XORoshiro-256 and ALFG as default PRNG for 64-Bit and 32-Bit platforms. Also PRNG method as default method. #566

Closed Knogle closed 3 months ago

Knogle commented 3 months ago

For legacy 32-bit systems, such as a Pentium 2, selecting an appropriate pseudo-random number generator (PRNG) is crucial for ensuring both performance and quality of randomness. When comparing the Xoroshiro256 algorithm with a Lagged Fibonacci Generator (LFG) utilizing subtraction and carry, several factors come into play, especially regarding performance on such dated hardware.

Performance Considerations on 32-bit Systems

  1. Xoroshiro256 is part of the Xoroshiro/Xoshiro family, known for its speed and excellent statistical properties. However, its implementation typically relies on 64-bit arithmetic operations to achieve optimal performance, which is not ideal on 32-bit systems. On such systems, 64-bit operations are internally broken down into multiple steps, leading to a decrease in performance.

  2. Lagged Fibonacci Generator (LFG) with subtraction and carry operations is a more traditional PRNG. Its main advantage lies in its straightforward implementation using 32-bit arithmetic, making it inherently compatible with 32-bit architectures. Although LFGs may not match the speed of some of the more modern alternatives, they run directly on 32-bit systems without the overhead of emulating 64-bit operations, potentially offering better performance on older hardware.

Recommendation for Legacy 32-bit Systems

Given these considerations, the Lagged Fibonacci Generator with subtraction and carry operations appears to be more suitable for legacy 32-bit systems from a performance standpoint for two primary reasons:

Conclusion

While performance is a critical factor, it's important to note that the choice of PRNG should also consider other aspects such as the required quality of randomness, the application's specific needs, and overall project requirements. If feasible, conducting benchmarks for both PRNGs under actual conditions on your specific 32-bit system is recommended to make an informed decision.

This recommendation is made with the understanding that, on older 32-bit architectures, optimizing for system compatibility and performance may outweigh the benefits of using a PRNG with superior statistical properties but higher computational demands.

Regarding PRNG stream, i think it is the most used, and most suitable method nowadays for modern HDDs.