Essentially a scripting challenge. You'll be given all sorts of parameters and need to calculate the missing one. Instead of going through every possible solution, which would've been really excruciating, I went through this approach -
Create a function that solves for a value.
The function's logic is as follows:
if we want a value that's already defined, just return it
if we want n, call ourself to solve p and q, then multiply
if we want ct, call ourself to solve n, then do pt^e mod n
if we want pt, call ourself to solve d and n, then do ct^d mod n
if we want d, call ourself to solve p and q,compute phi, then return inverse(e,phi)
if we want p, or q, then:
pretend p is the prime we have and q is the prime we want
if we have n, return n // p
if we have phi, return (phi // (p - 1)) + 1
if all else fails and we have e and d, use Crypto.PublicKey.RSA to compute p and q via n, e and d