Let the intercepted ciphertexts be
Since , the extended Euclidean algorithm gives integers with . The common-modulus RSA attack recovers
Negative powers are evaluated using modular inverses. If an inverse does not exist, its greatest common divisor with already factors the modulus.