A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Discrete Logarithms

Graduate Depth 81 in the knowledge graph ☐ I know this ☆ Set as goal
25topics build on this
388prerequisites beneath it
See this on the map →
Order of an Element Modulo nPrimitive Roots and Cyclic Groups Mod p→→Diffie-Hellman Key Exchange
discrete-log cryptography cyclic-groups

Core Idea

Given a primitive root g mod p and nonzero residue a, the discrete logarithm is the unique k (mod p-1) such that gk ≡ a (mod p). Computing discrete logs is believed hard; this one-way function underpins Diffie-Hellman and elliptic-curve cryptography.

Explainer

You already know that a primitive root g modulo p generates every nonzero residue as successive powers: g¹, g², g³, … cycle through all p-1 nonzero residues mod p before repeating. This means for any nonzero a mod p, there is exactly one exponent k in {0, 1, …, p-2} with gk ≡ a (mod p). That exponent k is called the discrete logarithm of a to the base g, written log_g(a) mod (p-1). It is the modular analogue of the ordinary logarithm: just as log_b(x) asks "to what power must I raise b to get x?", the discrete log asks the same question inside Z/pZ.

The crucial asymmetry is computational. Given g, k, and p, computing gk mod p is fast — repeated squaring does it in O(log k) multiplications. But given g, a, and p, finding k requires examining (in the naive case) each power of g until you hit a. For a prime p with hundreds of digits, this is astronomically slow. This one-way function property — easy in one direction, hard to reverse — is precisely what cryptographic protocols exploit. Diffie-Hellman key exchange works because two parties can combine public values derived from gk mod p without an eavesdropper being able to recover k.

The discrete log obeys algebraic laws that mirror ordinary logarithms. From your knowledge of the order of elements, you know gk has order (p-1)/gcd(k, p-1), so log_g(ab) ≡ log_g(a) + log_g(b) (mod p-1). This is the discrete analogue of log(xy) = log(x) + log(y). The exponents add in Z/(p-1)Z in the same way that ordinary logs add in the reals, because the group (Z/pZ)* is cyclic of order p-1, and g is a generator.

There are algorithms faster than brute force — baby-step giant-step runs in O(√p) time and space, and the index calculus method is subexponential for integers. This is why modern cryptographic systems use primes with thousands of bits, or move to elliptic curves where no index calculus analogue is known. The hardness assumption for discrete logs in carefully chosen groups remains one of the cornerstones of public-key cryptography.

Practice Questions 5 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Set Operations: Union, Intersection, and Complement → Proof by Cases → Proving by Cases and Exhaustion → Vacuous Truth and Trivial Cases → Proof by Cases (Proof by Exhaustion) → Mathematical Induction → Divisibility and Greatest Common Divisor → The Fundamental Theorem of Arithmetic → Divisibility Theory (Formal Treatment) → Fundamental Theorem of Arithmetic (Rigorous Proof) → Arithmetic Functions and Multiplicativity → Euler's Totient Function → Primitive Roots and Cyclic Groups Mod p → Discrete Logarithms

Longest path: 82 steps · 388 total prerequisite topics

Prerequisites (2)

Leads To (1)