Why it matters
Tonelli-Shanks enables sqrt mod p. Understanding shapes algorithm.
Advertisement
The architecture
Write p - 1 = Q * 2^S.
Find non-residue z.
Iteratively refine root.
Advertisement
How it works end to end
Case p = 3 mod 4: sqrt = a^((p+1)/4).
General: Tonelli-Shanks with S+1 iterations.
Cipolla's alternative.