# Is there any kind of function that has a property like this?

First of all, sorry for any horrible formatting, I have to type this in from my phone.

I know (or, at least, I think) that no currently used cryptographically secure hash functions exist with this property, and I doubt it would make sense if they did, but I want to know if there is any kind of "hash"-like function that does.

Is there any function where if $x+y=z$, then $f^{-1}(f(x) + f(y))=z$? (Or some other operator: subtraction, AND, OR, etc, if that makes the question easier to answer) Other than something trivial like $f(x)=x$.

It would seem to me that such a function would likely be very susceptible to attack, although I do not know this for sure, but I do not plan on using it for anything that requires even a tiny amount of legit security.

Based on what I know about functions and algorithms, I would hazard a guess that such a function would need to be linear, but I don't know that for sure. I am looking for some sort of "hash"-like function to be able to store information (text, numbers, etc) in fixed sized pieces but still be able to do operations on them (adding, subtracting, etc) in that "hashed" state. Even if you only have some general information on where to look, that would be appreciated.

## 1 Answer

The fact that you want an inverse function means hashing is not appropriate, as hashes are by definition not invertible due to the requirement of preimage resistance.

What you're looking for is homomorphic encryption. What operations you need to perform will determine what scheme you need to use. There is fully homomorphic encryption, which allows you to evaluate whatever operator you want, but it is relatively inefficient compared to schemes that only offer a specific operator (such as addition or multiplication).

• I wasn't sure of the terminology of the type of function I wanted, hence the quotes every time I said "hash" – runeguy Jun 11 '18 at 19:40