Kahibaro
Discord Login Register

Cryptography

Historical context: from simple ciphers to modern cryptography

Cryptography is about designing methods to keep information secret, authentic, and unaltered when others might be listening or tampering.

Historically, cryptography began with very simple number-based tricks:

These classical methods are easy to break with modern techniques, so modern cryptography relies heavily on number theory, especially on properties of integers and modular arithmetic that are hard to “undo” without special information.

In this chapter, we focus on the number-theoretic ideas that appear in cryptography and illustrate them using simple versions of real systems, especially RSA.

Basic goals of cryptography

Modern cryptography aims at several goals:

Number theory is especially central to confidentiality and authentication in many commonly used systems.

Symmetric vs public-key cryptography (number-theoretic perspective)

Cryptosystems can be grouped into two broad families.

Symmetric-key cryptography

Both parties share the same secret key. That key is used both to encrypt and to decrypt. Number theory is not always prominent here, but there are simple number-based examples.

A toy example: suppose the key is an integer $k$ and each letter $x$ (represented as $0$–$25$) is encrypted as
$$
E_k(x) \equiv x + k \pmod{26}.
$$
Decryption uses
$$
D_k(y) \equiv y - k \pmod{26}.
$$
This is just a more formal way of describing the Caesar cipher.

Real symmetric ciphers (like AES) do not rely directly on simple number-theoretic hardness; they use carefully designed bit-level operations and algebra over finite fields. Nevertheless, modular arithmetic and finite fields are foundational tools in their design and analysis.

Public-key (asymmetric) cryptography

Here each user has two keys:

The keys are related mathematically, but in such a way that computing the private key from the public key is believed to be computationally hard without extra information.

Public-key cryptography is where elementary number theory plays a starring role. The most famous example is RSA, which is built from:

Core number-theoretic tools used in cryptography

We highlight some tools from number theory that appear repeatedly in cryptographic constructions.

Modular arithmetic as the basic “language”

Most cryptographic algorithms operate on integers modulo some number $n$:

In cryptography, $n$ is often very large (hundreds or thousands of bits), and efficient computation of expressions like $a^b \bmod n$ is crucial.

Prime numbers and factorization

Many cryptosystems rely on the fact that:

For instance, given large primes $p$ and $q$, it is easy to compute
$$
n = p q.
$$
But given only $n$, no fast general algorithm is known that always finds $p$ and $q$ for very large $n$.

This asymmetry between easy and hard directions is exploited in RSA.

The Euclidean algorithm and modular inverses

Given integers $a$ and $n$, an integer $a^{-1}$ (a multiplicative inverse modulo $n$) is a number with
$$
a a^{-1} \equiv 1 \pmod{n}.
$$

Such an inverse exists precisely when $\gcd(a, n) = 1$, and it can be found efficiently using the extended Euclidean algorithm. This capability is essential in cryptography:

Euler’s totient function and Euler’s theorem

For a positive integer $n$, Euler’s totient function $\varphi(n)$ is the number of integers between $1$ and $n$ that are coprime to $n$.

Euler’s theorem says: if $\gcd(a, n) = 1$, then
$$
a^{\varphi(n)} \equiv 1 \pmod{n}.
$$

In cryptography, we use special cases such as:

The security of RSA does not rely on Euler’s theorem being difficult; Euler’s theorem is a known identity. Instead, RSA’s security relies on the difficulty of certain related computational problems, such as factoring $n$ or finding $\varphi(n)$ when $n$ is given but its factorization is unknown.

RSA: a basic public-key cryptosystem

RSA is a widely known public-key scheme built directly on number-theoretic ideas. We present a simplified explanation to illustrate the connection with number theory.

Key generation (using primes and totients)

