A non-mathematical explanation of one way functions
blog.jgc.org
blog.jgc.org
Also, I love the "Waldo" example of zero-knowledge proofs: I want to prove to someone that I found Waldo in a "Where's Waldo" puzzle. How do I do this without showing them where Waldo is?
.
.
I can simply cut a "Waldo-sized" hole in a big blanket, then position the "Where's Waldo" puzzle under the blanket with Waldo showing through the cut. Easy to do since I know where Waldo is, but impossible to get information from. (At least, theoretically).
It is a good example for lay people not in the paint/color/physics industry.
Take a word. Remove every second letter.
This is a one-way function, because it's basically impossible to recover the original, even for two letter words. It's not a very good as a one way hash, because you can trivially construct collisions. It does, however, nicely capture the idea that you are pretty much always going to be discarding information to get a hash (if the hash is shorter than the input), without really resorting to the pigeonhole principle.
What Alice wants is a commitment scheme[0] which has some secret randomized input. She would commit to her solution, send it to Bob, wait until Bob has solved the puzzle or gives up, and then prove that she had the solution first by providing both the solution and the randomness. Now you can construct a commitment scheme from a one way function, but a one way function is not a commitment scheme.
Now if they both just want to check if they have the same solution, you have to do far more complex than either of these involving Secure Multi Party Computation. [0] http://en.wikipedia.org/wiki/Commitment_scheme
See http://www.geekosystem.com/xkcd-philosophy/ for more.
http://blog.tanyakhovanova.com/?p=277
http://www.schneier.com/blog/archives/2013/04/nice_security_...
Now, you could make this a good example by continuing, in lesson 2, to show weaknesses with this approach.
For an analogous case, read Knuth. In 'the art of computer programming', chapter ?2? on random numbers, he gives a convoluted random number generator that, in an abstract sense, is not unlike your one-way function, then shows how bad it is, and makes the case that you shouldn't let ordinary programmers design (or even tweak) these algorithms for you.
I do agree that a follow up could be written (e.g. Bob could compute a 'rainbow table' of the dictionary for the next time Alice uses the same trick; and the Alice could introduce some salt; Alice could introduce multiple rounds as well with a 'work factor' to make Bob's life harder).
If you're trying to non-mathematically explain a mathematical process, I think, more often than not, you're going to end up with an incomplete example. If you try, I'd wager that you'd probably end up with something fairly long and possibly convoluted.
Which isn't to say that more blog posts about the topic would be wasted. I think the posts so far are great ideas for expansion. I just think it accomplished what it wanted to accomplish.
Hopefully the blog post won't spur too many novice developers into writing home-grown password hashing functions based on the outlined technique.
"There's a potential problem with this procedure. What if Alice had started with some other word - say 'FILES' - and following this procedure also led to the word 'THINGS'. In fact, it might be that many, many English words all lead to the word 'THINGS'. If that were so then Bob would be justified in feeling skeptical that Alice had solved the crossword. She'd be using a "bad" one-way function. Both Alice and Bob need to be confident that this procedure doesn't lead to too many collision between English words. This is a challenge that needs to be addressed if you want to prove that a function is truly a good one-way function."
http://www.merriam-webster.com/dictionary/elephant: any of a family (Elephantidae, the elephant family) of...
http://www.merriam-webster.com/dictionary/rhinoceros: any of a family (Rhinocerotidae) of...
http://www.merriam-webster.com/dictionary/crocodile: any of several large...
http://www.merriam-webster.com/dictionary/buffalo: any of several wild bovids...
So, there is some variation, but it isn't hard to find immediate collisions, especially for related words. That makes sense; a dictionary should not attempt to vary the way it describes similar words.
Sections 4 and 5 of the introductory notes [1] give the classic example of using prime factorization to verify bets in a game of "flipping a coin over the telephone". Much of the rest of the course develops the major ideas underlying this example (computational complexity, cryptography) and shows you other things you can do with them (machine learning).
0. http://ocw.mit.edu/courses/electrical-engineering-and-comput...
1. http://ocw.mit.edu/courses/electrical-engineering-and-comput... [PDF]
> How do you know it can't be reversed easily?
Some you prove: http://en.wikipedia.org/wiki/Provably_secure_cryptographic_h...
But more commonly (because provably secure crypto functions are extremely hard to design) you think hard about them, then unleash fellow and opposing crypto specialists to try and break them[0], as was done by NIST[1]
[0] http://en.wikipedia.org/wiki/Cryptanalysis
[1] http://en.wikipedia.org/wiki/NIST_hash_function_competition
Of course, almost everyone thinks these problems are in fact hard (at least for classical computers), but there's no proof (such a proof would imply P != NP).
Example: SAT-solving is NP-complete, but nonetheless heuristic SAT solvers are very good in practice, which makes its hardness too weak for cryptographic use. That can be ameliorated by trying to identify a more specific subset of "actually hard to solve SAT" (some of the research on the SAT "phase transition" aims at this), but it's pretty difficult. A few problems like integer factorization seem to have just arrived with this apparent always-hard property, but attempts to engineer it have been less successful, hence to my knowledge no used-in-practice cryptosystem is based on taking an NP-hard problem and turning it into a cryptographically useful one-way function (even though Diffie & Hellman suggested that as a research agenda way back in 1976).
I wrote an essay on that subject a few years ago, since the reverse question also comes up in AI discussions: http://www.kmjn.org/notes/nphard_not_always_hard.html
Not used in practice, but such a result was presented by Atjai and Dwork:
There's no way you could take the complete works of shakespeare , pass it through SHA1 and then take the output and somehow reverse it (the 160bits) to get the complete works of shakespeare back out because too much information has been destroyed. It's effectively an extreme form of lossy compression.
What a good hash function should do though is ensure that small changes in the source guarantee a completely different output hash.
Not always true. For example, see locality sensitive hashing [1] which relies on similar inputs being hashed to similar outputs to quickly look up similar items.
That's where I think the really interesting aspect of hashing algorithms comes from - what the different characteristics are and what applications that has (speed for checksums, slow for passwords, similar inputs giving similar outputs for similarity searching)
[Edit] The key characteristic of all hashing functions is it produces a fixed size output. The fact this makes a one way function is incidental; though crucial for many applications like password storage, it's not really that important for things like checksums [2] or hash tables.
[1] http://en.wikipedia.org/wiki/Locality_sensitive_hashing
[2] Though it can be useful if using checksums for security.
I meant the characteristic that makes it a hash function is producing a fixed size output.
It may not be that important for some contexts, but without that characteristic it's not a hashing function.
Conversely, I can have a function that isn't one way, but produces a fixed size output. Granted, it's not going to be that useful, but it's still a hashing function. If I have a one-way function that doesn't produce a fixed size output, it's not a hashing function.
The avalanche effect (referred to in the last sentence) is important as a heuristic. Among other things, it makes it harder to go from an "approximate" preimage to an exact one. If we had f(x) = y, where y is similar to our target y', we shouldn't be able to find x' with f(x') = y' just by looking at the neighborhood of x. But this doesn't rule out more "clever" ways of tweaking x, and it doesn't obviously stop an attacker from deducing some property of x'. So for one-way functions, what we really want to assert is the nonexistence of an algorithm for finding (properties of) preimages, that is any better than just trying lots of new values of x.
There's no practical way. Mathematically you can "just" brute force it, end of the universe will probably inhibit the practical application of that.
There are also standard attacking techniques, so you can check (and maybe prove) these techniques do not work, but that still does not show there is a trivial crack you have missed.
It's hard -- cryptographers have yet to even prove that one way functions actually exist! We have lots of theoretical candidates -- discrete logarithms for certain groups, integer factorization, problems related to hidden linear codes, and so forth. Some day, we will either prove that OWFs do not exist, or that OWFs do exist (and hopefully one of the candidates is actually an OWF), or that the existence or non-existence of OWFs is independent of the mathematical systems we use right now (i.e. that it is an axiom).
Having said that, you might be interested in the work of Atjai and Dwork on creating an OWF (a trapdoor OWF, actually, and a corresponding public key cryptosystem) from an NP-Hard problem:
Some tidbits:
* "The existence of such one-way functions is still an open conjecture. In fact, their existence would prove that the complexity classes P and NP are not equal"
* "It is not sufficient to make a function 'lossy' (not one-to-one) to have a one-way function."
* "The existence of a one-way function implies the existence of many other useful concepts, including: [PRNGs, MACs, etc.]"
So, the base case is "FOLIO is on page 655(?)" and Alice gives Bob the number 655. Now, there are only 12 five-letter words on page 655, so she's actually giving a pretty good hint away. Instead, she picks the second word of the first line, and give the page of that. Depending on how secure she wants the verification to be, she can repeat this process, with each round making the one-way-function 1000(?) times harder to reverse.
- Alice and Bob must have identical copies of the dictionary. Different editions could have slightly different definitions. The risk is not large, but it throws off all confidence.
- Alice tells Bob her procedure. Either they do it in real-time together or she tells him the procedure along with the encrypted word. But nowhere in the text as written does Alice communicate the "algorithm" to Bob.
Also, Bob does not know if Alice completed the puzzle until he completes the puzzle (or the solution is published) [actually that one clue, but Alice could've chosen any clue, possibly the last one that Bob finds]. The story made me believe Bob would know if Alice completed the puzzle immediately, so by definition of the problem, before he completed it. Is there a protocol that would allow this? [I think that's where we need 3rd party trusted sources]
You've lost me. I think OP does it in a way that people don't have to guess at what he's talking about, which is important (very important) when introducing an idea).
There are certain tweaks we can argue about to be sure, but I think this serves as an intro that everybody can "get." She's not securing a $100,000 account. If someone were to get interested in this and pursue more knowledge she would quickly realize that she couldn't use this algorithm to secure important accounts.
Note: I assume you mean that she picks the second word of the first line, looks that word up in the dictionary and gives the page number of that word.
I will note here, however, that in this thread OP agrees with you.
This is an example to show people what a one way function looks like. I even say at the bottom of the blog post that you wouldn't do this on a computer. This specific one way function is hard for a human to reverse. Writing a computer program to automate Bob's work is completely missing the point.
Bob can always just fall back on rubber hose cryptography.
I doubt writing a crossword solver is an easier solution since that would need to deal with word definitions and is hence a natural language problem.
I see crosswords as a data problem: given a dictionary of valid words, generate all possible solutions for the given grid. As the number of overlapping words is quite limited, shouldn't take long to run. The only natural-language factor is deciding which solution matches the clues provided. Dang, now I'm gonna have to go write one...
My one way function adds the values of each character, in case I apply it to 'america', it would be 1+13+5+18+9+3+1 => 50.
So, if somebody had to find the word from only from resultant sum or value, it would take time to come up with all the possible words.
Some of the possible candidates also include aameric, cmeriaa etc. Clearly in this case there are many possible words that map to a particular value or sum, in the good one way function there are not going to be as many words that map to one value, also a good one way function is more complicated(for a computer too or computer takes non polynomial time) than the one I chose!
Reminds me of this similar abstract explanation of zero-knowledge proofs: http://en.wikipedia.org/wiki/Zero-knowledge_proof#Abstract_e...
"The hiding virtues of ambiguity: quantifiably resilient watermarking of natural language text through synonym substitutions", U. Topkara et. al. MMSec'06 https://www.cerias.purdue.edu/assets/pdf/bibtex_archive/2006...
"Information hiding through errors: A confusing approach", M.Topkara et. al. SPIE'07 http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.94.1...
So, is "folio" the only (five letters) word in the dictionnary that has "individual" as the second word of its definition?
Is "individual" the only word in the dictionnary that has "human" as the third word of its definition?
I doubt it, so their way or identifying words is by no mean bijective, hence it's not a valid one.
X -> Y -> Z -> or -> alternatives -> things
EDIT: grammatical correction.
If you thought the answer was 'bored' and you followed the steps (which are not a secret) and you didn't come up with the same end confirmation word as I did. (i.e. me = 'things' you = 'hamster') one of us is wrong and neither of us had to provide our starting word to the other. We don't know who is right yet, we just know we don't agree.
One round leaves some room for error because we could both accidentally choose a word that resolves to the same word in the target position. But since we are doing 5 rounds and moving the target word (1st, 2nd, 3rd etc) for each successive round the odds become much better that we won't have an accidental collision.
(edit: grammar)
And, as you point out, this means that the function is not bijective. However, I am not claiming that it is, I am illustrating a process of going from one word to another that is easy in one direction and hard in the other.
This blog post is not about collision resistance, but it would make a good follow up topic. Especially since some previously thought to be resistant one way functions (MD5 and SHA1) are now known not to be.
Want to store a password (cow)? Meat grind it. Store the hamburger.
How does someone login? Grind their attempted password (cow) exactly as you did their stored password and compare hamburgers. If same, they can log
This of course assumes hackers are hindus and value cows but not hamburger.
When used in the context of password encryption though, all of these "overlapping" words are also the password.
"I've managed to solve for X, Y and Z!"
"So did I, but I don't believe you. Prove it to me."
"The sum of all the digits in X, Y and Z is 143"