Why it matters

Modexp is crypto workhorse. Understanding shapes cryptography.

Advertisement

The architecture

Square-and-multiply based on binary rep of b.

Reduce mod m at each step.

O(log b) mults.

Modexp flowBinary rep of bbitsSquare + multiplyper bitMod mat each stepMontgomery multiplication accelerates when many mults needed same modulus
Modexp.
Advertisement

How it works end to end

Right-to-left or left-to-right variants.

Montgomery form for repeated mult.

Side-channel considerations for crypto.