Compute $\sqrt{x} \pmod p$ working on finite fields.

90 Views Asked by At

I was wondering about how $\sqrt{x}$ is handled while working over finite modular fields.

As we know, we cannot get decimal values while working over prime modular fields.

So for example, the operation $\frac{a}{b}$ will be computed as: $a * b^{-1} \pmod p$ NOTE: It's a modular inversion.

But which is the way of handling $\sqrt{x} \pmod p$ assuming that $x$ is a value that will give a fraction as a result as for example $x\ =\ 411$ ??

Thanks.

1

There are 1 best solutions below

0
On

You should first decide if a solution exists. This is not always the case. For example, modulo $5$ the squares are $$ 0^2 \equiv 0 \quad 1^2 \equiv 1 \quad 2^2 \equiv 4 \quad 3^2 \equiv 4 \quad 4^2 \equiv 1 $$ so $\sqrt{3}$ is not in $\Bbb Z / 5 \Bbb Z$.

There are efficient ways to compute if $a$ is a quadratic residue modulo $p$. Usually one uses the Legendre symbol for this. https://en.wikipedia.org/wiki/Legendre_symbol.

Once you know there exists a solution, finding it is a whole different story. For small $p$ it may be easiest to do a brute force search. For larger values of $p$ there are known algorithms that are more efficient. See for example:

https://en.wikipedia.org/wiki/Tonelli%E2%80%93Shanks_algorithm

https://en.wikipedia.org/wiki/Pocklington%27s_algorithm

https://en.wikipedia.org/wiki/Cipolla%27s_algorithm