To create an RSA key pair, a user (say, Alice) does the following:

  1. Choose two large primes $p$ and $q$.
  2. Compute
    $$
    n = p q.
    $$
    The modulus $n$ will be part of both the public and private keys.
  3. Compute Euler’s totient for $n$:
    $$
    \varphi(n) = (p-1)(q-1),
    $$
    using the fact that $p$ and $q$ are prime.
  4. Choose a public exponent $e$ such that
    $$
    1 < e < \varphi(n)
    $$
    and $\gcd(e, \varphi(n)) = 1$.
  5. Compute the private exponent $d$ as the modular inverse of $e$ modulo $\varphi(n)$:
    $$
    e d \equiv 1 \pmod{\varphi(n)}.
    $$

Then:

The only obviously difficult step for an attacker is to determine $d$ from $(n, e)$ alone. That would typically require knowing $\varphi(n)$, which is easy to find if you know $p$ and $q$ (their product’s factorization), but believed hard otherwise.

Encryption and decryption (modular exponentiation)

To send a secret message, we work with integers modulo $n$.

The key property is that decryption recovers the original message:
$$
(m^e)^d \equiv m \pmod{n}.
$$

Why this works comes from Euler’s theorem and the way $d$ was chosen:

This algebraic identity is straightforward, but reversing the process (finding $d$ without $p$ and $q$) is believed difficult.

A very small numerical RSA example

Real RSA uses very large primes; here is a tiny, insecure example purely to show the arithmetic.

  1. Choose primes: $p = 5$, $q = 11$.
  2. Compute $n = p q = 55$.
  3. Compute $\varphi(n) = (5-1)(11-1) = 4 \cdot 10 = 40$.
  4. Choose $e$ with $\gcd(e, 40) = 1$ and $1 < e < 40$. Let $e = 3$.
  5. Find $d$ so that $e d \equiv 1 \pmod{40}$.
    We need d \equiv 1 \pmod{40}$. Trying small values,
    $$
    3 \cdot 27 = 81 \equiv 1 \pmod{40},
    $$
    so $d = 27$.

Public key: $(n, e) = (55, 3)$.

Private key: $d = 27$.

Suppose our message is $m = 7$.

To compute $13^{27} \pmod{55}$ efficiently, one uses repeated squaring and reduces modulo $55$ at each step. After carrying out the reductions (details omitted here), the result is
$$
13^{27} \equiv 7 \pmod{55},
$$
recovering the original message $m = 7$.

The whole procedure is just modular exponentiation, guided by number-theoretic identities.

In practice:

Hard problems underlying cryptography

The security of many cryptosystems is based on the assumption that certain number-theoretic problems are computationally hard for large inputs.

Relevant examples:

RSA relies (in practice) on the hardness of factoring large $n$. Other systems, like Diffie–Hellman key exchange and some digital signature schemes, rely on the hardness of discrete logarithms in modular arithmetic or related structures.

The connection to number theory is direct:

Simple number-theoretic authentication ideas

Beyond confidentiality, number theory also supports authentication and digital signatures.

A rough idea (simplified, inspired by RSA signatures):

This works because of the same exponentiation identity used in RSA decryption. In practice, additional steps (like hashing) are included to make signatures secure and efficient, but the arithmetic core is again modular exponentiation with large integers.

Here, number theory ensures:

Other number-theoretic cryptographic constructions (overview)

Beyond RSA, number theory appears in many other cryptographic settings, including:

While the exact structures differ, they all share a reliance on:

Limits and future directions

Cryptography based on classical number theory (like RSA and many discrete-log systems) is believed to be vulnerable to quantum computers running algorithms that can efficiently factor integers or compute discrete logarithms.

This has motivated work on post-quantum cryptography, where new systems are designed to rely on different hard problems. However:

In summary, cryptography is one of the most important real-world applications of number theory. Ideas such as primes, modular arithmetic, Euler’s theorem, and multiplicative inverses are not just theoretical curiosities; they are the mathematical engines behind secure communication in the modern world.

Views: 11

Comments

Please login to add a comment.

Don't have an account? Register now!