Well that's essentially what I have done, except the unique hash is just a single integer and the hash function is f(x,y) = x + y.

Such a trivial hash function would normally be unacceptable due to the prevalence of hash collisions but avoids them by x and y being (multiples of) prime numbers.

it works anyway