Answer key · Unit 7
Cryptography.
Each lesson’s practice questions, their correct answers and the mistakes they spot. Answers read off the Scene use the same setting the learner sees.
Answer key 4
Lesson 1 of 4 · About 20 minutes
Clock arithmetic
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.
The 6 steps and their answers
Practice · Calculate
Question
What is ?
Correct answer
2 ± 0.01
Setup, choices and feedback
The Scene at this step
- Alice's secret
- 6
- Locked message / The maths
- The maths
- Accepted within
- ± 0.01
- A fixed value in the question
Wrong answers it recognises
3 ± 0.01
Misconception: Gives the quotient of the division (how many times it goes in) instead of the remainder.
Feedback from the catalogue
“” is the remainder when is divided by , not the result of the division. In five goes in times, , and is left: so . The remainder is always between and , like a place on a clock with places.
3.4 ± 0.01
Misconception: Gives the quotient of the division (how many times it goes in) instead of the remainder.
Feedback from the catalogue
“” is the remainder when is divided by , not the result of the division. In five goes in times, , and is left: so . The remainder is always between and , like a place on a clock with places.
Feedback for a right answer
, so . On a clock with places, to , a step of from goes round three times and lands on .
Hint
How many times does go into , and what is left?
Worked solution
- Divide: goes into three times, .
- The remainder: .
- So .
If you answered or , you gave the result of the division. “Mod” keeps only what is left over.
Practice · Calculate
Question
The clock shows . What will it show in hours? (On a -hour clock, with written here as .)
Correct answer
5 ± 0.01
Setup, choices and feedback
The Scene at this step
- Alice's secret
- 6
- Locked message / The maths
- The maths
- Accepted within
- ± 0.01
- A fixed value in the question
Wrong answers it recognises
17 ± 0.01
Misconception: Forgets to wrap round: gives the plain result instead of its remainder mod n.
Feedback from the catalogue
In modular arithmetic every result wraps back onto the clock: after comes . Nine o’clock plus hours is not on a -hour clock, but . Powers too: , but . After each calculation, divide by and keep only the remainder.
Feedback for a right answer
, and : five o’clock. That is modular arithmetic, clock arithmetic: each time you pass , you start again from zero.
Hint
Add, then find the remainder on dividing by .
Worked solution
- Add: .
- On a -hour clock: .
- , and the clock shows .
If you answered , you forgot to wrap round: the clock has no place .
Practice · Calculate
Question
The arithmetic runs mod , with . Alice’s secret is fixed at . What does she send, ?
Correct answer
2 ± 0.01
Setup, choices and feedback
The Scene at this step
- Alice's secret
- 2fixed
- Locked message / The maths
- Mixing paintfixed
- Accepted within
- ± 0.01
- Computed from the Scene at this step’s setting
- What Alice sends, A = gᵃ mod p
/nodes/kx/outputs/alicePublic
Wrong answers it recognises
25 ± 0.01
Misconception: Forgets to wrap round: gives the plain result instead of its remainder mod n.
Feedback from the catalogue
In modular arithmetic every result wraps back onto the clock: after comes . Nine o’clock plus hours is not on a -hour clock, but . Powers too: , but . After each calculation, divide by and keep only the remainder.
10 ± 0.01
Misconception: Multiplies the base by the exponent (5 × 6) instead of raising it to that power (5⁶).
Feedback from the catalogue
means multiplying by itself times, not multiplying by . , not . Mod you do it step by step: each power is the one before times , then the remainder. From you get .
1 ± 0.01
Misconception: Gives the quotient of the division (how many times it goes in) instead of the remainder.
Feedback from the catalogue
“” is the remainder when is divided by , not the result of the division. In five goes in times, , and is left: so . The remainder is always between and , like a place on a clock with places.
Feedback for a right answer
, so . On the dial with places, Alice’s hand points at .
Hint
Work out , then its remainder on dividing by .
Worked solution
- .
- .
- .
If you answered , you did not take the remainder. If you answered , you multiplied instead of squaring. If you answered , you gave the result of the division, not the remainder.
Practice · Reach the target
Question
Change Alice’s secret until is , then press Check.
Goal
10 ± 0.1
At the start of the step: 5
Setup, choices and feedback
The Scene at this step
- Alice's secret
- 1
- Locked message / The maths
- The mathsfixed
- Read from the Scene at
- What Alice sends, A = gᵃ mod p
/nodes/kx/outputs/alicePublic
One setting that reaches it
- Alice's secret
- 3
Feedback for a right answer
: . There is no need to work out : you can take the remainder after every multiplication, and the numbers stay small. That is how powers of numbers hundreds of digits long are worked out.
Feedback for a wrong answer
Not yet. Watch Alice’s board: it shows for every .
Hint
Each power is the one before times , then the remainder: , , and next?
Worked solution
- .
- .
- .
- Set Alice’s secret to .
If you tried , you got : is multiplication, not a power.
Practice · Predict, then look
Question
At , . What will be when Alice’s secret goes up to ? Write a number, and then the Scene moves to .
Correct answer
4 ± 0.1
A number prediction counts as right within ± 0.1
Setup, choices and feedback
The Scene at this step
- Alice's secret
- 3fixed
- Locked message / The maths
- The mathsfixed
Once the prediction is locked in, the Scene changes
- Alice's secret
- 4fixed
The Scene then shows: 4 · What Alice sends, A = gᵃ mod p
/nodes/kx/outputs/alicePublicA prediction is never marked as a failure: the learner sees the outcome and the explanation either way.
Feedback for a right answer
, so . The hand jumped back from to : powers mod do not grow in order, they leap around the clock. That is exactly what makes them hard to guess.
Feedback for a wrong answer
Multiply the last , , by , and take the remainder on dividing by .
Hint
Multiply by and take the remainder on dividing by .
Worked solution
- , so .
- .
- .
- .
If you wrote , you forgot to wrap round the clock. If you wrote , you added instead of multiplying by it.
Practice · Predict, then look
Question
The powers of mod leap around the dial. What will be? Choose, and then Alice’s secret moves to .
Correct answer
Correct : after steps the powers come back to the start
Setup, choices and feedback
The Scene at this step
- Alice's secret
- 3fixed
- Locked message / The maths
- The mathsfixed
Choices
Correct : after steps the powers come back to the start
Wrong , the last place on the dial
Feedback
There is no reason the nd power should land on place : the powers leap about, and already lands there.
Wrong : the power is so big that it reaches a multiple of
Feedback
is a product of fives only, and is prime, so never divides it: the remainder is never , however large the exponent.
Once the prediction is locked in, the Scene changes
- Alice's secret
- 22fixed
The Scene then shows: 1 · What Alice sends, A = gᵃ mod p
/nodes/kx/outputs/alicePublicA prediction is never marked as a failure: the learner sees the outcome and the explanation either way.
Feedback for a right answer
. The powers of , from to , pass through all non-zero places, each once, and come back to . From there they repeat: . A number like , whose powers reach every place, is called a generator, and it is what a key exchange uses.
Hint
The dial has places besides . If reaches each of them exactly once, where do you arrive after a full round?
Worked solution
- The powers of mod : 5, 2, 10, 4, 20, 8, 17, 16, 11, 9, 22, 18, 21, 13, 19, 3, 15, 6, 7, 12, 14, 1.
- These are different numbers: every place on the dial except .
- The nd power is , and from there the sequence starts again.
This is a case of Fermat’s little theorem: when is prime and is not divisible by it, .
Lesson 2 of 4 · About 25 minutes
Prime numbers
What makes a number prime, how the sieve of Eratosthenes finds them all, why they thin out, and why primes are easy to multiply and hard to find again.
The 6 steps and their answers
Practice · Choose
Question
Which of these numbers are prime? Choose all of them.
Correct answer
Correct
Correct
Setup, choices and feedback
The Scene at this step
- Count up to
- 100
- Sieve the spiral
- Spiralfixed
Choices
More than one choice is correct: every one must be selected.
Wrong
Misconception: Counts 1 as a prime number.
Feedback from the catalogue
A prime is a whole number with exactly two divisors: and itself. has only one divisor, so it is neither prime nor composite. The definition was chosen so that every number has only one way to be written as a product of primes: if were prime, you could write and in endless other ways.
Correct
Wrong
Misconception: Takes an odd number that has no obvious small factor, such as 51, 91 or 99, to be prime.
Feedback from the catalogue
An odd number is not divisible by , but it can be divisible by , or any other prime. , and . To know a number is prime, check that no prime up to its square root divides it: for , check , , and , and divides it.
Wrong
Misconception: Takes an odd number that has no obvious small factor, such as 51, 91 or 99, to be prime.
Feedback from the catalogue
An odd number is not divisible by , but it can be divisible by , or any other prime. , and . To know a number is prime, check that no prime up to its square root divides it: for , check , , and , and divides it.
Correct
Feedback for a right answer
and . is the only even prime. is not divisible by , , or , and that is enough, because is already bigger. , , and is not prime: it has only one divisor.
Hint
For each number, try dividing it by the primes , , and .
Worked solution
- : it has only one divisor, so it is not prime.
- : its divisors are and . Prime.
- : its digit sum, , is divisible by , and . Composite.
- . Composite.
- : not divisible by , , or , and . Prime.
Numbers like and “look” prime because they are odd and do not end in . You have to check every prime up to the square root.
Practice · Calculate
Question
Count up to is fixed at . What is the largest prime up to ?
Correct answer
97 ± 0.1
Setup, choices and feedback
The Scene at this step
- Count up to
- 100fixed
- Sieve the spiral
- Spiralfixed
- Accepted within
- ± 0.1
- Computed from the Scene at this step’s setting
- The largest prime from 1 to count
/nodes/spiral/outputs/largestPrime
Wrong answers it recognises
99 ± 0.1
Misconception: Takes an odd number that has no obvious small factor, such as 51, 91 or 99, to be prime.
Feedback from the catalogue
An odd number is not divisible by , but it can be divisible by , or any other prime. , and . To know a number is prime, check that no prime up to its square root divides it: for , check , , and , and divides it.
Feedback for a right answer
. and are even, , and is divisible by none of the primes , , and . On the tray it is a raised gold tile.
Hint
Work down from and check each odd number.
Worked solution
- and are even: composite.
- : its digit sum, , is divisible by , and . Composite.
- : check the primes up to , that is , , and . None of them divides it.
- is the largest prime up to .
If you answered , it is odd but divisible by and by .
Practice · Predict, then look
Question
Count up to is . The sieve of Eratosthenes circles a prime, crosses out its multiples, and moves on to the next prime. Through how many primes must it go before every tile left is prime? Choose, and then Sieve the spiral runs the sieve to the end.
Correct answer
Correct : the primes up to
Setup, choices and feedback
The Scene at this step
- Count up to
- 400fixed
- Sieve the spiral
- Spiralfixed
Choices
Correct : the primes up to
Wrong : every prime up to
Misconception: Thinks the sieve must cross out multiples of every prime up to the count, not just of the primes up to its square root.
Feedback from the catalogue
A composite number up to always has a prime factor no bigger than : if both its factors were bigger than , their product would be bigger than . So once the sieve has run through the primes up to , every composite has been crossed out. Up to , , and eight primes are enough: to .
Wrong : the primes , , and
Feedback
, , and are enough up to , but not up to : , , and are composites none of them crosses out.
Once the prediction is locked in, the Scene changes
- Sieve the spiral
- 0.62 (Spiral → Sieve and gaps)fixed
The Scene then shows: 8 · How many primes the sieve runs through (those up to √count)
/nodes/spiral/outputs/sievingPrimesA prediction is never marked as a failure: the learner sees the outcome and the explanation either way.
Feedback for a right answer
Eight: . Every composite up to is divisible by a prime no bigger than , so after there is nothing left to cross out. The sieve starts crossing each prime’s multiples from its square, because the smaller ones are gone already.
Hint
A composite number up to has a prime factor no bigger than .
Worked solution
- If and both factors are bigger than , then .
- So every composite up to has a prime factor no bigger than .
- The primes up to : . Eight.
- Once the sieve has gone through them, every tile left is prime.
If you chose , the sieve would carry on for nothing: has no composite multiple up to that is not crossed out already, since .
Practice · Reach the target
Question
Up to there are primes. Change Count up to until the slate shows primes, then press Check.
Goal
168 ± 0.1
At the start of the step: 25
Setup, choices and feedback
The Scene at this step
- Count up to
- 100
- Sieve the spiral
- Spiralfixed
- Read from the Scene at
- How many primes there are from 1 to count
/nodes/spiral/outputs/primeCount
One setting that reaches it
- Count up to
- 1000
Feedback for a right answer
At . Ten times as many numbers, but only times as many primes: up to a quarter of the numbers are prime, and up to under a sixth. The bigger a number, the more small primes there are that might divide it.
Feedback for a wrong answer
Not yet. The slate behind the tray counts the primes. Keep counting further.
Hint
If the primes kept their density, would come at about . They do not.
Worked solution
- Move Count up to and watch the number of primes on the slate.
- Up to there are primes, and up to there are .
- Exactly comes at .
If you expected around , you assumed the primes keep to a quarter of the numbers. They thin out.
Practice · Calculate
Question
Count up to is fixed at , and the slate shows how many primes there are up to there. What share of the numbers up to is prime? Answer in per cent.
Correct answer
12.29 ± 0.05
Setup, choices and feedback
The Scene at this step
- Count up to
- 10000fixed
- Sieve the spiral
- Spiralfixed
- Accepted within
- ± 0.05
- Computed from the Scene at this step’s setting
- How many primes there are from 1 to count
/nodes/spiral/outputs/primeCount
Wrong answers it recognises
25 ± 0.05
Misconception: Thinks primes keep the same share of the numbers however far you count, as the quarter below 100.
Feedback from the catalogue
The primes thin out. Up to there are , a quarter of the numbers; up to there are , under a sixth; up to there are , about an eighth. The bigger a number, the more smaller primes there are that might divide it. The chance that a number near is prime is about , which shrinks slowly. And still they never run out: Euclid proved there are infinitely many primes.
16.8 ± 0.05
Misconception: Thinks primes keep the same share of the numbers however far you count, as the quarter below 100.
Feedback from the catalogue
The primes thin out. Up to there are , a quarter of the numbers; up to there are , under a sixth; up to there are , about an eighth. The bigger a number, the more smaller primes there are that might divide it. The chance that a number near is prime is about , which shrinks slowly. And still they never run out: Euclid proved there are infinitely many primes.
Feedback for a right answer
: about an eighth of the numbers. Up to it was a quarter, and up to about a sixth. The density falls roughly like , slowly, and never reaches zero.
Hint
Divide the number of primes by and multiply by .
Worked solution
- The slate shows primes up to .
- The share: .
- In per cent: .
If you answered or , you used the density up to or up to . The primes thin out as you count further.
Practice · Choose
Question
Multiplying is easy: . Now the other way round: someone gives you only . What is true of it?
Correct answer
Correct It is a product of two primes, and finding them takes far longer than multiplying them
Setup, choices and feedback
The Scene at this step
- Count up to
- 10000
- Sieve the spiral
- Sieve and gaps
Choices
Shown in a random order.
Correct It is a product of two primes, and finding them takes far longer than multiplying them
Wrong It is prime, because it is not divisible by , , or
Misconception: Takes an odd number that has no obvious small factor, such as 51, 91 or 99, to be prime.
Feedback from the catalogue
An odd number is not divisible by , but it can be divisible by , or any other prime. , and . To know a number is prime, check that no prime up to its square root divides it: for , check , , and , and divides it.
Wrong Its factors are found as fast as you multiply
Feedback
To find the factors you have to try primes one after another, up to : twenty-four tries, and only the last, , works. All that instead of one multiplication.
Feedback for a right answer
. Multiplying takes a moment, but the simple way to factor is to try primes one after another, and here you must get as far as . For numbers hundreds of digits long multiplying still takes a moment, and no fast way to factor is known. Cryptography rests on that gap between an easy direction and a hard one.
Hint
To know whether is prime, you must check every prime up to . How far is that?
Worked solution
- , so you must check the primes up to .
- , , , and nineteen more primes, up to , do not divide .
- does: .
- , a product of two primes.
If you thought it prime, you stopped too soon: checking up to is enough only for numbers up to .
Lesson 3 of 4 · About 20 minutes
Keys and guessing
A message locked with a key, the trouble of passing the key, and why every extra bit in the key doubles the time a codebreaker needs to try them all.
The 6 steps and their answers
Practice · Choose
Question
Alice wants to send Bob a message locked with a key. Eve copies everything that passes through the tube. What is the trouble with first sending the key down the same tube?
Correct answer
Correct Eve copies the key too, and opens every message with it
Setup, choices and feedback
The Scene at this step
- Key size
- 56 bits
- Unlock step by step
- Locked messagefixed
Choices
Shown in a random order.
Correct Eve copies the key too, and opens every message with it
Wrong No trouble: the key is short, and Eve will not notice it
Feedback
Eve copies every capsule that passes, short or long. A key that went down the open tube is hers too.
Wrong No trouble: lock the key with a second key
Feedback
Then Bob needs the second key, and down which tube? The problem only moves one step back. That is why for generations keys travelled by hand, by courier and at meetings.
Feedback for a right answer
A key that crossed an open channel is no longer secret. That is the key distribution problem: to talk in secret you need a shared key, and to pass a key you need a secret channel. In the next Lesson you will see how Diffie and Hellman solved it in 1976.
Hint
What can Eve do with anything she copies?
Worked solution
- Everything that passes through the tube reaches Eve too.
- If the key goes down the tube, Eve has the same key as Bob.
- With it she opens every message locked with it.
Locking the key with a second key does not help: the second key has to travel the same way.
Practice · Calculate
Question
Key size is fixed at bits, and Eve’s machine board shows keys to try. How many different keys are there at bits?
Correct answer
65540 ± 0.5
Setup, choices and feedback
The Scene at this step
- Key size
- 8 bitsfixed
- Unlock step by step
- Locked messagefixed
- Accepted within
- ± 0.5
- A fixed value in the question
Wrong answers it recognises
512 ± 0.5
Feedback from the catalogue
An -bit key has values, because each bit doubles the number of possibilities. A key eight bits longer does not hold eight more keys, nor times as many, but times as many. And a key twice as long, bits instead of , holds not twice as many keys but times as many. That is why keys only a little longer put guessing out of all reach.
32 ± 0.5
Feedback from the catalogue
An -bit key has values, because each bit doubles the number of possibilities. A key eight bits longer does not hold eight more keys, nor times as many, but times as many. And a key twice as long, bits instead of , holds not twice as many keys but times as many. That is why keys only a little longer put guessing out of all reach.
Feedback for a right answer
. Eight more bits doubled the number of keys eight times: . A key twice as long holds not twice as many keys, but the old number of keys squared.
Hint
Each extra bit doubles the number of keys. How many bits were added?
Worked solution
- Each bit has two possibilities, or .
- For bits: , sixteen times, that is .
- .
If you answered , you doubled once, as if a key twice as long held twice as many keys. If you answered , you multiplied .
Practice · Predict, then look
Question
Key size is bits, like DES’s from 1977, and Eve’s machine tries every key in about twenty hours. Now the key will grow to bits. How many times longer will Eve need?
Correct answer
Correct times
Setup, choices and feedback
The Scene at this step
- Key size
- 56 bitsfixed
- Unlock step by step
- Locked messagefixed
Choices
Correct times
Wrong times, because the key is a seventh longer
Feedback from the catalogue
An -bit key has values, because each bit doubles the number of possibilities. A key eight bits longer does not hold eight more keys, nor times as many, but times as many. And a key twice as long, bits instead of , holds not twice as many keys but times as many. That is why keys only a little longer put guessing out of all reach.
Wrong times, because eight bits were added
Feedback from the catalogue
An -bit key has values, because each bit doubles the number of possibilities. A key eight bits longer does not hold eight more keys, nor times as many, but times as many. And a key twice as long, bits instead of , holds not twice as many keys but times as many. That is why keys only a little longer put guessing out of all reach.
Once the prediction is locked in, the Scene changes
- Key size
- 64 bitsfixed
The Scene then shows: 0.5845 · The same in years of 365.25 days
/nodes/kx/outputs/yearsToTryAllA prediction is never marked as a failure: the learner sees the outcome and the explanation either way.
Feedback for a right answer
times: from twenty hours to about seven months. Each bit doubles the number of keys and the time, so eight bits, one byte, multiply it by . In 1998 a purpose-built machine found a DES key in under three days, which is why much longer keys are used today.
Hint
Each bit doubles the number of keys. What do eight bits do?
Worked solution
- At bits there are keys, and at bits .
- The ratio: .
- At the same rate of trying, the time grows times: from about twenty hours to about years.
If you chose or times, you thought the number of keys grows in the same ratio as the key’s length. It doubles for every bit.
Practice · Predict, then look
Question
Key size is bits, and Eve’s machine, trying keys a second, goes through them all in about seconds. How long will a -bit key take it? Write it in seconds.
Correct answer
281.5 s ± 5%
A number prediction counts as right within ± 5%
Setup, choices and feedback
The Scene at this step
- Key size
- 40 bitsfixed
- Unlock step by step
- Locked messagefixed
Once the prediction is locked in, the Scene changes
- Key size
- 48 bitsfixed
The Scene then shows: 281.5 s · Seconds Eve needs to try every key at guessRate keys a second
/nodes/kx/outputs/secondsToTryAllA prediction is never marked as a failure: the learner sees the outcome and the explanation either way.
Feedback for a right answer
seconds, a little under five minutes. Or directly: .
Feedback for a wrong answer
Multiply the seconds for bits by the number of times the key count grew.
Hint
Eight more bits: times as many keys.
Worked solution
- From to bits, bits are added, and the number of keys grows times.
- The rate does not change, so the time grows times too.
- seconds.
If you wrote about seconds, you grew the time in the same ratio as the key’s length, .
Practice · Reach the target
Question
Change Key size until Eve’s machine needs about seven months, years, to try every key, then press Check.
Goal
0.58 ± 5%
At the start of the step: 10780000000000000000
Setup, choices and feedback
The Scene at this step
- Key size
- 128 bits
- Unlock step by step
- Locked messagefixed
- Read from the Scene at
- The same in years of 365.25 days
/nodes/kx/outputs/yearsToTryAll
One setting that reaches it
- Key size
- 64 bits
Feedback for a right answer
bits: seconds, about seven months. Eight bits fewer and it is twenty hours; eight bits more, , and it is already about a hundred and fifty years.
Feedback for a wrong answer
Not yet. Watch the time on Eve’s board, and change the key size a byte at a time.
Hint
A year is about seconds. How many keys does the machine try in seven months?
Worked solution
- Seven months is about seconds.
- At keys a second, that is about keys.
- .
- Set Key size to bits.
Practice · Choose
Question
A -bit key is twice as long as a -bit key. How many times as many keys does it have?
Correct answer
Correct times, about
Setup, choices and feedback
The Scene at this step
- Key size
- 128 bits
- Unlock step by step
- Locked message
Choices
Shown in a random order.
Correct times, about
Wrong times
Feedback from the catalogue
An -bit key has values, because each bit doubles the number of possibilities. A key eight bits longer does not hold eight more keys, nor times as many, but times as many. And a key twice as long, bits instead of , holds not twice as many keys but times as many. That is why keys only a little longer put guessing out of all reach.
Wrong times, because bits were added
Feedback from the catalogue
An -bit key has values, because each bit doubles the number of possibilities. A key eight bits longer does not hold eight more keys, nor times as many, but times as many. And a key twice as long, bits instead of , holds not twice as many keys but times as many. That is why keys only a little longer put guessing out of all reach.
Feedback for a right answer
. A -bit key already takes Eve’s machine a billion times the age of the universe. A -bit key multiplies that another times. Guessing the key is no way to break good encryption; what threatens it is a weakness in the method itself.
Hint
Worked solution
- At bits there are keys, and at bits .
- The ratio: .
- .
Doubling a key’s length squares the number of keys: .
Lesson 4 of 4 · About 30 minutes
The Diffie–Hellman key exchange
How two strangers agree on a secret key over a channel everyone can hear: mixing paint, the same idea in modular arithmetic, and why Eve cannot work out the key herself.
The 6 steps and their answers
Practice · Choose
Question
Alice and Bob have never met and share no secret at all. They can talk only through the open tube, and Eve copies everything in it. Can they agree on a shared secret colour?
Correct answer
Correct Yes: each mixes a secret colour of their own into the public one, sends the mixture, and adds their secret to what they receive
Setup, choices and feedback
The Scene at this step
- Alice's secret
- 6hidden
- Bob's secret
- 15hidden
- Locked message / The maths
- Mixing paintfixed
Choices
Shown in a random order.
Correct Yes: each mixes a secret colour of their own into the public one, sends the mixture, and adds their secret to what they receive
Wrong No: first they must meet, or send the secret by courier
Misconception: Thinks two parties can only agree on a secret key if some secret has already passed between them, in advance or down the channel.
Feedback from the catalogue
Everyone thought so until 1976, when Diffie and Hellman showed it is not true. In their key exchange no secret passes down the channel: each side keeps its secret, or , and sends only or . Each side combines the value it received with its own secret, and both reach the same . Eve sees everything that passes, and still has no fast way to reach .
Wrong Yes, if each sends their secret colour fast enough
Feedback
Speed does not help: Eve copies every capsule, and a secret colour that goes down the tube is no longer secret.
Feedback for a right answer
Yes. Only mixtures of the public colour with a secret pass through the tube, and the secrets themselves stay at home. Each side adds its secret to the mixture it received, and both reach the same colour: public, Alice’s secret and Bob’s secret, in any order. Eve can only mix the two mixtures, which gives a colour with too much yellow.
Hint
Watch what passes through the tube in the Scene: does a secret colour ever pass through it?
Worked solution
- A public colour is known to everyone, Eve included.
- Alice sends public + her secret; Bob sends public + his secret. The secrets are not sent.
- Alice adds her secret to what she got from Bob, and Bob adds his to what he got from Alice.
- Both sides now hold public + Alice’s secret + Bob’s secret: the same colour.
- Eve holds two mixtures, and paint cannot be unmixed.
If you answered that they must meet, that was everyone’s assumption until 1976.
Practice · Calculate
Question
Now in numbers. The public values: and . Alice’s secret is . What does she send, ?
Correct answer
8 ± 0.1
Setup, choices and feedback
The Scene at this step
- Alice's secret
- 6fixed
- Bob's secret
- 15fixed
- Locked message / The maths
- Mixing paintfixed
- Accepted within
- ± 0.1
- Computed from the Scene at this step’s setting
- What Alice sends, A = gᵃ mod p
/nodes/kx/outputs/alicePublic
Wrong answers it recognises
30 ± 0.1
Misconception: Multiplies the base by the exponent (5 × 6) instead of raising it to that power (5⁶).
Feedback from the catalogue
means multiplying by itself times, not multiplying by . , not . Mod you do it step by step: each power is the one before times , then the remainder. From you get .
15630 ± 0.1
Misconception: Forgets to wrap round: gives the plain result instead of its remainder mod n.
Feedback from the catalogue
In modular arithmetic every result wraps back onto the clock: after comes . Nine o’clock plus hours is not on a -hour clock, but . Powers too: , but . After each calculation, divide by and keep only the remainder.
679 ± 0.1
Misconception: Gives the quotient of the division (how many times it goes in) instead of the remainder.
Feedback from the catalogue
“” is the remainder when is divided by , not the result of the division. In five goes in times, , and is left: so . The remainder is always between and , like a place on a clock with places.
Feedback for a right answer
. A short way: , and , so . Alice sends down the tube, and Eve copies it. The she sends to nobody.
Hint
Climb the powers step by step, taking the remainder after each multiplication: , , …
Worked solution
- , and .
- , so .
- , less than .
- .
Or directly: . If you answered , you multiplied . If you answered , you did not take the remainder, and if , you gave the result of the division.
Practice · Calculate
Question
Bob’s secret is , and he sent . Alice combines it with her own secret, . What is her shared key, ?
Correct answer
2 ± 0.1
Setup, choices and feedback
The Scene at this step
- Alice's secret
- 6fixed
- Bob's secret
- 15fixed
- Locked message / The maths
- Mixing paintfixed
- Accepted within
- ± 0.1
- Computed from the Scene at this step’s setting
- The shared key s = Bᵃ mod p = Aᵇ mod p
/nodes/kx/outputs/sharedSecret
Wrong answers it recognises
22 ± 0.1
Misconception: Multiplies the base by the exponent (5 × 6) instead of raising it to that power (5⁶).
Feedback from the catalogue
means multiplying by itself times, not multiplying by . , not . Mod you do it step by step: each power is the one before times , then the remainder. From you get .
47050000 ± 1
Misconception: Forgets to wrap round: gives the plain result instead of its remainder mod n.
Feedback from the catalogue
In modular arithmetic every result wraps back onto the clock: after comes . Nine o’clock plus hours is not on a -hour clock, but . Powers too: , but . After each calculation, divide by and keep only the remainder.
14 ± 0.1
Misconception: Thinks the shared key can be worked out directly from the public values, for example as A × B mod p.
Feedback from the catalogue
The shared secret is : reaching it takes or . From the public values you can only make combinations such as , with the sum of the exponents, not their product. Here , not . To find from , Eve must solve the discrete logarithm problem, and no fast way to do that is known.
Feedback for a right answer
. , , and . That is the key Alice will lock her messages with.
Hint
, and . Now , and .
Worked solution
- , so .
- , because .
- , so .
- .
If you answered , you multiplied instead of raising to the power. If you answered , you multiplied the two public values, : Eve can do that too, and it is not the key.
Practice · Predict, then look
Question
Bob got from Alice, and combines it with his own secret: he works out . What will he get? Choose, and then Look inside moves to The maths.
Correct answer
Correct , the same key as Alice’s
Setup, choices and feedback
The Scene at this step
- Alice's secret
- 6fixed
- Bob's secret
- 15fixed
- Locked message / The maths
- Mixing paintfixed
Choices
Correct , the same key as Alice’s
Wrong A different number, because each used a different secret
Feedback
Each did use a different secret, but each got the other secret from the other side, wrapped inside or . Both sides end up with raised to and to .
Wrong , the number Bob himself sent
Feedback
is : Bob’s secret alone. also holds Alice’s secret, because .
Once the prediction is locked in, the Scene changes
- Locked message / The maths
- The mathsfixed
The Scene then shows: 2 · The shared key s = Bᵃ mod p = Aᵇ mod p
/nodes/kx/outputs/sharedSecretA prediction is never marked as a failure: the learner sees the outcome and the explanation either way.
Feedback for a right answer
, exactly like Alice. and : both sides work out , each in its own way. That is the whole trick of Diffie and Hellman, from 1976.
Hint
, so . And what is ?
Worked solution
- , so .
- , so .
- The same number: .
- You can check: , and , so .
Practice · Reach the target
Question
Now you are Eve. You saw Bob send , and you know and . Find his secret: change Bob’s secret until comes out as , then press Check.
Goal
19 ± 0.1
At the start of the step: 5
Setup, choices and feedback
The Scene at this step
- Alice's secret
- 6fixed
- Bob's secret
- 1
- Locked message / The maths
- The mathsfixed
- Read from the Scene at
- What Bob sends, B = gᵇ mod p
/nodes/kx/outputs/bobPublic
One setting that reaches it
- Bob's secret
- 15
Feedback for a right answer
. To find it you had to try, one after another, because the powers leap around the dial in no order. That is the discrete logarithm problem: with places it takes a minute, with a prime hundreds of digits long it takes longer than the age of the universe, yet for Alice and Bob a power still takes a tiny fraction of a second.
Feedback for a wrong answer
Not yet. Keep trying: one of the exponents gives .
Hint
There is no shortcut: try exponents one after another and watch .
Worked solution
- Eve knows , and , and looks for with .
- The powers: , , , …, , .
- : set Bob’s secret to .
No way much faster than trying is known. That is why in a real exchange is a prime hundreds of digits long.
Practice · Choose
Question
Eve has copied , , and . What else does she need to work out the shared key ?
Correct answer
Correct or : she has to solve or
Setup, choices and feedback
The Scene at this step
- Alice's secret
- 6
- Bob's secret
- 15
- Locked message / The maths
- The maths
Choices
Shown in a random order.
Correct or : she has to solve or
Wrong Nothing:
Misconception: Thinks the shared key can be worked out directly from the public values, for example as A × B mod p.
Feedback from the catalogue
The shared secret is : reaching it takes or . From the public values you can only make combinations such as , with the sum of the exponents, not their product. Here , not . To find from , Eve must solve the discrete logarithm problem, and no fast way to do that is known.
Wrong Both and
Feedback
One of them is enough: with Eve works out , exactly as Alice does, and with she works out , as Bob does.
Feedback for a right answer
She needs one of the secrets. , with the sum of the exponents, not : here , not . To extract from she has to solve a discrete logarithm, and that is the hard part.
Hint
. What can Eve get from and without knowing the exponents?
Worked solution
- The shared key: .
- From the public values Eve can work out combinations such as , but not .
- If she finds , she works out . If she finds , she works out .
- So she needs or , that is to solve or .
Across the unit · 10 misconceptions
Misconception catalogue
Each common mistake this unit recognises, in a few words. Open one for what the learner reads when an answer matches it, and where it is asked.
Gives the quotient of the division (how many times it goes in) instead of the remainder.
- The learner reads
“” is the remainder when is divided by , not the result of the division. In five goes in times, , and is left: so . The remainder is always between and , like a place on a clock with places.
Forgets to wrap round: gives the plain result instead of its remainder mod n.
- The learner reads
In modular arithmetic every result wraps back onto the clock: after comes . Nine o’clock plus hours is not on a -hour clock, but . Powers too: , but . After each calculation, divide by and keep only the remainder.
Multiplies the base by the exponent (5 × 6) instead of raising it to that power (5⁶).
- The learner reads
means multiplying by itself times, not multiplying by . , not . Mod you do it step by step: each power is the one before times , then the remainder. From you get .
Counts 1 as a prime number.
- The learner reads
A prime is a whole number with exactly two divisors: and itself. has only one divisor, so it is neither prime nor composite. The definition was chosen so that every number has only one way to be written as a product of primes: if were prime, you could write and in endless other ways.
- Recognised in
Takes an odd number that has no obvious small factor, such as 51, 91 or 99, to be prime.
- The learner reads
An odd number is not divisible by , but it can be divisible by , or any other prime. , and . To know a number is prime, check that no prime up to its square root divides it: for , check , , and , and divides it.
Thinks the sieve must cross out multiples of every prime up to the count, not just of the primes up to its square root.
- The learner reads
A composite number up to always has a prime factor no bigger than : if both its factors were bigger than , their product would be bigger than . So once the sieve has run through the primes up to , every composite has been crossed out. Up to , , and eight primes are enough: to .
- Recognised in
Thinks primes keep the same share of the numbers however far you count, as the quarter below 100.
- The learner reads
The primes thin out. Up to there are , a quarter of the numbers; up to there are , under a sixth; up to there are , about an eighth. The bigger a number, the more smaller primes there are that might divide it. The chance that a number near is prime is about , which shrinks slowly. And still they never run out: Euclid proved there are infinitely many primes.
- Recognised in
Thinks the number of keys grows in step with the key's length, doubling when the length doubles, instead of doubling with every bit added.
- The learner reads
An -bit key has values, because each bit doubles the number of possibilities. A key eight bits longer does not hold eight more keys, nor times as many, but times as many. And a key twice as long, bits instead of , holds not twice as many keys but times as many. That is why keys only a little longer put guessing out of all reach.
Thinks the shared key can be worked out directly from the public values, for example as A × B mod p.
- The learner reads
The shared secret is : reaching it takes or . From the public values you can only make combinations such as , with the sum of the exponents, not their product. Here , not . To find from , Eve must solve the discrete logarithm problem, and no fast way to do that is known.