Skip to main content
Challenges Baby-Step Giant-Step
Cryptography Hard Discrete logarithm: BSGS Solves: 9

Baby-Step Giant-Step

Author: CyberSamSU
Points
90

Here too, it is necessary to solve the equation g^x ≡ h (mod p), but now p is much larger — simple brute-force would require ~2.8·10¹² steps in the worst case, that is, several days.

The Baby-step giant-step (BSGS) algorithm reduces time at the expense of memory. The idea: we take m = ⌈√n⌉ and write it as x = i·m + j (where 0 ≤ i, j < m). Then, g^j = h · (g^(-m))^i follows from g^(i·m + j) = h.

The algorithm works in two stages: first, all baby steps g^j are written to a dictionary, then giant steps h · (g^(-m))^i are calculated and searched for in the dictionary. When a match is found, x = i·m + j. As a result, ~√n steps are enough — a few seconds.

Find x from the following equation:

p = 2772139636423
g = 5
h = 1720281519722

g^x mod p = h

Answer: only the number — in decimal format, without spaces and extra characters (for example 1234).

Hints 3
Opening a hint reduces the points you get for solving this challenge.
Hint 1 −9 pts Log in
Hint 2 −18 pts Log in
Hint 3 −27 pts Log in
To submit a flag, log in.

First solvers

1. W.o.X 17.09.2026
2. Лазиз 04.10.2026
3. testrejim 09.10.2026
4. 11111tttt 09.10.2026
5. Mirjaxon Qaxxarov 26.10.2026
6. Odam 04.11.2026
7. arcanum 11.11.2026
8. Jasmin Xuseinova 15.11.2026
9. farang1z_06 20.11.2026