Search for a tool
Discret Logarithm

Tool for calculating and understanding the discrete logarithm: DLP solver, examples, cryptographic applications and detailed explanations.

Results

Discret Logarithm -

Tag(s) : Arithmetics

Share
Share
dCode and more

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!


Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!


Feedback and suggestions are welcome so that dCode offers the best 'Discret Logarithm' tool for free! Thank you!

Discret Logarithm

Discrete Logarithm Calculator

Find $ x $ in the equation $ g^x \equiv y \pmod{n} $




Answers to Questions (FAQ)

What is a Discrete Logarithm? (Definition)

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.

What is the purpose of the Discrete Logarithm?

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.

What is the problem with the discrete logarithm (DLP)?

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} $

How do you calculate a discrete logarithm for small numbers?

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

What are the known attacks against DLP?

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.

How to generate a safe group for DLP?

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)

Source code

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.

Cite dCode

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: https://www.dcode.fr/discret-log

In a scientific article or book, the recommended bibliographic citation is: Discret Logarithm on dCode.fr [online website], retrieved on 2025-12-18, https://www.dcode.fr/discret-log

Need Help ?

Please, check our dCode Discord community for help requests!
NB: for encrypted messages, test our automatic cipher identifier!

Questions / Comments

Feedback and suggestions are welcome so that dCode offers the best 'Discret Logarithm' tool for free! Thank you!


https://www.dcode.fr/discret-log
© 2025 dCode — The ultimate collection of tools for games, math, and puzzles.
 
Feedback