Reversible hash function for mapping a set of integers to another set

I'm looking for a reversible hash function that would map any 64-bit integer to another, with 1-to-1 correspondence, i.e. one number in one set maps to only one number in another set, both ways.

It is also important that the mapping is random-looking in a sense that if the function is not known to the outside observer, it should be relatively difficult to guess. Which means that the function should probably have some sort of a "seed" or "salt" (a large enough number or a sequence) that would make the mapping unique.


Solution 1:

You can use a block cipher with a 64-bit block size for your aim.

A block cipher is a family of permutations;

$$F:\{0,1\}^\ell\times\{0,1\}^b \to\{0,1\}^b$$

$\ell$ is the key size and $n$ is the block size. For DES $b=64$ as for PRESENT and SIMON can have it, too ( there are others in the lightweight cryptography). If one fixes a key $k$ then one selects one of the permutations from the family.

$$F_k:\{0,1\}^b \to\{0,1\}^b$$

If you use DES then we have

$$DES_k:\{0,1\}^{64} \to\{0,1\}^{64}$$

To map a value, encrypt it, to find the reverse, decrypt it always with the fixed key.

As long as the key is kept secret and the attacker cannot obtain input, the output will be unknown to the outsider. In the case of the input-output pairs are available to the attacker use SIMON with a 128-bit key. It is secure against Known-Plaintext Attack (KPA), that is one cannot find the key with given input and output pairs. DES key size is too short for today's standards, at least 112 bit is required from the lightweight ciphers.

This operation actually a single block ECB mode encryption where it can achieve CPA security, however, multiple block ECB mode encryption will fail CPA.

Under the unknown attack model, you may need integrity and/or authentication that can be supplied with a MAC like HMAC with another key or derive them from a single key.