Download presentation
Published byAlban McKinney Modified over 9 years ago
1
Number Theory(L5) Number Theory Number Theory(L5)
2
Modular Arithmetic m ÷ n = q …r (餘數) m=nq+r
Definition: remainder of m divided by n, define r non-negative integer and r {0,1,2,…,n-1}. If r=0, n|m, and if r≠0, n†m If two numbers a and b have the same remainder when divided n, we say a ≡b mod n also means b=a+kn or a = b+Jn (J=-kn) In arithmetic modulo n, two integers (a,b) are equivalent if their remainders are the same. Denote, a ≡b mod n e.g. 3 ,13,and -7 are equivalent in modulo 10. we use: 3= 13 mod 10 instead of 3≡13 mod 10 if clear Also means a-b=kn
3
Modular Arithmetic(+,-,*,/)
addition mod n : (a mod n + b mod n) mod n= a+b mod n a +b = a+b mod n subtraction mod n: (a mod n - b mon n ) mod n= a-b mod n a-b = a-b mon n multiplication mod n : (a mod n * b mon n ) mod n= a*b mod n a * b = a*b mon n division mon n: (a mod n / b mon n ) mod n= a*b-1 mod n
4
Algebraic based on Mod n
If a + b = c mod n, given b, c, how to find a ? Find number b additional inverse number(加法反元素) under mod n. since b + (-b) =0 mod n, so –b is the additional inverse number of b. Add to both sides with the additional inverse number of b, we can get a: a + b = c mod n a + b + (-b)=c + (-b) mod n a=c-b mod n e.g., m + K=c mod n (e.g, Verna cipher) To find m, use m=c-k mod n
5
Note that if m + K=c mod n , we can find m by using c-k mod n
Note that if m + K=c mod n , we can find m by using c-k mod n. m denote a set of numbers m+Jn J Z and only when m Zn Zn ={0,1,2,…,n-1}, m is unique. For example: k=5, c=23, n=10 m can be …,-12,-2,8, 18,28,…only number 8 Z10 Therefore, choose n is important when used in cipher. We need Zn to cover all the characters needed to coded.
6
Application For a file M,
Case 1: we cut M apart with a block size of 8, then we use the key: , and use m+k=c mod n as a cipher, (what is the value n?), Case 2: we cut M apart with a block size of 16, and use m+k=c mod n as a cipher, (what is the value n and key size ?)
7
If a * b = k mod n, given k, b, how to find a ?
Find number b multiplication inverse number(乘法反元素) under mod n. i.e., b * (b-1) =1 mod n, so b-1 is the multiplication inverse number of b. multiply both sides with the multiplication inverse number of b, we can get a: a * b = k mod n a*b* b-1 =k* b-1 mon n a=k* b-1 mod n 應用: M * K = C mod n, given C and K, find M?
8
Questions about multiplication inverse number(乘法反元素) under mod n
Exists? b*b-1=1 mod n. Does b-1 exist? e.g., 3 * 3-1 =1 mod 6, 3-1 exist? Exist condition: gcd(b,n)=1 When use M * K = C mod n, first choose K that gcd(k,n)=1 efficient way ? to find multiplication inverse number(乘法反元素) under mod n (when both number are very very very big)
9
Euclid’s Algorithm Euclid’s Algorithm :finds the greatest common divisor (gcd) of two integers. e.g., gcd(x, y) or (x,y) multiplicative inverses(乘法反元素) mod n. b *b-1 =1 mod n (mean, 1= b *b-1 +Kn, and gcd(b,n)= b *b-1 +Kn if exists) e.g., 1 = 3 *7 +(-4)* 5 , what is ,3’s multiplicative inverses(乘法反元素) mod 5
10
(x,y) and (x-y,y) have the same common divisors (also (x-ky,y) )
Find gcd, <x,y> <y, remainder (x/y)> For example, (find gcd(797,1047)) (797,1047)(1047,797) (797,250) (250, 47) (47,15) (15,2) (2,1) (1,0) so 1 is the gcd(797, 1047)
11
For example, find the gcd ( 797 , 1047)
n qn rn un vn rn= rn-2- qnrn-1
12
The Algorithm find gcd(x,y)
Initial setup: Let r-2=x and r-1=y set n=0 Step n: if rn-1=0, gcd(x,y) =rn-2 otherwise, divide rn-2 by rn-1 to get quotient qn and remainder rn. Set n=n+1. Repeat.
13
Finding Multiplicative Inverses in Modular Arithmetic
Use numbers un and vn rn= unx+ vny: Initial setup, set u-2 =1, v-2 =0 and u-1 =0 and v-1 =1 (since, rn= unx+ vny for n=-2 and n=-1) At step n, set un = un-2 – qnun-1 and vn = vn-2 – qnvn-1. (since rn= rn-2- qnrn-1, rn-2= un-2x+ vn-2y,and rn-1= un-1x+ vn-1y)
14
rn-2= un-2x+ vn-2y (1) rn-1= un-1x+ vn-1y (2) rn= unx+ vny (3) rn= rn-2- qnrn-1 (3)=(1)-qn (2)
15
For example, find the inverse of 797 mod 1047
n qn rn un vn From the last line, 1=-490* *1047, give 797-1=-490=557 (mod 1047)
16
Modular Exponentiation
Define the Exponentiation as: E(x,y) = yx mon n If y equal some constant g: E(x,g)= gx mon n or use E(g) = gx mon n
17
Euler’s totient function
(n), Euler’s totient function, as the number of elements in Zn*. e.g., Z10* ={1,3,7,9} and (n)=4 Given n, can we calculate (n)? if n is prime, (n)= n-1 If n =pq, p and q are prime, (pq)=(p-1)(q-1)?
18
Theorem Theorem: y x mod n = y x mod (n) mod n
Special case, if x = 1 mod (n) , then for any y, y x mod n = y mod n
19
if x = 1 mod (n) , then for any y,
y x mod n = y mod n 應用: if e * d =1 mod (n) , then for any m encrypted with C=m e mod n Given C and d, how to find m?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.