Safekipedia
Computer arithmeticCryptographic algorithmsModular arithmetic

Montgomery modular multiplication

Adapted from Wikipedia · Adventurer experience

Montgomery modular multiplication is a smart way to make multiplying numbers under modular arithmetic faster. It was created in 1985 by American mathematician Peter L. Montgomery. This method is very useful when we need to do lots of multiplications one after another, like in some important computer security systems.

The secret behind Montgomery multiplication is to represent numbers in a special way, called Montgomery form. This helps the computer skip a slow step called division that normally happens when multiplying numbers under modulus. Instead, it only needs to divide by a special number R, which can be picked to make this division really easy. On computers that work with binary numbers, R is often a power of two, and dividing by such numbers is as simple as shifting bits.

Even though changing numbers to and from this special form takes a few extra steps, it saves time when many multiplications are needed. This is why Montgomery multiplication is used in important systems like RSA and Diffie–Hellman key exchange. These systems work with very large numbers, and Montgomery multiplication helps make those calculations faster and more efficient.

Modular arithmetic

Let N be a positive integer. In modular arithmetic, we look at numbers based on what remains after we divide them by N. These remainders are called residue classes.

For example, when N is 17, the numbers 7 and 24 are in the same residue class. This is because both leave a remainder of 7 when divided by 17.

We can add, subtract, or multiply these residue classes using their remainders. For example, to add 7 and 15 modulo 17, we first add the numbers to get 22. Then we find the remainder when 22 is divided by 17, which is 5. So, 7 + 15 is the same as 5 modulo 17. This helps keep numbers small and easy to work with.

Montgomery form

Montgomery form is a special way to represent numbers that makes multiplying large numbers easier and faster under modular arithmetic. Normally, multiplying two numbers and finding the remainder after division can be slow because division takes a lot of time on computers.

In Montgomery form, numbers are changed so that division can be replaced with simpler actions like shifting or dropping parts of the number. This helps computers do big calculations more quickly.

Montgomery arithmetic on multiprecision integers

Most tools that keep information safe need to work with very large numbers. These numbers can be so big that they do not fit into one piece of computer memory. So, they are split into smaller parts for calculation.

Montgomery multiplication is a clever way to make these big number calculations faster. It breaks down the problem into smaller, easier steps. This helps the computer work more quickly. This method is especially useful when dealing with numbers in modular arithmetic. Modular arithmetic is important for keeping information safe online.

Side-channel attacks

Montgomery reduction avoids extra steps needed in regular division when guesses are wrong. This helps protect against timing and power side-channel attacks because the steps the computer takes do not change based on the numbers being used. There is one small exception at the end, but it can be adjusted to stay safe. It's also important that the overall exponentiation method used with this multiplication is secure.

This article is a child-friendly adaptation of the Wikipedia article on Montgomery modular multiplication, available under CC BY-SA 4.0.