Modular Arithmetic: Mathematical Background for Public-Key Ciphers, Study notes of Cryptography and System Security

Material Type: Notes; Class: Cryptography/Comp Netwk Sec; Subject: Electrical & Computer Enginrg; University: George Mason University; Term: Unknown 1989;

Typology: Study notes

Pre 2010

Uploaded on 02/10/2009

koofers-user-cm3-1
koofers-user-cm3-1 🇺🇸

9 documents

1 / 20

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Mathematical Background:
Modular Arithmetic
ECE 646 - Lecture 5
Motivation:
Public-key ciphers
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14

Partial preview of the text

Download Modular Arithmetic: Mathematical Background for Public-Key Ciphers and more Study notes Cryptography and System Security in PDF only on Docsity!

Mathematical Background:

Modular Arithmetic

ECE 646 - Lecture 5

Motivation:

Public-key ciphers

RSA as a trap-door one-way function

M C = f(M) = Me^ mod N C

M = f-1(C) = Cd^ mod N

PUBLIC KEY
PRIVATE KEY

N = P ⋅ Q P, Q - large prime numbers

e ⋅ d ≡ 1 mod ((P-1)(Q-1))

message ciphertext

RSA keys

PUBLIC KEY (^) PRIVATE KEY

{ e, N } { d, P, Q }

N = P ⋅ Q

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:

P, Q:
N:

e:

Basic definitions

General Notation

Z – integers

∃ - there exists

  • for all

∃! - there exists unique

∈ - belongs to (^) ∉ - does not belong to

Divisibility

a | b iff ∃ c ∈ Z such that b = c ⋅ a

a | b a divides b a is a divisor of b

a | b a does not divide b a is not a divisor of b

Prime vs. composite numbers

An integer p ≥ 2 is said to be prime if its only positive

divisors are 1 and p. Otherwise, p is called composite.

Properties of the greatest common divisor

gcd ( a , b ) = gcd ( a - kb , b )

for any k ∈∈∈∈ Z

Quotient and remainder

Given integers a and n , n >

∃! q , rZ such that

a = q ⋅ n + r and 0 ≤ r < n

q – quotient

r – remainder (of a divided by n )

q =

a n =^ a^ div^ n

r = a - q ⋅ n = a –

a

n^ ⋅^ n^ =

= a mod n

Integers coungruent modulo n

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

Laws of modular arithmetic

Modular Multiplication: Example

18 ≡ 42 (mod 8) 6 ⋅ 3 ≡ 6 ⋅ 7 (mod 8)

3 ≡ 7 (mod 8)

x 6 ⋅ x mod 8

x

5 ⋅ x mod 8

Algorithms

Euclid’s Algorithm

for computing gcd(a,b)

i

  • 0 1

t - t

ri

r -2 = max (a, b) r -1 = min (a, b) r 0 r 1

rt-1 = gcd(a, b) rt =

qi

q - q 0 q 1

qt-

qi = ri - ri ri +1 = ri -1 - qi ⋅⋅⋅⋅ ri

ri +1 = ri -1 mod ri

Euclid’s Algorithm

Example: gcd(36, 126)

i

  • 0 1

ri

r -2 = max (a, b) = r -1 = min (a, b) = r 0 = 18 = gcd(36, 126) r 1 = 0

qi

q -1 = 3 q 0 = 2 q 1 qi = ri - ri ri +1 = ri -1 - qi ⋅⋅⋅⋅ ri

ri +1 = ri -1 mod ri

Extended Euclid’s Algorithm (2)

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

Extended Euclid’s Algorithm

for computing z = a -1^ mod n

i

  • 0 1

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 =

n/a  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

Extended Euclid’s Algorithm

Example z = 20-1^ mod 117

i

  • 0 1 2 3 4

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

Motivation

Breaking ciphers

Historical ciphers

Affine Cipher – Example (1)

ci = f(mi) = 3 ⋅ mi + 11 mod 26

mi = f-1(ci) = 9 ⋅ (ci - 11) mod 26

Key = (k 1 , k 2 ) = (3, 11) 3, 11 ∈ [0, 25], gcd (3, 26)=

Encryption transformation:

Decryption transformation:

Key:

k 1 -1^ = 3-1^ mod 26 = 9^ because^3 ⋅^ 9 mod 26 = 1

Historical ciphers

Affine Cipher – Example (2)

N
S
A

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

Historical ciphers

Affine Cipher – Example (3)

Y
N
L

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

Breaking the affine cipher (1)

Step 1: Establish a relative frequency of letters in the ciphertext

f(4) = 17 f(19) = 3

Breaking the affine cipher (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)

The equation a ⋅⋅⋅⋅ x ≡≡≡≡ b mod n has

1. one solution iff gcd( a , n ) = 1 x = a -1^ ⋅ b (mod n ) 2. no solutions iff d = gcd( a , n ) ≠ 1, and d | b 3. d solutions iff d = gcd( a , n ) ≠ 1, and d | b The solutions are x 0 , x 0 + n / d , x 0 + 2 ⋅ n / d , x 0 + 3 ⋅ n / d , …, x 0 + ( d -1) ⋅ n / d , where x 0 = ( a / d )-1^ ⋅ ( b / d ) (mod n / d )

Solving equations of the form a ⋅ x ≡ b mod n

(linear congruences)

Case 2:

Case 1:

Case 3:

Solving equations of the form a ⋅ x ≡ b mod n

(linear congruences)

n / d

x

x 0

0 n

0 n

n / d

(^0) n / d n