In basic cryptology we become very comfortable with arithmetic carried out mod 26, but it rapidly becomes necessary to consider other possible moduli as well. Here we provide the basics of modular arithmetic.
First we have to pick a modulus which is a positive whole
number m. We say two numbers a, b are equal modulo m (or
congruent modulo m; that is the proper term) if
m divides a-b. In that case, we write
(an
equals sign with three bars).
Examples:
The neat things about modular arithmetic is that all the basic
operations, addition, subtraction, multiplication and division, all
preserve congruences to the same modulus. Thus, given
and
,
we can conclude that
We have to be a little careful about division, because we do not want
to divide by 0, of course, and in modular arithmetic other numbers
(such as 11 or 22 in this example) could be equivalent to 0.
Arithmetic modulo 2 is especially simple, because we have a very small addition table.
| + | 0 | 1 |
| 0 | 0 | 1 |
| 1 | 1 | 0 |
Here is a more indepth look at modular arithmetic. Suppose we have a
modulus m, and pairs of congruent integers modulo m:
Multiplication is a little harder:
The first step is known as ``adding-and-subtracting.'' If you add and
subtract the same quantity, you don't change the expression.
Theoretically, though, that allows us to see that ab-cd is still a
multiple of m. That proves the multiplication property.
These are very powerful properties. For instance, we can use them to
compute congruences with extremely large numbers. As an example,
suppose we would like to know the last decimal digit of 7100. That
number is far too large for our calculator, but all we are asking for
is
(the last decimal digit). Then we might compute a
few powers and see that
.
Aha! That means
As a final note here, you should be careful of the difference between
modular arithmetic and word arithmetic. Words are strings of
bits, such as 10111001, which is a word of length 8 bits. We have
seen in [Beutelspacher, 1994] the use of arithmetic of words in
cipher systems such as the one-time pad and the Data Encryption
System. This not quite the same as modular arithmetic. Addition of
words is carried out bit by bit. One common notation is