Challenge description:

Decrypt it.

twin-primes.7z

We have 4 files in the archive:

**encrypt.py**– A Python script uses RSA algorithm to encrypt the flag**encryped**– The encrypted message**key 1**– n, and e of one of the keys used in the encryption process**key 2**– n, and e of the other key used in the encryption process

Are you ready for your math lesson? Here we go.

After reading encrypt.py we know that:

- n1 = p*q
- n2 = (p+2)(q+2)
- p and q are twin primes.
*i.e*p is prime and p+2 is also prime; similar for q.

Now let’s turn the equation into an equation with one unknown and then solve it for the unknown.We can Isolate q to be and substitute q in the other equation. Now we have an equation in one unknown:

Solve the equation and you’ll get:

We need to solve this quadratic equation in order to find p and q. After that it will not be a problem to find the d’s and build the keys.

The rest is in the script: