Skip to Content
CSE442TIntroduction to Cryptography (Lecture 9)

CSE442T Introduction to Cryptography (Lecture 9)

Chapter 2: Computational Hardness

Continue on Cyclic groups

107662mod  51=(107mod  51)662mod  51=5662mod  51\begin{aligned} 107^{662}\mod 51&=(107\mod 51)^{662}\mod 51\\ &=5^{662}\mod 51 \end{aligned}

Remind that ϕ(p),p∈Π,ϕ(p)=p−1\phi(p),p\in\Pi,\phi(p)=p-1.

51=3×17,ϕ(51)=ϕ(3)×ϕ(17)=2×16=3251=3\times 17,\phi(51)=\phi(3)\times \phi(17)=2\times 16=32, So 532mod  15^{32}\mod 1

52≡25mod  51=255^2\equiv 25\mod 51=25
54≡(52)2≡(25)2mod  51≡625mod  51=135^4\equiv (5^2)^2\equiv(25)^2 \mod 51\equiv 625\mod 51=13
58≡(54)2≡(13)2mod  51≡169mod  51=165^8\equiv (5^4)^2\equiv(13)^2 \mod 51\equiv 169\mod 51=16
516≡(58)2≡(16)2mod  51≡256mod  51=15^16\equiv (5^8)^2\equiv(16)^2 \mod 51\equiv 256\mod 51=1

5662mod  51=107662mod  32mod  51=522mod  51=516⋅54⋅52mod  51=19\begin{aligned} 5^{662}\mod 51&=107^{662\mod 32}\mod 51\\ &=5^{22}\mod 51\\ &=5^{16}\cdot 5^4\cdot 5^2\mod 51\\ &=19 \end{aligned}

For a∈ZN∗a\in \mathbb{Z}_N^*, the order of aa, o(a)o(a) is the smallest positive kk such that ak≡1mod  Na^k\equiv 1\mod N. o(a)≤ϕ(N),o(a)∣ϕ(N)o(a)\leq \phi(N),o(a)|\phi (N)

In a general finite group

g∣G∣=eg^{|G|}=e (identity)

o(g)∣∣G∣o(g)\vert |G|

If a group G={a,a2,a3,...,e}G=\{a,a^2,a^3,...,e\} GG is cyclic

In a cyclic group, if o(a)=∣G∣o(a)=|G|, then a is a generator of GG.

Fact: Zp∗\mathbb{Z}^*_p is cyclic

∣Zp∗∣=p−1|\mathbb{Z}^*_p|=p-1, so ∃\exists generator gg, and Z\mathbb{Z}, ϕ(Z13∗)=12\phi(\mathbb{Z}_{13}^*)=12

For example, 22 is a generator for Z13∗\mathbb{Z}_{13}^* with 2,4,8,3,6,12,11,9,5,10,7,12,4,8,3,6,12,11,9,5,10,7,1.

If gg is a generator, f:Zp∗→Zp∗f:\mathbb{Z}_p^*\to \mathbb{Z}_p^*, f(x)=gxmod  pf(x)=g^x \mod p is onto.

What type of prime pp?

  • Large prime.
  • If p−1p-1 is very factorable, that is very bad.
    • Pohlig-Hellman algorithm
    • p=2n+1p=2^n+1 only need polynomial time to invert
  • We want p=2q+1p=2q+1, where qq is prime. (Sophie Germain primes, or safe primes)

There are probably infinitely many safe prime and efficient to sample as well.

If pp is safe, gg generator.

Zp∗={g,g2,..,e}\mathbb{Z}_p^*=\{g,g^2,..,e\}

Then {g2,...g2q}Sg,p⊆Zp∗\{g^2,...g^{2q}\}S_{g,p}\subseteq \mathbb{Z}_p^* is a subgroup; g2k⋅g2l=g2(k+l)∈Sg,pg^{2k}\cdot g^{2l}=g^{2(k+l)}\in S_{g,p}

It is cyclic with generator g2g^2.

It is easy to find a generator.

  • Pick a∈Zp∗a\in \mathbb{Z}_p^*
  • Let x=a2x=a^2. If x≠1x\neq 1, it is a generator of subgroup SpS_p
    • Sp={x,x2,...,xq}mod  pS_p=\{x,x^2,...,x^q\}\mod p

Example: p=2⋅11+1=23p=2\cdot 11+1=23

we have a subgroup with generator 44 and S4={4,16,18,3,12,2,8,9,13,6,1}S_4=\{4,16,18,3,12,2,8,9,13,6,1\}

def get_generator(p): """ p should be a prime, or you need to do factorization """ g=[] for i in range(2,p-1): k=i sg=[] step=p while k!=1 and step>0: if k==0: raise ValueError(f"Damn, {i} generates 0 for group {p}") sg.append(k) k=(k*i)%p step-=1 sg.append(1) # if len(sg)!=(p-1): continue g.append((i,[j for j in sg])) return g

(Computational) Diffie-Hellman assumption

If pp is a randomly sampled safe prime.

Denote safe prime as Π~n={p∈Πn:q=p−12∈Πn−1}\tilde{\Pi}_n=\{p\in \Pi_n:q=\frac{p-1}{2}\in \Pi_{n-1}\}

Then

P[p←Πn~;a←Zp∗;g=a2≠1;x←Zq;y=gxmod  p:A(y)=x]≤ϵ(n)P\left[p\gets \tilde{\Pi_n};a\gets\mathbb{Z}_p^*;g=a^2\neq 1;x\gets \mathbb{Z}_q;y=g^x\mod p:\mathcal{A}(y)=x\right]\leq \epsilon(n)

p←Πn~;a←Zp∗;g=a2≠1p\gets \tilde{\Pi_n};a\gets\mathbb{Z}_p^*;g=a^2\neq 1 is the function condition when we do the encryption on cyclic groups.

Notes: f:Zq→Zp∗f:\Z_q\to \mathbb{Z}_p^* is one-to-one, so f(A(y))  ⟺  A(y)=xf(\mathcal{A}(y))\iff \mathcal{A}(y)=x

Last updated on