Week - 6
Lecture 26:
More on RSA
Fast Modular Exponentiation (Square & Multiply)
Goal
Compute:
efficiently
Idea
-
Write exponent in binary:
-
Then:
Key Observation
✔ Compute using repeated squaring
Complexity
- Number of steps:
✔ Much faster than naive ( O(n) )
Algorithm (Concept)
-
Convert ( n ) to binary
-
Initialize result = 1
-
For each bit:
- Square current value
- If bit = 1 → multiply
Side-Channel Attack (Timing Attack)
Problem
-
Computation time depends on:
- Bits of exponent
Idea
-
Attacker measures:
- Execution time
-
Infers:
- Whether bit = 1 or 0
Example Insight
- If extra multiplication occurs → bit = 1
- Leads to key leakage
RSA Key Generation (Practical Issues)
1. Prime Generation
Need:
Naive Method (Inefficient)
- Check divisibility up to:
❌ Too slow for large numbers
Sieve Method
-
Remove multiples:
- 2, 3, 5, ...
✔ Works for small ( n ) ❌ Not practical for large primes
Efficient Approach
- Use probabilistic tests
Example:
- Miller-Rabin test
✔ Fast ✔ High probability of correctness
RSA Security
Based On
-
Public:
-
Secret:
Hard Problem
Why Secure?
- Given:
❌ Hard to compute:
Key Insight
- If attacker finds:
→ Can compute:
→ Then:
→ System breaks
Key Takeaways
-
Square & multiply:
- Efficient exponentiation
-
Timing attacks:
- Real-world vulnerability
-
Prime generation:
- Uses probabilistic tests
-
RSA security:
- Depends on factorization hardness
Final Conclusion
-
RSA efficiency:
-
RSA security:
✔ Still widely used, but requires:
- Large keys
- Secure implementations
Lecture 27:
Primality Testing
Goal
- Check whether a number ( n ) is prime or composite
Fermat Primality Test
Idea (from Fermat’s Little Theorem)
If ( p ) is prime and ( \gcd(a,p)=1 ), then:
Algorithm
-
Choose random:
-
Compute:
-
Check:
-
If:
→ ( n ) is composite ✅
-
If:
→ ( n ) is probably prime
Limitation
-
Some composite numbers pass test
-
Called:
- Fermat pseudoprimes
Miller–Rabin Primality Test
Stronger Test
Step 1: Write
where:
Step 2: Choose Random Base
Step 3: Compute
Step 4: Check Conditions
- If: → probably prime
- Else compute:
Check if any:
→ probably prime
Final Decision
- If none satisfy:
→ ( n ) is composite ✅
Key Property
- If test says composite → always correct
- If says prime → probabilistic
Why Better than Fermat
-
Detects:
- Carmichael numbers
-
Much lower error probability
Key Takeaways
-
Fermat test:
- Fast but weak
-
Miller-Rabin:
- Fast and reliable
-
Used in:
- RSA key generation
Final Conclusion
-
Primality testing is:
-
Practical systems use:
- Miller-Rabin test
✔ Efficient + high confidence for cryptography
Lecture 28:
ElGamal Cryptosystem.
Overview
- Public key cryptosystem based on:
Setup (Bob)
Step 1: Choose Parameters
-
Prime:
-
Generator:
Step 2: Choose Secret Key
Step 3: Compute Public Value
Keys
-
Public key:
-
Private key:
Encryption (Alice)
Input
-
Message:
-
Choose random:
Compute Ciphertext
Ciphertext
Decryption (Bob)
Step 1
Step 2
Why It Works
So:
✔ Correct decryption
Important Property
- Same message → different ciphertexts
✔ Because of random:
Example
Given
Compute
Encryption
Message:
Choose:
Ciphertext
Decryption
✔ Original message recovered
Security
- Based on:
Key Takeaways
-
Uses:
- Modular exponentiation
-
Randomness:
- Provides semantic security
-
Different from RSA:
- Non-deterministic
Final Conclusion
-
ElGamal provides:
- Strong security
- Randomized encryption
Lecture 29:
Elliptic Curve over the Reals
Curve Equation
- Condition:
✔ Ensures no singular points
Point Set
-
Points:
satisfying equation
-
Plus point at infinity:
Point Addition
Let:
Case 1:
Slope:
Coordinates:
Case 2:
- Where:
Case 3: (Point Doubling)
Slope:
Coordinates:
Inverse of Point
Identity Element
- Point at infinity
Group Properties
-
Closure
-
Associativity
-
Identity:
-
Inverse:
-
Commutative:
✔ Forms Abelian group
Key Operation (Scalar Multiplication)
Cryptographic Idea
- Given:
❌ Hard to find:
✔ Elliptic Curve Discrete Log Problem
Key Takeaways
- Points on curve form group
- Addition defined geometrically + algebraically
- Security based on:
Final Conclusion
- Elliptic curves provide:
✔ Widely used in modern cryptography (ECC)
Lecture 30:
Elliptic curve Modulo a Prime
Over ()
Curve
-
Points:
-
Plus:
Finding Points
For each:
Compute:
Check Validity
- Check if is quadratic residue:
✔ If true → valid point exists
Compute ( y )
If:
Then:
- Points:
Example
Given:
Quadratic Residues mod 11
Valid Points
Total Points
(including )
Notes
-
For each valid ( x ):
- Either 0 or 2 points
-
Symmetry:
Key Idea
- Points form group under addition
- Used for: