J. Math. Cryptol. 8 (2014), 115–140 DOI 10.1515/jmc-2013-0001 © de Gruyter 2014
The distribution of quadratic residues and non-residues in the Goldwasser–Micali type of cryptosystem
Benjamin Justus Communicated by Spyros Magliveras
Abstract. We provide unconditional results and conditional ones under the assumption of GRH (Generalized Riemann Hypothesis) on the distribution of quadratic residues and quadratic non-residues in Z=N Z, where N pq is an RSA modulus used in the Gold- wasser–Micali cryptosystem. The paper alsoD discusses cryptographic implications of the results obtained.
Keywords. Quadratic residuosity problem, Goldwasser–Micali cryptosystem, quadratic residues distribution.
2010 Mathematics Subject Classification. 94A60, 11A15.
1 Introduction
Goldwasser and Micali in [6] introduced the concept of probabilistic encryption. In the same paper, they proved that their probabilistic public-key encryption scheme is secure based on the hardness of the quadratic residuosity problem. Given a composite integer N , and a positive integer a relative prime to N , the quadratic residuosity problem is to decide whether a is a quadratic residue or a quadratic non-residue modulo N (i.e. whether or not x2 a mod N has a solu- D tion). The modulus N in the Goldwasser–Micali cryptosystem is a typical RSA modulus used in the RSA cryptosystem. That is, N pq for odd distinct primes D p; q about the same size. The quadratic residuosity problem is known to be com- putationally hard if the factorization of N is not known, see Section 2. The prob- lem currently does not admit polynomial time solutions, and is listed as an open problem [1]. Given the difficulty of the quadratic residuosity problem, one could ask how the quadratic residues and quadratic non-residues are distributed in the Goldwasser– Micali cryptosystem. The following questions are not only interesting but also important in certain specialized cryptanalytic applications. 116 B. Justus
(i) Given a pattern of quadratic residues and non-residues (a string containing consecutive residues or non-residues), how is the pattern distributed in the ring Z=N Z?
(ii) Given a subset A (possibly sparse) of the ring Z=N Z, what is the proportion of quadratic residues and non-residues in the set A?
(iii) Fix a square-free integer l. What is the density of the RSA moduli among the positive integer for which l is a quadratic residue (resp. quadratic non- residue)?
With regard to question (i), there is a result of Davenport [4, 5] in the setting of finite field Fp Z=pZ where p is a large prime. Davenport considered the D problem of estimating the number of s consecutive quadratic residues (resp. non- residues) in Z=pZ. Davenport showed that the number of s consecutive quadratic residues (resp. non-residues) for large p is
p  Os.p /; 2s C where 3 < 1. The error terms derived by Davenport were later improved 4 Ä [2, 10] using Weil’s bound and made explicit. In this paper, we generalize Davenport’s result to the setting Z=N Z where N D pq. Let N . / be the Jacobi symbol to the modulus N . Clearly N .n/ 1 D N D ˙ if n is relative prime to N . For a given pattern of 1 of length s, we are inter- ˙ ested in counting the number of occurrences of the pattern in the sequence N .n/, s 0 n < N . Precisely, let .0; : : : ; s 1/ 1; 1 be a binary vector of length s. Ä 2 ¹ º Consider the set
® ¯ D 0 n < N N .n i/ i for all 0 i s 1 : WD Ä W C D Ä Ä The theorem we prove is
Theorem 1.1. Let N pq where p; q are distinct odd prime numbers satisfying D 1 < p; q cN 1=2 for a fixed c > 0. Let s be a positive integer satisfying 1 s 1 Ä 1 Äs Ä . 2 ı/ log2 N where 0 < ı < 2 . Then for any .0; : : : ; s 1/ 1; 1 , we have 2 ¹ º
N 1 2 D O.N 2 log N /: j j D 2s C The implied constant depends only ı and c. Quadratic residues distribution 117
Our treatment of the theorem allows generalization to the case where N is square-free and the error term in the theorem can be made explicit in terms of s. One immediate consequence of Theorem 1.1 is that for a suitable length s, the pattern of ( 1) derived from the Jacobi symbol of length s tends to a uniform dis- ˙ tribution. Another application of the theorem is a connection of how the pattern distribution can be used to describe the complexity of predicting cryptographically strong pseudorandom bit generators whose constructions are based on the Legen- dre and Jacobi symbols [3]. The method used in the proof of Theorem 1.1 however does not allow us to ob- tain a similar asymptotic result in the study of the pattern distribution of quadratic residues and non-residues modulo N . The principal difficulty here is our inability of bounding non-trivially character sums of the type X XX p.f .n; i// q.f .n; j //; n i j ¤ where f .x; y/ is a certain type of polynomial in ZŒx; y. With regard to question (ii), we consider in this paper two types of A. The first type of A consists of arithmetic sequences whose distribution can be studied using analytic theory of L-functions. Such instances include for example the sequence of prime numbers, the sequence of square-free integers, etc. In Section 4, we prove a simplest result in this direction:
Theorem 1.2. Let N pq where p; q are distinct odd primes. Let 0 < ı 1. Define the sets D Ä
A ® prime l < N ı l is quadratic residue mod N ¯; WD W NA ® prime l < N ı l is quadratic non-residue mod N ¯: WD W Then under the assumption of GRH, we have
ı N ı A O.N 2 log N /; j j D 4ı log N C ı 3N ı NA O.N 2 log N /: j j D 4ı log N C The implied constants depend only on ı. We should remark that the assumption of GRH is necessary in order to have the desired asymptotic result. Without the assumption of GRH, the error terms based on the current state of the zero-free region of Dirichlet L-functions are as large as ı 1=2 N C , see Proposition 4.1. 118 B. Justus
The second type of A we consider is a subinterval or a union of subintervals in Œ1; N . We start with the case of a single subinterval. For a subinterval ŒQ; Q C H Œ1; N where H is a positive integer, consider the sets  A ®n Q < n Q H; n is quadratic residue mod N ¯; WD W Ä C NA ®n Q < n Q H; n is quadratic non-residue mod N ¯: WD W Ä C Since there are about 1=4 quadratic residues and 3=4 quadratic non-residues in Z=N Z, one could expect the same proportions of residues and non-residues hold true for an interval inside Œ1; N if one believes the residues (resp. non-residues) are uniformly distributed. Indeed, we have the following result.
Proposition 1.3. Let N pq where p; q are distinct odd primes. Let c1; c2 be D 1=2 1=4 ı positive real numbers such that 1 < p; q c1N and H c2N C . Then we have Ä 2 1 1 2ı A H O H 1 4ı ; j j D 4 C C 2 3 1 2ı NA H O H 1 4ı j j D 4 C C 1 for every 0 < ı . The implied constants depend only on ı, c1 and c2. Ä 2 Recently Heath-Brown [7] discovered a mean-value character sum estimate which includes the original Burgess bound as a special case. The advantage of Heath-Brown’s mean-value estimate lies in the fact that one is now able to bound non-trivially on average character sums whose ranges are as small as N pro- vided there are sufficiently many of them. We make this precise in the following theorem. Let I .Q ;Q H , 1 k J be a collection of disjoint subintervals k D k k C k Ä Ä inside the interval Œ1; N . Consider the sets
J ° [ ± A n I I n is quadratic residue mod N ; WD 2 WD k W k 1 D J ° [ ± NA n I I n is quadratic non-residue mod N : WD 2 WD k W k 1 D Theorem 1.4. Let N pq where p; q are distinct odd prime numbers satisfying 1=2 D 1 < p; q cN . Let positive real numbers ı; ı1; ı2 be given such that 0 < ı 1 Ä Ä , 0 < ı1; ı2 < 1, and 0 < ı1 ı2 1. Suppose for large N , 4 C Ä ı1 ı2 H c1N ; 1 k J;J c2N ; k Ä Ä Quadratic residues distribution 119
where c1; c2 > 0. Then we have
1 2 A I O I 1 ı ; j j D 4j j C j j 3 2 NA I O I 1 ı j j D 4j j C j j provided the following conditions hold:
ı2 1 ı ı1 > 2ı; ı1 : C 3 4.1 ı/ C 1 ı
The implied constants depend only on ı; ı1; ı2; c1; c2.
Question (iii) set out in the introduction can be viewed as an inverse scenario of question (ii). As we fix a square-free integer l, we are interested in knowing the density of those integers having two prime factors for which l is a quadratic residue. Consider the sets
Q.x l/ ®n pq x p q; l is quadratic residue mod n¯; I WD D Ä W ¤ NQ.x l/ ®n pq x p q; l is quadratic non-residue mod n¯: I WD D Ä W ¤ Theorem 1.5. Let 2 < l log log x be a square-free positive integer. Then Ä x x Á Q.x l/ log log x O log log log x ; j I j D 4 log x C log x 3x x Á NQ.x l/ log log x O log log log x : j I j D 4 log x C log x
It is well known that the number of integers having two distinct prime factors x log log x is asymptotic to log x for large x. Theorem 1.5 shows that the proportion of residues 1=4 (resp. non-residues 3=4) is the same for both families: (1) running over ring elements for a fixed modulus N ; (2) running over N pq for a fixed D square-free integer l. We could pose here a more cryptanalytic relevant question: what is the density of the RSA moduli among the natural integers for which l is a quadratic residue (resp. non-residue). In this direction, the author [9] defined two notions of RSA modulus which correspond to the current methods of generating a usable modulus for the RSA cryptosystem. The first method of generating an RSA modulus is to pick a prime q that is near a predetermined prime p of suitable bit-length. An in- stance of implementation of this method is the generation of safe primes. Consider 120 B. Justus the sets S.x l; ; c/ ®n pq x p < q x p; p xc; I WD D Ä W Ä Ä l is quadratic residue mod n¯; NS.x l; ; c/ ®n pq x p < q x p; p xc; I WD D Ä W Ä Ä l is quadratic non-residue mod n¯:
Here the parameter c describes the size of p. We can always take c 1 since p Ä 2 is the smaller of the two prime factors. The parameter is the description of how close q is located towards p. In this paper, we prove the following:
Theorem 1.6. Let l be a square-free positive integer satisfying 2 < l log x. Let Ä 0 < < 1 and 0 < c 1 be fixed. Then we have Ä 2 8 2c  2c  1 x C x C 1  < 2 O 3 ; c ; 8c. c/ log x C log x Ä 2 S.x l; ; c/ C c.1 Â/ x x 1  1 j I j D log C O ; < c ; : .1 c/.1 Â/ 4 log x log2 x 2 2 C Ä 8 2c  2c  3 x C x C 1  < 2 O 3 ; c ; 8c. c/ log x C log x Ä 2 NS.x l; ; c/ C c.1 Â/ 3x x 1  1 j I j D log C O ; < c : : .1 c/.1 Â/ 4 log x log2 x 2 2 C Ä Notice that the proportion of residues (resp. non-residues) in Theorem 1.6 is 1=8 (resp. 3=8) instead of the usual 1=4 (resp. 3=4). The halving of the proportion is expected because we have enforced the condition p < q in the definition of the set S.x l; ; c/. Regarding applications of the theorem, we immediately have in I the following a useful cryptanalytic result. Corollary 1.7 quantifies the probability that a randomly generated integer of the prescribed bit-length is a desired RSA modulus (satisfying the distance condition among p and q), and furthermore for which modulus a square-free l is a quadratic residue (resp. non-residue). The result has implications in chosen-plaintext attack scenarios in the Goldwasser– Micali cryptosystem.
Corollary 1.7. Let positive integers m, n and l be given such that 2m l n. C Ä Let s be a square-free positive integer satisfying 2 < s n. Randomly generate a Ä positive integer N with at most n bits. Consider the following conditions: (1) N is an RSA modulus whose prime factors have at most m l bits and are at most C l bits apart; (2) s is a quadratic non-residue modulo N . Then the probability that N satisfies conditions (1) and (2) is asymptotic to (as n ) ! 1 3 P.N / : D .log 2/2.ml m2/2n 2m l 2 C C Quadratic residues distribution 121
Another common method of generating an RSA modulus is by randomly choos- ing p and q in an interval. Consider the sets:
B.x l; a; b/ ®n pq x xa < p q xb; I WD D Ä W ¤ Ä l is quadratic residue mod n¯; NB.x l; a; b/ ®n pq x xa < p q xb; I WD D Ä W ¤ Ä l is quadratic non-residue mod n¯:
In the direction of finding the density of such RSA moduli satisfying the speci- fied quadratic residue conditions, we prove:
Theorem 1.8. Let l be a square-free positive integer satisfying 2 < l log x. Let 1 Ä a; b be two positive real numbers such that a < 2 and a < b < 1. Then the following estimates hold:
8 1 x2b x2b 1 < 2 2 O 3 ; b ; B.x l; a; b/ 4b log x C log x Ä 2 j I j D log b x O x ; b > 1 ; : 1 b 4 log x log2 x 2 C 8 3 x2b x2b 1 < 2 2 O 3 ; b ; NB.x l; a; b/ 4b log x C log x Ä 2 j I j D log b 3x O x ; b > 1 : : 1 b 4 log x log2 x 2 C As an immediate corollary of Theorem 1.8, we have
Corollary 1.9. Let positive integers m, n and l be given such that m 1 < l n . Ä 2 Let s be a square-free positive integer satisfying 2 < s n. Randomly generate Ä a positive integer N with at most n bits. Consider the following conditions: (1) N is an RSA modulus whose prime factors have at least m bits and at most l bits; (2) s is a quadratic non-residue modulo N . Then the probability that N satisfies conditions (1) and (2) is asymptotic to (as n ) ! 1 3 P.N / : 2 2 n 2l 3 D .log 2/ l 2 C
2 Background and elementary facts
In this paper, a positive integer N is always a product of two distinct odd primes p; q unless it is specified otherwise. Let p . / be the Legendre symbol to the D p modulus p, and N . / the Jacobi symbol to the modulus N . By Kronecker’s D N extension of the Legendre symbol and the Jacobi symbol, p; N can be viewed as primitive quadratic characters with the conductor p and N , respectively. 122 B. Justus
Let Z=N Z be the ring of integers modulo N , and Z=N Z the multiplicative subgroup of units. Among Z=N Z, half the numbers have Jacobi symbol equal to 1, and half the numbers have Jacobi symbol equal to 1. If a is a positive integer relative prime to N , a is a quadratic residue modulo N if and only if a is a quadratic residue modulo p and a quadratic residue modulo q. In terms of the quadratic symbols, a is a quadratic residue modulo N if and only if p.a/ 1 and q.a/ 1. Thus the quadratic residuosity problem is easy if D D the factorization of N pq is known since the problem of computing Legendre D symbols admits polynomial time solutions. The group of units Z=N Z consists of elements, among which precisely 1=4 of them are quadratic residues and 3=4 of them quadratic non-residues. The well-known Burgess’s bound is as follows:
Theorem 2.1 (D. Burgess). Let be a primitive character of conductor N > 1. Then 1 r 1 X 1 C2 S .Q; H / .n/ H r N 4r C WD Q 3 Deduction of Theorem 1.1 We start with the following proposition which is reminiscent of Weil’s bound. Proposition 3.1. Let .mod N/ be a primitive character of conductor N of order h. Let f .x/ ZŒx be a polynomial written as 2 s Y f .x/ .x a /dk ; D C k k 1 D where dk are positive integers and ak are any integers. Define YY .ai aj /: D i j ¤ Suppose the condition .d1; : : : ; ds; h/ 1 D is satisfied. Then we have ˇ X ˇ !.N / 1 1 ˇ .f .x//ˇ .s 1/ .; N / 2 N 2 ; ˇ ˇ Ä x .mod N/ where !.N / is the number of divisors of N . Quadratic residues distribution 123 Proof. See for instance [8, Corollary 12.12]. Recall the set ® ¯ D 0 n < N N .n i/ i for all 0 i s 1 : WD Ä W C D Ä Ä Lemma 3.2. Let N pq where p and q are distinct primes, and s a positive D integer such that 1 s min.p; q/. Set D0 0 n < N there exists i; 0 Ä Ä WD ¹ Ä W Ä i s 1; N .n i/ 0 . Then Ä C D º 2 D0 s.p q/ s : j j D C Proof. Notice that N .n i/ 0 if and only if p .n i/ or q .n i/. Consider C D j C j C the sets E ®0 n < N n i 0 .mod l/¯ i;l WD Ä W C Á with 0 i s 1 and l p; q . Clearly, we have E pq=l, and Ä Ä 2 ¹ º j i;l j D s 1 [ [ D0 E : D i;l i 0 l p;q D D Since s min.p; q/, we have E E for i j . Consequently, any Ä i;l \ j;l D; ¤ intersection of more than two distinct of these sets is empty. Furthermore, since ® ¯ Ei;p Ej;q 0 n < N n i .mod p/ and n j .mod q/ ; \ D Ä W Á Á we have Ei;p Ej;q 1 for 0 i; j s 1. By the inclusion-exclusion j \ j D Ä Ä principle, it follows that s 1 s 1 s 1 X X X X 2 D0 E Ei;p Ej;q s.p q/ s : j j D j i;l j j \ j D C i 0 l p;q i 0j 0 D 2¹ º D D Proof of Theorem 1.1. The idea of the proof goes back to Davenport. The sum N s s 1 1 X Y S 1 i N .n i/ WD 2s C C n 0 i 0 D D counts the number of occurrences of the pattern .0; : : : ; s 1/ for the Jacobi sym- bol provided N does not vanish. Thus in view of Lemma 3.2, 1 D S O. D0 / S O .N 2 log N /: (3.1) j j D C j j D C ı;c 124 B. Justus We have s N s 1 1 X X S s C s i0 il 1 D 2 C 2 l 1 0 i0<