Docsity

Cryptography Math Problems with Worked Solutions, Exams of Cryptography and System Security

Toggle sidebar
bg1
WORKED-OUT CRYPTOGRAPHY MATH
QUESTIONS
1. RSA Key Generation
Given: p=61p=61p=61, q=53q=53q=53, e=17e=17e=17
Find: n,ϕ(n),dn, \phi(n), dn,ϕ(n),d
Solution:
n=61×53=3233n = 61 \times 53 = 3233n=61×53=3233
ϕ(n)=(61−1)(53−1)=60×52=3120\phi(n) = (61-1)(53-1) = 60 \times 52 =
3120ϕ(n)=(61−1)(53−1)=60×52=3120
Find ddd such that 17d≡1(mod3120)17d \equiv 1 \
pmod{3120}17d≡1(mod3120). Using Extended Euclidean Algorithm,
d=2753d = 2753d=2753.
2. RSA Encryption
Encrypt: M=65M=65M=65 with e=17e=17e=17,
n=3233n=3233n=3233
Solution:
Calculate C=6517 mod 3233C = 65^{17} \bmod 3233C=6517mod3233
by repeated squaring:
Result: C=454C = 454C=454.
3. RSA Decryption
Decrypt: C=454C=454C=454 with d=2753d=2753d=2753,
n=3233n=3233n=3233
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download Cryptography Math Problems with Worked Solutions and more Exams Cryptography and System Security in PDF only on Docsity!

WORKED-OUT CRYPTOGRAPHY MATH

QUESTIONS

1. RSA Key Generation Given: p=61p=61p=61, q=53q=53q=53, e=17e=17e= Find: n,ϕ(n),dn, \phi(n), dn,ϕ(n),d Solution: n=61×53=3233n = 61 \times 53 = 3233n=61×53= ϕ(n)=(61−1)(53−1)=60×52=3120\phi(n) = (61-1)(53-1) = 60 \times 52 = 3120ϕ(n)=(61−1)(53−1)=60×52= Find ddd such that 17d≡1(mod3120)17d \equiv 1
pmod{3120}17d≡1(mod3120). Using Extended Euclidean Algorithm, d=2753d = 2753d=2753. 2. RSA Encryption Encrypt: M=65M=65M=65 with e=17e=17e=17, n=3233n=3233n= Solution: Calculate C=6517 mod 3233C = 65^{17} \bmod 3233C=6517mod by repeated squaring: Result: C=454C = 454C=454. 3. RSA Decryption Decrypt: C=454C=454C=454 with d=2753d=2753d=2753, n=3233n=3233n=

Solution: Compute M=4542753 mod 3233=65M = 454^{2753} \bmod 3233 = 65M=4542753mod3233=65.

4. Modular Inverse Find: inverse of 3 modulo 11 Solution: 3×4=12≡1(mod11)3 \times 4 = 12 \equiv 1
pmod{11}3×4=12≡1(mod11), so inverse is 4. 5. Discrete Logarithm Find: xxx such that 5x≡8(mod23)5^x \equiv 8 \pmod{23}5x≡8(mod23) Solution: Calculate powers of 5 modulo 23: 56=85^6 = 856=8, so x=6x=6x=6. 6. Compute ϕ(35)\phi(35)ϕ(35) Solution: 35=5×735 = 5 \times 735=5× ϕ(35)=(5−1)(7−1)=4×6=24\phi(35) = (5-1)(7-1) = 4 \times 6 = 24ϕ(35)=(5−1)(7−1)=4×6=24. 7. Find 7100 mod 137^{100} \bmod 137100mod Solution: By Fermat's theorem 712≡1 mod 137^{12} \equiv 1 \bmod 13712≡1mod13. 100 mod 12=4100 \bmod 12 = 4100mod12=4. So 7100≡74=2401≡2401−184×13=2401−2392=9 mod 137^{100} \equiv

31=33^1=331=3, 32=23^2=232=2, 33=63^3=633=6, 34=43^4=434=4,

35=53^5=535=5, 36=13^6=136=1 mod 7. All residues appear before 1, so g=3g=3g=3 is primitive root.

