The Chinese Remainder Theorem
Used to speed up modulo computations!!!
If working modulo a product of numbers: mod M=m1*m2*m3*....*mk
CRT let us work in each moduli mi separately.
To compute A(mod M):
1. First compute all separately
Problem 1
If x≡5 mod 7, x≡3 mod 11, x≡10 mod 13, x mod 1001?
By CRT Theorem,
a1=5, m1=7, M1=143, Y1=M1^-1 mod m1=143^-1 mod 7=2
a2=3,m2=11,M2=91,Y2=M2^-1 mod m2=91^-1 mod 11=12
a3=10,m3=13,M3=77,Y3=M3^-1 mod m3=77^-1 mod 13=12
x=(Y1M1a1+Y2M2a2+Y3M3a3)=(2*143*5+12*91*3+12*77*10)=1430+3276+9240=13946
143d-7f=1
143=20*7+3
7=2*3 +1
1= 7-2*3
1=7-2*(143-20*7)
1=7-2*143+2*20*7
1=-2*143+41*7
-1=143*2-7*41
-6=143*12-7*41*6
1=143*12-7*247
thus k=12
Problem 2
x≡2 mod 3 , x≡3 mod 5, x≡2 mod 7, 求x
Answer:
a1=2 , m1=3
a2=3, m2=5
a3=2, m3=7
M=3*5*7=105
M1=m2*m3=35
M2=m3*m1=21
M3=m1*m2=15
Y1=M1^-1 mod m1=35^-1 mod 3=2
Y2=M2^-1 mod m2=21^-1 mod 5=1
Y3=M3^-1 mod m3=15^-1 mod 7=1
x=(Y1M1a1+Y2M2a2+Y3M3a3) mod M
=(140+63+30)
=233 mod 105
=23
PS:
Y2=21^-1 mod 5=?
By Euclid Theorem,
21d= 1 mod 5
then 21d=1+5f, f is integer,
21d- 5f=1
21= 4*5 +1
1= 21- 4*5
thus d=1 , f=4
---------------------------
Y3=15^-1 mod 7=
15d- 7f=1
15=2*7 +1
1=15-2*7
thus d=1 , f=2
-------------------------
Primitive roots
From Euler's theorem have a^Ø(n) =1 mod n
Then what is primitive roots???
Consider a^m =1 mod n, gcd(a,n)=1, must exist for m but may be smaller than Ø(n),
if smallest is m=Ø(n) then a is called a primitive root.
for a prime number 19, primitive roots are 2,3,10,13,14,15
Discrete Logarithms