I'm trying to implement modular exponentiation in Java using Lagrange and the Chinese remainder theorem.
The example we've been given is:
Let $N = 55 = 5 · 11$ and suppose we want to compute $27^{37} \pmod N$.
He doesn't give us the answer, but says:
The most efficient way to do it is is using Lagrange's theorem, a few multiplications modulo 5 and 11 and CRT to combine both results.
Using Lagrange / Euler totient I get $\varphi(N) = 40$, which it seems I'm supposed to use calculate the congruences needed for putting into the Chinese remainder theorem.
I know I can calculate the congruences using the Extended Euclidean algorithm, but the answers need to be reduced or the run time will still be unfeasible (maybe not in this case, but for the 1024 bit numbers I'm working with, this is a huge problem).
I know they can be reduced, from a document I found while researching this, which states:
$$a^k \equiv a ^ { k \pmod{\varphi(n)}} \pmod n.$$
I've tried and tried and tried to follow how he does the reduction but I just don't get it. He also doesn't mention what $m$ is when he says $k = m · \varphi(n) + k'$.
As you can probably gather, my math is not so hot, so if possible maybe give a "for dummies" answer.
The example given – Let $N = 55 = 5 · 11$ and suppose we want to compute $27^{37} \pmod N$ – is not homework, so if anyone could step me through it, in particular the reductions to get to the simplified Chinese remainder theorem congruences, I would be VERY grateful.