12. Compute 413 mod 4974^{13} \bmod 497413mod Solution: Use repeated squaring: 41=44^1=441= 42=164^2=1642= 44=162=2564^4=16^2=25644=162= 48=2562=65536≡65536−131×497=65536−65007=529 mod 497≡324^8=256^2 = 65536 \equiv 65536 - 131 \times 497 = 65536 - 65007 = 529 \bmod 497 \equiv 3248=2562=65536≡65536−131×497=65536−65007=529mod497≡ Now, 413=48×44×41=32×256×44^{13} = 4^{8} \times 4^{4} \times 4^{1} = 32 \times 256 \times 4413=48×44×41=32×256×4. Calculate stepwise modulo 497: 32×256=8192≡8192−16×497=8192−7952=24032 \times 256 = 8192
equiv 8192 - 16 \times 497 = 8192 - 7952 = 24032×256=8192≡8192−16×497=8192−7952=240. 240×4=960≡960−1×497=463240 \times 4 = 960 \equiv 960 - 1 \times 497 = 463240×4=960≡960−1×497=463. Answer: 463463463. 13. Find ddd given e=7e=7e=7, ϕ(n)=40\phi(n) = 40ϕ(n)= Solution: Solve 7d≡1(mod40)7d \equiv 1 \pmod{40}7d≡1(mod40). Try multiples of 7: 7×23=161≡1(mod40)7 \times 23 = 161 \equiv 1
pmod{40}7×23=161≡1(mod40). So d=23d=23d=23.

14. Compute 220 mod 172^{20} \bmod 17220mod Solution: 28=256≡1(mod17)2^8 = 256 \equiv 1 \pmod{17}28=256≡1(mod17) (since 28=2562^8 = 25628=256, 256mod 17=1256 \mod 17 = 1256mod17=1) 220=28×2+4=(28)2×24=12×16=16(mod17)2^{20} = 2^{8 \times 2 + 4} = (2^8)^2 \times 2^4 = 1^2 \times 16 = 16
pmod{17}220=28×2+4=(28)2×24=12×16=16(mod17). 15. Compute discrete log: 3x≡13(mod17)3^x \equiv 13
pmod{17}3x≡13(mod17) Solution:
Calculate powers of 3 mod 17: 31=33^1=331=3, 32=93^2=932=9, 33=103^3=1033=10, 34=133^4=1334=13. So x=4x=4x=4. 16. Compute gcd(252,105)\text{gcd}(252, 105)gcd(252,105) Solution: 252 = 105×2 + 42 105 = 42×2 + 21 42 = 21×2 + 0 GCD = 21. 17. Calculate 11−1 mod 2611^{-1} \bmod 2611−1mod Solution: Find xxx so that 11x≡1(mod26)11x \equiv 1 \pmod{26}11x≡1(mod26). Try multiples of 11: 11×19=209≡1(mod26)11 \times 19 = 209 \equiv 1
pmod{26}11×19=209≡1(mod26). So inverse is 19.

21. Compute ϕ(221)\phi(221)ϕ(221) Solution: 221=13×17221 = 13 \times 17221=13× ϕ(221)=(13−1)(17−1)=12×16=192\phi(221) = (13-1)(17-1)=12 \times 16 = 192ϕ(221)=(13−1)(17−1)=12×16=192. 22. Find ddd such that 3d≡1(mod40)3d \equiv 1
pmod{40}3d≡1(mod40) Solution:
Try multiples: 3×27=81≡1(mod40)3 \times 27 = 81 \equiv 1
pmod{40}3×27=81≡1(mod40). So d=27d=27d=27. 23. Find the order of 2 modulo 7 Solution: Calculate powers: 21=22^1=221=2, 22=42^2=422=4, 23=8≡12^3=8 \equiv 123=8≡1. Order = 3. 24. Compute 645 mod 476^{45} \bmod 47645mod Solution: Since 646≡1(mod47)6^{46} \equiv 1 \pmod{47}646≡1(mod47), 645≡6−1(mod47)6^{45} \equiv 6^{-1} \pmod{47}645≡6−1(mod47). Find inverse of 6 mod 47: 6×8=48≡1(mod47)6 \times 8 = 48 \equiv 1
pmod{47}6×8=48≡1(mod47). So answer is 8. 25. Compute 1050 mod 2310^{50} \bmod 231050mod

