Modular arithmetic: a remainder as a place on a clock, addition that wraps back to zero, and powers that leap around the dial and in the end return to 1.
Step 1 of 6 · Remainders
Step 1 of 6
Remainders
Today’s encryption is built on arithmetic in which numbers never grow: they wrap round. When you divide a whole number by a number , a remainder between and is left. That remainder is written , read “ mod ”.
In the Scene, Alice and Bob are at either end of an open tube, and Eve listens in the middle. Look inside is open at The maths: in the middle of the board stands a dial with places, to , like a clock. Every number lands on the place of its remainder on dividing by .
Step 2 of 6
Round the clock
An ordinary clock is arithmetic mod : after comes again, which we call . To know the time in a few hours, add and take the remainder. The same works for multiplication: you can take the remainder after every step, and the result does not change.
Step 3 of 6
Powers mod p
A key exchange does not add but raises to powers. Choose a prime , here , and a number , here . Alice chooses a secret number and works out
Alice’s secret is now fixed at , and the maths is hidden. Work out yourself.
Step 4 of 6
Step by step
There is no need to work out , an eight-digit number, to know what is. Each power is the one before times , and you can take the remainder after every multiplication. That way the numbers always stay smaller than , and that is how powers of numbers hundreds of digits long are worked out too.
Change Alice’s secret and watch her board and her hand on the dial.
Step 5 of 6
Leaps
The powers of mod do not rise in order: , , , and then a jump. The hand leaps around the dial, and there is no way to know where it will land without working it out.
Step 6 of 6
A full circle
Mod , has a special property: its powers reach every place on the dial except , each place once. Such a number is called a generator. In the last Lesson of this Unit it will be the of the key exchange.
Loading the interactive version…
Loading the interactive version…
Each step sets up the Scene for you, and a control marked “fixed” stays put for that step.
Practice · Calculate
What is ?
Practice · Calculate
What is ?
Practice · Calculate
The clock shows . What will it show in hours? (On a -hour clock, with written here as .)
Practice · Calculate
The clock shows . What will it show in hours? (On a -hour clock, with written here as .)
Practice · Calculate
The arithmetic runs mod , with . Alice’s secret is fixed at . What does she send, ?
Practice · Calculate
The arithmetic runs mod , with . Alice’s secret is fixed at . What does she send, ?
Practice · Reach the target
Change Alice’s secret until is , then press Check.
Practice · Reach the target
Change Alice’s secret until is , then press Check.
Practice · Predict, then look
At , . What will be when Alice’s secret goes up to ? Write a number, and then the Scene moves to .
Practice · Predict, then look
At , . What will be when Alice’s secret goes up to ? Write a number, and then the Scene moves to .
Practice · Predict, then look
The powers of mod leap around the dial. What will be? Choose, and then Alice’s secret moves to .
Practice · Predict, then look
The powers of mod leap around the dial. What will be? Choose, and then Alice’s secret moves to .
Lesson complete. Every practice question here is done.