University of Auckland · FACULTY OF COMPUTER SCIENCE

COMPSCI110 · Introduction to Computer Systems

- one subject, every graph, every model, every mark
Computer Science14 Chapters8-page Bible
Our own words - no uploaded lecturer files
Updated for this semester
Chapter 9 of 11 · COMPSCI 110

Security & Cryptography

Module 9 of University of Auckland COMPSCI110 covers keeping data safe: classical ciphers (the Caesar/substitution cipher and the matrix block cipher, V·M mod n), the block-vs-stream and symmetric-vs-asymmetric taxonomies, symmetric algorithms (DES, 3DES, AES), public-key encryption (RSA and Diffie-Hellman key exchange) and digital certificates. It carries 6 marks on the final exam, and the block-cipher arithmetic is a reliable, mechanical source of marks if you keep the mod arithmetic tidy.

In this chapter

What this chapter covers

  • 01Caesar / substitution cipher: shift each letter a fixed distance; only 25 keys, so frequency analysis and brute force break it, and it preserves the plaintext 'fingerprint'
  • 02Matrix block cipher: map A=0…Z=25, group into blocks, encrypt ciphertext = V·M mod n, decrypt with the inverse M′ (M·M′ = I mod n)
  • 03Diffusion: a block cipher spreads each plaintext letter across several ciphertext letters, destroying structure
  • 04Cipher taxonomy by processing: block (a block at a time) vs stream (element by element)
  • 05Cipher taxonomy by keys: symmetric (one shared secret key — key distribution is the challenge) vs asymmetric / public-key
  • 06Symmetric algorithms: DES (56-bit key, 64-bit block — now too small), 3DES (~168-bit), AES (128/192/256-bit keys, 128-bit block)
  • 07Asymmetric / public-key: RSA and Diffie-Hellman key exchange solve key distribution; digital certificates authenticate a public key
Worked example · free

Matrix block cipher: encrypting 'GO' with V·M mod 26

Q [4 marks]. Encrypt the block GO with the matrix block cipher using key M = [[3, 5], [2, 3]] and a 26-letter alphabet (A=0 … Z=25). Compute the ciphertext, and state how decryption recovers the plaintext.
  • +1Map the letters to numbers: G = 6, O = 14, so the plaintext vector is V = [6 14]. All arithmetic is mod 26.
  • +1Multiply V·M: [6·3 + 14·2, 6·5 + 14·3] = [18 + 28, 30 + 42] = [46, 72].
  • +1Reduce each entry mod 26: 46 mod 26 = 20, 72 mod 26 = 20 (72 − 52). So the ciphertext vector is [20 20].
  • +1Map back to letters: 20 → U, 20 → U, giving ciphertext 'UU'. Decryption multiplies by the inverse matrix M′ (where M·M′ = I mod 26): [20 20]·M′ mod 26 recovers [6 14] = GO.
Ciphertext = 'UU'. Decryption uses the inverse key M′ (M·M′ = I mod 26) on the ciphertext vector to return [6 14] = GO.
Sia tip — Do the matrix product first, THEN take mod 26 on each entry — reducing too early is fine arithmetically but easy to get wrong, so keep the full products (46, 72) visible before reducing. The whole point of a block cipher is diffusion: both output letters depend on both input letters, which is exactly why it resists the frequency analysis that breaks Caesar. Ask Sia to encrypt a fresh two-letter block with the same key to drill the steps.
Glossary

Key terms

