From what i have learnt,in Asymmetric key there is public key and a private key. For instance:

Step 1: Alice and Bob get public numbers P = 23, G = 9

Step 2: Alice selected a private key a = 4 and Bob selected a private key b = 3

Step 3: Alice and Bob compute public values Alice: x =(9^4 mod 23) = (6561 mod 23) = 6 Bob: y = (9^3 mod 23) = (729 mod 23) = 16

Step 4: Alice and Bob exchange public numbers

Step 5: Alice receives public key y =16 and Bob receives public key x = 6

Step 6: Alice and Bob compute symmetric keys Alice: ka = y^a mod p = 65536 mod 23 = 9 Bob: kb = x^b mod p = 216 mod 23 = 9

Step 7: 9 is the shared secret.

So my questions would be,

1)Is the decryption done using the private key(which is 4 and 3 in this case) or the shared secret key.

2)If its done using the private key, then what would be the use of the shared secret key which is 9 in each case.

1 Answer 1


You're mixing up different things.

DH is used to exchange a shared secret which can be used as a symmetric key. Due to DH being vulnerable to a man-in-the-middle attack it ,is most often combined with other methods.

Public and private key pairs are used for asymmetric encryption. The public key is often contained in a public certificate signed by a commonly agreed authority. Public keys may also be exchanged using a symmetrically encrypted channel established using DH (also vulnerable to MITM without further measures).

1) The private numbers used in DH are only used for the key exchange. Once that is done they must not be used any more (to avoid someone else reconstructs the exchange). The shared secret is used for encryption.

2) see 1)

  • So please correct me if i am wrong in understanding the concept. The shared secret is the one which is used to encrypt and decrypt the data as symmetric encryption on both the sides. And as asymmetric encryption is concerned, there is nothing called shared secret, and all they have is public key which is used to encrypt and private key which is used to decrypt.
    – RRHS
    Commented Nov 27, 2018 at 9:52
  • Yes, that's it. In asymmetric encryption, the private key can also be used to sign/authenticate a message and the public key to verify the signature.
    – Zac67
    Commented Nov 27, 2018 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.