Elements of Coding and Encryption
description
Transcript of Elements of Coding and Encryption
![Page 1: Elements of Coding and Encryption](https://reader036.fdocuments.net/reader036/viewer/2022062314/56814516550346895db1d85e/html5/thumbnails/1.jpg)
Elements of Coding and Encryption
Continuation
1
![Page 2: Elements of Coding and Encryption](https://reader036.fdocuments.net/reader036/viewer/2022062314/56814516550346895db1d85e/html5/thumbnails/2.jpg)
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
![Page 3: Elements of Coding and Encryption](https://reader036.fdocuments.net/reader036/viewer/2022062314/56814516550346895db1d85e/html5/thumbnails/3.jpg)
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).
if =0
, if =0
, mod otherwise
b
GCD
GC
a
a b ab
bD ba
3
![Page 4: Elements of Coding and Encryption](https://reader036.fdocuments.net/reader036/viewer/2022062314/56814516550346895db1d85e/html5/thumbnails/4.jpg)
4
Euclidean Algorithm.Example
GCD(22,77):
Step r = a mod b a b
0 - 22 77
if =0
, if =0
, mod otherwise
a b
GCD a b b a
GCD b a b
![Page 5: Elements of Coding and Encryption](https://reader036.fdocuments.net/reader036/viewer/2022062314/56814516550346895db1d85e/html5/thumbnails/5.jpg)
5
Euclidean Algorithm.Example
GCD(22,77):
Step r = a mod b a b
0 - 22 77
122 mod 77
= 2277 22
if =0
, if =0
, mod otherwise
a b
GCD a b b a
GCD b a b
![Page 6: Elements of Coding and Encryption](https://reader036.fdocuments.net/reader036/viewer/2022062314/56814516550346895db1d85e/html5/thumbnails/6.jpg)
6
Euclidean Algorithm.Example
GCD(22,77):
Step r = a mod b a b
0 - 22 77
122 mod 77
= 2277 22
277 mod 22
= 1122 11
if =0
, if =0
, mod otherwise
a b
GCD a b b a
GCD b a b
![Page 7: Elements of Coding and Encryption](https://reader036.fdocuments.net/reader036/viewer/2022062314/56814516550346895db1d85e/html5/thumbnails/7.jpg)
7
Euclidean Algorithm.Example
GCD(22,77):
Step r = a mod b a b
0 - 22 77
122 mod 77
= 2277 22
277 mod 22
= 1122 11
322 mod 11
= 011 0
if =0
, if =0
, mod otherwise
a b
GCD a b b a
GCD b a b
![Page 8: Elements of Coding and Encryption](https://reader036.fdocuments.net/reader036/viewer/2022062314/56814516550346895db1d85e/html5/thumbnails/8.jpg)
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).
![Page 9: Elements of Coding and Encryption](https://reader036.fdocuments.net/reader036/viewer/2022062314/56814516550346895db1d85e/html5/thumbnails/9.jpg)
9
Letter Number Conversion Table
A B C D E F G H I J K L M
1 2 3 4 5 6 7 8 910
11
12
13
N O P Q R S T U V W X Y Z
14
15
16
17
18
19
20
21
22
23
24
25
26
![Page 10: Elements of Coding and Encryption](https://reader036.fdocuments.net/reader036/viewer/2022062314/56814516550346895db1d85e/html5/thumbnails/10.jpg)
10
Encryption example
• Let the encryption function (“secret key”) bef (a) = (3a + 9) mod 26
• Encrypt “Stop Thief”1. STOP THIEF (capitals)2. 19,20,15,16 20,8,9,5,63. 14,17,2,5 17,7,10,24,14. Scipher obtained: NQBE QGJXA
![Page 11: Elements of Coding and Encryption](https://reader036.fdocuments.net/reader036/viewer/2022062314/56814516550346895db1d85e/html5/thumbnails/11.jpg)
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 beg (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
![Page 12: Elements of Coding and Encryption](https://reader036.fdocuments.net/reader036/viewer/2022062314/56814516550346895db1d85e/html5/thumbnails/12.jpg)
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
![Page 13: Elements of Coding and Encryption](https://reader036.fdocuments.net/reader036/viewer/2022062314/56814516550346895db1d85e/html5/thumbnails/13.jpg)
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
![Page 14: Elements of Coding and Encryption](https://reader036.fdocuments.net/reader036/viewer/2022062314/56814516550346895db1d85e/html5/thumbnails/14.jpg)
Modular Exponentiation
• Modular exponentiation is a key operation in the RSA encryption. It is raising of a number to a power e in Zn:
• 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
mod 0e na b a n
![Page 15: Elements of Coding and Encryption](https://reader036.fdocuments.net/reader036/viewer/2022062314/56814516550346895db1d85e/html5/thumbnails/15.jpg)
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
1 2 ... ; 2sk ie e e e e
1 2 1 2
1 2
... ...
(mod ) (mod ) ... (mod )
k k
k
e e e ee ee
ee e
b b b b b
b n b n b n
![Page 16: Elements of Coding and Encryption](https://reader036.fdocuments.net/reader036/viewer/2022062314/56814516550346895db1d85e/html5/thumbnails/16.jpg)
Modular Exponentiation
• For example, let• Then
16
90; 101; 1189b e n
0 2 5 6
101 1 4 32 64 4 32 64
2 2 2 5 2 6
101 2 2 2 2 1 4 32 64
90 90 90 90 90 90 (mod1189)
90(mod1189) (90 ) (mod1189) (90 ) (mod1189) (90 ) (mod1189)
90 980 1125 529 88200 1125 529 240750 529 240750 529(mod1189)
2
eb
e
40750(mod1189) 529(mod1189) 572 529(mod1189) 302588(mod1189) 582
![Page 17: Elements of Coding and Encryption](https://reader036.fdocuments.net/reader036/viewer/2022062314/56814516550346895db1d85e/html5/thumbnails/17.jpg)
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
![Page 18: Elements of Coding and Encryption](https://reader036.fdocuments.net/reader036/viewer/2022062314/56814516550346895db1d85e/html5/thumbnails/18.jpg)
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
![Page 19: Elements of Coding and Encryption](https://reader036.fdocuments.net/reader036/viewer/2022062314/56814516550346895db1d85e/html5/thumbnails/19.jpg)
19
RSA Encryption
n = 4559, e = 13. Smiley Transmits: “Last name Smiley”
b e (mod n)
![Page 20: Elements of Coding and Encryption](https://reader036.fdocuments.net/reader036/viewer/2022062314/56814516550346895db1d85e/html5/thumbnails/20.jpg)
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)
![Page 21: Elements of Coding and Encryption](https://reader036.fdocuments.net/reader036/viewer/2022062314/56814516550346895db1d85e/html5/thumbnails/21.jpg)
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)
![Page 22: Elements of Coding and Encryption](https://reader036.fdocuments.net/reader036/viewer/2022062314/56814516550346895db1d85e/html5/thumbnails/22.jpg)
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
120113 mod 4559, 192013 mod 4559, …
b e (mod n)
![Page 23: Elements of Coding and Encryption](https://reader036.fdocuments.net/reader036/viewer/2022062314/56814516550346895db1d85e/html5/thumbnails/23.jpg)
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
120113 mod 4559, 192013 mod 4559, …
2853 0116 1478 2150 3906 4256 1445 2462
b e (mod n)
![Page 24: Elements of Coding and Encryption](https://reader036.fdocuments.net/reader036/viewer/2022062314/56814516550346895db1d85e/html5/thumbnails/24.jpg)
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
120113 mod 4559, 192013 mod 4559, …
2853 0116 1478 2150 3906 4256 1445 2462
b e (mod n)
![Page 25: Elements of Coding and Encryption](https://reader036.fdocuments.net/reader036/viewer/2022062314/56814516550346895db1d85e/html5/thumbnails/25.jpg)
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
![Page 26: Elements of Coding and Encryption](https://reader036.fdocuments.net/reader036/viewer/2022062314/56814516550346895db1d85e/html5/thumbnails/26.jpg)
Homework
• Read Sections 3.2 – 3.3• Problems (Exercises 3.3) 1, 2.
26