Jump to content

Cipolla's algorithm

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Cryptproject (talk | contribs) at 14:07, 11 January 2010 (Created page with ''''Cipolla's algorithm''' is used to solve a congruence of the form <math> x^2 \equiv n \pmod p </math>, where <math>n \in \mathbf{F}_{p}<...'). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

Cipolla's algorithm is used to solve a congruence of the form

,

where is a quadratic residue and is an odd prime. Here denotes the finite field , which has elements; . The algorithm is named after M. Cipolla, who discovered it in the year 1907.

The algorithm

Inputs:

  • , an odd prime,
  • , an integer which is a quadratic residue .

Outputs:

  • , an integer satisfying .


Step 1 is to find an such that is a quadratic non-residue . There is no known algorithm for finding such an , except the trial and error method. Simply pick an and by computing the Legendre symbol one can see whether satisfies the condition. The chance that a random will satisfy is . With large enough this is about . Therefore, the expected number of trials before finding a suitable a is about 2.

Step 2 is to compute x by computing within the field . This x will be the one satisfying .

If , then also holds. And since p is odd, . So whenever a solution x is found, there's always a second solution, -x.


Example

Find all x such that .

Before applying the algorithm, it must be checked that is indeed a quadratic residue . Therefore, the Legendre symbol has to be equal to 1. This can be computed using Euler's criterion; . This confirms 10 being a quadratic residue and hence the algorithm can be applied.

  • Step 1: Find an a such that is a quadratic non-residue . As stated, this has to be done by trial and error. Choose . Then becomes . The Legendre symbol has to be -1. Again this can be computed using Euler's criterion. . So is a suitable choice for a.
  • Step 2: Compute .
.
.
.
.


So is a solution, as well as . Indeed, and .

Proof

This is nice. This is very very very nice. Yes! The first part of the proof is to verify that is indeed a field. For the sake of notation simplicity, is defined as . Of course, is a quadratic non-residue, so there is no square root in . This can roughly be seen as analogous to the complex number i. The field arithmetic is quite obvious. Addition is defined as

.

Multiplication is also defined as usual. With keeping in mind that , it becomes

.

Now the field properties have to be checked. The properties of closure under addition and multiplication, associativity, commutativity and distributivity are easily seen. This is because in this case the field is somewhat equivalent to the field of complex numbers (with being the analogon of i).
The additive identity is , more formal : Let , then

.

The multiplicative identity is , or more formal :

.

The only thing left for being a field is the existence of additive and multiplicative inverses. It is easily seen that the additive inverse of is , which is an element of , because . In fact, those are the additive inverse elements of x and y. For showing that every non-zero element has a multiplicative inverse, write down and . In other words,

.

So the two equalities and must hold. Working out the details gives expressions for and , namely

,
.

The inverse elements which are shown in the expressions of and do exist, because these are all elements of . This completes the first part of the proof, showing that is a field.

The second and middle part of the proof is showing that for every element . By definition, is a quadratic non-residue. Euler's criterion then says that

.

Thus . This, together with Fermat's little theorem (which says that for all ) shows the desired result

.

The third and last part of the proof is to show that if , then .
Compute

.

Note that this computation took place in , so this . But with Lagrange's theorem, stating that a non-zero polynomial of degree n has at most n roots in any field K, and the knowledge that has 2 roots in , these roots must be all of the roots in . It was just shown that and are roots of in , so it must be that .

Q.E.D.