Montgomery (really fast) Modular Exponentiation

Inputs
a
b
N
Completion time (msec):
Derived parameters
k = bits(N)
R = 2k
R-1 mod N
N' = (R*R-1 - 1)/N
Calculations
a(M)
ab(M)
ab (mod N)
Modular exponentiation is a component of many cryptographic protocols (RSA, Diffie-Helman, etc.). It is also computationally expensive and time-consuming. The Montgomery reduction algorithm speeds the process way up by substuting bitwise operations for modular reduction and integer division. This version is based on Javascript BigInt primitives, which may have some security issues in terms of timing attacks. That can be overcome by end-to-end use of binary arrays, which comes with a significant speed reduction.