Skip to content

Instantly share code, notes, and snippets.

@erdostom
Created January 12, 2021 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erdostom/8b39fd73bd983f048af336a7fc535985 to your computer and use it in GitHub Desktop.
Save erdostom/8b39fd73bd983f048af336a7fc535985 to your computer and use it in GitHub Desktop.

The Padlock Problem

Alice wants to propose to Bob by sending him an emerald ring (screw diamonds). The problem is that Alice lives in New York and Bob lives in Moscow. All correspondence between them is subject to inspection and confiscation by Russian customs officials, unless it is secured via a lock. How can Alice send Bob the emerald ring without risk of confiscation?

She could try to send a padlocked package and then the key in separate package, but of course the the customs officials could intercept the key. She could also use a combination lock, but then how would she send the code in a secure way?

There is a solution that doesn't require external systems: Alice sends the locked package to Bob. Bob then adds his own lock to the package and sends it back to Alice. Alice removes the lock she placed with her key and sends the package (now secured only with Bob's lock) to him. Bob removes his lock and opens the package! Everyone lives happily ever after (except the customs officials).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment