What is public key cryptography and what are its components ? Explain the Diffie-Hellman Algorithm.

Subject: Mobile Computing

Difficulty: Medium

Marks: 8 Marks

1 Answer

Public key Cryptography: In this cryptography two different keys are used for encryption and decryption. Thos is also called as Asymmetric key cryptography. It is based on mathematical functions rather than permutation & substitution. The encryption key and decryption key form a key pair. One of the key from the key pair is made public and the other is kept private or secret. There are six main components

enter image description here

enter image description here

Plaintext: Human readable message or data given to public key algorithm as input for encryption.


This is the scrambled data produced as output of the format of data produced as output of the encryption algorithm. This is unique data and depends only on the unique key used for encryption.

Encryption Algorithm: It does computation and various transformations on the input plain text. The output of the transformation is too garbled to be decipherable for an intruder.

Decryption Algorithm: This algorithm does the reverse function of the encryption algorithm. This function accepts the cipher text as input and does some transformation on the data so that the original data is recovered.

Public Key: This is one of the keys from the key pair. This key can be used either for encryption or decryption.

Private key: This is the other key from the key pair. This key is called the private key, because this is kept secret. This can be used either for encryption or decryption.

Diffie Hellman Algorithm:

Consider Alice and Bob want to exchange the key

  1. Firstly, Alice and Bob agree on two large prime numbers, n and g. These two integers need not be kept secret. Alice and Bob can use an insecure channel to agree to them
  2. Alice chooses another large random number x, and calculates A such that : A =$g^{x}$ mod n
  3. Alice sends the number A to Bob.
  4. Bob independently chooses another large random integer y and calculates B such that: B =$g^{y}$ mod n
  5. Bob sends the number B to Alice.
  6. A now computers the secret key K1 as follows: K1= $B^{x}$ mod n
  7. B now computers the secret key K2 as follows: K2= $A^{y}$ mod n
Please log in to add an answer.