Cryptography studies methods for protecting information.
Its basic tasks are confidentiality, integrity, authentication, and key exchange. A cryptographic system may hide a message, verify that data were not changed, prove identity, or allow two parties to agree on a secret over an insecure channel.
Linear algebra appears in cryptography through finite fields, vector spaces over modular arithmetic, matrix transformations, error-correcting codes, lattices, and systems of equations. Classical ciphers such as the Hill cipher use matrix multiplication modulo an integer. Modern cryptographic constructions use deeper algebraic structures, but many of their computations still reduce to vectors, matrices, rings, and finite-field linear algebra. MIT’s linear algebra notes introduce cryptography through finite fields and modular matrix operations, including the Hill cipher.
124.1 Plaintext, Ciphertext, and Keys
A plaintext is the original message.
A ciphertext is the encrypted message.
A key is auxiliary information that determines how encryption and decryption are performed.
The general pattern is
Decryption reverses this process:
A cryptographic scheme is secure only if an adversary cannot recover useful information without the required key.
124.2 Modular Arithmetic
Cryptography often uses arithmetic modulo an integer.
For an integer , two integers and are congruent modulo if
This means that divides .
For example,
Modular arithmetic turns numbers into residue classes. In the alphabet cipher setting, letters may be represented by numbers modulo :
| Letter | Number |
|---|---|
| A | 0 |
| B | 1 |
| C | 2 |
| Z | 25 |
Then encryption can be expressed as arithmetic on numbers.
124.3 Finite Fields
A finite field is a field with finitely many elements.
The simplest finite fields are
where is prime. Their elements are
with addition and multiplication performed modulo .
The prime condition is important. If is prime, every nonzero element has a multiplicative inverse.
For example, in ,
because
Finite fields allow linear algebra to be performed in a finite setting. Vectors, matrices, bases, inverses, rank, and linear systems all make sense over .
124.4 Vector Spaces over Finite Fields
The vector space
consists of length- vectors whose entries are elements of .
For example,
Vector addition and scalar multiplication are performed modulo .
If
then in ,
The first coordinate is , and the third is .
124.5 Linear Ciphers
A linear cipher encrypts blocks of symbols using a linear transformation.
Let
be a plaintext block. Let be an invertible matrix over .
Encryption is
Decryption is
The matrix is the key.
The requirement that be invertible is essential. Without invertibility, different plaintext blocks may produce the same ciphertext block, and decryption would be ambiguous.
124.6 The Hill Cipher
The Hill cipher is a classical matrix cipher.
It groups letters into blocks, converts each block into a vector, and multiplies by a key matrix modulo .
For a block of two letters, choose a matrix
Encryption is
The matrix must be invertible modulo . This means
If the determinant shares a factor with , then has no inverse modulo , and decryption fails.
The Hill cipher is historically important because it shows how matrix multiplication can be used directly for encryption.
124.7 Example of Hill Encryption
Use the key matrix
Its determinant is
Since
the matrix is invertible modulo .
Encode the plaintext block HI as
Thus
Then
Reduce modulo :
Thus
The ciphertext block is TC.
124.8 Decryption Matrix
To decrypt, compute
For a matrix,
Here
The inverse of modulo is , because
Therefore
Check decryption:
Reducing modulo ,
This recovers HI.
124.9 Affine Ciphers
An affine cipher combines a linear transformation with a translation.
For a vector block , encryption has the form
Here is an invertible matrix and is a fixed vector.
Decryption is
Affine transformations are familiar from geometry. In cryptography, they act on finite vector spaces.
Affine ciphers are more general than purely linear ciphers, but they remain vulnerable to known-plaintext attacks because linear structure is easy to recover from enough examples.
124.10 Known-Plaintext Attacks on Linear Ciphers
A known-plaintext attack assumes that an adversary knows some plaintext blocks and their corresponding ciphertext blocks.
For a linear cipher
suppose the adversary knows pairs
Form matrices
Then
If is invertible, then
Thus the key matrix can be recovered.
This shows why simple linear ciphers are not secure by modern standards.
124.11 Confusion and Diffusion
Classical cryptographic design often uses two principles: confusion and diffusion.
Confusion hides the relationship between the key and the ciphertext.
Diffusion spreads the influence of each plaintext symbol across many ciphertext symbols.
Linear transformations are useful for diffusion. A well-chosen matrix can spread one input difference across many output coordinates.
However, linear transformations alone are insufficient. If every operation is linear, the whole cipher can be reduced to one large linear map.
Modern block ciphers therefore combine nonlinear substitution layers with linear mixing layers.
124.12 Substitution-Permutation Networks
A substitution-permutation network is a common block cipher structure.
It alternates between nonlinear substitution and linear permutation or mixing.
A simplified round has the form:
Here:
| Symbol | Meaning |
|---|---|
| Nonlinear substitution layer | |
| Linear mixing layer | |
| Round key |
The nonlinear layer creates confusion. The linear layer creates diffusion.
Repeated rounds make the relationship between plaintext, key, and ciphertext difficult to analyze.
124.13 Matrix Mixing Layers
A mixing layer may be represented by multiplication by a matrix over a finite field.
Let
A mixing layer may compute
where
The goal is that a small change in affects many coordinates of .
This is linear algebra over a finite field, not over the real numbers.
Finite-field matrix multiplication is used because bytes can be treated as field elements.
124.14 Boolean Vector Spaces
Many cryptographic algorithms operate on bits.
A block of bits is a vector in
Bitwise exclusive-or is addition in :
A linear Boolean function has the form
over .
An affine Boolean function has the form
Nonlinear Boolean functions are essential in modern symmetric cryptography. They prevent the cipher from collapsing into a solvable linear system.
124.15 Stream Ciphers and Linear Recurrences
A stream cipher generates a keystream
and encrypts by
over .
Some stream cipher components use linear feedback shift registers.
A linear recurrence over has the form
The state evolves linearly.
Such systems are efficient, but linearity makes them vulnerable if used alone. Secure stream ciphers combine linear state update with nonlinear filtering, irregular clocking, or nonlinear feedback.
124.16 Public-Key Cryptography
Public-key cryptography uses two keys.
The public key may be shared with everyone. The private key must be kept secret.
A public-key encryption scheme allows anyone to encrypt using the public key, but only the private-key holder can decrypt.
The mathematical design is based on a trapdoor function:
Classical examples use number theory, such as integer factorization or discrete logarithms. Modern post-quantum candidates often use lattices, codes, multivariate polynomials, or hash functions.
Linear algebra appears in several of these families.
124.17 Linear Codes in Cryptography
Error-correcting codes can be used for cryptography.
A code-based cryptosystem may publish a matrix that looks like a general linear code, while the private key contains hidden structure that allows efficient decoding.
The McEliece cryptosystem is a classical example. It is based on the difficulty of decoding a general linear code, which can be written as solving noisy linear equations over a finite field. Lecture notes on lattice-based cryptography describe McEliece as relying on the problem of recovering from over a finite field when the error vector is small.
The public problem has the form
Here:
| Symbol | Meaning |
|---|---|
| Public matrix | |
| Message or hidden vector | |
| Small error vector | |
| Received or encrypted vector |
Without the secret code structure, decoding is computationally hard.
124.18 Lattices
A lattice is a discrete set of points generated by integer combinations of basis vectors.
Given linearly independent vectors
the lattice is
In matrix form, if
then
Lattices are central in modern post-quantum cryptography. Their security is often based on the difficulty of finding short vectors, close vectors, or solving noisy linear equations.
124.19 Learning With Errors
The Learning With Errors problem, or LWE, is based on noisy linear equations.
A simplified form gives samples
where
Here is a secret vector, is public, and is a small error term.
In matrix form,
If there were no error, this would be an ordinary linear system over . With the small error vector, recovering becomes hard for suitable parameters.
This is the same structural theme as code-based cryptography: linear equations become hard after controlled noise is added. Lattice cryptography lectures describe LWE as solving noisy linear equations of the form with small error.
124.20 Short Vector Problems
One central lattice problem is the shortest vector problem.
Given a lattice basis, find a nonzero lattice vector of minimum length.
Formally,
Another problem is the closest vector problem:
These problems are geometric and algebraic. They depend on norms, bases, integer combinations, and changes of basis.
Cryptographic security often relies on the practical difficulty of solving such problems in high dimensions.
124.21 Basis Quality
The same lattice may have many bases.
A basis with short, nearly orthogonal vectors is easier to use.
A basis with long, highly skewed vectors may hide the structure of the lattice.
Two bases and generate the same lattice if
where is an integer unimodular matrix, meaning
This is a change of basis over the integers.
Many lattice cryptosystems use the distinction between a good private basis and a bad-looking public basis.
124.22 Hash Functions
A cryptographic hash function maps data of arbitrary length to a fixed-length digest.
A secure hash function should make it hard to find:
| Property | Meaning |
|---|---|
| Preimage | Given , find with |
| Second preimage | Given , find with same hash |
| Collision | Find any with same hash |
Hash functions are not usually simple linear maps. If they were linear, collisions and preimages would be easier to analyze.
However, their internal operations often include vector-like bit operations, finite word arithmetic, permutations, and mixing steps.
124.23 Message Authentication Codes
A message authentication code, or MAC, verifies integrity and authenticity using a shared secret key.
The sender computes
The receiver recomputes the tag and checks equality.
A secure MAC prevents an adversary from producing valid tags for new messages.
Some MAC constructions use finite-field arithmetic. Polynomial authentication, for example, evaluates data as coefficients of a polynomial over a finite field or ring.
This again connects cryptography with algebraic computation.
124.24 Digital Signatures
A digital signature scheme uses a private signing key and a public verification key.
The signer computes
Anyone can check
The goal is unforgeability: without the private key, an adversary should not be able to produce a valid signature on a new message.
Some modern signature schemes are lattice-based. Others are code-based, hash-based, or based on elliptic curves.
Linear algebra appears especially in lattice and code-based constructions.
124.25 Secret Sharing
Secret sharing splits a secret into pieces so that authorized groups can reconstruct it, while unauthorized groups learn nothing.
In Shamir secret sharing, choose a polynomial
over a finite field, where is the secret.
Each participant receives a point
Any points determine the polynomial by interpolation, hence recover .
Fewer than points do not determine the secret.
Polynomial interpolation is a linear algebra problem over a finite field. It can be written using a Vandermonde matrix.
124.26 Threshold Reconstruction
Suppose we have shares
The unknown polynomial coefficients satisfy
The coefficient matrix is a Vandermonde matrix.
If the are distinct, the matrix is invertible over the field.
Thus reconstructing the secret is solving a linear system.
124.27 Multivariate Cryptography
Multivariate cryptography uses systems of polynomial equations over finite fields.
A public key may consist of quadratic polynomials
The private key gives hidden structure that makes inversion efficient.
The public problem is to solve
This is generally nonlinear, but linear algebra appears in attacks and algorithms through linearization, Macaulay matrices, Gröbner basis methods, rank conditions, and finite-field matrix reduction.
Thus even nonlinear cryptography often returns to large-scale linear algebra.
124.28 Side Note on Security
A mathematical construction being algebraically elegant does not imply security.
A secure cryptographic scheme needs precise threat models, parameter choices, reductions or strong evidence, implementation safety, side-channel resistance, and extensive public analysis.
Simple linear ciphers are useful for teaching but insecure in practice.
Modern cryptography uses linear algebra as one component inside carefully designed systems.
124.29 Cryptography and Linear Algebra
The dictionary is direct.
| Cryptography concept | Linear algebra object |
|---|---|
| Bit string | Vector over |
| Block of symbols | Vector over a finite field |
| Linear cipher | Matrix multiplication |
| Decryption | Matrix inverse |
| Diffusion | Linear mixing map |
| Known-plaintext attack | Solving for an unknown matrix |
| Code-based cryptography | Linear codes and noisy equations |
| Lattice cryptography | Integer spans and basis reduction |
| LWE | Noisy modular linear system |
| Secret sharing | Vandermonde linear system |
| Boolean functions | Maps on |
| Multivariate attacks | Matrix linearization |
Cryptography uses linear algebra both constructively and adversarially. Designers use matrices and vector spaces to build systems. Attackers use linear algebra to break weak structure.
124.30 Summary
Cryptography protects information by transforming it with secret structure.
Linear algebra appears first in classical matrix ciphers, where plaintext vectors are multiplied by invertible key matrices modulo an integer. It appears more deeply in finite-field vector spaces, Boolean functions, code-based cryptography, lattice cryptography, secret sharing, and multivariate systems.
The Hill cipher shows the simplest form:
Modern cryptography uses harder problems. Code-based systems hide structured error-correcting codes. Lattice-based systems use integer vector spaces and noisy modular equations such as
Secret sharing reconstructs information by solving finite-field linear systems.
The central principle is that cryptography often makes computation asymmetric. The intended user has secret structure that makes the problem easy. The adversary sees a matrix, vector, code, lattice, or polynomial system designed to make the inverse problem hard.