Introduction to Number Theory c Eli Biham - November 5, 006 345 Introduction to Number Theory (1)
Quadratic Residues Definition: The numbers 0, 1,,...,(n 1) mod n, are called uadratic residues modulo n. Numbers which are not uadratic residues modulo n are called uadratic non-residues modulo n. Examle: Modulo 11: i 0 1 3 4 5 6 7 8 9 10 i mod 11 0 1 4 9 5 3 3 5 9 4 1 There are six uadratic residues modulo 11: 0, 1, 3, 4, 5, and 9. There are five uadratic non-residues modulo 11:, 6, 7, 8, 10. c Eli Biham - November 5, 006 346 Introduction to Number Theory (1)
Quadratic Residues (cont.) Lemma: Let be rime. Exactly half of the numbers in Z are uadratic residues. With 0, exactly +1 numbers in Z are uadratic residues. Proof: There are at most +1 uadratic residues, since 0 1 ( 1) (mod ) ( ). (mod ) i ( i). (mod ) i Thus, all the elements in Z san at most +1 uadratic residues. There are at least +1 uadratic residues, otherwise, for some i j 1 / it holds that i = ( i) = j = ( j), in contrast to Lagrange theorem that states that the euation x i = 0 has at most two solutions (mod ). c Eli Biham - November 5, 006 347 Introduction to Number Theory (1)
Quadratic Residues (cont.) Since Z is cyclic, there is a generator. Let g be a generator of Z. 1. g is a uadratic non-residue modulo, since otherwise there is some b such that b g (mod ). Clearly, b 1 1 (mod ), and thus g 1 b 1 1 (mod ). However, the order of g is 1. Contradiction.. g, g 4,...,g ( 1) mod are uadratic residues, and are distinct, therefore, there are at least 1 uadratic residues. 3. g,g 3,g 5,...,g ( ) mod are uadratic non-residues, since if any of them is a uadratic residue, g is also a uadratic residue. QED c Eli Biham - November 5, 006 348 Introduction to Number Theory (1)
Euler s Criterion Theorem: Let be a rime, and let a Z. Then, a is a uadratic residue modulo iff a 1 1 (mod ). Proof: ( ) If a is a uadratic residue, there is some b such that a b Thus, a 1 (b ) 1 b 1 1 (mod ). (mod ). c Eli Biham - November 5, 006 349 Introduction to Number Theory (1)
Euler s Criterion (cont.) ( ) If a is a uadratic non-residue: For any r there is a uniue s such that rs a (mod ), i.e., s = ar 1, and there is no r r such that s = ar 1. Since a is a uadratic non-residue, r s (mod ). Thus, the numbers 1,, 3,..., 1 are divided into 1 distinct airs (r 1, s 1 ), (r,s ),..., (r 1, s 1), such that r i s i = a, and we get a 1 by Wilson s theorem. QED r 1 s 1 r s...r 1 s 1 1... ( 1) 1 (mod ) c Eli Biham - November 5, 006 350 Introduction to Number Theory (1)
Quadratic Residues Modulo n = Let and be large rimes and let n = (as in RSA). Theorem: Let m Z n. If m is a uadratic residue modulo n, then m has exactly four suare roots modulo n in Z n. Proof: Assume α m (mod n). Then gcd(m, n) = 1 gcd(α, n) = 1 gcd(α, n) = 1 α Z n. and since then m α (mod n) m α (mod ) m α (mod ) m has two suare roots modulo (α mod and α mod ) and two suare roots modulo (α mod and α mod ). c Eli Biham - November 5, 006 351 Introduction to Number Theory (1)
Quadratic Residues Modulo n = (cont.) Look at the systems of euations x ±α (mod ) x ±α (mod ) which reresent four systems (one of each ossible choice of ±). Each system has an uniue solution modulo n which satisfies and thus satisfies x m (mod ) x m (mod ) x m (mod n) All the four solutions are roots of m modulo n. These are all the roots. Otherwise there must be more than two roots either modulo or modulo. QED c Eli Biham - November 5, 006 35 Introduction to Number Theory (1)
Quadratic Residues Modulo n = (cont.) Conclusion: Exactly a uarter of the numbers in Z n are uadratic residues modulo n. c Eli Biham - November 5, 006 353 Introduction to Number Theory (1)
Legendre s Symbol Definition: Let be a rime such that a. Legendre s symbol of a over is a = +1, if a is a uadratic residue modulo ; 1, if a is a uadratic non-residue modulo. By Euler: a a 1 (mod ). c Eli Biham - November 5, 006 354 Introduction to Number Theory (1)
Legendre s Symbol (cont.) Proerties of Legendre s symbol: 1. a a (mod ) ( a. ( 1 ) = ( c ) = 1 c. ) = ( a 3. ( ) 1 1, if = 4k + 1; = 1, if = 4k + 3. Proof: ). 1 ( 1) 1 (mod ) ( 1) 4k+1 1 ( 1) 4k+3 1 ( 1) k 1, if = 4k + 1; ( 1) k+1 1, if = 4k + 3. c Eli Biham - November 5, 006 355 Introduction to Number Theory (1)
4. ( ) = ( 1) 1 8. (given without a roof). 5. ( ) ( ) ( ) ab = a b. Proof: Legendre s Symbol (cont.) Let g be a generator modulo. Then, i,a g i (mod ) and j, b g j (mod ). a is a uadratic residue iff i is even, b is a uadratic residue iff j is even, and ab is a uadratic residue iff i + j is even. Thus, by Euler: ab ( 1) i+j ( 1) i ( 1) j a b (mod ). c Eli Biham - November 5, 006 356 Introduction to Number Theory (1)
Legendre s Symbol (cont.) 6. The recirocity law: if are both odd rimes then = ( 1) 1 1. (given without a roof). c Eli Biham - November 5, 006 357 Introduction to Number Theory (1)
Jacobi s Symbol Jacobi s symbol is a generalization of Legendre s symbol to comosite numbers. Definition: Let n be odd, and let 1,,..., k be the rime factors of n (not necessarily distinct) such that n = 1 k. Let a be corime to n. Jacobi s symbol of a over n is a n = a 1 a k a. In articular, for n = a n = a = a a. c Eli Biham - November 5, 006 358 Introduction to Number Theory (1)
Jacobi s Symbol (cont.) Remarks: 1. a Z n is a uadratic residue modulo n iff the Legendre s symbols over all the rime factors are 1.. When Jacobi s symbol is 1, a is not necessarily a uadratic residue. 3. When Jacobi s symbol is -1, a is necessarily a uadratic non-residue. c Eli Biham - November 5, 006 359 Introduction to Number Theory (1)
Proerties of Jacobi s symbol: Jacobi s Symbol (cont.) Let m and n be integers, and let a and b be corime to m and n. Assume that n is odd and that the factorization of n is n = 1 k. 1. a b (mod n) ( ( ) a n) = b n.. ( ) 1 n = 1 n (1 is a uadratic residue modulo any n). 3. ( ) 1 n 1 n = ( 1). Proof: oening arentheses: = n = 1 k = (( 1 1) + 1)(( 1) + 1) (( k 1) + 1) S {1,,...,k} ( i 1) i S c Eli Biham - November 5, 006 360 Introduction to Number Theory (1)
= Jacobi s Symbol (cont.) S {1,,...,k} S ( i 1) i S + i {1,,...,k} ( i 1) + 1 = [( 1 1)( 1) ( k 1) +...] + ( 1 1) + ( 1) +... + ( k 1) + 1 where all the terms with S (in the brackets) are multiles of four, and all the i 1 are even. Thus, and n 1 1 = n ( 1 1) 1 1 + ( 1) 1 1 k +... + ( k 1) (mod ), = ( 1) ( 1 1)/ ( 1) ( 1)/ ( 1) ( k 1)/ = ( 1) ( 1 1)/+( 1)/+...+( k 1)/ = ( 1) (n 1)/. c Eli Biham - November 5, 006 361 Introduction to Number Theory (1)
Jacobi s Symbol (cont.) 4. ( ) n n = ( 1) 1 8. Proof: We saw that ( ) = ( 1) 1 8, thus: n = 1 k = ( 1) 1 1 8 + 1 8 + + k 1 8 It remains to show that n 1 8 1 1 8 + 1 8 + + k 1 8 (mod ) 1 = (1 + ( 1 1))(1 + ( 1)) = 1 + ( 1 1) + ( 1) + ( 1 1)( 1) But 8 ( 1 1) and 8 ( 1), thus 64 ( 1 1)( 1). Therefore, 1 1 + ( 1 1) + ( 1) (mod 16) c Eli Biham - November 5, 006 36 Introduction to Number Theory (1)
Jacobi s Symbol (cont.) And, 1 3 (1 + ( 1 1))(1 + ( 1))(1 + ( 3 1)) (mod 16) 1 + ( 1 1) + ( 1) + ( 3 1) (mod 16) etc., thus, n 1 + ( 1 1) + ( 1) + + ( k 1) (mod 16) n 1 8 1 1 8 + 1 8 + + k 1 8 (mod ) c Eli Biham - November 5, 006 363 Introduction to Number Theory (1)
Jacobi s Symbol (cont.) 5. The first multilication roerty: ( ( ( ) a mn) = a a m) n. (if a is corime to mn it is corime to m and to n; the rest is derived directly from the definition). 6. The second multilication roerty: ( ) ( ) ( ) ab n = a b n n. (if ab is corime to n, the both a and b are corime to n; the rest is derived since this roerty holds for Legendre s symbol). c Eli Biham - November 5, 006 364 Introduction to Number Theory (1)
Jacobi s Symbol (cont.) 7. The recirocity law: if m, n are corime and odd then n m = ( 1) m 1 n 1 m n. Proof: First assume that m = is a rime, thus, n = 1 By the recirocity law of Legendre s symbol we know that Thus, i n = ( 1) 1 = ( 1) i 1 1 ( 1 1 +...+ k 1 ) 1 k i.. k }{{} c Eli Biham - November 5, 006 365 Introduction to Number Theory (1) ( n).
We saw in roerty 3 that, Jacobi s Symbol (cont.) thus, n 1 ( 1 1) Now for any odd m: + ( 1) n = ( 1) 1 +... + ( k 1) n 1 n. (mod ), n m = = n 1 1 n n = ( 1) m 1 n l l n n n 1 m n ( 1) n 1 ( 1 1 +...+ l 1 ) QED c Eli Biham - November 5, 006 366 Introduction to Number Theory (1)
Alication of Jacobi s Symbol: Jacobi s Symbol (cont.) Using the roerties of Jacobi s symbol, it is easy to calculate Legendre s symbols in olynomial time. Examle: 117 71 37 117 6 = 71 7 +1 = 117 1 = 117 7 = 37 1 37 3 3 = 6 = 37 37 4 ( 1) = 37 7 ( 1)(+1) 1 = 1 ( 1)(+1) = 3 ( 1)(+1)1 = 1 37 3 71 is rime, therefore ( ) 117 71 can also be comuted by: 117 117 71 1 117 135 1 (mod 71). 71 c Eli Biham - November 5, 006 367 Introduction to Number Theory (1)
Comlexity: Jacobi s Symbol (cont.) The only reuired arithmetic oerations are modular reductions and division by owers of two. Clearly, a division (rule 6) reduces the numerator by a factor of two. A modular reduction (using rule 7 and then rule 1), reduces the number by at least two: as if a > b then a = b + r b + r > r + r, thus r < a/, i.e, a mod b < a/. Therefore, at most O(log n) modular reductions/divisions are erformed, each of which takes O((log n) ) time. This shows that the comlexity is O((log n) 3 ), which is olynomial in log n. A more recise analysis of this algorithm shows that the comlexity can be reduced to O((log n) ). c Eli Biham - November 5, 006 368 Introduction to Number Theory (1)