Skip to Content

Lecture 1

Toy example (RSA encryption)

EncEnc

  1. Choose a letter, count to number of letters in the alphabet.
  2. Calculate s7s^7, then divide by 33, take the remainder.
  3. Send the remainder.

Dec:s=r3mod33Dec: s = r^3 \mod 33

To build up such system.

Step 1: Understanding the arithmetic of remainders.

Part 1: Divisibility and prime numbers

Divisibility and division algorithm

Let a,bZa, b\in \mathbb{Z}, with b>0b>0. There are unique integers, qq (quotient) and rr (remainder), such that a=bq+ra = bq + r and 0r<b0 \leq r < b.

Example: 31=7×4+331=7\times 4 + 3

Proof:

The quotient and remainder are unique.

(1) Existence:

Let S={abkkZ,abk0}S = \{a - bk \mid k \in \mathbb{Z}, a - bk \geq 0\}. Choose rr to be the smallest non-negative element of SS. This means r=abqr = a - bq for some qZq \in \mathbb{Z}. i.e. a=bq+ra=bq+r.

New notion: FSOC\triangle FSOC means For the sake of contradiction.

Notice that r0r \geq 0, by contradiction, suppose rbr \geq b, then rb0r-b \geq 0 and rbSr-b \in S, but rb<rr-b < r, which contradicts the minimality of rr.

Therefore, r0r \geq 0 and r<br < b.

Example: a=31,b=7a=31, b=7, S={317kkZ,317k0}={,32,25,18,11,4,3,10,17,24,31,}S = \{31-7k \mid k \in \mathbb{Z}, 31-7k \geq 0\}=\{\cdots, -32, -25, -18, -11, -4, 3, 10, 17, 24, 31, \cdots\}, r=3r=3.

So We choose q=4q=4 and r=3r=3.

(2) Uniqueness:

Suppose we have two pairs (q,r)(q, r) and (q,r)(q', r') such that a=bq+r=bq+ra = bq + r = bq' + r' Suppose qqq \neq q', without loss of generality, suppose q>qq > q', qq1q-q' \geq 1. Then b(qq)=rrb(q-q') = r'-r.

