31-4 Quadratic residues

Let pp be an odd prime. A number aโˆˆZpโˆ—a \in Z_p^* is a quadratic residue if the equation x2=a(modp)x^2 = a \pmod p has a solution for the unknown xx.

a. Show that there are exactly (pโˆ’1)/2(p - 1) / 2 quadratic residues, modulo pp.

b. If pp is prime, we define the Legendre symbol (ap)(\frac{a}{p}), for aโˆˆZpโˆ—a \in \mathbb Z_p^*, to be 11 if aa is a quadratic residue modulo pp and โˆ’1-1 otherwise. Prove that if aโˆˆZpโˆ—a \in \mathbb Z_p^*, then

(ap)โ‰กa(pโˆ’1)/2(modp).\left(\frac{a}{p}\right) \equiv a^{(p - 1) / 2} \pmod p.

Give an efficient algorithm that determines whether a given number aa is a quadratic residue modulo pp. Analyze the efficiency of your algorithm.

c. Prove that if pp is a prime of the form 4k+34k + 3 and aa is a quadratic residue in Zbโˆ—\mathbb Z_b^*, then ak+1modโ€‰โ€‰pa^{k + 1} \mod p is a square root of aa, modulo pp. How much time is required to find the square root of a quadratic residue aa modulo pp?

d. Describe an efficient randomized algorithm for finding a nonquadratic residue, modulo an arbitrary prime pp, that is, a member of Zpโˆ—\mathbb Z_p^* that is not a quadratic residue. How many arithmetic operations does your algorithm require on average?

(Omit!)