Skip to Content
CSE442TIntroduction to Cryptography (Lecture 8)

CSE442T Introduction to Cryptography (Lecture 8)

Chapter 2: Computational Hardness

Computational number theory/arithmetic

We want to have a easy-to-use one-way functions for cryptography.

How to find axmodNa^x\mod N quickly. a,x,Na,x,N are positive integers. We want to reduce [amodN][a\mod N]

Example: 12939mod41(129mod41)39mod41=639mod41129^{39}\mod 41\equiv (129\mod 41)^{39}\mod 41=6^{39}\mod 41

Find the binary representation of xx. e.g. express as sums of powers of 2.

x=39=bin(1,0,0,1,1,1)

Repeatedly square floor(log2(x))floor(\log_2(x)) times.

639mod41=632+4+2+1mod41=(632mod41)(64mod41)(62mod41)(61mod41)mod41=(4)(25)(5)(6)mod41=7\begin{aligned} 6^{39}\mod 41&=6^{32+4+2+1}\mod 41\\ &=(6^{32}\mod 41)(6^{4}\mod 41)(6^{2}\mod 41)(6^{1}\mod 41)\mod 41\\ &=(-4)(25)(-5)(6)\mod 41\\ &=7 \end{aligned}

The total multiplication steps is floor(log2(x))floor(\log_2(x))

looks like fast exponentiation right?

Goal: fg,p(x)=gxmodpf_{g,p}(x)=g^x\mod p is a one-way function, for certain choice of p,gp,g (and assumptions)

A group (Nice day one for MODERN ALGEBRA)

A group GG is a set with, a binary operation \oplus. and a,bG\forall a,b\in G, abca \oplus b\to c

  1. a,bG,abGa,b\in G,a\oplus b\in G (closure)
  2. (ab)c=a(bc)(a\oplus b)\oplus c=a\oplus(b\oplus c) (associativity)
  3. e\exists e such that aG,eg=g=ge\forall a\in G, e\oplus g=g=g\oplus e (identity element)
  4. g1G\exists g^{-1}\in G such that gg1=eg\oplus g^{-1}=e (inverse element)

Example:

  • ZN={0,1,2,3,...,N1}\mathbb{Z}_N=\{0,1,2,3,...,N-1\} with addition modN\mod N, with identity element 00. aZN,a1=Naa\in \mathbb{Z}_N, a^{-1}=N-a.
  • A even simpler group is Z\Z with addition.
  • ZN={x:xZ,1xN:gcd(x,N)=1}\mathbb{Z}_N^*=\{x:x\in \mathbb{Z},1 \leq x\leq N: gcd(x,N)=1\} with multiplication modN\mod N (we can do division here! yeah…).
    • If N=pN=p is prime, then Zp={1,2,3,...,p1}\mathbb{Z}_p^*=\{1,2,3,...,p-1\}
    • If N=24N=24, then Z24={1,5,7,11,13,17,19,23}\mathbb{Z}_{24}^*=\{1,5,7,11,13,17,19,23\}
      • Identity is 11.
      • Let aZNa\in \mathbb{Z}_N^*, by Euclidean algorithm, gcd(a,N)=1gcd(a,N)=1,x,yZ\exists x,y \in Z such that ax+Ny=1,ax1modN,x=a1ax+Ny=1,ax\equiv 1\mod N,x=a^{-1}
      • a,bZNa,b\in \mathbb{Z}_N^*. Want to show gcd(ab,N)=1gcd(ab,N)=1. If gcd(ab,N)=d>1gcd(ab,N)=d>1, then some prime pdp|d. so p(a,b)p|(a,b), which means pap|a or pbp|b. In either case, gcd(a,N)>dgcd(a,N)>d or gcd(b,N)>dgcd(b,N)>d, which contradicts that a,bCNa,b\in \mathbb{C}_N^*

Euler’s totient function

ϕ:Z+Z+,ϕ(N)=ZN={1xN:gcd(x,N)=1}\phi:\mathbb{Z}^+\to \mathbb{Z}^+,\phi(N)=|\mathbb{Z}_N^*|=|\{1\leq x\leq N:gcd(x,N)=1\}|

Example: ϕ(1)=1\phi(1)=1, ϕ(24)=8\phi(24)=8, ϕ(p)=p1\phi (p)=p-1, ϕ(pq)=(p1)(q1)\phi(p\cdot q)=(p-1)(q-1)

Euler’s Theorem

For any aZNa\in \mathbb{Z}_N^*, aϕ(N)1modNa^{\phi(N)}\equiv 1\mod N

Consequence: axmodNa^x\mod N, x=Kϕ(N)+r,0rϕ(N)x=K\cdot \phi(N)+r,0\leq r\leq \phi(N)

a^x\equiv a^{K \cdot \phi (N) +r}\equiv ( a^{\phi(n)} )^K \cdot a^r \mod N$

So computing axmodNa^x\mod N is polynomial in log(N)\log (N) by reducing amodNa\mod N and xmodϕ(N)<Nx\mod \phi(N)<N

Corollary: Fermat’s little theorem:

1ap1,ap11modp1\leq a\leq p-1,a^{p-1}\equiv 1 \mod p

Last updated on