Chinese Remainder Theorem

Chinese Remainder Theorem

The Chinese Remainder Theorem (CRT) is a fundamental result in number theory that describes when and how a system of congruences can be solved simultaneously. It has applications in cryptography, computer science, and abstract algebra.

Statement

Let n1,n2,…,nk n sub 1 comma n sub 2 comma dot dot dot comma n sub k be pairwise coprime positive integers (gcd⁡(ni,nj)=1 the gcd of open paren n sub i comma n sub j close paren equals 1 for i≠j i is not equal to j). Then the system of congruences:

x≡a1⁢(mod⁡(n1)),x≡a2⁢(mod⁡(n2)),…,x≡ak⁢(mod⁡(nk)) x is identical to a sub 1 times open paren the mod of open paren n sub 1 close paren close paren comma x is identical to a sub 2 times open paren the mod of open paren n sub 2 close paren close paren comma dot dot dot comma x is identical to a sub k times open paren the mod of open paren n sub k close paren close paren

has a unique solution modulo N=n1⁢n2⋯nk N equals n sub 1 n sub 2 dot dot dot n sub k.

Constructive Proof

Let Ni=Nni N sub i equals the fraction with numerator N and denominator n sub i for each i i. Since gcd⁡(Ni,ni)=1 the gcd of open paren N sub i comma n sub i close paren equals 1, there exists Mi M sub i such that Ni⁢Mi≡1⁢(mod⁡(ni)) N sub i M sub i is identical to 1 times open paren the mod of open paren n sub i close paren close paren.

The solution is:

x=∑i=1k(ai)⁢Ni⁢Mi⁢(mod⁡(N)) x equals the sum from i equals 1 to k of open paren a sub i close paren N sub i M sub i times mod N

Ring-Theoretic Formulation

CRT states there is a ring isomorphism:

ℤ/N⁢ℤ≅ℤ/n1⁢ℤ×ℤ/n2⁢ℤ×⋯×ℤ/nk⁢ℤ the integers divided by N the integers approximately equals the integers divided by n sub 1 the integers times the integers divided by n sub 2 the integers times dot dot dot times the integers divided by n sub k the integers

This generalizes to ideals in any ring: if I I and J J are coprime ideals, then R/(I∩J) R divided by open paren I intersection J close paren is isomorphic to R/I×R/J R divided by I times R divided by J.

Applications

RSA Decryption

CRT speeds up RSA decryption by computing md⁢mod⁡(p) m to the d-th power mod p and md⁢mod⁡(q) m to the d-th power mod q separately, then combining using CRT. This is about 4 4 times faster than direct computation.

Secret Sharing

Shamirs secret sharing uses CRT ideas: a secret is split into shares that can be recombined when enough shares are present.

Computer Arithmetic

Residue number systems use CRT for parallel computation. Operations mod different primes can proceed independently and be combined at the end.

Calendar Calculations

Computing Easter dates and finding when calendar cycles repeat uses systems of congruences solved by CRT.

Generalization to Polynomials

CRT applies to polynomials: given coprime polynomials ƒ1,…,ƒk f with hook sub 1 comma dot dot dot comma f with hook sub k, a polynomial can be uniquely determined mod ƒ1⋯ƒk f with hook sub 1 dot dot dot f with hook sub k from its remainders mod each ƒi f with hook sub i.

This is the basis for Lagrange interpolation and fast polynomial multiplication.

Algorithm Complexity

Finding the solution requires computing modular inverses (via extended Euclidean algorithm) and combining terms. Total complexity is O⁢(k⁢log2⁡N) O times open paren k log squared N close paren using fast algorithms.

When Moduli Are Not Coprime

