I am looking for a way to shuffle an array of known values (like a deck of cards) between two clients who don’t trust each other, in a way that can be verified by both parties, and no advantage can be gained.
So far I am thinking…
for each item in array:
A tells B random number to use (Ra1) <~ prevent B from using pre-calculated password
B creates secret random number, and shows hash to A <~ can prove this number is used
B adds his own secret random number (Ra1+Rb1) <~ prevent A from using pre-calculated password
B encrypts a random array value using the combined password (Ra1+Rb1), removing from the stack
B gives encrypted value to A
A re-encrypts the value <~ prevent B from recognizing his package later
A stores at random index in new array of unknown items
A shows the full array to B <~ B can be confident that the array will not be tampered with
A does not know what is in each package, nor does B
B can now choose a package for himself, and A can then provide the password for that package, allowing B to recognize his package, and know the contents.
A can also choose a package, and request the key to unlock it form B.
After all transactions are agreed, and secrecy is no longer required, all secrets are revealed by both parties, who can both then verify the contents of the boxes
This all seems overly complex to me – and I can’t imagine how to make it work for A, B and C in such a way that no party needs to be trustworthy, or reliable (might not provide keys later – interfering with transactions between other parties).
Summary
Ideally, I need an algorithm to shuffle a deck of cards, between two untrustworthy parties, in such a way the deck, and the cards can be verified later by all parties, so long as there are at least 2 interested parties providing each other their secrets at the end.
This is the famous Mental Poker Problem. One solution involves commutative encryption (ie. E1(E2(M)) == E2(E1(M))).
From the wiki article:
This allows the cards to be shuffled, without allowing either side to cheat, and without either side knowing what cards the other has (if you remove the last requirement and only want fair shuffling, the problem becomes much easier).
The encryption used must be secure against known plaintext attacks.