Example. Shamir’s three-pass protocol [01F6]

Whereas Diffie-Hellman is a way for two actors to agree upon a secret key that neither of them started with, Shamir’s three-pass protocol is a way for one actor to securely send secret information to another. Here is how Alice would send a secret integer k<p to Bob without anyone else being able to intercept it:

  1. In public, Alice and Bob agree upon a prime p.
  2. In private, Alice choose a key pair (e_A,d_A) satisfying d_A\cdot e_A\equiv 1 \mod p-1. Bob similarly chooses a key pair (e_B,d_B) satisfying the same property.
  3. Alice encrypts k as the modular exponentiation {\mathopen {}\left [k^{e_A}\right ]\mathclose {}}_p, and sends it to Bob.
  4. Bob then encrypts the received value as {\mathopen {}\left [k^{e_A\cdot e_B}\right ]\mathclose {}}_p , and the result back to Alice.
  5. Alice decrypts the received value as {\mathopen {}\left [k^{e_A\cdot e_B\cdot d_A}\right ]\mathclose {}}_p and sends it back to Bob.
  6. Finally, Bob decrypts the received value as {\mathopen {}\left [k^{e_A\cdot e_B\cdot d_A\cdot d_B}\right ]\mathclose {}}_p \equiv k^{e_A\cdot e_B\cdot d_A\cdot d_B} \equiv {\mathopen {}\left (k^{e_A\cdot d_A}\right )\mathclose {}}^{e_B\cdot d_B} \equiv k\mod p\text {.} Because k<p, Bob’s final decrypted value is equal to k.