Addition chaining is a method of computing a^{x} mod n
efficiently that is sometimes used in cryptographic systems. Instead
of performing a series of multiplications followed by a large
division, there are ways to minimize the size and number of
multiplications. Because the operations of multiplication and modulo
division are distributive, it is faster to take the modulus between
successive multiplications thus limiting the size of the operands
being multiplied. For instance,
a^{8} mod n = ((a^{2} mod n)^{2} mod n)^{2} mod n
If x in a^{x} mod n is not a power of two then the binary
representation of x can be used.
a^{25} mod n = (a * a^{24}) mod n
But we also know that
a^{24} mod n = (a^{8} * a^{16}) mod n. a^{8}is
((a^{2})^{2})^{2} (a^{(23)}). Likewise
a^{16} = a^{(24)}.
