I need some crypto operation for matching data privately between two peers (let say Alice and Bob). Alice should be able to encrypt her data with Alice and Bob public keys and pass the cipher text to Bob. Bob could not decrypt the cipher text but could match it with the same cipher text produced on the Bob side. As a result Alice and Bob will know which source messages have both of them.
So I am looking for asymmetric cipher which allows to change the order of encryptions providing the same cipher text (I suppose it is called commutative). So given $M$ - plain text message, $pub_1$ - first public key, $pub_2$ - second public key. I need the crypto function $F(message, pubkey)$ with such property:
$F(F(M,pub_1), pub_2) = F(F(M,pub_2), pub_1)$