If gcd⁡(n1,n2)=d>1 the gcd of open paren n sub 1 comma n sub 2 close paren equals d is greater than 1, the system x≡a1⁢(mod⁡(n1)),x≡a2⁢(mod⁡(n2)) x is identical to a sub 1 times open paren the mod of open paren n sub 1 close paren close paren comma x is identical to a sub 2 times open paren the mod of open paren n sub 2 close paren close paren has a solution iff a1≡a2⁢(mod⁡(d)) a sub 1 is identical to a sub 2 times mod d.

Historical Origin

The theorem appears in the 3 3rd-century Chinese text Sunzi Suanjing. The problem asks: find a number that leaves remainder 2 2 when divided by 3 3, remainder 3 3 when divided by 5 5, and remainder 2 2 when divided by 7 7.

Garners Algorithm

An efficient algorithm for CRT that avoids large intermediate values by computing the solution incrementally.

CRT and Eulers Totient

CRT implies φ⁢(n1⁢n2)=φ⁡(n1)⁢φ⁡(n2) phi times open paren n sub 1 n sub 2 close paren equals phi of open paren n sub 1 close paren phi of open paren n sub 2 close paren when gcd⁡(n1,n2)=1 the gcd of open paren n sub 1 comma n sub 2 close paren equals 1, since the units mod n1⁢n2 n sub 1 n sub 2 decompose as products.

Explicit Formula

For two moduli n1 n sub 1 and n2 n sub 2 with gcd⁡(n1,n2)=1 the gcd of open paren n sub 1 comma n sub 2 close paren equals 1:

x=a1⁢n2⁢(n2−1⁢mod⁡(n1))+a2⁢n1⁢(n1−1⁢mod⁡(n2))⁢(mod⁡(n1⁢n2)) x equals a sub 1 n sub 2 times open paren n sub 2 to the negative 1 power the mod of open paren n sub 1 close paren close paren plus a sub 2 n sub 1 times open paren n sub 1 to the negative 1 power the mod of open paren n sub 2 close paren close paren times open paren the mod of open paren n sub 1 n sub 2 close paren close paren

Simultaneous Congruences

CRT allows solving systems like x≡1⁢(mod⁡(2)),2⁢(mod⁡(3)),3⁢(mod⁡(5)),4⁢(mod⁡(7)) x is identical to 1 times mod 2 comma 2 times mod 3 comma 3 times mod 5 comma 4 times mod 7 by working with each congruence independently.

Idempotents

The isomorphism in CRT is given by idempotent elements. If ei e sub i is 1⁢(mod⁡(ni)) 1 times open paren the mod of open paren n sub i close paren close paren and 0⁢(mod⁡(nj)) 0 times open paren the mod of open paren n sub j close paren close paren for j≠i j is not equal to i, then x=∑(ai)⁢ei x equals the sum of open paren a sub i close paren e sub i.

CRT for Groups

For abelian groups: if G G has order n=n1⁢n2 n equals n sub 1 n sub 2 with gcd⁡(n1,n2)=1 the gcd of open paren n sub 1 comma n sub 2 close paren equals 1, then G G is isomorphic to G1×G2 G sub 1 times G sub 2 where |G1|=n1 the absolute value of G sub 1 equals n sub 1 and |G2|=n2 the absolute value of G sub 2 equals n sub 2.

Iterative Solution

For many congruences, solve two at a time. Combine x≡a⁢(mod⁡(m)) x is identical to a times mod m and x≡b⁢(mod⁡(n)) x is identical to b times mod n into x≡c⁢(mod⁡(m⁢n)) x is identical to c times mod m n, then continue with remaining congruences.

Error Detection

CRT enables redundant computation for error detection: compute a result mod several primes and check consistency.

Uniqueness

The solution is unique modulo N N, the product of all moduli. Different representatives of the same residue class are congruent mod N N.

Summary

CRT states: working mod n1⁢n2⋯nk n sub 1 n sub 2 dot dot dot n sub k (coprime factors) is equivalent to working mod each ni n sub i separately. This decomposition is fundamental in number theory, algebra, and computer science.

The theorem transforms hard problems mod large N N into easier problems mod smaller factors.