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.

Tonelli-ShanksFactor p-1Q * 2^SFind non-residue zfor towerIterative refineget rootHandles p = 3 mod 4 simple case; general algorithm for other primes
Tonelli-Shanks.
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.