Two standard facts from elementary number theory are used (Appendix 4 of
Nielsen and Chuang): the Chinese remainder theorem, by which
a↦(amodp1α1,…,amodpmαm) is a group isomorphism
ZN∗≅Zp1α1∗×⋯×Zpmαm∗; and
the fact that for an odd prime p the group Zpα∗ is cyclic, of
order φ(pα)=pα−1(p−1).
The gcd step. Suppose r is even and b=ar/2≡−1. Also
b≡1, since r/2<r and r is the least exponent with ar≡1. Then
N∣b2−1=(b−1)(b+1) while N∤b−1 and N∤b+1. So N shares a
factor with b−1 but is not contained in it: 1<gcd(b−1,N)<N, and likewise for
b+1.
Failure forces equal valuations. Let rj be the order of a modulo
pjαj, so that r=lcm(r1,…,rm), and let dj be the
exponent of the largest power of 2 dividing rj; let d be that of r, so
d=maxjdj. The procedure fails when r is odd or ar/2≡−1.
- If r is odd, every rj is odd and d1=⋯=dm=0.
- If r is even and ar/2≡−1(modN), then ar/2≡−1≡1
modulo each pjαj (as pj is odd), so rj∤r/2. Since rj∣r,
this means rj contains the full power 2d, i.e. dj=d for every j.
In both cases all dj are equal.
Each valuation is spread out. By the Chinese remainder theorem, a uniform on
ZN∗ means that the components aj=amodpjαj are independent and
uniform on Zpjαj∗, and dj depends only on aj. Fix j, let g be
a generator of the cyclic group Zpjαj∗ of order φj, and let
2D be the largest power of 2 dividing φj; D≥1 because pj−1 is even.
The element gk has order φj/gcd(k,φj), whose 2-adic exponent is D
when k is odd and less than D when k is even. As k ranges uniformly over
{0,…,φj−1} exactly half the values are odd, so Pr[dj=D]=1/2 and
consequently Pr[dj=c]≤1/2 for every value c.
Conclusion. Conditioning on a1 and using independence,
Pr[failure]≤Pr[d2=d1,…,dm=d1]=Ea1[j=2∏mPr[dj=d1∣a1]]≤2m−11.
For m≥2 this is at most 1/2. The structure of the argument follows the proof of
Theorem 5.3 in Nielsen and Chuang; counting the conditioning
on d1 explicitly gives the exponent m−1.