Skip to content

Commit

Permalink
Merge pull request exercism#10 from soniakeys/master
Browse files Browse the repository at this point in the history
new exercise diffie-hellman
  • Loading branch information
kytrinyx committed Jun 26, 2014
2 parents f2782f4 + e328d6e commit b75f5cd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
29 changes: 29 additions & 0 deletions diffie-hellman.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Alice and Bob use Diffie-Hellman key exchange to share secrets. They start with prime numbers, pick private keys, generate and share public keys, and then generate a shared secret key.

## Step 0

The test program supplies prime numbers p and g.

## Step 1

Alice picks a private key, a, greater than 1 and less than p. Bob does the same to pick a private key b.

## Step 2

Alice calcuates a public key A.

A = g**a mod p

Using the same p and g, Bob similarly calculates a public key B from his private key b.

## Step 3

Alice and Bob exchange public keys. Alice calculates secret key s.

s = B**a mod p

Bob calculates

s = A**b mod p

The calculations produce the same result! Alice and Bob now share secret s.
4 changes: 4 additions & 0 deletions diffie-hellman.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
blurb: "Diffie-Hellman key exchange."
source: "Wikipedia, 1024 bit key from www.cryptopp.com/wiki."
source_url: "http://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange"

0 comments on commit b75f5cd

Please sign in to comment.