Does a "commutative" asymmetric system exist? Completely crypto noob here.

I'm looking for a cryptosystem made of a func f + key1 + key2 such that they satisfy:


g(f(msg, key1),key2)=msg
g(f(msg, key2),key1)=msg
key1 != key2


Does such a cryptosystem exist?

Ideally I'd like f and g, to be the same function, but I'm ok if they are different.

It is ok if it's not Fort Knox secure, I want it to play with my nephews but I don't mind going hardcore :)
RSA with random exponents would fulfill your key-swapping requirement. I.e. RSA where you generate one exponent randomly and then compute the other from it normally, with neither exponent made public. The operation to encrypt and decrypt is the same (modular exponentiation).

The security of this scheme, or some uses of it is considered in the (currently unanswered) question: Could this &quot;symmetric RSA&quot; scheme provide key compromise resistant communications?

Since you say you do not need it to be extremely secure, it should fit your bill regardless.