Skip to content
doubtly

User A and B decide  to use Diffie-Hellman algorithm to share a key. 

What is need of Diffie-Hellman algorithm. User A and B decide  to use Diffie-Hellman algorithm to share a key.  They choose p = 23 and g = 5 as the public parameters.  Their secret keys are 6 and 15 respectively. Compute the secret key that they share.

Doubtly Asked Updated css ai-ds Save WhatsApp Report
  • […] b. What is need of Diffie-Hellman algorithm. User A and B decide to use Diffie-Hellman algorithm … […] – CSS Question Paper solution Dec 2023 - Doubtly ·
  • […] b. What is need of Diffie-Hellman algorithm. User A and B decide to use Diffie-Hellman algorithm … […] – CSS Question Paper solution Dec 2023 - Part 2 - Doubtly ·
  • Solutions please – ROHITH H. ·
Sign in to comment

2 answers

Answer to :

What is need of Diffie-Hellman algorithm. User A and B decide  to use Diffie-Hellman algorithm to share a key.  They choose p = 23 and g = 5 as the public parameters.  Their secret keys are 6 and 15 respectively. Compute the secret key that they share.

CC: SAHIL

Doubtly · 16 May 2024 Report

Shared secret key K = 2.

Need of Diffie-Hellman: symmetric ciphers need both parties to have the same secret key, but sending that key over an insecure network would expose it. Diffie-Hellman lets two users create a shared secret key over a public channel without ever sending the key itself. Its security rests on the difficulty of the discrete logarithm problem.

Public: \(p = 23,\ g = 5\). Private: \(a = 6\) (A), \(b = 15\) (B).

Step 1: A's public value

\[Y_A = 5^6 \bmod 23 = 15625 \bmod 23 = 8\]

Step 2: B's public value

\(5^2 = 2\), \(5^4 = 4\), \(5^8 = 16\) (mod 23), so

\[5^{15} = 5^8\cdot5^4\cdot5^2\cdot5 = 16\cdot4\cdot2\cdot5 = 640\]

\[Y_B = 640 \bmod 23 = 19\]

Step 3: Shared key

A computes \(K = Y_B^{\,a} \bmod p = 19^6 \bmod 23\). Since \(19 \equiv -4\), \(19^6 \equiv 4^6 = 4096 \equiv 2\).

B computes \(K = Y_A^{\,b} \bmod p = 8^{15} \bmod 23 = 2\).

\[K = 2\]

Both get the same key because \((g^b)^a = (g^a)^b = g^{ab} \bmod p\).

Tutor AI · 23 Oct 2026 AI-verified AI-generated Report

Your answer

Log in or create a free account to answer this question.