News for hackers. Stuff that matters.
Re:Reversing an integer hash function by rurban on Friday January 14, 2022 @02:54PM (#29939472)
I'm collecting such inverters at https://github.com/rurban/smhasher/tree/inverse/inverse

But only 3 so far.

Re:Reversing an integer hash function by elsamuko on Saturday January 15, 2022 @09:40AM (#29946668)
For the cryptopals challenge, you have to invert the Mersenne Twister scramble function:

https://cryptopals.com/sets/3/challenges/23

https://github.com/elsamuko/cryptopals/blob/610ab19bf6823a34...

Re:Reversing an integer hash function by Retr0id on Saturday January 15, 2022 @09:57AM (#29946780)
I wrote an inverter for XXHASH64, in python: https://gist.github.com/DavidBuchanan314/13020be9e2a251e2a2a...
Re:Reversing an integer hash function by superjan on Saturday January 15, 2022 @09:08AM (#29946431)
Is there a category of hash functions that hash a 64/32 bit input to exactly 64/32 bits output, such that all inputs are uniquely preserved? This could be an interesting property for a hash table of integers, because a hash match implies a key match.
Re:Reversing an integer hash function by ninkendo on Saturday January 15, 2022 @10:22AM (#29946987)
Even if you used such a bijective hash, your hash table would have to have 2^32 available buckets in order for the hash match to be all you need for lookup. Or 2^64 for 64-bit… which is why nobody really does this. (And if you did this, why even hash the input? The input integer could just be the key, and you’re basically using a really big sparse array.)
Re:Reversing an integer hash function by superjan on Saturday January 15, 2022 @04:39PM (#29950575)
I agree that for standard hash tables this won’t work. However, I recently read about “Ideal Hash Trees” [0], that preserves the entire hash. That design also requires all bits to be “random” because it lacks the usual prime division.

[0] https://lampwww.epfl.ch/papers/idealhashtrees.pdf

Re:Reversing an integer hash function by JD557 on Saturday January 15, 2022 @09:23AM (#29946553)
I think the word you are looking for is "permutation".

However, if you can use a permutation as a hash function, you might be fine with just using the identity function.

Re:Reversing an integer hash function by dragontamer on Saturday January 15, 2022 @12:18PM (#29948184)
> However, if you can use a permutation as a hash function, you might be fine with just using the identity function.

This certainly isn't true for 8-bit characters using ASCII.

The top-bit of all ASCII strings is always zero, its effectively a wasted bit. Permuting all ASCII characters to randomly use all 8-bits means a better distribution in virtually any hash-based data-structure. (ex: 64 slot hashtable will have fewer collisions after you permute the 7-bit ASCII into an 8-bit random permutation)

Re:Reversing an integer hash function by judofyr on Saturday January 15, 2022 @09:35AM (#29946633)
This would be a “bijective function” or a “perfect hash function”, although the latter is usually used when the input is much smaller than the output.
Re:Reversing an integer hash function by hinkley on Saturday January 15, 2022 @02:01PM (#29949158)
Linear congruential generators in some cases can do that, though more often they are used to convert n bits of input data into a uniform distribution over a range from 0-m. For instance simulating chance in a game (dice rolls, or % probability).
Re:Reversing an integer hash function by praptak on Saturday January 15, 2022 @10:11AM (#29946889)
Basically every cipher works like this.
Re:Reversing an integer hash function by namibj on Saturday January 15, 2022 @10:28AM (#29947043)
For 64bit: (triple)DES should do the trick.
Re:Reversing an integer hash function by omegalulw on Saturday January 15, 2022 @02:45PM (#29949527)
A hash is typically used in the context of mapping arbitrary size input to fixed size output.
Re:Reversing an integer hash function by Retr0id on Tuesday January 18, 2022 @01:17AM (#29975760)
XXHASH64 is bijective for 64-bit input strings.
Re:Reversing an integer hash function by blastonico on Saturday January 15, 2022 @04:15PM (#29950342)
> otherwise you could simply trace backwards and generate an input that produces a specific hash

This is when I know for sure that I'm not included in that "you".

Re:Reversing an integer hash function by clon on Saturday January 15, 2022 @08:36AM (#29946228)
Excellent tutorial for bitwise arithmetic this is. The key is the motivation you receive from the prospect of being able to do something that seems "l33t".