probcomp / Venturecxx

Primary implementation of the Venture probabilistic programming system
http://probcomp.csail.mit.edu/venture/
GNU General Public License v3.0
28 stars 6 forks source link

Replace Mersenne Twister with a cryptographic PRNG #522

Open axch opened 8 years ago

axch commented 8 years ago

For example, on @riastradh-probcomp has written:

http://mumble.net/~campbell/python/prng.py (32-byte state w/ 32-byte buffer, lower throughput) http://mumble.net/~campbell/python/weakprng.py (48-byte state w/ 64-byte buffer, higher throughput) http://mumble.net/~campbell/python/chacha.py (crypto core PRF)

Why?

Any cryptographic PRNG makes the latter two concerns vanish entirely; and at least ChaCha's full state is small enough to print out on one 80-character line using only non-special printable ASCII characters.

axch commented 8 years ago

366 would make this saner and higher performance, but does not strike me as strictly necessary.

riastradh-probcomp commented 8 years ago

C implementation of weakprng here:

https://github.com/probcomp/crosscat/blob/4f75431b06978c77fc1c8e9c559af0f68101316d/cpp_code/src/weakprng.cpp https://github.com/probcomp/crosscat/blob/4f75431b06978c77fc1c8e9c559af0f68101316d/cpp_code/include/CrossCat/weakprng.h

(Nominally C++98 for build convenience but it is valid C99 too.)