









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










M C = f(M) = Me^ mod N C
M = f-1(C) = Cd^ mod N
N = P ⋅ Q P, Q - large prime numbers
e ⋅ d ≡ 1 mod ((P-1)(Q-1))
message ciphertext
PUBLIC KEY PRIVATE KEY
e ⋅ d ≡ 1 mod ((P-1)(Q-1))
P, Q - large prime numbers
gcd(e, P-1) = 1 and gcd(e, Q-1) = 1
d:
e:
PUBLIC KEY PRIVATE KEY
3 ⋅ d ≡ 1 mod 40
gcd(e, 5-1) = 1 and gcd(e, 11-1) = 1
d:
e: e=
d=
M=2 C = f(2) = 2^3 mod 55 = 8 C=
M = f-1(C) = 8^27 mod 55 = 2
N = 5 ⋅ 11 5, 11 - prime numbers
3 ⋅ 27 ≡ 1 mod ((5-1)(11-1))
message ciphertext
An integer p ≥ 2 is said to be prime if its only positive divisors are 1 and p. Otherwise, p is called composite.
See “The Prime Pages: prime number research, records, and resources” by Chris Caldwell
http://www.utm.edu/research/primes/
Greatest common divisor of a and b , denoted by gcd( a , b ) ,
is the largest positive integer that divides both a and b.
d = gcd ( a , b ) iff 1) d | a and d | b
gcd (8, 44) =
gcd (-15, 65) =
gcd (45, 30) =
gcd (31, 15) =
gcd (0, 40) =
gcd (121, 169) =
Two integers a and b are relatively prime or co-prime if gcd( a , b ) = 1
Two integers a and b are congruent modulo n ( equivalent modulo n )
written a ≡≡≡≡ b iff a mod n = b mod n or a = b + kn , k ∈∈∈∈ Z or n | a - b
a + b mod n = (( a mod n ) + ( b mod n )) mod n
a - b mod n = (( a mod n ) - ( b mod n )) mod n
a ⋅ b mod n = (( a mod n ) ⋅ ( b mod n )) mod n
Modular addition
Modular multiplication
Regular addition
Regular multiplication
a + b = a + c iff b = c
a + b ≡ a + c (mod n ) iff b ≡ c (mod n )
If a ⋅ b = a ⋅ c and a ≠ 0 then b = c
If a ⋅ b ≡ a ⋅ c (mod n) and gcd ( a , n ) = 1 then b ≡ c (mod n)
18 ≡ 42 (mod 8) 6 ⋅ 3 ≡ 6 ⋅ 7 (mod 8)
3 ≡ 7 (mod 8)
x 6 ⋅ x mod 8
x
5 ⋅ x mod 8
The multiplicative inverse of a modulo n is an integer [!!!]
x such that
a ⋅⋅⋅⋅ x ≡≡≡≡ 1 (mod n )
The multiplicative inverse of a modulo n is denoted by a -1^ mod n (in some books a or a*). According to this notation: a ⋅⋅⋅⋅ a -1^ ≡≡≡≡ 1 (mod n )
i
…
t - t
ri
r -2 = n r -1 = a r 0 r 1
…
rt- rt =
xi
x -2= x -1= x 0 x 1
…
xt - xt
qi
q -1 =
q 0 q 1
…
qt-
qi = ri - ri ri +1 = ri -1 - qi ⋅⋅⋅⋅ ri xi +1 = xi -1 - qi ⋅⋅⋅⋅ xi yi +1 = yi -1 - qi ⋅⋅⋅⋅ yi
yi
y -2= y -1= y 0 y 1
…
yt - yt
r i = x i ⋅⋅⋅⋅ a + y i ⋅⋅⋅⋅ n
r t-1 = x t-1 ⋅⋅⋅⋅ a + y t-1 ⋅⋅⋅⋅ n
r t-1 = x t-1 ⋅⋅⋅⋅ a + y t-1 ⋅⋅⋅⋅ n
r t-1 = x t-1 ⋅⋅⋅⋅ a + y t-1 ⋅⋅⋅⋅ n ≡≡≡≡ x t-1 ⋅⋅⋅⋅ a (mod n)
If r t-1 = gcd (a, n) = 1 then x t-1 ⋅⋅⋅⋅ a ≡≡≡≡ 1 (mod n) and as a result x t-1 = a-1^ mod n
i
…
t - t
ri
r -2 = n r -1 = a r 0 r 1
…
rt-1 = 1 rt =
xi
x -2= x -1= x 0 x 1
…
xt -1 = a -1^ mod n xt = ± n
qi
q -1 =
q 0 q 1
…
qt-
qi = ri - ri ri +1 = ri -1 - qi ⋅⋅⋅⋅ ri xi +1 = xi -1 - qi ⋅⋅⋅⋅ xi
Note: If rt -1 ≠≠≠≠ 1 the inverse does not exist
i
ri
r -2 = 117 r -1 = 20 r 0 = 17 r 1 = 3 r 2 = 2 r 3 = 1 r 4 = 0
xi
x -2= 0 x -1= 1 x 0 =- x 1 = 6 x 2 = - x 3 = 41 = 20-1^ mod 117 x 4 = -
qi
q -1 = 5 q 0 = 1 q 1 = 5 q 2 = 1 q 3 = 2
qi = ri - ri ri +1 = ri -1 - qi ⋅⋅⋅⋅ ri xi +1 = xi -1 - qi ⋅⋅⋅⋅ xi
Check: 20 ⋅ 41 mod 117 = 1
Affine Cipher – Example (2)
encryption
13
3 ⋅ 13 + 11 mod 26 = 24
coding decoding
Y
3 ⋅ 18 + 11 mod 26 = 13 N
3 ⋅ 0 + 11 mod 26 = 11 L
Affine Cipher – Example (3)
decryption
24
9 ⋅ (24 – 11) mod 26 = 13
coding decoding
N
9 ⋅ (13 – 11) mod 26 = 18 S
9 ⋅ (11 – 11) mod 26 = 0 A
Ciphertext:
FMXVE DKAPH FERBN DKRXR SREFM ORUDS DKDVS HVUFE DKAPR KDLYE VLRHH RH
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
R - 8 D - 7 E, H, K - 5
Step 1: Establish a relative frequency of letters in the ciphertext
Average frequency in a long English text: E — 13% T, N, R, I, O, A, S — 6%-9% D, H, L — 3.5%-4.5% C, F, P, U, M, Y, G, W, V — 1.5%-3% B, X, K, Q, J, Z — < 1%
Average frequency in a random string of letters: 1 26
f(E) = R f(T) = D
f(4) = 17 f(19) = 3
Step 2: Assuming the relative frequency of letters in the corresponding message, derive the corresponding equations
Assumption: Most frequent letters in the message: E and T
Corresponding equations:
f(4) = 17 f(19) = 3
Step 3: Solving a set of equations for unknowns k 1 and k 2
4 ⋅ k 1 + k 2 ≡ 17 (mod 26) 19 ⋅ k 1 + k 2 ≡ 3 (mod 26)
15 ⋅ k 1 ≡ -14 (mod 26)
15 ⋅ k 1 ≡ 12 (mod 26)