Rating:

The key generation process is flawed - the function used to find modulus is monotonic and thus we can use binary search to recover original input fast:

```
#!/usr/bin/env python3

import gmpy2

def find_n(seed):
p = gmpy2.next_prime(seed)
p1 = gmpy2.next_prime(10*p)
p2 = gmpy2.next_prime(10*p1)
p3 = gmpy2.next_prime(10*p2)
return p*p1*p2*p3

N = 603040899191765499692105412408128039799635285914243838639458755491385487537245112353139626673905393100145421529413079339538777058510964724244525164265239307111938912323072543529589488452173312928447289267651249034509309453696972053651162310797873759227949341560295688041964008368596191262760564685226946006231
c = 153348390614662968396805701018941225929976855876673665545678808357493865670852637784454103632206407687489178974011663144922612614936251484669376715328818177626125051048699207156003563901638883835345344061093282392322541967439067639713967480376436913225761668591305793224841429397848597912616509823391639856132

r = 0

for i in range(280, 0, -1):
if find_n(r + 2**i) <= N:
r += 2**i

p = gmpy2.next_prime(r)
p1 = gmpy2.next_prime(10*p)
p2 = gmpy2.next_prime(10*p1)
p3 = gmpy2.next_prime(10*p2)

phi = (p-1)*(p1-1)*(p2-1)*(p3-1)

d = gmpy2.invert(2**16+1, phi)

decrypted = int(pow(c, d, N))

print(decrypted.to_bytes(50, 'big'))

```