Cryptographic problem - locks Three players, Bob, Alice and Ted are seated at a poker-table and are 
  playing a game of Texas Hold’em. Bob is the dealer, and he generates a deck of 52 cards on his machine, only he can view the cards. Using Fisher-Yates /dev/urandom he shuffles the deck of cards, and then encrypts the deck with the same encryption key on each card, making the deck unreadable to anyone but himself. He then passes the now encrypted deck to Alice, who does the same thing: shuffles the deck of cards and then encrypts them. Finally, Alice passes the deck to Ted who goes through the same process.  
  The deck is now in its final ordered state, 1 through 52, and this order does not change throughout the course of the hand. Ted passes the now 3x encrypted deck of cards back to Bob, who takes off his “shuffle lock” and now encrypts each individual card with a different encryption key: B1, B2….B52. He passes the deck to Alice, who does the same thing: removes her “shuffle-key” and encrypts the deck with a unique encryption key A1, A2….A52. Alice then passes the deck back to Ted, who completes this same process.


How is it possible that Bob can remove his encryption key of a string that is completely random for him, because Alice and Ted encrypted it?

Is this a feature of asymetric cryptography? If so a jsfiddle or so mayb be nice :)

I understand that you can encrypt something with a private key and decrypt it with a public key, but is it like that that this also works on strings that somebody else also encrypted (like in the example above)? So can I just simply remove my encryption?
This seems to be a variation of Shamir's 3-pass protocol.

I guess that the card trick requires commutative encryption to work, meaning that encrypting with a key K_1 and then with another key K_2 will produce the same result as encrypting with K_2 and then K_1.

Most public-key encryption algorithms do NOT have this feature (at least, RSA and Elgamal do not).