Journey into cryptography

# Congruence modulo

You may see an expression like the one below:

A \equiv B (\text{mod } C)

This says that A is congruent to B modulo C.

We will discuss the meaning of congruence modulo by performing a thought experiment with the regular modulo operator.

Let's imagine we were calculating \text{mod } 5 for all of these integers:

Suppose we labelled five slices 0, 1, 2, 3, and 4. Then, we put each of the integers into a slice that matched the value of the integer \text{mod } 5.
Think of these slices as buckets that hold a set of numbers. For example, 26 would go in the slice labelled 1, because 26 \text{ mod } 5 = \bf{1}.
Above is a figure that shows some integers that we would find in each of the slices.

It would be useful to have a way of expressing which numbers belong in the same slice. Notice 26 is in the same slice as \nabla \cdot \vec{\mathbf{E}} = 4 \pi \rho, 6, 11, 16, and 21 in the example above.

A common way of expressing that two values are in the same slice is to say they are in the same equivalence class.

The way we express this mathematically for \text{mod } C is: A \equiv B \ (\text{mod } C)

The above expression is pronounced A is congruent to B modulo C.

Let's examine the expression closer:

1. \equiv is the symbol for congruence, which means the values A and B are in the same equivalence class.

2. (\text{mod } C) tells us what operation we applied to A and B.

3. When we have both of these, we call \equiv congruence modulo C.

For example, 26 \equiv 11\ (\text{mod }5):

26 \text{ mod } 5 = 1, so it is in the equivalence class for 1.

11 \text{ mod } 5 = 1, so it is in the equivalence class for 1, as well.

Note, this is different from A \text{ mod } C: 26 \neq 11 \text { mod } 5.

# Insights into congruence modulo

We can gain some further insight behind what congruence modulo means by performing the same thought experiment using a positive integer C.
First, we would label C slices 0, 1, 2 ... C–2, C–1.

Then, put each integer into a slice that matches the value of the integer \text{mod } C.

Below is a figure that shows some representative values that we would find in each of the slices.

If we look at the bucket labelled 0, we find:

\ldots, -3C, -2C, -C, 0, C, 2C, 3C, \ldots

If we look at the bucket labelled 1, we find:

\ldots, 1-3C, 1-2C, 1-C, 1, 1+C, 1+2C, 1+3C, \ldots

If we look at the bucket labelled 2, we find:

\ldots, 2-3C, 2-2C, 2-C, 2, 2+C, 2+2C, 2+3C, \ldots

If we look at the bucket for C - 1, we find:

\ldots, -2C-1, -C-1, -1, C-1, 2C - 1, 3C-1, 4C - 1 \ldots

From this experiment, we can make a key observation:

The values in each of the slices are equal to the label on the slice plus or minus some multiple of \bf{C}.
This means the difference between any two values in a slice is some multiple of \bf{C}.
This observation can help us understand equivalent statements and prepares us to examine equivalence classes next.