pub fn tonelli_shanks<F: Field>(a: F) -> Option<F>Expand description
Return a square root of a if one exists, otherwise None.
This is the generic Tonelli–Shanks algorithm. Writing the multiplicative
group order as |F| - 1 = q * 2^s with q odd, it uses Field::GENERATOR
(a generator of F^*, hence a quadratic non-residue) to seed the 2-Sylow
subgroup via c = GENERATOR^q.
For a quadratic residue this returns one of its two square roots; which one
is unspecified. ZERO maps to ZERO.