Since r=b(qq)+rb(qq)br'=b(q-q')+r \geq b(q-q') \geq b, which contradicts that r<br' < b.

Therefore, q=qq=q' and r=rr=r'.

QED

Definition: Divisibility

Let a,bZa, b \in \mathbb{Z}, we say bb divides aa and write bab \mid a if there exists kZk\in \mathbb{Z} such that a=bka = bk.

Example: 3123 \mid 12 because 12=3×412 = 3 \times 4.

Properties of divisibility

Let a,b,cZa, b, c \in \mathbb{Z}.

(1) ba    r=0b \mid a \iff r=0 in the division algorithm.

(2) If aba \mid b and bcb \mid c, then aca \mid c.

(3) If aba \mid b and bab \mid a, then a=±ba = \pm b.

(4) If aba \mid b and aca \mid c, then abx+cya \mid bx + cy for all x,yZx, y \in \mathbb{Z}. (We call such bx+cybx+cy a linear combination of bb and cc.)

(5) If c0c\neq 0 and ab    acbca \mid b \iff ac \mid bc.

Some proof examples:

(2) Since aba \mid b and bcb \mid c, there exist k,lZk, l \in \mathbb{Z} such that b=akb = ak and c=blc = bl. Then c=bl=(ak)l=a(kl)c = bl = (ak)l = a(kl), so aca \mid c.

QED

(3) If aba \mid b and bab \mid a, then there exist k,lZk, l \in \mathbb{Z} such that b=akb = ak and a=bla = bl. Then a=bl=(ak)l=a(kl)a = bl = (ak)l = a(kl), so a(1kl)=0a(1-kl) = 0.

Case 1: a=0a=0, then b=0b=0, so a=ba=b.

Case 2: a0a \neq 0, then 1kl=01-kl=0, so kl=1kl=1. Since k,lZk, l \in \mathbb{Z}, k=l=±1k=l=\pm 1, so a=±ba = \pm b.

QED

Definition: Divisor

Let aZa\in \mathbb{Z}, we define D(a)={dZda}D(a) = \{d\in \mathbb{Z} \mid d \mid a\}.

Note that D(0)=ZD(0) = \mathbb{Z}.

Example: D(12)={±1,±2,±3,±4,±6,±12}D(12) = \{\pm 1, \pm 2, \pm 3, \pm 4, \pm 6, \pm 12\}.

Definition: Greatest common divisor

Let a,bZa, b \in \mathbb{Z}, where a,ba,b not both zero, we define the greatest common divisor of aa and bb to be the largest element in D(a)D(b)D(a) \cap D(b). It is denoted by (a,b)(a,b).

Terrible, I really hate this notation. But professor said it’s unlikely to be confused with the interval (a,b)(a,b) since they don’t show up in the same context usually.

Example:

(12,18)=6(12, 18) = 6.

Note that (0,0)(0,0) is not defined. (there is no largest element in D(0)D(0)D(0) \cap D(0).)

but it is okay that one of a,ba, b is zero. For example, (0,18)=18(0, 18) = 18.

(n,n)=n(n,n) = |n| for all nZn \in \mathbb{Z}.

In general, if (a,b)=0(a,b)=0 we say aa and bb are relatively prime, or coprime.

a,bZ\forall a, b \in \mathbb{Z}, (a,b)1(a,b) \geq 1.

Theorem for calculating gcd

Let a,bZa, b \in \mathbb{Z}, with b0b\neq 0, then for any kZk\in \mathbb{Z}, (a,b)=(b,abk)(a,b) = (b,a-bk).

Example: (12,18)=(18,1218)=(18,6)=6(12, 18) = (18, 12-18) = (18, -6) = 6.

(938,210)=(210,938210×4)=(210,938840)=(210,98)(938,210)=(210,938-210\times 4)=(210,938-840)=(210,98).

Proof:

We will prove that D(a)D(b)=D(b)D(abk)D(a) \cap D(b) = D(b) \cap D(a-bk).

(1) D(a)D(b)D(b)D(abk)D(a) \cap D(b) \subseteq D(b) \cap D(a-bk):

Let dD(a)D(b)d \in D(a) \cap D(b), then dad \mid a and dbd \mid b.

By property of divisibility (4), If aba\mid b and bcb\mid c, then for all x,yZx,y\in \mathbb{Z}, abx+cya\mid bx+cy.

So da+b(k)=abkd\mid a+b\cdot (-k) = a-bk.

Therefore, dD(b)D(abk)d \in D(b) \cap D(a-bk).

(2) D(b)D(abk)D(a)D(b)D(b) \cap D(a-bk) \subseteq D(a) \cap D(b):

Let dD(b)D(abk)d \in D(b) \cap D(a-bk), then dbd \mid b and dabkd \mid a-bk.

By property of divisibility (4), dbk+(abk)=ad \mid bk + (a-bk) = a.

Therefore, dD(a)D(b)d \in D(a) \cap D(b).

QED

This theorem gives rise to the Euclidean algorithm which is a efficient way to compute the greatest common divisor of two integers. 2Θ(logn)+1=O(logn)2\Theta(\log n)+1=O(\log n) (Proof in CSE 442T Lecture 7 ).

Euclidean algorithm

We will skip this part, it’s already the third time we see this algorithm in wustl.

Theorem: Euclidean algorithm returns correct gcd

Let a>b>0a>b>0, be integers. Using the Euclidean algorithm, we can find b>r0>r1>r2>>rnb>r_0>r_1>r_2>\cdots>r_n such that a=bq0+r0,b=r0q1+r1,,rn1=rnqn+1+rn+1,rn=0a=bq_0+r_0, b=r_0q_1+r_1, \cdots, r_{n-1}=r_nq_{n+1}+r_{n+1}, r_n=0. Then (a,b)=rn(a,b)=r_n.

Proof:

(a) This process terminates. b>r0>r1>r2>>rnb>r_0>r_1>r_2>\cdots>r_n is a strictly decreasing sequence of positive integers, so it must terminate.

Last updated on