Tonelli(++++++) [computes ++++++]
Tonelli's Algorithm
In a cyclic group of odd order , it is easy to compute square roots: simply exponentiate by . In general, for an odd prime , is isomorphic to , giving rise to the following procedure.
-
Choose at random until is not a square
-
let , odd
-
-
for to do
-
if then
-
-
-
-
return
A nonquadratic residue in can be found by picking random elements and computing the Legendre symbol.
In general, if is any prime power, one can determine if an element has a square root by seeing if divides , which is equivalent to checking that . The actual square roots can be found by using a factoring algorithm such as the Cantor-Zassenhaus algorithm, though more efficient methods exist.