Python implementation of the attacks explained in the 2.7 part of “Reconstructing truncated integer variables satisfying linear congruences”.
This part is explaining how we can attack a Truncated Linear Congruential Generator if we have either the Most Significant Bits or the Least Significant Bits.
Almost all the code is what me and my classmates did during this project, I only added code for the second case in this repo.
We have :
Note : it is also possible to make an attack where
For the second case, we use the fact that
For a given
with
Let
Thus, Z_i is lower than Y_i and therefore we are in the first case.
The first case is better explained in the article, but basically : we can make a matrix of the outputs and, using Euclidean Lattices, we can attack the PRNG. This implementation uses LLL, and it's great wrapper in Python that is fpylll.
I couldn't test if my MSB code if running, as I added it from a machine that can't run it for the repo to be "complete". I'll gladly modify it in order to make it work if it has any problem.