Updated · By Pete Bromfield, former Head of Maths with IB examining experience

IA idea · Cryptography & number theory

Encrypting with matrices: when can a Hill cipher be undone?

AI HLAA HL Ambitious Also in: Matrices & Markov

Research question

Which 2 × 2 matrices can be used as keys for a Hill cipher on 26 letters, how many valid keys are there, and how many known plaintext letters does an attacker need?

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

Matrices meet modular arithmetic: a key works only when its determinant has an inverse mod 26. Counting valid keys and breaking the cipher with known plaintext are both real, finishable investigations.

The mathematics you'll need

  • Matrix multiplication and inverses
  • Determinants and invertibility mod 26 (new)
  • Counting invertible matrices (inclusion–exclusion or direct counting)
  • Solving linear systems mod 26
  • Known-plaintext attack

Where the data comes from

No data needed; encrypt your own messages.

A possible outline

  1. Explain encryption with a 2 × 2 key.
  2. Show why the determinant must be coprime to 26.
  3. Count the valid keys.
  4. Break a message using a few known letters.
  5. Reflect on why the cipher is not secure.

Pitfalls that cost marks

  • Using the ordinary inverse instead of the inverse mod 26.
  • Counting by computer without explaining the count.
  • No worked example by hand.

Showing personal engagement

  • Exchange encrypted messages with a friend.
  • Find keys that leave some messages unchanged.
  • Time your own attack.

See Criterion C: personal engagement for what examiners look for.

Which course is it for?

CourseFitMaths to lean on
AA SLNot a natural fitThe core technique sits in the AI course or at HL; an AA SL student could use it only as clearly explained new mathematics.
AA HLGood fitMatrix multiplication and inverses; Determinants and invertibility mod 26 (new)
AI SLNot a natural fitThe 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 HLGood fitMatrix multiplication and inverses; Determinants and invertibility mod 26 (new)

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: using the ordinary inverse instead of the inverse mod 26; and counting by computer without explaining the count. Say how each one affects your answer.

Use of mathematics (E)

HL: matrix multiplication and inverses; determinants and invertibility mod 26 (new); counting invertible matrices (inclusion–exclusion or direct counting); solving linear systems mod 26; known-plaintext attack, 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

Count valid 3 × 3 keys, or compare mod 26 with mod 29 (a prime) and explain the difference.

Extending it for HL

Add an HL technique the question genuinely needs: what an HL cryptography exploration adds.

Frequently asked questions

Which IB Maths course is this IA idea for?

It works for AI HL and AA 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?

Matrix multiplication and inverses, determinants and invertibility mod 26 (new), counting invertible matrices (inclusion–exclusion or direct counting), solving linear systems mod 26 and known-plaintext attack.

Where can I get data for this IA?

No data needed; encrypt your own messages. Checked sources and tools: Desmos graphing calculator.

Turn this idea into your IA

The planner opens with “Encrypting with matrices: when can a Hill cipher be undone?” filled in: the question, the maths and the data sources.

Plan this IA free

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

All cryptography ideas · AI HL ideas · AA HL ideas · All 239 IA ideas