]> Programming ECC - Tonelli's Algorithm

Tonelli's Algorithm

In a cyclic group of odd order t, it is easy to compute square roots: simply exponentiate by (t+1 )/2 . In general, for an odd prime q, 𝔽 q * is isomorphic to 2 s +× t +, giving rise to the following procedure.

Tonelli(+++a+++) [computes +++b=a𝔽 q *+++]
  1. Choose g𝔽 q * at random until g is not a square

  2. let q1 =2 st, t odd

  3. e0

  4. for i2 to s do

    1. if (ag e) (q1 )/2 i1 then e2 i1 +e

  5. hag e

  6. bg e/2 h (t+1 )/2

  7. return b

A nonquadratic residue in 𝔽 q can be found by picking random elements and computing the Legendre symbol.

In general, if q is any prime power, one can determine if an element a has a square root by seeing if x 2 a divides x qx, which is equivalent to checking that a (q1 )/2 1 . The actual square roots can be found by using a factoring algorithm such as the Cantor-Zassenhaus algorithm, though more efficient methods exist.