Solution: 1011≡1(mod23)10^{11} \equiv 1 \pmod{23}1011≡1(mod23) (since 23 is prime and order divides 22) 50 mod 11=650 \bmod 11 = 650mod11=6, Calculate 106 mod 2310^6 \bmod 23106mod23: 102=100≡810^2=100 \equiv 8102=100≡8, 104=82=64≡1810^4=8^2=64 \equiv 18104=82=64≡18, 106=104×102=18×8=144≡610^6=10^4 \times 10^2=18 \times 8=144
equiv 6106=104×102=18×8=144≡6. Answer: 6.

26. Compute gcd(462,1071)\text{gcd}(462, 1071)gcd(462,1071) Solution: 1071 = 462×2 + 147 462 = 147×3 + 21 147 = 21×7 + 0 GCD = 21. 27. Calculate 3−1 mod 113^{-1} \bmod 113−1mod Solution: 3×4=12≡1(mod11)3 \times 4 = 12 \equiv 1
pmod{11}3×4=12≡1(mod11) Inverse = 4. 28. Solve for xxx in 7x≡13(mod17)7^x \equiv 13
pmod{17}7x≡13(mod17) Solution:
Calculate powers: 71=77^1=771=7, 72=157^2=1572=15, 73=37^3=373=3,

31. Calculate gcd(12345,54321)\text{gcd}(12345, 54321)gcd(12345,54321) Solution: Apply Euclid’s algorithm: 54321 = 12345×4 + 4941 12345 = 4941×2 + 2463 4941 = 2463×2 + 15 2463 = 15×164 + 3 15 = 3×5 + 0 GCD = 3. 32. Find modular inverse of 17 mod 3120 Solution: From Q1, d=2753d=2753d=2753, inverse of 17 mod 3120 is 2753. 33. Compute 21000 mod 132^{1000} \bmod 1321000mod Solution: 212≡1(mod13)2^{12} \equiv 1 \pmod{13}212≡1(mod13), 1000 mod 12=41000 \bmod 12 = 41000mod12=4, So 21000≡24=16≡32^{1000} \equiv 2^4 = 16 \equiv 321000≡24=16≡3. 34. Find order of 5 modulo 23 Solution: Check powers: 511=1(mod23)5^{11} = 1 \pmod{23}511=1(mod23) (calculated in Q18), so order divides 11. Check smaller powers; 11 is prime, so order is 11.

35. Calculate 1337 mod 1913^{37} \bmod 191337mod Solution: 1318≡113^{18} \equiv 11318≡1, 37 mod 18=137 \bmod 18 = 137mod18=1, So 1337≡1313^{37} \equiv 131337≡13. 36. Find xxx such that 2x≡15(mod17)2^x \equiv 15
pmod{17}2x≡15(mod17) Solution:
Calculate powers: 21=22^1=221=2, 22=42^2=422=4, 23=82^3=823=8, 24=162^4=1624=16, 25=152^5=1525=15, so x=5x=5x=5. 37. Compute 9−1 mod 289^{-1} \bmod 289−1mod Solution: Find xxx such that 9x≡1(mod28)9x \equiv 1 \pmod{28}9x≡1(mod28). Try: 9×31=279≡279−10×28=279−280=−1≡279 \times 31 = 279 \equiv 279 - 10 \times 28 = 279 - 280 = -1 \equiv 279×31=279≡279−10×28=279−280=−1≡ Try 9×25=225≡225−8×28=225−224=19 \times 25 = 225 \equiv 225 - 8
times 28 = 225 - 224 = 19×25=225≡225−8×28=225−224=1. So inverse = 25. 38. Calculate 4123 mod 294^{123} \bmod 294123mod

Solution: 316≡13^{16} \equiv 1316≡1, 101 mod 16=5101 \bmod 16 = 5101mod16=5, 35=34×3=13×3=22≡53^5 = 3^4 \times 3 = 13 \times 3 = 22 \equiv 535=34×3=13×3=22≡5. Answer: 5.