This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-*- coding:utf-8 -*- | |
''' | |
In the challenge we are given a recently proposed cryptosystem | |
based on Mersenne primes ( https://eprint.iacr.org/2017/481 ). | |
The cryptosystem was broken quickly in https://eprint.iacr.org/2017/522.pdf | |
using random partitioning and LLL. Here this attack is implemented. | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Slide attack on the TwinPeaks2 cipher from NSUCRYPTO. | |
Disclaimer: this is not an optimal solution, just a proof-of-concept! | |
An actual solution is to note that Reverse(Encrypt(Reverse(x)) = Decrypt(x), where Reverse(a,b,c,d) = (d,c,b,a). | |
""" | |
from random import shuffle, randint |