Closed pfalcon closed 8 years ago
CPython uses Mersenne Twister which has a large state (2496 bytes). This is pretty large for "micro". So -1 for CPython compat.
Smallest by code size would be to write no code, and this can be achieved by reusing AES cipher: your key is the seed and you generate raw AES blocks which are the pseudo random numbers. This has the advantage of being cryptographically secure. (I assume here we have implemented AES for SSL.)
The AES implementation I wrote uses 208 bytes of state for AES 128, and 272 bytes for AES 256.
I just learned that the Python ssl module has a set of functions for crypto-secure PRNG: https://docs.python.org/3/library/ssl.html#ssl.RAND_bytes
Point 2 above (Implement the smallest (by code size) reasonable PRNG) was implemened in a58a91eb04c50daafb31228a79f6752374338c5e using Yasmarang generator.
It's nice that stmhal port has hw random generator, but we really should implement port-independent reproducible PRNG. I can think of following choices: