I saw that one but im looking for a mathematical explanation actually and its use with bitcoins, the sha 256 and that kind of stuff but thanks for your help
Not sure what you are exactly looking for but the simplest "one way" function I can think of is f(x) = x
2, which gives you the value you put in mutiplied by itself. Now the question is which number did I put in when you only know the result. E.g.:
I say a result of f(x) = x
2 is 4. What was the x? You cant
know the answer, because there are two (in |R) possible answers -2 and 2. If it was a game you could
guess and would win 50% of the time.
Its a "one way" function because you cant bijective (math. for one-to-one) reverse the calculation, its only a function in one direction, but not in the other direction, its not a function if you reverse the operation. A function is defined such that for each input there is only a single possible output. Two different inputs may return the same output, thats fine, but there may never be more than one possible result for any given input. If you want to reverse f(x) = x
2 you get f
R(x) = sqrt(x) which gives you the root of the number you put in, but it will return two results the negative and the positive root, thus its usually only defined on |R
>0 if its used as a function and only returns positive numbers.
SHA256 is very similar to this, its a function as any given input gives the exact same hash value. But since it is mapping all possible (and thus infinte) values to a small (in mathmatical terms) subspace of 2
256 possible results, there must be a collision. There must be infinity values that result in the same SHA256 hash. They are just not humanly possible to find. In this sense SHA256 is a one way function similar to x
2 only that you have no way to try all combinations for a given result. If this was a game, you, your family and everyone on earth could guess all day every day until the sun burned out and I still would win.
This is the basis for bitcoin mining. As the hash must be below a certain value and miners cant just reverse SHA256 that value and get a valid block. They have to try many different combinations to find a value that fits.