
i
i
“main-v1” — 2012/4/28 — 9:15
i
i
i
i
i
i
190 Communication System Security
Input: a and b, b > a
Output: gcd(a, b)
Procedure:
Set: r
0
= b and r
1
= a.
Compute:
r
0
= q
1
r
1
+ r
2
, 0 < r
2
< r
1
r
1
= q
2
r
2
+ r
3
, 0 < r
3
< r
2
r
2
= q
3
r
3
+ r
4
, 0 < r
4
< r
3
...
r
m−1
= q
m
r
m
.
Return r
m
.
The Chinese Remainder Theorem
Let m
1
, ...., m
r
be pairwise co-prime numbers, i.e., gcd(m
i
, m
j
) = 1 if i 6=
j, and let a
1
, ...., a
r
be integers. Then the following system of r congruent
equations:
x ≡ a
1
mod m
1
x ≡ a
2
mod m
2
......
x ≡ a
r
mod m
r
has a unique solution X modulo M = m
1
...m
r
, which is given by
x ≡
r
X
i=1
a
i
M
i
y
i
mod M
where M
i
= M/m
i
, and y
i
= M
−1
i
mod m
i
for 1 ≤ i ≤ r.
Example 2 Suppose r = 3 and three pairwise co-prime ...