Compute and print the values of p the generator g random


You need help writing a java program for the Diffie-Hellmann Key Exchange. The program needs only 1 input from the user where it takes a prime number p (in bits) as an argument during execution.

Based on the size of p, your program should be able to compute and print the values of p, the generator g, random numbers a,b Z* p, and other intermediate results computed in the Dife-Hellman protocol.

Note that the values of p,g,a, and b have to be generated randomly by your program based on the input argument.

Your program should finally output the shared key generated. An example of how the code's output should look upon execution is below:

>> 5

>> The value of p selected: 23

>> The value of g selected: 5

>> The value of a selected by Alice: 6

>> The value of b selected by Bob: 15

>>The value of A sent to Bob by Alice: 8

>> The value of B sent to Alice by Bob: 19

>>The value of key shared between Alice and Bob: 2

In the above scenario, the program takes 5 as input meaning that the size of p should be 5 bits (i.e., the value of p should be selected in the range (16,31]).

Note that since the values of p,g,a,b are assumed to be generated randomly as per the Dife-Hellman protocol, their values and the shared key value can be very different during each execution.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Compute and print the values of p the generator g random
Reference No:- TGS02873646

Expected delivery within 24 Hours