# The magic box puzzle: How to implement a verifiable self-contained secret system?

Imagine we have a magic box that will open only if we pronounce the secret words. Everybody at the beginning of the game have some verifiable proof of the correct secret words.
During the first phase all contestants will say their guesses for the secret words.
On a second phase the magic box will open if any of the contestants said the secret words. And using the proof provided and the beginning of the game you will be able to verify the secret words are the same, and the box is not trying to trick you. If none of the contestants guessed the secret words the box will tell the secret words and the game will start again resetting the secret words and offering a new proof.

My own guess
Based on my limited cryptography knowledge my implementation will be as follows: The proof provided at the beginning of the game would be a hash of the encrypted secret. When the secret is revealed on the second phase, a key and method to encrypt the secret is also provided, so contestants will be able to encrypt themselves the secret and compared the hash to the proof provided at the beginning. I would use a simple symmetric encryption method and a md5 hash for the proof.

Please let me know of your thoughts and if you get a better approach of the problem.

• I would suggest using SHA2/3 over md5, because as unlikely as it is, it is technically possible that someone could say an incorrect word, that when hashed, happens to match the known hash, due to collisions – SamG101 Jan 24 '20 at 11:10
• but the md5 hash is just an initial proof, during the revealing phase both secret and key to encrypt will be revealed. Md5 collision for the encrypted secret is irrelevant if you can reconstruct the encryption steps using the key and the secret – Veilkrand Jan 24 '20 at 11:31
• Why can't the box just give a key for a hmac of the secret: hash-based and requires a key. – SamG101 Jan 24 '20 at 12:16
• @SamG101 hmac will absolutely works using a good key – Veilkrand Jan 24 '20 at 14:02