def decrypt(c, p, q): if GCD(c, p*q) != 1: return None if legendreSymbol(c, p) != 1: return None if legendreSymbol(c, q) != 1: return None return pow(c, ((p-1)*(q-1) + 4) / 8, p*q)