Quiz 2

Number Theory and RSA

253 words
1 min read
Python Week 1: the first filter for runtime behavior
Visual companion
Python
Type and operator map

Python Week 1: the first filter for runtime behavior

View
Revision summary

What this note is really saying

Short form

# Number Theory and RSA ## 8.1 Modular Arithmetic Review $a \equiv b \pmod{n}$ means $n \mid (a-b)$. **Key properties:** - $a \equiv b \pmod{n}$ and $c \equiv d \pmod{n} \implies ac \equiv bd \pmod{n}$ - $a \equiv b \pmod{n} \implies a^k \equiv b^k \pmod{n}$ ## 8.2 Euler's Theorem $$ \phi(n) = n \prod_{p \mid n} \le...

Number Theory and RSA

8.1 Modular Arithmetic Review

ab(modn)a \equiv b \pmod{n} means n(ab)n \mid (a-b). Key properties:
  • ab(modn)a \equiv b \pmod{n} and cd(modn)    acbd(modn)c \equiv d \pmod{n} \implies ac \equiv bd \pmod{n}
  • ab(modn)    akbk(modn)a \equiv b \pmod{n} \implies a^k \equiv b^k \pmod{n}

8.2 Euler's Theorem

ϕ(n)=npn(11p)\phi(n) = n \prod_{p \mid n} \left(1 - \frac{1}{p}\right)
For pp prime: ϕ(p)=p1\phi(p) = p-1. For n=pqn = pq (product of two primes): ϕ(n)=(p1)(q1)\phi(n) = (p-1)(q-1). Euler's Theorem: If gcd(a,n)=1\gcd(a, n) = 1, then aϕ(n)1(modn)a^{\phi(n)} \equiv 1 \pmod{n}.

8.3 RSA Algorithm

Key generation:
  1. Choose large primes p,qp, q
  2. Compute n=pqn = pq, ϕ(n)=(p1)(q1)\phi(n) = (p-1)(q-1)
  3. Choose ee with gcd(e,ϕ(n))=1\gcd(e, \phi(n)) = 1
  4. Compute d=e1(modϕ(n))d = e^{-1} \pmod{\phi(n)}
  5. Public key: (n,e)(n, e), Private key: (n,d)(n, d) Encryption: c=me(modn)c = m^e \pmod{n} Decryption: m=cd(modn)m = c^d \pmod{n} Why it works: cd(me)dmedm1+kϕ(n)m(mϕ(n))km(modn)c^d \equiv (m^e)^d \equiv m^{ed} \equiv m^{1 + k\phi(n)} \equiv m \cdot (m^{\phi(n)})^k \equiv m \pmod{n}

✅ Practice Questions

Q1: For p=5,q=11p=5, q=11, find nn, ϕ(n)\phi(n), and choose ee.
Solution
n=5×11=55n = 5 \times 11 = 55, ϕ(55)=4×10=40\phi(55) = 4 \times 10 = 40. Choose e=3e = 3 (coprime with 40). d=31(mod40)=27d = 3^{-1} \pmod{40} = 27 since 3×27=811(mod40)3 \times 27 = 81 \equiv 1 \pmod{40}. Q2: Encrypt m=7m=7 using the above keys. Solution
c=73(mod55)=343(mod55)=3436×55=343330=13c = 7^3 \pmod{55} = 343 \pmod{55} = 343 - 6 \times 55 = 343 - 330 = 13. Join Discord PreviousGraph AlgorithmsNextBoolean Algebra
Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.