Basic Concept in Number Theory and Finite Fields
Total Page:16
File Type:pdf, Size:1020Kb
BasicBasic ConceptsConcepts inin NumberNumber TheoryTheory andand FiniteFinite FieldsFields Raj Jain Washington University in Saint Louis Saint Louis, MO 63130 [email protected] Audio/Video recordings of this lecture are available at: http://www.cse.wustl.edu/~jain/cse571-14/ Washington University in St. Louis CSE571S ©2014 Raj Jain 4-1 OverviewOverview 1. The Euclidean Algorithm for GCD 2. Modular Arithmetic 3. Groups, Rings, and Fields 4. Galois Fields GF(p) 5. Polynomial Arithmetic These slides are partly based on Lawrie Brown’s slides supplied with William Stalling’s book “Cryptography and Network Security: Principles and Practice,” 6th Ed, 2013. Washington University in St. Louis CSE571S ©2014 Raj Jain 4-2 Euclid'sEuclid's AlgorithmAlgorithm Goal: To find greatest common divisor Example: gcd(10,25)=5 using long division 10) 25 (2 20 -- 5)10 (2 10 -- 00 Test: What is GCD of 12 and 105? Washington University in St. Louis CSE571S ©2014 Raj Jain 4-3 Euclid'sEuclid's Algorithm:Algorithm: TabularTabular MethodMethod 1. Write the first 2 rows. Set i = 2. 2. Divide ri-1 by ri, write quotient qi+1 on the next row 3. Fill out the remaining entries in the new bottom row: a. Multiply ri by qi+1 and subtract from ri-1 b. Multiply ui by qi+1 and subtract from ui-1 c. Multiply v by q and subtract from previous v r = u x + v y i i+1 i-1 i i i ui = u i-2 -q i ui-1 vi = v i-2 -qi vi-1 Finally, If r i = 0, gcd(x,y) = ri-1 -1 If gcd( x, y)= 1, ui x + vi y = 1 x mod y = ui ui is the inverse of x in “mod y” arithmetic. Washington University in St. Louis CSE571S ©2014 Raj Jain 4-4 EuclidEuclid’’ss AlgorithmAlgorithm TabularTabular MethodMethod (Cont)(Cont) Example 2: Fill in the blanks Washington University in St. Louis CSE571S ©2014 Raj Jain 4-5 HomeworkHomework 4A4A Find the multiplicative inverse of 5678 mod 8765 Do it on your own. Do not submit. Answer: 2527 Washington University in St. Louis CSE571S ©2014 Raj Jain 4-6 ModularModular ArithmeticArithmetic xy mod m = (x mod m) (y mod m) mod m (x+y) mod m = ((x mod m)+ (y mod m)) mod m (x-y) mod m = ((x mod m)- (y mod m)) mod m x4 mod m = (x2 mod m)(x2 mod m) mod m xij mod m = (xi mod m)j mod m 125 mod 187 = 125 (225+285) mod 187 = (225 mod 187) + (285 mod 187) = 38+98 = 136 1252 mod 187 = 15625 mod 187 = 104 4 2 2 125 mod 187 = (125 mod 187) mod 187 = 104 2 mod 187 = 10816 mod 187 = 157 1256 mod 187 = 1254+2 mod 187 = (157104) mod 187 = 59 Washington University in St. Louis CSE571S ©2014 Raj Jain 4-7 ModularModular ArithmeticArithmetic OperationsOperations Z = Set of all integers = {…, -2, -1, 0, 1, 2, …} Zn = Set of all non-negative integers less than n = {0, 1, 2, …, n-1} Z2 = {0, 1} Z8 = { 0, 1, 2, 3, 4, 5, 6, 7} 8 Addition, Subtraction, Multiplication, and division can all be defined in Z n For Example: (5+7) mod 8 = 4 (4- 5) mod 8 = 7 (5 7) mod 8 = 3 (3/7) mod 8 = 5 (5*5) mod 8 = 1 Washington University in St. Louis CSE571S ©2014 Raj Jain 4-8 ModularModular ArithmeticArithmetic PropertiesProperties Washington University in St. Louis CSE571S ©2014 Raj Jain 4-9 HomeworkHomework 4B4B Determine 125107 mod 187 Do it on your own. Do not submit. Answer: 5 Washington University in St. Louis CSE571S ©2014 Raj Jain 4-10 GroupGroup Group: A set of elements that is closed with respect to some operation. Closed The result of the operation is also in the set The operation obeys: Obeys associative law:(a.b).c = a.(b.c) Has identity e: e.a = a.e = a -1 -1 Has inverses a : a.a = e Abelian Group: The operation is commutative a.b = b.a Example: Z8, + modular addition, identity =0 Washington University in St. Louis CSE571S ©2014 Raj Jain 4-11 CyclicCyclic GroupGroup ExponentiationExponentiation:: RepeatedRepeated applicationapplication ofof operatoroperator 3 example:example: aa == a.a.aa.a.a CyclicCyclic GroupGroup:: EveryEvery elementelement isis aa powerpower ofof somesome fixedfixed element,element, i.e.,i.e., bb == aak forfor somesome aa andand everyevery bb inin groupgroup aa isis saidsaid toto bebe aa generatorgenerator ofof thethe group group Example:Example: {0,1,{0,1, 2,2, 4,4, 8} 8} withwith modmod 1212 multiplication,multiplication, thethe generatorgenerator isis 2.2. 220=1,=1, 221=2,=2, 222=4,=4, 223=8,=8, 224=4,=4, 225=8=8 Washington University in St. Louis CSE571S ©2014 Raj Jain 4-12 RingRing Ring: 1. A group with two operations: addition and multiplication 2. The group is abelian with respect to addition: a+b=b+a 3. Multiplication and additions are both associative: a+(b+c)=(a+b)+c a.(b.c)=(a.b).c 1. Multiplication distributes over addition a.(b+c)=a.b+a.c (a+b).c = a.c + b.c Commutative Ring: Multiplication is commutative, i.e., a.b = b.a Integral Domain: Multiplication operation has an identity and no zero divisors Ref: http://en.wikipedia.org/wiki/Ring_%28mathematics%29 Washington University in St. Louis CSE571S ©2014 Raj Jain 4-13 HomeworkHomework 4C4C Consider the set S = {a, b, c} with addition and multiplication defined by the following tables: + abc abc × a abc a abc b bac b bbb c cca c cbc Is S a ring? Justify your answer. Washington University in St. Louis CSE571S ©2014 Raj Jain 4-14 FieldField FieldField:: AnAn integralintegral domaindomain inin whichwhich eacheach elementelement hashas a multiplicative inverse. a multiplicative inverse. Washington University in St. Louis CSE571S ©2014 Raj Jain 4-15 FiniteFinite FieldsFields oror GaloisGalois FieldsFields Finite Field: A field with finite number of elements Also known as Galois Field The number of elements is always a power of a prime number. n Hence, denoted as GF(p ) GF(p) is the set of integers {0,1, … , p-1} with arithmetic operations modulo prime p Can do addition, subtraction, multiplication, and division without leaving the field GF(p) GF(2) = Mod 2 arithmetic GF(8) = Mod 8 arithmetic There is no GF(6) since 6 is not a power of a prime. Washington University in St. Louis CSE571S ©2014 Raj Jain 4-16 GF(7)GF(7) MultiplicationMultiplication ExampleExample × 0 1 2 3 4 5 6 0 0 0 0 0 0 0 0 1 0 1 2 3 4 5 6 2 0 2 4 6 1 3 5 3 0 3 6 2 5 1 4 4 0 4 1 5 2 6 3 5 0 5 3 1 6 4 2 6 0 6 5 4 3 2 1 Washington University in St. Louis CSE571S ©2014 Raj Jain 4-17 PolynomialPolynomial ArithmeticArithmetic n n-1 i ff((xx)) == aanxx ++ aan-1xx ++ …… ++ aa1xx ++ aa0 == ∑∑ aaixx 1. OrdinaryOrdinary polynomialpolynomial arithmetic:arithmetic: Add,Add, subtract,subtract, multiply,multiply, dividedivide polynomials,polynomials, FindFind remainders,remainders, quotient.quotient. SomeSome polynomialspolynomials havehave nono factorsfactors andand areare prime.prime. 2. PolynomialPolynomial arithmeticarithmetic withwith modmod pp coefficientscoefficients 3. PolynomialPolynomial arithmeticarithmetic withwith modmod pp coefficientscoefficients andand modmod m(xm(x)) operationsoperations Washington University in St. Louis CSE571S ©2014 Raj Jain 4-18 Polynomial Arithmetic with Mod 2 Coefficients All coefficients are 0 or 1, e.g., 3 2 2 let f(x) = x + x and g(x) = x + x + 1 f(x) + g(x) = x3 + x + 1 f(x) g(x) = x5 + x 2 Polynomial Division: f(x) = q(x) g(x) + r(x) can interpret r(x) as being a remainder r(x ) = f(x) mod g(x) if no remainder, say g(x) divides f(x) if g (x) has no divisors other than itself & 1 say it is irreducible (or prime) polynomial Arithmetic modulo an irreducible polynomial forms a finite field Can use Euclid’s algorithm to find gcd and inverses. Washington University in St. Louis CSE571S ©2014 Raj Jain 4-19 ExampleExample GF(2GF(23)) Washington University in St. Louis CSE571S ©2014 Raj Jain 4-20 ComputationalComputational ExampleExample inin GF(2GF(2n)) Since coefficients are 0 or 1, any polynomial can be represented as a bit string 3 2 2 In GF(2 ), (x +1) is 1012 & (x +x+1) is 1112 Addition: 2 2 (x +1) + (x +x+1) = x 101 XOR 111 = 0102 Multiplication: 2 2 2 (x+1).(x +1) = x.(x +1) + 1.(x +1) 3 2 3 2 = x +x+x +1 = x +x +x+1 011.101 = (101)<<1 XOR (101)<<0 = <<n Shift left n 1010 XOR 101 = 1111 1010 XOR 101 = 11112 Polynomial modulo reduction (get q(x) & r(x)) is 3 2 3 3 2 2 (x +x +x+1 ) mod (x +x+1) = 1.(x +x+1) + (x ) = x 1111 mod 1011 = 1111 XOR 1011 = 0100 2 Washington University in St. Louis CSE571S ©2014 Raj Jain 4-21 HomeworkHomework 4D4D Determine the gcd of the following pairs of polynomials over GF(11) 5x3+2x2-5x-2 and 5x5+2x4+6x2+9x Washington University in St. Louis CSE571S ©2014 Raj Jain 4-22 UsingUsing aa GeneratorGenerator AA generatorgenerator gg isis anan elementelement whosewhose powerspowers generategenerate allall nonnon--zerozero elementselements inin FF havehave 0,0, gg0,, gg1,, ……,, ggq-2 CanCan createcreate generatorgenerator fromfrom rootroot ofof thethe irreducibleirreducible polynomialpolynomial thenthen addingadding exponentsexponents ofof generatorgenerator Washington University in St. Louis CSE571S ©2014 Raj Jain 4-23 SummarySummary 1. Euclid’s tabular method allows finding gcd and inverses 2.