Finite Fields (PART 4)
Total Page:16
File Type:pdf, Size:1020Kb
Lecture 7: Finite Fields (PART 4) PART 4: Finite Fields of the Form GF (2n) Theoretical Underpinnings of Modern Cryptography Lecture Notes on “Computer and Network Security” by Avi Kak ([email protected]) February 9, 2021 4:58pm ©2021 Avinash Kak, Purdue University Goals: n To review finite fields of the form GF (2 ) To show how arithmetic operations can be carried out by directly operating on the bit patterns for the elements of GF (2n) Perl and Python implementations for arithmetic in a Galois Field using my BitVector modules CONTENTS Section Title Page 7.1 Consider Again the Polynomials over GF (2) 3 7.2 Modular Polynomial Arithmetic 5 7.3 How Large is the Set of Polynomials When 8 Multiplications are Carried Out Modulo x2 + x +1 7.4 How Do We Know that GF (23) is a Finite Field? 10 7.5 GF (2n) a Finite Field for Every n 14 7.6 Representing the Individual Polynomials 15 in GF (2n) by Binary Code Words 7.7 Some Observations on Bit-Pattern Additions 18 in GF (2n) 7.8 Some Observations on Arithmetic Multiplication 20 in GF (2n) 7.9 Direct Bitwise Operations for Multiplication 22 in GF (28) 7.10 Summary of How a Multiplication is Carried 25 Out in GF (28) 7.11 Finding Multiplicative Inverses in GF (2n) 27 with Implementations in Perl and Python 7.12 Using a Generator to Represent the Elements 34 of GF (2n) 7.13 Homework Problems 38 2 Computer and Network Security by Avi Kak Lecture 7 Back to TOC 7.1 CONSIDER AGAIN THE POLYNOMIALS OVER GF (2) Recall from Lecture 6 that GF (2) is a finite field consisting of the set {0, 1}, with modulo 2 addition as the group operator and modulo 2 multiplication as the ring operator. In Section 6.7 of Lecture 6, we also talked about polynomials over GF (2). Along the lines of the examples shown there, here are some more: x + 1 x2 + x + 1 x2 + 1 x3 + 1 x 1 x5 x10000 ... ... The examples shown only use 0 and 1 for the coefficients in the polynomials. Obviously, we could also have shown polynomials with negative coefficients. However, as you’d recall from Lecture 6, -1 is the same as +1 in GF (2).[Does 23 ∗ x5 + 1 belong to the set of polynomials defined over GF (2)? How about − 3 ∗ x7 + 1? The answer to both questions is yes. Can you justify the answer?] 3 Computer and Network Security by Avi Kak Lecture 7 Obviously, the number of such polynomials is infinite. The polynomials can be subject to the algebraic operations of addition and multiplication in which the coefficients are added and multiplied according to the rules that apply to GF (2). As stated in the previous lecture, the set of such polynomials forms a ring, called the polynomial ring. 4 Computer and Network Security by Avi Kak Lecture 7 Back to TOC 7.2 MODULAR POLYNOMIAL ARITHMETIC Let’s now add one more twist to the algebraic operations we carry out on all the polynomials over GF (2): In Section 6.11 of Lecture 6, I defined an irreducible polynomial as a polynomial that cannot be factorized into lower-degree polynomials. From the set of all polynomials that can be defined over GF (2), let’s now consider the following irreducible polynomial: x3 + x + 1 By the way there exist only two irreducible polynomials of degree 3 over GF (2). The other is x3 + x2 + 1. For the set of all polynomials over GF (2), let’s now consider polynomial arithmetic modulo the irreducible polynomial x3 + x + 1. To explain what I mean by polynomial arithmetic modulo the irreduciable polynomial, when an algebraic operation — we are 5 Computer and Network Security by Avi Kak Lecture 7 obviously talking about polynomial multiplication — results in a polynomial whose degree equals or exceeds that of the irreducible polynomial, we will take for our result the remainder modulo the irreducible polynomial. For example, (x2 + x + 1) × (x2 + 1) mod (x3 + x + 1) = (x4 + x3 + x2)+(x2 + x + 1) mod (x3 + x + 1) = (x4 + x3 + x + 1) mod (x3 + x + 1) = −x2 − x = x2 + x Recallthat1 + 1 = 0in GF (2). That’s what caused the x2 term to disappear in the second expression on the right hand side of the equality sign. For the division by the modulus in the above example, we used the result (x4 + x3 + x + 1) −x2 − x = x + 1 + (x3 + x + 1) x3 + x + 1 Obviously, for the division on the left hand side, our first quotient term is x. Multiplying the divisor by x yields x4 + x2 + x that when subtracted from the dividend gives us 6 Computer and Network Security by Avi Kak Lecture 7 x3 − x2 + 1. This dictates that the next term of the quotient be 1, and so on. 7 Computer and Network Security by Avi Kak Lecture 7 Back to TOC 7.3 HOW LARGE IS THE SET OF POLYNOMIALS WHEN MULTIPLICATIONS ARE CARRIED OUT MODULO x3 + x + 1 3 With multiplications modulo x + x + 1, we have only the following eight polynomials in the set of polynomials over GF (2): 0 1 x x2 x + 1 x2 + 1 x2 + x x2 + x + 1 3 We will refer to this set as GF (2 ) where the exponent of 2, which in this case is 3, is the degree of the modulus polynomial. 3 Our conceptualization of GF (2 ) is analogous to our conceptualization of the set Z8. The eight elements of Z8 are 8 Computer and Network Security by Avi Kak Lecture 7 to be thought of as integers modulo 8. So, basically, Z8 maps all integers to the eight numbers in the set Z8. Similarly, GF (23) maps all of the polynomials over GF (2) to the eight polynomials shown above. 3 But note the crucial difference between GF (2 ) and Z8: 3 GF (2 ) is a field, whereas Z8 is NOT. 9 Computer and Network Security by Avi Kak Lecture 7 Back to TOC 7.4 HOW DO WE KNOW THAT GF (23) IS A FINITE FIELD? 3 We do know that GF (2 ) is an abelian group because of the operation of polynomial addition satisfies all of the requirements on a group operator and because polynomial addition is commutative. [Every polynomial in GF (23) is its own additive inverse because of how the two numbers in GF (2) behave with respect to modulo 2 addition.] 3 GF (2 ) is also a commutative ring because polynomial multiplication distributes over polynomial addition (and because polynomial multiplication meets all the other stipulations on the ring operator: closedness, associativity, commutativity). 3 GF (2 ) is an integral domain because of the fact that the set contains the multiplicative identity element 1 and because if for a ∈ GF (23) and b ∈ GF (23) we have a × b = 0 mod (x3 + x + 1) then either a = 0or b = 0. This can be proved easily as follows: – Assume that neither a nor b is zero when 10 Computer and Network Security by Avi Kak Lecture 7 a × b = 0 mod (x3 + x + 1). In that case, the following equality must also hold a × b = (x3 + x + 1) since 0 ≡ (x3 + x + 1) mod (x3 + x + 1) – But the above implies that the irreducible polynomial x3 + x + 1 can be factorized, which by definition cannot be done. 3 We now argue that GF (2 ) is a finite field because it is a finite set and because it contains a unique multiplicative inverse for every non-zero element. 3 GF (2 ) contains a unique multiplicative inverse for every non-zero element for the same reason that Z7 contains a unique multiplicative inverse for every non-zero integer in the set. (For a counterexample, recall that Z8 does not possess multiplicative inverses for 2, 4, and 6.) Stated formally, we say that for every non-zero element a ∈ GF (23) there is always a unique element b ∈ GF (23) such that a × b = 1. The above conclusion follows from the fact if you multiply a non-zero element a with each of the eight elements of GF (23), 11 Computer and Network Security by Avi Kak Lecture 7 the result will the eight distinct elements of GF (23). Obviously, the results of such multiplications must equal 1 for exactly one of the non-zero element of GF (23). So if a × b = 1, then b must be the multiplicative inverse for a. The same thing happens in Z7. If you multiply a non-zero element a of this set with each of the seven elements of Z7, you will get seven distinct answers. The answer must therefore equal 1 for at least one such multiplication. When the answer is 1, you have your multiplicative inverse for a. For a counterexample, this is not what happens in Z8. When you multiply 2 with every element of Z8, you do not get eight distinct answers. (Multiplying 2 with every element of Z8 yields {0, 2, 4, 6, 0, 2, 4, 6} that has only four distinct elements). For a more formal proof (by contradiction) of the fact that if you multiply a non-zero element a of GF (23) with every element of the same set, no two answers will be the same, let’s assume that this assertion is false. That is, we assume the existence of two distinct b and c in the set such that a × b ≡ a × c mod (x3 + x + 1) That implies a × (b − c) ≡ 0 mod (x3 + x + 1) 12 Computer and Network Security by Avi Kak Lecture 7 That implies that either a is 0 or that b equals c.