Home
Writeups Misc About
No Way Back Home

No Way Back Home

We are presented a key-exchange protocol where there is some v generated by px, where p is one of the two primes given, x is a random number generated. We are also given the following:

vka=v×kAmodn
vkakb=vka×kBmodn
vkb=v×kBmodn

Obviously we can calculate kA by doing (vkb)1×vkakb, but unfortunately v is a multiple of p that is not possible. Therefore, we can divide everything by p, which makes the inversion possible on modulo n/p=q

xka=x×kA=(vka)/p
xkakb=x×kA×kB=(vkakb)/p
xkb=x×kB=(vkb)/p

Hence, as we can now invert xkb under modulo q, we can then have:

kA=xkakb×xkb1
x=kA1×xka

From x, calculating the original v is trivial. There are other solution that uses CRT as well, but all are doing operation under modulo q.

Python Implementation: