#Diffie hellman key exchange example mod#
Alice chooses secret value x and sends the public value g x mod p to Bob.Each uses the other party's public value to calculate the shared secret key that is used by both parties for confidential communications.Ī third party cannot, in theory, derive the shared secret key because they do not know either of the secret values, x or y.Both parties use their secret values to derive public values, g x mod p and g y mod p,.the other party chooses a secret value y.on a public value g and a large prime number p.If another party Eve had been listening in on the exchange, it would be computationally difficult for that Eve to determine the common secret color in fact, when using large numbers rather than colors, this action is impossible for modern supercomputers to do in a reasonable amount of time.ĭiffie-Hellman key-exchange is the Best Practice for Key-Exchange.ĭiffie-Hellman key-exchange or " Diffie-Hellman key agreement" is not based on encryption and decryption, but instead relies on mathematical functions that enable two parties to generate a shared secret key for exchanging information confidentially over an insecure channel. The result is a final color mixture (brown) that is identical to the partner's color mixture. The crucial part of the process is that Alice and Bob now mix their secret color together with their mutually shared color, resulting in orange and blue mixtures respectively, then publicly exchange the two mixed colors.įinally, each of the two mix together the color they received from the partner with their own private color. Each of them selects a secret color–red and aqua respectively–that they keep to themselves. The process begins by having the two parties, Alice and Bob, agree on an arbitrary starting color that does not need to be kept secret (but should be different every time). Illustration of the Diffie–Hellman Key Exchange The following conceptual diagram illustrates the general idea of the key exchange by using colors instead of very large numbers. Diffie-Hellman key-exchange is a specific method of securely Key-Exchange over a public channel and was one of the first Public Key protocols as originally conceptualized by Ralph Merkle.ĭiffie-Hellman key-exchange establishes a shared secret between two parties that can be used for secret communication for exchanging data over a public network.