Skip to Content
CSE442TIntroduction to Cryptography (Lecture 9)

CSE442T Introduction to Cryptography (Lecture 9)

Chapter 2: Computational Hardness

Continue on Cyclic groups

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

Remind that ϕ(p),pΠ,ϕ(p)=p1\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 532mod15^{32}\mod 1

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

5662mod51=107662mod32mod51=522mod51=5165452mod51=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 aZNa\in \mathbb{Z}_N^*, the order of aa, o(a)o(a) is the smallest positive kk such that ak1modNa^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

gG=eg^{|G|}=e (identity)

o(g)Go(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)=Go(a)=|G|, then a is a generator of GG.

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

Zp=p1|\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:ZpZpf:\mathbb{Z}_p^*\to \mathbb{Z}_p^*, f(x)=gxmodpf(x)=g^x \mod p is onto.

What type of prime pp?

  • Large prime.
  • If p1p-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,pZp\{g^2,...g^{2q}\}S_{g,p}\subseteq \mathbb{Z}_p^* is a subgroup; g2kg2l=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 aZpa\in \mathbb{Z}_p^*
  • Let x=a2x=a^2. If x1x\neq 1, it is a generator of subgroup SpS_p
    • Sp={x,x2,...,xq}modpS_p=\{x,x^2,...,x^q\}\mod p

Example: p=211+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=p12Πn1}\tilde{\Pi}_n=\{p\in \Pi_n:q=\frac{p-1}{2}\in \Pi_{n-1}\}

Then

P[pΠn~;aZp;g=a21;xZq;y=gxmodp: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~;aZp;g=a21p\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:ZqZpf:\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