Presentation is loading. Please wait.

Presentation is loading. Please wait.

Elements of Coding and Encryption Continuation 1.

Similar presentations


Presentation on theme: "Elements of Coding and Encryption Continuation 1."— Presentation transcript:

1 Elements of Coding and Encryption Continuation 1

2 Greatest Common Divisor Given integers m and n, not both zero, we define the greatest common divisor of m and n to be the largest integer that divides both m and n: GCD(m, n). Note that if m ≠ 0, then GCD(m, 0) = |m|. 2

3 Greatest Common Divisor: Euclidian Algorithm Determine the greatest common divisor (GCD) for two numbers. Euclidean algorithm: GCD (a,b) can be recursively found from the formula Theorem. Let a, b, c, and q be integers with b>0. If a=qb+c, then GCD(a, b) = GCD (b, c). 3

4 4 Euclidean Algorithm. Example GCD(22,77): Stepr = a mod bab 0 - 2277

5 5 Euclidean Algorithm. Example GCD(22,77): Stepr = a mod bab 0 - 2277 1 22 mod 77 = 22 7722

6 6 Euclidean Algorithm. Example GCD(22,77): Stepr = a mod bab 0 - 2277 1 22 mod 77 = 22 7722 2 77 mod 22 = 11 2211

7 7 Euclidean Algorithm. Example GCD(22,77): Stepr = a mod bab 0 - 2277 1 22 mod 77 = 22 7722 2 77 mod 22 = 11 2211 3 22 mod 11 = 0 110

8 8 Simple Encryption Variations on the following have been used to encrypt messages for thousands of years. 1.Convert a message to capitals. 2.Encode each letter by a number between 1 and 26. 3.Apply an invertible modular function to each number. 4.Convert back to letters (0 becomes 26).

9 9 Letter  Number Conversion Table ABCDEFGHIJKLM 12345678910111213 NOPQRSTUVWXYZ 14151617181920212223242526

10 10 Encryption example Let the encryption function (“secret key”) be f (a) = (3a + 9) mod 26 Encrypt “ Stop Thief ” 1.STOP THIEF (capitals) 2.19,20,15,16 20,8,9,5,6 3.14,17,2,5 17,7,10,24,1 4.Scipher obtained: NQBE QGJXA

11 11 Decryption example Decryption works the same, except that we apply the inverse key function. Find the inverse of f (a) = (3a + 9) mod 26  If we didn ’ t have to deal with mod 26, inverse would be g (b) = 3 -1 (b - 9)  We ’ ll see that since GCD(3,26) = 1, the inverse of 3 (mod 26) is the number 9. This gives: g (b) = 9 (b - 9) mod 26 = (9b – 3) mod 26

12 Open key Encryption Encryption methods, which are based on the “secret key” function have one, but significant disadvantage: it is necessary to distribute a key among all users and all of them must take care of keeping the key unavailable to others. The alternative is an “open key” encryption, which became very popular during last 15-20 years. In this method, which is based on the modular arithmetic, two different keys are used for encryption and decryption. The encrypting key is a “public key”, it is open, while the decrypting key is hidden. 12

13 RSA Encryption In “open key” encryption methods, it is extremely hard (actually, it is impossible within some reasonable long time interval) to reverse a key, which is used for the encryption. One of the most popular, efficient (and simple!) modern “open key” encryption methods is RSA named for its inventors (Rivest, Shamir, Adleman). 13

14 Modular Exponentiation Modular exponentiation is a key operation in the RSA encryption. It is raising of a number to a power e in Z n : In the RSA method, both e and n are very large numbers. In the real world applications, n is an integer of about 400 decimal digits. 14

15 Modular Exponentiation To perform modular exponentiation, congruence properties are used. To reduce computations, exponent e should be presented as a sum of powers of 2 (any integer number should be easily presented in such a way: ) Then the following technique should be applied: 15

16 Modular Exponentiation For example, let Then 16

17 RSA Encryption In the RSA encryption method, a message is converted into numbers, as in the modular encryption that we saw before. The letters are then put together into number blocks with each block less than n. Then each number block is exponentiated by the exponent e modulo n, which completes the encryption procedure. 17

18 RSA Encryption In the RSA encryption method, n is chosen to be the product of prime numbers. If n=pq, then e is chosen so that GCD (e, r) = 1, where r= (p-1)(q-1). There are many such es (almost all positive integers satisfy the given condition). In the RSA decryption, the exponent d is chosen as the smallest positive solution x to the congruence ex  1 (mod r): (b e (mod n )) d (mod n )= b 18

19 19 RSA Encryption n = 4559, e = 13. Smiley Transmits: “Last name Smiley” b e (mod n)

20 20 RSA Encryption n = 4559, e = 13. Smiley Transmits: “Last name Smiley”  L A S T N A M E S M I L E Y b e (mod n)

21 21 RSA Encryption n = 4559, e = 13. Smiley Transmits: “Last name Smiley”  L A S T N A M E S M I L E Y  1201 1920 0014 0113 0500 1913 0912 0525 b e (mod n)

22 22 RSA Encryption n = 4559, e = 13. Smiley Transmits: “Last name Smiley”  L A S T N A M E S M I L E Y  1201 1920 0014 0113 0500 1913 0912 0525  1201 13 mod 4559, 1920 13 mod 4559, … b e (mod n)

23 23 RSA Encryption n = 4559, e = 13. Smiley Transmits: “Last name Smiley”  L A S T N A M E S M I L E Y  1201 1920 0014 0113 0500 1913 0912 0525  1201 13 mod 4559, 1920 13 mod 4559, …  2853 0116 1478 2150 3906 4256 1445 2462 b e (mod n)

24 24 RSA Encryption n = 4559, e = 13. Smiley Transmits: “Last name Smiley”  L A S T N A M E S M I L E Y  1201 1920 0014 0113 0500 1913 0912 0525  1201 13 mod 4559, 1920 13 mod 4559, …  2853 0116 1478 2150 3906 4256 1445 2462 b e (mod n)

25 RSA Encryption a private decryption exponent d,which when applied to n, recovers the original blocks b : (b e mod n ) d mod n = b For n = 4559, e = 13 the decryptor d = 3397 25

26 Homework Read Sections 3.2 – 3.3 Problems (Exercises 3.3) 1, 2. 26


Download ppt "Elements of Coding and Encryption Continuation 1."

Similar presentations


Ads by Google