Skip to content
🎉 Welcome! Enjoy your reading, and I hope you will learn something new.

Mersenne Twister (MT19937)

The Mersenne Twister is a widely used pseudorandom number generator (PRNG). Its most popular variant, MT19937, is based on the Mersenne prime \(2^{19937} - 1\).

Python Attacks

In its most common implementation, this PRNG has a period length of 624, after which it cycles back. This means that, given enough generated outputs, one can predict the future outputs of the generator or even recover the initial state. This allows the recovery of all past generated values and all the ones to come.

It is also possible that, given two outputs separated by a fixed number of intermediate generations, the implementation may allow state recovery or output prediction, as seen in the last attack.

Tip

This blog post details most of the below attacks.

Known 32-bit outputs

Known 1-bit outputs

Known partial 16-bits

Only 6 known ouputs

Only 2 known outputs

PHP Attacks

Only 2 known values

Resources

Last updated on