CHAPTER 2 Number Theory Basics Badran Awad Computer Department Palestine Technical College Motivation

CHAPTER 2 Number Theory Basics Badran Awad Computer Department Palestine Technical College Motivation

CHAPTER 2 Number Theory Basics Badran Awad Computer Department Palestine Technical College Motivation • Public key cryptography is based on large primes that have to be generated & tested using modular arithmetic. • Fermat & Euler’s work is used to prime or relatively prime numbers. • Euclid’s algorithm finds multiplicative inverses that are needed to find appropriate encryption keys in public key cryptography. Divisibility Definition 2.1.1 Let 푎, 푏 ∈ ℤ and 푎 ≠ 0. We say 푎 divides 푏 if there exists 푘 ∈ ℤ such that 푏 = 푎푘. This is denoted by 푎|푏. Example 2.1.1 3|15, -15|60, 7 ∤ 18 Proposition 2.1.1 Let 푎, 푏, 푐 ∈ ℤ. For every 푎 ≠ 0, 푎|0 and 푎|푎. Also 1|푏 for every 푏. If 푎|푏 and 푏|푐 then 푎|푐. If 푎|푏 and 푎|푐 then 푎| 푠푏 + 푡푐 where 푠, 푡 ∈ ℤ. Proof: Divisibility Q: Which of the following is true? 1. 77 | 7 2. 7 | 77 3. 24 | 24 4. 0 | 24 5. 24 | 0 Greatest Common Divisor Definition: The greatest common divisor (gcd) for two integers a and b is the largest integer dividing a and b. Example 2.1.2 gcd(4,6) = 2, gcd(5,7) = 1, gcd(24,60) = 12 Definition 2.1.2 2 integers a and b are relative prime if gcd(a,b) = 1. Euclidean algorithm Definition This is a method to find the gcd of 2 integers. As an example , let’s say we want to find gcd(a,b) and a>b. Step 1 Divide a by b. Determine the remainder. We will have 푎 = 푞1푏 + 푟1 Step 2 If 푟1 = 0 then If 푟1 ≠ 0, continue by dividing 푏 with 푟1. We will have 푏 = 푞2푟1 + 푟2 Step 3 If 푟2 = 0, gcd 푎, 푏 = 푟, else do 푟1 = 푞3푟2 + 푟3 ⋮ 푟푘−2 = 푞푘푟푘−1 + 푟푘 푟푘−1 = 푞푘+1푟푘 + 0 So, gcd 푎, 푏 = 푟푘. Euclidean algorithm Example 2.1.3 Compute 푔푐푑 482,1180 . 1180 = 2(482) +216 482 = 2(216) + 50 This is the gcd 216 = 4(50) + 16 50 = 3(16) + 2 16 = 8(2) That is, gcd(482,1180) = 2. Example 2.1.4 Compute gcd(12345,11111). Euclidean algorithm Solving 풂풙 + 풃풚 = 풅. In the above Euclidean algorithm we did not use the quotients 푞푖. Theorem 2.1.2 Let 푎, 푏 ∈ ℤ with at least one of the numbers is non-zero and let gcd 푎, 푏 = 푑. Then there exists 푥, 푦 ∈ ℤ such that 푎푥 + 푏푦 = 푑 (푥 and 푦 can be either positive or negative). Example 2.1.5 gcd 4,6 = 2. There exists 푥 = −1, 푦 = 1 such that 4푥 + 6푦 = 2 Euclidean algorithm Example 2.1.6 Determine gcd 748,2024 and find the two integers 푥, 푦 ∈ ℤ such that 푎푥 + 푏푦 = gcd 748,2024 . To solve 푎푥 + 푏푦 = gcd 푎, 푏 where 푎 < 푏. We need to use an algorithm called extended Euclidean algorithm. Extended Euclidean algorithm Solve 푎푥 + 푏푦 = gcd 푎, 푏 where 푎 < 푏. • Step 1 푏 Divide 푎 into 푏 (i.e. ). 푎 푎 = 푞1푏 + 푟1 푏 = 푞2푟1 + 푟2 푟1 = 푞3푟2 + 푟3 ⋮ 푟푘−2 = 푞푘푟푘−1 + 푟푘 푟푘−1 = 푞푘+1푟푘 + 0 • Step 2 Set 푥0 = 0, 푥1 = 1 and 푥푗 = −푞푗−1푥푗−1 + 푥푗−2. Set 푦0 = 1, 푦1 = 0 and 푦푗 = −푞푗−1푦푗−1 + 푦푗−2 • Step 3 Then 푎푥푛 + 푏푦푛 = gcd 푎, 푏 . Extended Euclidean algorithm Example 2.1.7 Find gcd 4,6 gcd 6,21 gcd 748,2024 Extended Euclidean algorithm Remark 2.1.1 We will define the solution pair 푥푛, 푦푛 as the initial solution for 푎푥 + 푏푦 = gcd 푎, 푏 . We re-denote as 푋0, 푌0 . We define the general solution for 푎푥 + 푏푦 = gcd 푎, 푏 as 푋 = 푋0 + 푏푡 and 푌 = 푌0 − 푎푡 where 푡 ∈ ℤ. That is for any 푡 ∈ ℤ, 푋, 푌 will always satisfy 푎푥 + 푏푦 = gcd 푎, 푏 . Example 2.1.8 Try to find gcd 12345,11111 and solve 12345x + 11111y = gcd(12345,11111). Modular Arithmetic 2.2.1 Congruence Definition 2.2.1 푎−푏 Let 푎, 푏, 푛 ∈ ℤ and 푛 ≠ 0. We say 푎 ≡ 푏 mod 푛 if = 푘 ∈ ℤ. 푛 Example 2.2.1 32 ≡ 7 mod 5 Modular Arithmetic Proposition 2.2.1 Let 푎, 푏, 푛 ∈ ℤ and 푛 ≠ 0. i) 푎 ≡ 푎 mod 푛 ii) 푎 ≡ 푏 mod 푛 implies 푏 ≡ 푎 mod 푛 iii) If 푎 ≡ 푏 mod 푛 and 푏 ≡ 푐 mod 푛 then 푎 ≡ 푐 mod 푛 . Proof: Modular Arithmetic Arithmetic operations i. [(a mod n) + (b mod n)] mod n = (a + b) mod n ii. [(a mod n) - (b mod n)] mod n = (a - b) mod n iii. [(a mod n) x (b mod n)] mod n = (a x b) mod n Modular Arithmetic Remark 2.2.1 Cryptography thought in this course will work with the integers modulo 푛. They are denoted by ℤ푛 or also as ℤ/푛ℤ. ℤ푛 = 0,1,2, … , 푛 − 1 Example 2.2.2 Generate the addition and multiplication table modulo 10. Modular Arithmetic • Rules for Addition, Modulo 10 + 0 1 2 3 4 5 6 7 8 9 0 0 1 2 3 4 5 6 7 8 9 1 1 2 3 4 5 6 7 8 9 0 2 2 3 4 5 6 7 8 9 0 1 3 3 4 5 6 7 8 9 0 1 2 4 4 5 6 7 8 9 0 1 2 3 5 5 6 7 8 9 0 1 2 3 4 6 6 7 8 9 0 1 2 3 4 5 7 7 8 9 0 1 2 3 4 5 6 8 8 9 0 1 2 3 4 5 6 7 9 9 0 1 2 3 4 5 6 7 8 Modular Arithmetic 2.2.1.1 Division in modular arithmetic Proposition 2.2.2 Let 푎, 푏, 푛 ∈ ℤ and 푛 ≠ 0 with 푎푏 ≡ 푎푐 mod 푛 then 푏 ≡ 푐 mod 푛 . Proof: Example 2.2.5 Solve 2푥 + 7 ≡ 3 mod 17 . (Note: please observe gcd 2,17 ) Modular Arithmetic Proposition 2.2.3 Suppose gcd 푎, 푛 = 1. Let 푠, 푡 ∈ ℤ such that 푎푠 + 푛푡 = 1 (푠 and 푡 can be found using the extended Euclidean algorithm). If 푎푠 ≡ 1 mod 푛 , then 푠 is the multiplicative inverse for 푎 mod 푛 . Proof: Inverses - Preliminaries Observe that if (a + b) (a + c) mod n, then b c mod n For a = 5; b = 23; c = 7, n = 8 If (5 + 23) (5 + 7) mod 8; then 23 7 mod 8. Is this true? Part 1: Is (5 + 23) (5 + 7) mod 8? (5 + 23) = 28; 28/8 = 3, 4 (i.e., r = 4), and (5 + 7) mod 8 = 12 mod 8 = 12/8 = 1, 4 (i.e., r = 4) OK! Part 2: Is 23 7 mod 8? 23/8 = 2, 7 (i.e., r = 7), and 7 mod 8 = 0, 7 (i.e., r = 7) OK! So, what is the point? Inverses - Preliminaries This is true because there is an additive inverse. It is the number you would have to subtract from the original number to get 0. That is: (a + b) - a -a + (a + c) mod n, or b c mod n Inverses in Cryptography We will use one number to encrypt and its inverse to decrypt. Consider an input string to be encrypted = 3692. Add a constant mod 10 to map the string to a new string (character by character). (3 + 6) mod 10 = 9 (6 + 6) mod 10 = 2 (9 + 6) mod 10 = 5 (2 + 6) mod 10 = 8 The encrypted string for 3692 = 9258 Inverses in Cryptography Now use the additive inverse of 6; it is 6 + x = 0; x = 4 to decrypt (inverse is taken from the table). (9 + 4) mod 10 = 3 (2 + 4) mod 10 = 6 (5 + 4) mod 10 = 9 (8 + 4) mod 10 = 2 The encrypted string is decrypted! This is a simple substitution cipher (e.g., Caesar). The only difference is numbers were used instead of letters. But – easy to break – lets do something harder! Inverses in Cryptography - Multiplicative 0 1 2 3 4 5 6 7 8 9 x 0 0 0 0 0 0 0 0 0 0 0 1 0 1 2 3 4 5 6 7 8 9 2 0 2 4 6 8 0 2 4 6 8 3 0 3 6 9 2 5 8 1 4 7 4 0 4 8 2 6 0 4 8 2 6 5 0 5 0 5 0 5 0 5 0 5 6 0 6 2 8 4 0 6 2 8 4 7 0 7 4 1 8 5 2 9 6 3 8 0 8 6 4 2 0 8 6 4 2 9 0 9 8 7 6 5 4 3 2 1 If this works like addition, we should be able to encrypt and decrypt. Trouble is, it only works part of the time. We can encrypt/decrypt some, but not all, numbers. Inverses in Cryptography - Multiplicative Encrypt the string 8732 using a multiplicative constant of: 5 mod 10 (8 x 5) mod 10 = 0; (40/10 = 4, 0) (7 x 5) mod 10 = 5; (35/10 = 3, 5) (3 x 5) mod 10 = 5; (15/10 = 1, 5) (2 x 5) mod 10 = 0; (10/10 = 1, 0) So the encrypted string would be 0550. Trouble is, half the characters mapped to 0 and half to 5. We might guess this is a problem since results are not unique.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    88 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us