Tool for calculating and understanding the discrete logarithm: DLP solver, examples, cryptographic applications and detailed explanations.
Discret Logarithm - dCode
Tag(s) : Arithmetics
dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!
The discrete logarithm is a central mathematical problem in cryptography. It involves finding an integer $ x $ such that:
$$ g^x \equiv y \pmod{n} $$
where:
— $ g $ is a generator of a finite cyclic group (often $ \mathbb{Z}_n^* $),
— $ y $ is an element of this group,
— $ n $ is a prime number (or an integer defining the order of the group).
This is the discrete equivalent of the classical logarithm, where is seek the exponent $ x $ that transforms $ g $ into $ y $ in a finite space.
Its primary applications are in cryptography. It forms the basis of algorithms like Diffie-Hellman (key exchange) and ElGamal (encryption/signature).
It is also used in Zero-Knowledge Proof for authentication protocols that do not require disclosure of secrets.
The Discrete Logarithm Problem (DLP) consists of finding $ x $ in the equation: $$ g^x \equiv y \pmod{n} $$ where $ g, y, n $ are known.
This problem is considered difficult for well-chosen groups, making it a cornerstone of asymmetric cryptography.
Example: $ n = 19 $, $ g = 5 $, $ y = 1 $. Find $ x $ such as $ 5^x \equiv 1 \pmod{19} $. The solution is $ x = 9 $, as $ 5^9 = 1953125 \equiv 1 \pmod{19} $
For small $ n $, use:
— Exhaustive brute-force search: Test $ x $ from 1 to $ n-1 $
— Baby-step Giant-step algorithm:
1. Calculate $ g^j $ for $ j = 0 $ to $ m-1 $ (baby-steps)
2. Calculate $ y \cdot g^{-km} $ for $ k = 0 $ to $ m-1 $ (giant-steps)
3. Look for a collision
Many researchers have attempted to find methods for quickly solving the discrete logarithm problem. Several algorithms can be efficient in certain cases:
— Baby-step Giant-step: Generic algorithm in O(√n)
— Index Calculus: Efficient in (Z/nZ)^*, but not in elliptic curves.
— Pohlig-Hellman algorithm: Exploits the factorization of n (group order)
— Quantum computing attacks: Shor's algorithm solves the DLP in polynomial time on a quantum computer.
For $ (\mathbb{Z}/n\mathbb{Z})^* $:
— Choose a large prime $ n $ (e.g., 2048 bits).
— Verify that $ n-1 $ has a large prime factor.
— Select a generator $ g $ of prime order.
For elliptic curves:
— Use standardized curves (e.g., NIST P-256, Curve25519)
— Avoid curves with special properties (e.g., supersingular curves)
dCode retains ownership of the "Discret Logarithm" source code. Any algorithm for the "Discret Logarithm" algorithm, applet or snippet or script (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or any "Discret Logarithm" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) or any database download or API access for "Discret Logarithm" or any other element are not public (except explicit open source licence). Same with the download for offline use on PC, mobile, tablet, iPhone or Android app.
Reminder: dCode is an educational and teaching resource, accessible online for free and for everyone.
The content of the page "Discret Logarithm" and its results may be freely copied and reused, including for commercial purposes, provided that dCode.fr is cited as the source (Creative Commons CC-BY free distribution license).
Exporting the results is free and can be done simply by clicking on the export icons ⤓ (.csv or .txt format) or ⧉ (copy and paste).
To cite dCode.fr on another website, use the link:
In a scientific article or book, the recommended bibliographic citation is: Discret Logarithm on dCode.fr [online website], retrieved on 2025-12-18,