Skip to Content
CSE442TIntroduction to Cryptography (Lecture 7)

CSE442T Introduction to Cryptography (Lecture 7)

Chapter 2: Computational Hardness

Letter choosing experiment

For 100 letter tiles,

p1,...,p27p_1,...,p_{27} (with one blank)

(p1)2+⋯+(p27)2≥127(p_1)^2+\dots +(p_{27})^2\geq\frac{1}{27}

For any p1,...,pnp_1,...,p_n, 0≤pi≤10\leq p_i\leq 1.

∑pi=1\sum p_i=1

P[the same event twice in a row]=p12+p22....+pn2P[\text{the same event twice in a row}]=p_1^2+p_2^2....+p_n^2

By Cauchy-Schwarz: ∣u⋅v∣2≤∣∣u∣∣⋅∣∣v∣∣2|u\cdot v|^2 \leq ||u||\cdot ||v||^2.

let u⃗=(p1,...,pn)\vec{u}=(p_1,...,p_n), v⃗=(1,..,1)\vec{v}=(1,..,1), so (p12+p22....+pn)2≤(p12+p22....+pn2)⋅n(p_1^2+p_2^2....+p_n)^2\leq (p_1^2+p_2^2....+p_n^2)\cdot n. So p12+p22....+pn2≥1np_1^2+p_2^2....+p_n^2\geq \frac{1}{n}

So for an adversary A\mathcal{A}, who random choose x′x' and output f(x′)=f(x)f(x')=f(x) if matched. P[f(x)=f(x′)]≥1∣Y∣P[f(x)=f(x')]\geq\frac{1}{|Y|}

So P[x←f(x);y=f(x):A(y,1n)=y]≥1∣Y∣P[x\gets f(x);y=f(x):\mathcal{A}(y,1^n)=y]\geq \frac{1}{|Y|}

Modular arithmetic

For a,b∈Za,b\in \mathbb{Z}, N∈Z2N\in \mathbb{Z}^2

a≡bmod  N  ⟺  N∣(a−b)  ⟺  ∃k∈Z,a−b=kN,a=kN+ba\equiv b \mod N\iff N|(a-b)\iff \exists k\in \mathbb{Z}, a-b=kN,a=kN+b

Ex: N=23N=23, −20≡3≡26≡49≡72mod  23-20\equiv 3\equiv 26\equiv 49\equiv 72\mod 23.

Equivalent relations for any NN on Z\mathbb{Z}

a≡amod  Na\equiv a\mod N

a≡bmod  N  ⟺  b≡amod  Na\equiv b\mod N\iff b\equiv a\mod N

a≡bmod  Na\equiv b\mod N and b≡cmod  N  ⟹  a≡cmod  Nb\equiv c\mod N\implies a\equiv c\mod N

Division Theorem

For any a∈Za\in \mathbb{Z}, and N∈Z+N\in\mathbb{Z}^+, ∃unique r,0≤r<N\exists unique\ r,0\leq r<N.

ZN={0,1,2,...,N−1}\mathbb{Z}_N=\{0,1,2,...,N-1\} with modular arithmetic.

a+bmod  N,a⋅bmod  Na+b\mod N,a\cdot b\mod N

Theorem: If a≡bmod  Na\equiv b\mod N andc≡dmod  Nc\equiv d\mod N, then a⋅c≡b⋅dmod  Na\cdot c\equiv b\cdot d\mod N.

Definition: gcd(a,b)=d,a,b∈Z+gcd(a,b)=d,a,b\in \mathbb{Z}^+, is the maximum number such that d∣ad|a and d∣bd|b.

Using normal factoring is slow… (Example: large p,q,rp,q,r, N=p⋅q,,M=p⋅rN=p\cdot q,,M=p\cdot r)

Euclidean algorithm

Recursively relying on fact that (a>b>0)(a>b>0)

gcd(a,b)=gcd(b,amod  b)gcd(a,b)=gcd(b,a\mod b)

def euclidean_algorithm(a,b): if a<b: return euclidean_algorithm(b,a) if b==0: return a return euclidean_algorithm(b,a%b)

Proof:

We’ll show d∣ad|a and d∣b  ⟺  d∣bd|b\iff d|b and d∣(amod  b)d|(a\mod b)

  ⟸  \impliedby a=q⋅b+ra=q\cdot b+r, r=amod  br=a\mod b

  ⟹  \implies d∣rd|r, r=amod  br=a\mod b

Runtime analysis:

Fact: bi+2<12bib_{i+2}<\frac{1}{2}b_i

Proof:

Since ai=qi⋅bi+bi+1a_i=q_i\cdot b_i+b_{i+1}, and b1=q2⋅b2+b3b_1=q_2\cdot b_2+b_3, b2>b3b_2>b_3, and q2q_2 in worst case is 11, so b3<b12b_3<\frac{b_1}{2}

T(n)=2Θ(log⁡b)=O(log⁡n)T(n)=2\Theta(\log b)=O(\log n) (linear in size of bits input)

Extended Euclidean algorithm

Our goal is to find x,yx,y such that ax+by=gcd(a,b)ax+by=gcd(a,b)

Given a⋅x≡bmod  Na\cdot x\equiv b\mod N, we do euclidean algorithm to find gcd(a,b)=dgcd(a,b)=d, then reverse the steps to find x,yx,y such that ax+by=dax+by=d

def extended_euclidean_algorithm(a,b): if a%b==0: return (0,1) x,y=extended_euclidean_algorithm(b,a%b) return (y,x-y*(a//b))

Example: a=12,b=43a=12,b=43, gcd(12,43)=1gcd(12,43)=1

43=3⋅12+712=1⋅7+57=1⋅5+25=2⋅2+12=2⋅1+01=1⋅5−2⋅21=1⋅5−2⋅(7−1⋅5)1=3⋅5−2⋅71=3⋅(12−1⋅7)−2⋅71=3⋅12−5⋅71=3⋅12−5⋅(43−3⋅12)1=−5⋅43+18⋅12\begin{aligned} 43&=3\cdot 12+7\\ 12&=1\cdot 7+5\\ 7&=1\cdot 5+2\\ 5&=2\cdot 2+1\\ 2&=2\cdot 1+0\\ 1&=1\cdot 5-2\cdot 2\\ 1&=1\cdot 5-2\cdot (7-1\cdot 5)\\ 1&=3\cdot 5-2\cdot 7\\ 1&=3\cdot (12-1\cdot 7)-2\cdot 7\\ 1&=3\cdot 12-5\cdot 7\\ 1&=3\cdot 12-5\cdot (43-3\cdot 12)\\ 1&=-5\cdot 43+18\cdot 12\\ \end{aligned}

So x=−5,y=18x=-5,y=18

Last updated on