Tuti

Cryptography is coupled with all kinds of equations very much!

Files given:

m_1, m_2 = flag[: l // 2], flag[l // 2:]

x, y = bytes_to_long(m_1), bytes_to_long(m_2)

k = '''
000bfdc32162934ad6a054b4b3db8578674e27a165113f8ed018cbe9112
4fbd63144ab6923d107eee2bc0712fcbdb50d96fdf04dd1ba1b69cb1efe
71af7ca08ddc7cc2d3dfb9080ae56861d952e8d5ec0ba0d3dfdf2d12764
'''.replace('\n', '')

assert((x**2 + 1)*(y**2 + 1) - 2*(x - y)*(x*y - 1) == 4*(int(k, 16) + x*y))

We are given the equation

\[(x^2+1)(y^2+1)-2(x-y)(xy-1)=4(k+xy)\]

and need to find integer solutions for \(x,y\). Since this is a quadratic in both \(x,y\), we can easily solve this quadratic for \(x\) in terms of \(y\) as

\[x=\frac{2\sqrt k}{y-1}-1\]

and this tells us that \(y-1\) is a factor of \(2\sqrt k\). Factoring this in yafu, we can write a quick brute force script to print all possible flags.

Solution at solve.sage

Flag: CCTF{S1mPL3_4Nd_N!cE_Diophantine_EqUa7I0nS!}