1

I am dealing with the following question:

Given a,b,c,d, p positive integers, I wanna compute a^(b^(c^d)) mod 2p+1.

Given that p is sophie-germain. That is, 2p+1 is also prime.

Any ideas?

1 Answers1

1

Here are my comments in more detail.

Fermat's little theorem allows us too first reduce $b^{(c^d)}$ modulo $2p+ 1 - 1 = 2p$ since $2p+1$ is a prime.

Now, we actually need a slightly stronger result to go further, namely Euler's generalization of the above. This allows us to reduce the new exponent $c^d$ mod $\varphi(2p) = p-1$ (or modulo $2$ if $p=2$), at least when $b$ is coprime to $2p$.

So in the end we need to find $c^d$ modulo $p-1$ which can be done by repeated squaring.