Mathematical Introduction to Coding Theory and Cryptography Yi Ouyang
Total Page:16
File Type:pdf, Size:1020Kb
Mathematical Introduction to Coding Theory and Cryptography Yi Ouyang School of Mathematical Sciences, University of Science and Technology of China Email address: [email protected] Contents Chapter 1. Preliminaries 1 1. Theory of Integers 1 2. Polynomials over a field 4 3. Finite fields 6 Notations 9 Part 1. Coding Theory 11 Chapter 2. Introduction to Coding Theory 13 1. Background 13 2. Basic Definitions 15 Chapter 3. Linear Codes 19 1. Basic definitions 19 2. Hamming codes 23 3. Equivalence of codes 23 4. Encoding and decoding Algorithms 24 Chapter 4. Bounds of codes and codes with good bounds 29 1. Bounds of codes 29 2. Golay Codes 33 3. Other examples of optimal codes 36 Chapter 5. Constructing Codes from Other Codes 39 1. General Rules for Construction 39 2. Reed Muller Codes 41 Chapter 6. Weight Enumerators and the MacWilliams Theorem 47 1. MacWilliams Identity 47 Chapter 7. Sequences over finite fields 53 1. Sequences and Power Series over Finite Fields 53 2. Linear Feedback Shift Registers(LFSR) 57 3. Berlekamp-Massey Algorithm 60 Chapter 8. Cyclic codes and BCH codes 63 1. Cyclic codes 63 2. Trace Expression of Cyclic codes 67 iii iv CONTENTS 3. The BCH codes 69 4. Goppa Code 75 Chapter 9. Generalized GRS codes 79 1. Generalized GRS codes 79 2. Decoding GRS codes 80 Part 2. Cryptography 83 Chapter 10. History and Basic knowledge about Cryptography 85 1. Cryptography from early age 85 Chapter 11. Hard Computational Problems 91 1. Trapdoor function and One-way function 91 2. Factoring and RSA 92 Chapter 12. Primality Testing and Factoring 95 1. Primality Test 95 2. Factoring Algorithms 97 Chapter 13. Public Key Encryption Algorithms 103 1. Public Key Cryptography 103 2. Factoring and RSA-based algorithms 103 3. Discrete Logarithm Problem based algorithms 105 Chapter 14. Discrete Logarithms 107 1. Pohlig-Hellman Algorithm 107 2. Baby-Step/Giant-Step Method 109 3. Pollard Type Methods 109 4. Modern Method for DLP over Finite Fields 113 Chapter 15. Hash Functions 117 1. Hash Functions 117 2. Message Authentication Codes (MAC) 119 Chapter 16. Key Exchange and Signature Schemes 121 1. Diffie-Hellman Key Exchange 121 2. Digital Signature Schemes 122 3. Digital Signature Algorithm 123 4. Schnorr Signatures 125 5. Authenticated Key Agreement 125 Chapter 17. Elliptic Curves 127 1. Elliptic Curves over general fields 127 2. Elliptic Curves over Finite Fields 130 Chapter 18. Applications of Elliptic Curves 133 1. ECDLP-based algorithms 133 2. Elliptic curve primality test 134 CONTENTS v 3. Factorization Using Elliptic Curve 135 Chapter 19. Stream Cipher 137 1. Principles of Symmetric Ciphers 137 2. Stream Cipher basic 137 3. Linear feedback shift register 138 4. Combining LFSRs 139 Chapter 20. Block Cipher 141 1. Feistel Cipher and DES 141 2. AES (Rijndael) 145 CHAPTER 1 Preliminaries 1. Theory of Integers 1.1. Size of an integer. Let Z be the ring of integers and Z+ the subset of positive integers. For N 2 Z+, suppose the binary expansion of N is n−1 n N = a0 + ··· + an−1 · 2 + 2 ; ai = 0 or 1: Then n = [log2 N] + 1 is called the size or length of N, as it takes n bits to store the number N in a computer. 1.2. Division with remainder. Theorem 1.1. For a; b 2 Z and b =6 0, there exist unique integers q (called quotient) and r (called remainder) in Z, such that a = bq + r; 0 ≤ r < jbj: Recall that an ideal I of a commutative ring R is a nonempty subset of R such that for any a; b 2 I and r; s 2 R, ra + sb 2 I. Certainly any subset (a) = aR for a 2 R is an ideal of R, which is called a principal ideal of R. R is called a principal ideal domain (PID) if every ideal of R is principal Theorem 1.2. The ring of integers Z is a PID. Proof. Let I be any non-zero ideal of Z, let 0 =6 a 2 I, then a 2 I and hence I \ Z+ =6 ;. Let d be the smallest positive integer in I. Then on one hand, by definition dZ ⊆ I. On the other hand, for any b 2 I, write b = dq + r, 0 ≤ r < d. Then r = b − dq 2 I. By the minimality of d, r = 0, b 2 dZ and hence I ⊆ dZ. □ Theorem 1.3 (Bezout). For a; b 2 Z not all zero, there exist u; v 2 Z such that ua + vb = gcd(a; b). Moreover, gcd(a; b) = 1 if and only if there exist u, v 2 Z such that ua + vb = 1. Proof. Let I be the ideal generated by a and b. Then I = dZ for some d > 0 by Theorem 1.2. It suffices to show d = gcd(a; b). On one hand, d is a Z-linear combination of a and b, hence a multiple of gcd(a; b) and d ≥ gcd(a; b). On the other hand, Let a = qd + r, 0 ≤ r < d, then r = a − qd 2 I and by the minimality of d, one must have r = 0 and d j a. Similarly d j b. Hence d is a common divisor of a and b, and d ≤ gcd(a; b). Thus d = gcd(a; b). □ 1 2 1. PRELIMINARIES Problem 1.1. Find all possible u’s (and v’s) such that the Bezout iden- tity ua + vb = gcd(a; b) is satisfied. 1.3. Euclidean Algorithm. The Euclidean Algorithm is an algorithm finding the greatest common divisor of two integers. The algorithm wasfirst described in Euclid’s Elements 2300 years ago but is still effective and widely used in practice nowadays. Algerithm 1.1 (Euclidean Algorithm). Input: a; b 2 Z, not simultane- ously zero. Output: gcd(a; b) 2 Z+, u and v in Z such that ua + vb = gcd(a; b). • Let q0 = a and r0 = jbj > 0. Perform the division algorithm: q0 = r0q1 + r1, 0 ≤ r1 < r0. • If r1 = 0, then gcd(a; b) = r0; if r1 > 0, repeat the division algo- rithm: r0 = r1q2 + r2. • Continue until rn−1 = rnqn+1 (i.e., rn+1 = 0), then rn = gcd(a; b). • Moreover, rn = rn−2 − rn−1qn = ··· = ua + vb: Example 1.1. Compute gcd(33; 111). Problem 1.2. Decide the complexity of Euclidean Algorithm. 1.4. Congruent theory. For n 2 Z+. The integer a is congruent to b modulo n, denoted by a ≡ b mod n, if n divides a − b, i.e., a and b have the same remainder if divided by n. The congruent relation is an equivalence relation: (1) (reflexive) a ≡ a mod n for any a 2 Z; (2) (symmetric) If a ≡ b mod n, then b ≡ a mod n; (3) (transitive) If a ≡ b mod n and b ≡ c mod n, then a ≡ c mod n. Moreover, if a ≡ b mod n and c ≡ d mod n, then a c ≡ b d mod n; ac ≡ bd mod n: For i 2 Z, the congruent class ¯i of i modulo n is the subset i+nZ = fi+nk j k 2 nZg of Z. Then Zn = Z=nZ := f0¯; 1¯; ··· ; n −¯ 1g is the set of all congruent classes of Z modulo n. Proposition 1.1. The set Z=nZ is a commutative ring under the fol- lowing addition and multiplication: a¯ + ¯b = a + b; a¯ · ¯b = ab: Moreover, (0) The reduction map Z ! Z=nZ, i 7! ¯i is a surjective homomorphism of commutative rings. (1) The multiplicative group (Z=nZ)×, i.e. the set of invertible elements in Z=nZ, is the set fa¯ j 0 < a < n; gcd(a; n) = 1g. 1. THEORY OF INTEGERS 3 (2) As a cyclic group, the set of generators of Z=nZ is (Z=nZ)×. Con- sequently, the set of generators of a cyclic group of order n with a generator g is fga j 0 < a < n; gcd(a; n) = 1g. (3) Z=nZ is a domain if and only if n = p is a prime. When this is the case, Fp := Z=pZ is a field of p elements. Proof. We prove (1). On one hand, if gcd(a; n) = 1, then there exist u and v such that au + vn = 1, hence u¯ is the inverse of a¯. On the other hand, if a¯ is invertible in Z=nZ, let ¯b be its inverse. Then ab = 1¯ and hence ab ≡ 1 mod n. Then ab = 1 + kn and gcd(a; n) = 1. □ Remark 1.1. From now on, we drop ¯ and write Z=nZ = f0; 1; ··· ; n − 1g, and call it the residue ring modulo n. Let '(n) be the order of the group (Z=nZ)×. The function n 7! '(n) is called Euler’s totient function. By Proposition 1.1(2), '(n) is the number of generators of a cyclic group of order n. One also has Corollary 1.1. The following identities hold: X (1.1) n = '(d); djn X n (1.2) '(n) = µ(d) d djn where µ(d) is the Möbius function: µ(d) = (−1)s if d is squarefree of s prime factors and 0 if d is not squarefree. Proof. The set X = f0; 1; ··· ; n−1g is the disjoint union of Xd = fa 2 j g ≤ j f j ≤ n n g X gcd(a; n) = d for 1 d Pn. But Xd = Pcd 0 c < d ; gcd(c; d ) = 1 is of order '(n=d), hence n = djn '(n=d) = djn '(d).