Intermediate Number Theory

From cryptographic algorithms to quadratic reciprocity and p-adic fields

Intermediate (upper-undergraduate level)

About This Section

Intermediate number theory is organized in two parts. The applied/implementation part applies the theorems learned at the elementary level to cryptography and primality-testing algorithms, deepening understanding alongside Python implementations. The theoretical part studies deeper theories such as quadratic residues and the law of quadratic reciprocity, continued fractions, arithmetic functions, and p-adic number fields.

Prerequisites

  • Elementary-level content (congruences, Euler's theorem, the Chinese remainder theorem, primitive roots)
  • Basics of group theory (order, cyclic groups) recommended

Table of Contents

Applied / Implementation Part

Applies the theorems of the elementary level to cryptography and algorithms, with Python implementations.

Theoretical Part

Deeper number-theoretic topics including quadratic residues, continued fractions, and p-adic number fields.

Key Theorems

Applied / Implementation Part

Correctness of RSA

Let $n = pq$ (with $p, q$ prime) and $ed \equiv 1 \pmod{\varphi(n)}$. Then for every $m \in \mathbb{Z}/n\mathbb{Z}$,

$$m^{ed} \equiv m \pmod{n}$$

This is a direct application of Euler's theorem $m^{\varphi(n)} \equiv 1$.

Error Probability of the Miller-Rabin Test

When $n$ is composite, a randomly chosen base $a$ misjudges "$n$ is prime" with probability at most $1/4$. After $k$ independent trials, the error probability is at most $(1/4)^k$.

Hasse's Theorem (Elliptic Curves)

For an elliptic curve $E$ over a finite field $\mathbb{F}_p$, the number of rational points $\#E(\mathbb{F}_p)$ satisfies

$$|\#E(\mathbb{F}_p) - (p+1)| \le 2\sqrt{p}$$

Theoretical Part

The Prime Number Theorem

Let $\pi(x)$ denote the number of primes not exceeding $x$. Then

$$\pi(x) \sim \dfrac{x}{\ln x} \quad (x \to \infty)$$

that is, $\displaystyle\lim_{x \to \infty} \dfrac{\pi(x)}{x/\ln x} = 1$. More precisely, $\pi(x) \sim \mathrm{Li}(x) = \int_2^x \dfrac{dt}{\ln t}$.

The Law of Quadratic Reciprocity

For distinct odd primes $p$ and $q$,

$$\left(\dfrac{p}{q}\right)\left(\dfrac{q}{p}\right) = (-1)^{\dfrac{p-1}{2}\cdot\dfrac{q-1}{2}}$$

The Möbius Inversion Formula

If $f(n) = \sum_{d \mid n} g(d)$, then $g(n) = \sum_{d \mid n} \mu(d) f(n/d)$.

Here $\mu$ is the Möbius function.

Liouville's Theorem

If $\alpha$ is an algebraic irrational of degree $n$, then there is a constant $c(\alpha) > 0$ such that for every rational $p/q$,

$$\left|\alpha - \dfrac{p}{q}\right| > \dfrac{c(\alpha)}{q^n}$$

Applications Accessible at This Level

Implementing Public-Key Cryptography

RSA uses Euler's totient function for key generation and the Chinese remainder theorem (CRT-RSA) for decryption. Diffie-Hellman key exchange relies on the hardness of the discrete logarithm problem. These cryptosystems can be fully understood from chapters A1-A4 of the applied part.

Primality Testing and Key Generation

Generating RSA keys requires large primes. The Miller-Rabin test (A5) is in practice the most widely used probabilistic primality test, and runs inside OpenSSL and GnuPG.

Signal Processing and Number-Theoretic Transforms

The number-theoretic transform (NTT) performs the FFT over a finite field, using primitive roots in place of roots of unity. It is free of floating-point error and is used in cryptography and large-integer multiplication.

Elliptic Curve Cryptography (ECC)

The discrete logarithm problem on an elliptic curve (A7) yields cryptosystems more efficient than RSA. ECDHE key exchange, standardized in TLS 1.3, and Bitcoin signatures (ECDSA) lie at the heart of modern Internet security.

Study Tips

  • From theory to implementation: develop the skill of casting Euler's theorem and the CRT into concrete cryptographic algorithms
  • Algorithmic complexity: compare and analyze the efficiency of algorithms such as Baby-step Giant-step and binary GCD
  • Probabilistic methods: understand the significance and limitations of "probabilistically correct" algorithms such as Miller-Rabin
  • Where algebra meets geometry: experience the synthesis of number theory, algebra, and geometry through elliptic curves

Frequently Asked Questions

What does intermediate number theory cover?

Quadratic residues, the Legendre symbol, quadratic reciprocity, continued fractions and rational approximation, p-adic number fields, applications of congruences (cryptographic algorithms such as RSA and Diffie-Hellman), and an introduction to algebraic integers.

What is the law of quadratic reciprocity (Gauss's golden theorem)?

For odd primes $p, q$, $\left(\dfrac{p}{q}\right)\left(\dfrac{q}{p}\right) = (-1)^{\dfrac{p-1}{2}\cdot\dfrac{q-1}{2}}$. This deep theorem links whether $p$ is a quadratic residue modulo $q$ to whether $q$ is a quadratic residue modulo $p$.

What kind of number system are the p-adic numbers ($p$-adic numbers)?

A number system $\mathbb{Q}_p$ that is, in a certain sense, "complete" with respect to a prime $p$. It is the completion of $\mathbb{Q}$ under the metric in which higher powers of $p$ are "small", and is indispensable for tools such as Hensel's lemma and p-adic L-functions.