IA idea · Cryptography & number theory
Finding the key length of a Vigenère cipher with the index of coincidence
Research question
Why does the probability that two randomly chosen letters match reveal the key length of a Vigenère cipher, and how long must the ciphertext be for the method to work?
Make it yours, then agree it with your teacher.
Next step: plan this IA free — the planner opens with this question filled in. For feedback on your own draft, the IA package (€39 once) gives you 5 AI feedback credits and every annotated exemplar in full.
Why it makes a good exploration
The index of coincidence is a beautiful probability argument that broke a cipher once thought unbreakable. You can derive it, test it, and measure its limits.
The mathematics you'll need
- Probability that two letters match: Σ pᵢ²
- Expected index of coincidence for English and for random text
- Splitting text into columns; averaging
- Testing the method against ciphertext length
- HL: variance of the estimate
Where the data comes from
Use public-domain texts from Project Gutenberg as plaintext; encrypt with keys you choose.
- Project Gutenberg — 70,000+ free public-domain books as plain text — ideal for letter and word frequency counts.
- Desmos graphing calculator — Free graphing and regression (y₁ ~ ax₁ + b) — fit models to your data and show residuals.
Real data for this idea
- Primary source: Project Gutenberg: Free ebooks. Download two or three books as “Plain Text UTF-8” by hand and remove the licence header before counting. Licence: Public domain in the US; download a few books by hand (the site blocks bulk robots).
Links checked October 2026; we link to the data and never copy it. More free data sets.
A possible outline
- Explain the cipher and why Caesar attacks fail.
- Derive the expected index for English and for uniform letters.
- Compute the index for each candidate key length.
- Measure how reliably the true length is found for different lengths of text.
- Reflect on long keys and non-English text.
Pitfalls that cost marks
- Quoting the index for English without calculating it from data.
- Testing only one key.
- Not explaining why the columns behave like Caesar ciphers.
Showing personal engagement
- Use a language you speak.
- Choose keys that make the method fail and explain why.
- Break a message a friend encrypts.
See Criterion C: personal engagement for what examiners look for.
Which course is it for?
| Course | Fit | Maths to lean on |
|---|---|---|
| AA SL | Not a natural fit | The core technique sits in the AI course or at HL; an AA SL student could use it only as clearly explained new mathematics. |
| AA HL | Good fit | Probability that two letters match: Σ pᵢ²; Expected index of coincidence for English and for random text |
| AI SL | Not a natural fit | The mathematics is mainly AA or HL (calculus or proof beyond AI SL); an AI SL version would need a data-driven, technology-based approach. |
| AI HL | Good fit | Probability that two letters match: Σ pᵢ²; Expected index of coincidence for English and for random text |
Level: Ambitious. Suits confident students; expect to learn some mathematics on your own. See how the IA differs between AA and AI, SL and HL.
How this idea reaches the top bands
Reflection (D)
For this idea, start with the weak points: quoting the index for English without calculating it from data; and testing only one key. Say how each one affects your answer.
Use of mathematics (E)
HL: probability that two letters match: Σ pᵢ²; expected index of coincidence for English and for random text; splitting text into columns; averaging; testing the method against ciphertext length; variance of the estimate, each explained in your own words and carried out correctly.
How cryptography explorations reach the top bands in general: Cryptography & number theory IA ideas. Guides: A · B · C · D · E · self-grade sheet.
Taking it further
Recover the full key with chi-squared on each column, or study why a key as long as the message defeats the method.
Extending it for HL
This idea already has HL mathematics in it: variance of the estimate. Make that the centre of the exploration and use it with full rigour.
See a complete IA, marked
How long does a game of Snakes and Ladders last on my grandmother's board? (AI HL) is a complete cryptography exploration, marked on every criterion.
Frequently asked questions
Which IB Maths course is this IA idea for?
It works for AA HL and AI HL. We rate it Ambitious: it suits confident students, who should expect to learn some mathematics on their own.
What mathematics does this IA use?
Probability that two letters match: Σ pᵢ², expected index of coincidence for English and for random text, splitting text into columns; averaging, testing the method against ciphertext length and hL: variance of the estimate.
Where can I get data for this IA?
Use public-domain texts from Project Gutenberg as plaintext; encrypt with keys you choose. Checked sources and tools: Project Gutenberg and Desmos graphing calculator.
Turn this idea into your IA
The planner opens with “Finding the key length of a Vigenère cipher with the index of coincidence” filled in: the question, the maths and the data sources.
Your plan is kept in this browser. A free account keeps it with your drafts on any device: Join free · Sign in
Also: free IA self-check · A–E checklist (PDF) · have a draft? AI feedback or a review with Pete (€100)
Writing it up: how to write a Maths IA, step by step · structure and format · mistakes that cost marks · annotated exemplars, marked on every criterion
Similar ideas
- Breaking a cipher with letter frequencies and chi-squaredAI SLAA SLAI HLAA HLAccessible
- The Collatz conjecture: what can we say about stopping times?AA SLAA HLAI SLAI HLSolid
- How long would it take to guess your password? Counting and logarithmsAA SLAI SLAA HLAI HLAccessible
- How many extra tickets should an airline sell?AA SLAA HLAI SLAI HLSolid
All cryptography ideas · AA HL ideas · AI HL ideas · All 239 IA ideas