Legendre symbol
(a/p) = a^((p-1)/2) mod p by Euler's criterion. +1 if QR, -1 if not, 0 if p | a.
Advertisement
Tonelli-Shanks
Given QR a, find x with x² ≡ a. Split p-1 = Q·2^S. Find non-residue z. Iterate with initial guess a^((Q+1)/2).
Advertisement
Complexity
Tonelli-Shanks: O(log² p) expected. Fast in practice.
Applications
Elliptic curve point compression. Cryptographic protocols. Analytic number theory.