RSA monoprime: when n = p

If only one prime is used, then n = p where p is the only prime and n is the public modulus. When sharing the public values, n, e, and c, we accidentally reveal our secret prime in n.

Euler phi is p - 1, and the rest is textbook RSA decryption.

c = ...
e = ...
n = ...

p = n
phi = p - 1

assert gcd(e, phi) == 1
d = pow(e, -1, phi)
m = pow(c, d, n)

print(long_to_bytes(m))