Discrete Logarithms and RSA Cryptosystem
Discrete Logarithms
Discrete Logarithm is defined as: Given a prime number p, a generator g, and a value y, find x such that gxmodp=y.
- It is the inverse of modular exponentiation
- Computing discrete logarithms is computationally hard, which forms the basis of many asymmetric cryptosystems (like Diffie-Hellman, ElGamal)
- Example: If 3xmod7=6, then the discrete logarithm x=3
RSA Key Generation, Encryption and Decryption
A. Key Generation
- Step a: Choose two large prime numbers p and q
- Step b: Compute n=p×q
- Step c: Compute Euler's totient function ϕ(n)=(p−1)(q−1)
- Step d: Choose public exponent e such that 1<e<ϕ(n) and gcd(e,ϕ(n))=1
- Step e: Compute private exponent d such that e⋅d≡1modϕ(n)
- Public Key = (e,n)
- Private Key = (d,n)
B. Encryption
Ciphertext: C=Memodn
C. Decryption
Plaintext: M=Cdmodn
Numerical Solution: p = 13, q = 7, M = 'hi'
Step a: Compute n
n=p×q=13×7=91
Step b: Compute ϕ(n)
ϕ(n)=(p−1)(q−1)=12×6=72
Step c: Choose e
Choose e such that gcd(e,72)=1 and 1<e<72
Let e=5 (since $\gcd(5, 72) = 1$)
Step d: Compute d
Find d such that e⋅d≡1mod72
5⋅d≡1mod72
d=29(since 5×29=145=2×72+1≡1mod72)
Keys:
- Public Key = (e,n) = (5,91)
- Private Key = (d,n) = (29,91)
Step e: Convert plaintext M = 'hi' to numbers (a=0, b=1, ..., z=25)
Step f: Encryption (C=Memodn)
For h (M = 7):
C1=75mod91
72=49
74=492=2401mod91=2401−26×91=2401−2366=35
75=74×7=35×7=245mod91=245−2×91=63
C1=63
For i (M = 8):
C2=85mod91
82=64
84=642=4096mod91=4096−45×91=4096−4095=1
85=84×8=1×8=8
C2=8
Ciphertext = (63, 8)
Step g: Decryption (M=Cdmodn)
For C1=63:
M1=6329mod91
63mod91=63
632=3969mod91=3969−43×91=3969−3913=56
634=562=3136mod91=3136−34×91=3136−3094=42
638=422=1764mod91=1764−19×91=1764−1729=35
6316=352=1225mod91=1225−13×91=1225−1183=42
6329=6316×638×634×631=42×35×42×63mod91
42×35=1470mod91=1470−16×91=1470−1456=14
14×42=588mod91=588−6×91=588−546=42
42×63=2646mod91=2646−29×91=2646−2639=7
M1=7=h
For C2=8:
M2=829mod91
84mod91=1 (calculated above)
$8^{29} = 8^{28} \times 8^1 = (8^4)^7 \times 8 = 1^7 \times 8 = 8$
M2=8=i
Conclusion
Decrypted message = 'hi', which matches the original plaintext, confirming that RSA encryption and decryption work correctly with the generated keys.