Number Theory and RSA
253 words
1 min read
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
a≡b(modn) means n∣(a−b).
Key properties:
- a≡b(modn) and c≡d(modn)⟹ac≡bd(modn)
- a≡b(modn)⟹ak≡bk(modn)
8.2 Euler's Theorem
ϕ(n)=np∣n∏(1−p1)For p prime: ϕ(p)=p−1. For n=pq (product of two primes): ϕ(n)=(p−1)(q−1).
Euler's Theorem: If gcd(a,n)=1, then aϕ(n)≡1(modn).
8.3 RSA Algorithm
Key generation:
- Choose large primes p,q
- Compute n=pq, ϕ(n)=(p−1)(q−1)
- Choose e with gcd(e,ϕ(n))=1
- Compute d=e−1(modϕ(n))
- Public key: (n,e), Private key: (n,d) Encryption: c=me(modn) Decryption: m=cd(modn) Why it works: cd≡(me)d≡med≡m1+kϕ(n)≡m⋅(mϕ(n))k≡m(modn)
✅ Practice Questions
Q1: For p=5,q=11, find n, ϕ(n), and choose e.
Solutionn=5×11=55, ϕ(55)=4×10=40. Choose e=3 (coprime with 40). d=3−1(mod40)=27 since 3×27=81≡1(mod40). Q2: Encrypt m=7 using the above keys. Solutionc=73(mod55)=343(mod55)=343−6×55=343−330=13. Join Discord PreviousGraph AlgorithmsNextBoolean Algebra