Apex › Cryptography

Montgomery multiplication — modular multiply without division

RSA and elliptic-curve crypto compute a·b mod n for a huge modulus thousands of times, and the slow, timing-leaky part is the "mod n" — a full division. Montgomery's trick works in a coordinate system where numbers are held as a·R mod n, so reduction (REDC) needs only multiplies, adds, a bit-mask (mod R) and a shift (÷R) — never a division by n, and the same fixed operations regardless of the values (constant-time). Enter a modulus and two numbers and watch a·b mod n fall out with only masks and shifts.

More in Cryptography