Skip to main content
Challenges Tonelli-Shanks: modular square root
Cryptography Medium Modular square root Solves: 6

Tonelli-Shanks: modular square root

Author: CyberSamSU
Points
45

In the previous challenge, because p ≡ 3 (mod 4), we found the square root with a single formula. Here, however, p ≡ 1 (mod 8) — that formula does not work, and a general algorithm is needed.

The Tonelli-Shanks algorithm is for exactly this task: it solves the equation x² ≡ a (mod p) for any odd prime p. The algorithm writes p-1 = 2^s · q (where q is odd), finds a quadratic non-residue, and step-by-step applies a "correction" multiplier.

Find the square roots of the following a modulo mod p. Submit the smaller of the two roots as the answer.

p = 18125264933088838729
a = 2255170422501462431

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

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

First solvers

1. W.o.X 17.09.2026
2. Лазиз 04.10.2026
3. Mirjaxon Qaxxarov 26.10.2026
4. Odam 05.11.2026
5. arcanum 11.11.2026
6. farang1z_06 20.11.2026