Caesar (substitution) cipher
A cipher that shifts each letter a fixed distance along the alphabet (key 4: A→E, B→F, …). With only 25 possible non-trivial keys it falls instantly to brute force, and because each letter always maps the same way it preserves the plaintext's frequency 'fingerprint', so frequency analysis breaks it even without trying every key.
Matrix block cipher
A block cipher that groups plaintext into n-letter blocks (letters as numbers A=0…Z=25) and encrypts each as ciphertext = V·M mod (alphabet size), where M is an invertible n×n key matrix. Decryption multiplies by the inverse M′, with M·M′ = I mod n. It diffuses each plaintext letter across the block, defeating simple frequency analysis.
Symmetric-key encryption
Encryption where the same secret key both encrypts and decrypts. It is fast and is used for bulk data, but its central problem is key distribution — getting the shared key to the other party securely. DES, 3DES and AES are the course's symmetric examples.
Asymmetric (public-key) encryption
Encryption using a key pair: a public key encrypts (or verifies) and a matching private key decrypts (or signs). Because the public key can be shared openly, it solves the key-distribution problem of symmetric ciphers. RSA and Diffie-Hellman key exchange are the course's examples.
Block vs stream cipher
A processing distinction. A block cipher transforms a fixed-size block of data at a time (e.g. the matrix cipher, AES's 128-bit block); a stream cipher processes the data element by element as it arrives. Block ciphers naturally provide diffusion within each block.
Digital certificate
A document that binds a public key to an identity, vouched for by a trusted authority, so a party can trust that a public key really belongs to who it claims. Certificates underpin authenticated, encrypted web connections built on public-key cryptography.
FAQ

Security & Cryptography FAQ

What's the difference between symmetric and asymmetric encryption?

Symmetric encryption uses one shared secret key for both encryption and decryption — fast, but you must somehow deliver that key securely (the key-distribution problem). Asymmetric (public-key) encryption uses a key pair: the public key encrypts and can be published, while only the private key decrypts. That neatly solves key distribution, at the cost of being slower — which is why real systems often use public-key crypto to exchange a symmetric key and then switch to the faster symmetric cipher.

How does the matrix block cipher work, and why is it stronger than Caesar?

You turn letters into numbers (A=0…Z=25), group them into blocks, and multiply each block vector by the key matrix M modulo the alphabet size: ciphertext = V·M mod n. Decryption multiplies by the inverse matrix M′. It's stronger than Caesar because it diffuses — every ciphertext letter depends on several plaintext letters — so the same letter can encrypt differently depending on its neighbours, destroying the frequency pattern that makes a Caesar cipher trivial to crack.

Can AI help me with cryptography in COMPSCI110?

Yes, as a study aid. Sia can walk a Caesar shift or a matrix-block encryption step by step, check your mod-26 arithmetic, and explain the symmetric/asymmetric and block/stream distinctions. Use it to understand the method and rehearse on fresh blocks — it explains and checks your reasoning but does not do graded assignments or the exam for you, and the University of Auckland's academic-integrity rules apply to controlled assessments.

Why is the Caesar cipher so easy to break?

Two reasons. First, there are only 25 possible shifts, so an attacker can simply try them all (brute force) in seconds. Second, it's a fixed substitution — every occurrence of a letter maps to the same ciphertext letter — so the ciphertext keeps the plaintext's letter-frequency 'fingerprint', and frequency analysis reveals the shift even faster than brute force. Modern ciphers defeat both attacks with huge key spaces and diffusion.

Is Module 9 on the final exam?

Yes — Security carries 6 marks on the final exam. The most dependable of those are the mechanical block-cipher and Caesar calculations, so drill the arithmetic; the rest are recall about the cipher taxonomy (block/stream, symmetric/asymmetric) and the named algorithms (DES, 3DES, AES, RSA, Diffie-Hellman) plus digital certificates. Confirm the current per-module breakdown on Canvas.

Study strategy

Exam move

Security is 6 marks split between mechanical cipher work and recall — bank the mechanical marks first. Drill the matrix block cipher until it's routine: letters → numbers, do the full matrix product, THEN reduce mod 26, then numbers → letters, and know that decryption uses the inverse matrix M′. Practise Caesar encryption/decryption and be able to explain in one line why it's weak (25 keys, preserved frequency fingerprint). For recall, build a compact table of the taxonomy — block vs stream, symmetric vs asymmetric — and the symmetric algorithms with their key/block sizes (DES 56-bit key/64-bit block, 3DES ~168-bit, AES 128/192/256-bit keys/128-bit block). Understand at a concept level how public-key encryption (RSA, Diffie-Hellman) solves key distribution and what a digital certificate does — the exam tests these as ideas rather than heavy RSA arithmetic, so don't over-invest in numeric RSA. A couple of timed block-cipher questions plus flashcards for the taxonomy is the efficient prep.

Working through Security & Cryptography in COMPSCI 110? Sia is AskSia’s AI Computer Science tutor — ask any COMPSCI 110 Security & Cryptography question and get a clear, step-by-step explanation grounded in how COMPSCI 110 is taught and assessed. Read this chapter free, then take your hardest questions to Sia.

A+Everything unlocked
Unlocks this Bible + all 12 of your University of Auckland subjects - and 1,000+ Bibles across every Australian university.
Sia - your COMPSCI110 tutor, unlimited, worked the way the exam marks it
The full 8-page Bible + practice bank with worked solutions
Chrome extension - sync your LMS so Sia knows your deadlines
Bilingual EN / Chinese on every Bible and every Sia answer
$25/ month
30-day money-back · cancel in one tap · how it works
Unlock the full COMPSCI110 Bible + 12 University of Auckland subjects解锁完整 COMPSCI110 Bible + University of Auckland 12 门科目
$25/mo