Clock (Modular) Arithmetic

From the earliest encryption solutions to zk-SNARKs, all cryptography models make use of Modular Arithmetic

Trapdoor Functions

Clock Arithmetic is a classic example of a trapdoor function.

What does that even mean?

Simply put, a trapdoor function is a problem that is easy to solve in one direction, but extremely hard in the other. For example, solving a Sudoku can be extremely tough. But once you have solved it, it’s easy to verify if the solution is correct.

Because of this property, trapdoor functions are incredibly useful in encryption cryptography.

Modulo Operator

Clock arithmetic uses a function called the "modulo operator" or simply 'mod'. It looks like this in an equation:

A mod B = R 

Let's look at a simple example to understand how the mod works:

Say you want to calculate the value of:

27 mod 12 

You could take a rope of length 27 units, and wrap it around a clock. Wherever the rope ends, is the solution to this modular equation.

In this case, the rope goes around the clock two times and ends at 3 so,

27 mod 12 = 3

In more technical terms, we divide the number 27 by 12, and the remainder of 3 is the solution. As simple as that!

We say, ‘27 mod 12 is congruent to 3’ or,

27 mod 12 ≡ 3

Why do we need Modular Arithmetic?

So why on earth is this helpful? Turns out, using modulo arithmetic, we get a cyclic group of answers. In our example, whenever we take a modulus of any number with 12, the answer will always be one of the following: {0, 1, 2, 3,.., 10, 11}

For example:

  • 15 mod 12 ≡ 3

  • 350 mod 12 ≡ 2

  • 1000 mod 12 ≡ 6

  • 25000 mod 12 ≡ 4

  • 5427519 mod 12 ≡ 3 

It is easy to calculate the mod of any number. But, if you only have the solution to the mod of a number, it is extremely difficult to do a back calculation to find the original number. This property forms the basis of all encryption techniques.

In the next few posts, we’ll learn how modular arithmetic has been used in various cryptographic models over the years.