This is part five of a series on the Random Oracle Model. See here for the previous posts:
Part 1: An introduction
Part 2: The ROM formalized, a scheme and a proof sketch
Part 3: How we abuse the ROM to make our security proofs work
Part 4: Some more examples of where the ROM is used
About eight years ago I set out to write a very informal piece on a cryptographic heuristic called the “random oracle model”. This was back in the good ol’ days of 2011, when cryptographic proofs were something that only a small handful of hardy nerds really cared about — and frankly, some were still on the fence. This was a more innocent and gentle era where nobody had to remind you that “crypto means cryptography“; people used Bitcoin to actually buy things; and elliptic curves were unlikely to show up anywhere in a major HBO series.
That one random oracle post eventually sprouted three sequels, each one more ridiculous than its predecessor. I guess at some point I got a bit embarrassed about the whole thing, and it ran out of a steam. Which is a shame! Because I had always planned a fifth, and final post, to cap the whole mess off. This was going to be the best of the bunch, the capstone. It was the one I wanted to write all along.
To give you some context for this, let me briefly remind you what the random oracle model is, and why you should care about it. (Though you’d do better just to read the series.)
The random oracle model is a bonkers way to model (reason about) hash functions, in which we assume that these are actually random functions and use this assumption to prove things about cryptographic protocols that are way more difficult to prove without such an assumption. Just about all the “provable” cryptography we use today depends on this model, which means that many of these proofs would be called into question if it was “false”.
And to tease the rest of this post, I’ll quote the final paragraphs of Part 4, which ended like this:
You see, we always knew that this ride wouldn’t last forever, we just thought we had more time. Unfortunately, the end is nigh. Just like the imaginary city that Leonardo de Caprio explored during the boring part of Inception, the random oracle model is collapsing under the weight of its own contradictions.
As promised, that collapse — and what it means for cryptographers, security professionals, and everyone else — will be the subject of this final post.
First, let’s recap a few basics that were covered in the previous posts.
In which we (very quickly) remind the reader what hash functions are, what random functions are, and what a random oracle is.
As discussed in the first sections of this series, hash functions (or hashing algorithms) are a standard primitive used in many areas of computer science. They take in some input, typically a string of variable length, and repeatably output a short and fixed-length “digest”. We often denote these functions as follows:
Cryptographic hashing adds a few important security properties that make cryptographic applications possible. Probably the most famous application of hashing is to digest large files so that they can be digitally signed: at a minimum this requires collision resistance. Hash functions are also fundamental-though-little-appreciated components of many other protocols, ranging from encryption to zero-knowledge proofs, which often demand stronger properties. Those stronger properties can sometimes be challenging to put into formal terms: some protocols require a hash functions to produce output that is extremely “random-looking”.*
In the earliest days of provably security, cryptographers realized that the ideal hash function would behave like a “random function”. This term refers to a function that is uniformly sampled from the set of all possible functions that have the appropriate input/output specification (domain and range). Your protocol could randomly choose one of the possible functions at the start, bake it into your public key or something, and you’d be off to the races.
Unfortunately the actual use of random functions quickly runs into a basic problem: sampling and evaluating random functions is too much work. For example, the number of distinct functions that consume a piddly 256-bit input and produce a 256-bit digest is a mind-boggling (2^{256})^{2^{256}}. Simply writing down the index of which function you’ve chosen would require storage exponential in the function’s input length, and just forget about evaluating it. We want our cryptographic algorithms to be efficient (meaning, at very least, they run in polynomial time), and that means using random functions is right out.
So we don’t use random functions. Out in “the real world” we use weird functions like SHA2 and SHA3, which are made up by Belgians or the National Security Agency. These algorithms are fast, and we can describe them in a few hundred lines of code. As best we can tell, the output looks pretty random.
Still, cryptographers hanker for the security that using a random function would give their protocol. What if, they ask, we could model our hash functions using random function — just for the sake of writing our proofs — and then we could go and use efficient hash functions like SHA2 when people wanted to implement those protocols. These proofs wouldn’t apply to the real protocol used out in the world, but they might at least help us rule out specific bugs that don’t come from the hash function itself.
A proof in this model is called a random oracle proof, and the model is (unsurprisingly) called the random oracle model, or ROM. For the full mechanics of what the ROM looks like, you’ll have to go back and read the series from the start. The part you do need to know is that proofs in this model must somehow hack around the fact that evaluating a random function takes exponential time. The way they do this is simple: instead of giving individual parties a description of the hash function itself — it’s way too big for anyone to deal with — they give each party (including the adversary) access to a magical “oracle” that can evaluate the random function efficiently, and hand them back a result.
This means that every time one of the parties wants to compute they’re actually calling out to a third party, the “random oracle”. It looks like this:

Since all parties in the system “talk” to the same random oracle, they all get the same result when they ask it to hash a given message. This is a pretty good model for what happens with a concrete hash function. At the same time, we can bury all the “costs” of evaluating the random function inside the oracle itself, so that nobody else needs to spend exponential time evaluating one. Inside this artificial model, we get ideal hash functions with none of the complications.
This seems pretty ridiculous already…
It absolutely is!
However — there are several very important things you should know about the random oracle model before you write it off as obvious inanity:
- Of course everyone knows random oracle proofs aren’t “real”. More precisely: it’s widely recognized that proving something secure in the random oracle model does not actually mean it will be secure when you “instantiate” that hash function with something real — like SHA3. In other words, this isn’t some deep secret I’m just now letting you in on.
-
However: ROM proofs are still a useful heuristic. “Heuristic” is a word that grownups use before they protect your life’s savings using cryptography they can’t prove secure
Sarcasm aside: random oracle proofs are still quite valuable. This is mainly because they often help us detect bugs in our schemes. This is incredibly valuable even if they don’t formally guarantee that a protocol will be secure when the random oracle is replaced with a real hash function.Moreover, the existence of a ROM proof should hopefully indicate to us that any real-world problems that do crop up will probably have something to do with the hash function, rather than being in other areas of the protocol.
- ROM-validated schemes have a really decent track record.If ROM proofs were kicking up absurdities every day, we’d probably have abandoned the thing. Yet despite an enormous amount of shade poured over the ROM from the cryptographic research community — not to mention the recent publication of hundreds of papers that have re-invented cryptography without random oracles — the majority of our widely-used public-key crypto is still reliant on the ROM. And most of it works just fine.This is not to say that every ROM-proven scheme has always been unbroken. Schemes have broken in predictable ways when instantiated with broken hash functions, for one thing. However, those flaws have generally been easily fixed by simply upgrading to a better hash function. Moreover, the practical attacks are historically more likely to come from legible issues like the discovery of hash collisions, rather than from some exotic mathematical flaw.Which brings us to a final, critical note…
- For years, many people believed that the ROM could actually be saved. This hope was driven by the fact that ROM schemes generally seemed to work pretty well when implemented with strong hash functions, and so perhaps we could simply identify a type of function that was good enough to make ROM proofs meaningful. Some theoreticians hoped that fancy techniques like cryptographic obfuscation could somehow be used to make concrete hashing algorithms that behaved indistinguishably from random oracles.**
So that’s the state of the ROM, or it was up until the late 1990s. We knew it was artificial, and yet it stubbornly refused to explode or produce totally crazy results.
And then, in 1998, everything went sour.
CGH98: an “uninstantiable” scheme
For theoretical cryptographers, the real breaking point for the random oracle model came in the form of a 1998 STOC paper by Canetti, Goldreich and Halevi (henceforth CGH). I’m going to devote the rest of this (long!) post to explaining the gist of this result, so it’s important that I get across how surprising it was.
What the CGH paper proved was that, in fact, there exist cryptographic schemes that can be proven perfectly secure in the random oracle model, but that become catastrophically insecure when you instantiate the hash function — and not merely with a bad hash function — but with any concrete function at all.
This is a really scary result, at least from the point of view of the provable security community. It’s one thing to know in theory that your proofs might not be that strong. It’s a different thing entirely to know that in practice there are schemes that can walk right past your proofs and then explode in the most serious possible way.
So how do the CGH examples work? Before we get to the details, a few caveats.
First, CGH is very much a theory result. The cryptographic schemes that trip this result generally do not look like real cryptosystems that we would use in practice (although later offers have offered some more “realistic” variants). They are, in fact, designed to do very artificial things that no “real” scheme would ever do. Anyone who looks at these counterexamples might be inclined to dismiss them on the grounds of artificiality.
That could be a mistake.
Unfortunately, there’s no real scientific distinction between a provably-secure scheme that’s “real” and one that’s “artificial”. Both are valid cryptosystems. You can certainly try to avoid schemes that look like the CGH examples, but there’s nothing particularly principled behind this.
And even better, though the CGH paper is a model of technical wizardry, the basic ideas that form the result are pretty simple to get across. I’m going to try focus on an intuition that mixes CGH with a simplified variant of the same result by Maurer, Renner and Holenstein (MRH).
A signature scheme
The basic idea of CGH-style counterexamples is to construct a “contrived” scheme that’s secure in the ROM, but totally blows up when we “instantiate” the random oracle using any concrete hash function. To explain why this happens, we’re going to have to get a lot more specific.
While the CGH techniques work with lots of different types of cryptosystem — ranging from encryption to zero knowledge proof systems — in this explanation, we’re going to use a relatively simple type of system: a digital signature scheme.
A normal signature scheme consists of three algorithms: key generation, signing, and verification. The key generation algorithm outputs a public and secret key. Signing uses the secret key to sign a message, and outputs a signature. Verification takes the resulting signature, the public key and the message, and determines whether the signature is valid: it outputs “True” if the signature checks out, and “False” otherwise.
Traditionally, we demand that signature schemes be (at least) existentially unforgeable under chosen message attack, or UF-CMA. This means that that we consider an attacker who can ask for signatures on chosen messages — i.e., who has access to a “signing oracle” that contains the secret signing key and will sign messages the attacker asks it to. Our expectation of a secure scheme is that, even given access to many such signatures, no attacker will be able to come up with a signature on some new message that she didn’t ask to be signed (except with negligible probability.****)
Having explained what a signature scheme is, let’s talk about what we’re going to do with one. This involves several steps:
- First, we’re going to start with some existing, secure signature scheme. It doesn’t matter what signature scheme we start with, as long as it’s secure (as described above). This existing signature scheme will be used as a building block for the new scheme we want to build.*** We’ll call this scheme S.
-
Now we’ll use the existing scheme S as an ingredient to build a “new” signature scheme, which we’ll call
. Building this new scheme will mostly consists of grafting weird bells and whistles onto the algorithms of the original scheme S.
-
Having described the working of
, we’ll argue that it’s totally secure in the ROM. Since we started with an (assumed) secure signature scheme S, this argument mostly comes down to showing that in the random oracle model that the weird additional features we added in the previous step don’t actually make the scheme exploitable.
-
Finally, we’ll demonstrate that
is totally broken when you instantiate the random oracle with any concrete hash function. In short, we’ll show that one you replace the random oracle with a real hash function, there’s a simple attack that always succeeds in forging signatures.
We’ll start by explaining how works.
Building the Perfect Beast
To build our contrived scheme, we start with an existing secure (in the UF-CMA sense) signature scheme S. This consists of the three algorithms mentioned above: key generation, signing and verification.
To construct our new scheme , we’re going to have to build the same three algorithms for that scheme.
What makes this simple is that two of the algorithms will be stolen unmodified from S. Specifically: key generation and signature verification for will be exactly the same as the equivalent algorithms in S. So two-thirds of our task is already complete.
All of the novel elements of appear in the signing algorithm. Like all signing algorithms, this algorithm will take in a secret signing key and some message, and it will output a signature.
The basic intuition of our new signing algorithm is that it will have two cases. Which branch the algorithm follows will depend on the structure of the message it is given to sign. These can be described as follows:
The “normal” case: for most messages M, the signing algorithm will simply run the original signing algorithm from S as a subroutine. This will output a signature that’s identical to those generated by the original, secure signature scheme.
The “evil” case: for a subset of (reasonably-sized) messages that have a different (and very highly specific) form, our signing algorithm will not output a signature. It will instead output the secret key for the signature scheme. This is an outcome that cryptographers call “very, very bad.”
This description hides all of the important details, but at least gives a flavor of where we’re going.
Recall that under the UF-CMA definition I described above, our attacker is allowed to ask for signatures on arbitrary messages. When we consider our new signature scheme , it’s easy to see that the presence of these two cases makes things exciting.
Specifically: if an attacker can construct a message that triggers the “evil” case, her request for a signature will actually result in her obtaining the scheme’s secret key. From that point onward she’ll be able to sign any message that she wants — breaking the UF-CMA security of the scheme. Or if you prefer a visceral example: imagine requesting a signed certificate from LetsEncrypt, and instead obtaining a copy of that authority’s signing keys? That’s what the evil case gives us.
In fact, the only way this scheme could ever be secure is if we could somehow rule out the “evil” case happening at all.
More concretely: we would have to prove that no attacker can construct a message that triggers the “evil case” — or at least, that their probability of doing so is negligible. If we could do that, then our scheme would actually turn out to be exactly the same in practice as the original scheme S. And since we’ve already stipulated that S is a secure signature scheme, this means
would be too.
In short: what we’ve accomplished is to build a kind of “master password” backdoor into our new scheme . Anyone who knows the password can break the scheme. Everything depends on whether the attacker can figure out that password.
So what is the “backdoor”?
The message that breaks the scheme isn’t a password at all, of course. In reality, it’s a computer program.
More concretely, it’s a piece of software that can be decoded and then executed on some input by some an interpreter that runs within the signing algorithm. If we’re being computer scientists, we’d say the message contains a program for a universal Turing machine (UTM), along with a unary-encoded integer t that represents the number of timesteps that the machine should be allowed to run for. However, it’s perfectly fine if you prefer to think of the message as containing a hunk of Javascript, an Ethereum VM program combined with some maximum “gas” value, a .tgz encoding of a Docker container, or whatever other executable format you prefer.
What matters is not the structure of the message, but rather the program it encodes.
A program that successfully triggers the “evil case” — the one that causes the scheme to spit out its secret key and destroy its own security — must contain a program that contains an efficient (e.g., polynomial-sized) implementation of a hash function P that is identical to (or at least similar to, in a manner we’ll discuss below) the random oracle H.
Let’s briefly think about what this means.
Case 1: in the random oracle model
Recall that in the random oracle model, the “hash function” H is a random function. Since the description of a random functions has exponential size (in its domain), none of the parties are likely to “know” the entire function. Instead, the description of the function itself lives inside a magical third party — the random oracle — which keeps track of it and evaluates the function for them.
Imagine an attacker wishes to trigger the “evil case” in our broken signing scheme.If we are in the random oracle model, the attacker would need to somehow download the the function table from the random oracle, and then “encode” it into a reasonably-sized (i.e., polynomial-sized) program that they can send to the signer as a message. Yet this seems implicitly challenging: even if the attacker can somehow download the function and encode the program, the resulting program would be exponentially-sized. Simply constructing such a program (let alone transmitting and having the signer evaluate it) should not be achievable in a world where the attacker must run in polynomial time.
(Of course, we’re leaving out how the signing algorithm checks that the function P is identical to H, so this leaves some wiggle room for P to just be somewhat identical. We’ll address that much further below.)
So intuitively under this description— and note I am still leaving aside numerous details, like how the signing algorithm actually verifies whether the given program “implements” the random oracle — the attacker should not be able to succeed at formulating such a program, except with negligible probability.
This is hardly an exhaustive security analysis. But at a high level our argument should clear: in the random oracle model, the scheme is secure because the attacker can’t know the backdoor “password” that breaks the scheme. Having eliminated the “evil case”, the scheme
simply devolves to the original, secure scheme S.
Case 2: In the “real world”
We’ve already noted that the random oracle model is a polite fiction. Out in the real world, we don’t use random oracles. When we want to implement a scheme that has a proof in the ROM, we must first “instantiate” the scheme by substituting in some real hash function in place of the random oracle H.
This instantiated hash function must be efficient to evaluate and describe — meaning that it has a polynomial-size description and can be evaluated in polynomial time. If we did not require this, our schemes would take forever to execute, and this type of cryptography wouldn’t make any sense. Moreover, we must assume that all parties — including the attacker — possess a description of the hash function. This is merely a statement of Kerckhoff’s principle.
With these facts stipulated, the problem with our signing scheme becomes obvious.
In this setting, the attacker actually does have a short description of the hash function H. In practice, it will probably be something like SHA2 or Blake2. But even if it’s some weird, crazy obfuscated function, the attacker is still expected to have a program that they can efficiently evaluate. Since the attacker possesses this, they can easily encode that knowledge into a reasonably-sized computer program.
To reliably break the signature scheme, all the real world attacker needs to do is take her copy of the hash function, turn it into a UTM program for P (or a piece of Javascript or whatever) and send in to the signing oracle to be “signed”. When the signing algorithm receives this code, it will perform some kind of test of this function P against its own implementation of H, and — when it inevitably finds a match between the two functions with high probability — it will output the scheme’s secret key.
Hence, out in the real world our scheme is always and forever, totally broken.
A few boring technical details (that you can feel free to skip)
If you’re comfortable with the highly-imprecise technical intuition I’ve given above, feel free to skip this section. You can jump on to the next part, which tries to grapple with tough philisophical questions like “what does this mean for the random oracle model” and “I think this is all nonsense” and “why do we drive on a parkway, and park in a driveway?”
All I’m going to do here is clean up a few technical details.
One of the biggest pieces that’s missing from the intuition above is a specification of how the signing algorithm verifies that the program P it receives from the attacker actually “matches” the random oracle function H. One obvious way to do this is to simply evaluate P(x) = H(x) on every possible input x, and output the scheme’s secret key if every comparison succeeds. But doing this exhaustively isn’t practical. (Imagine testing every input to the SHA2 function, and you’ve got an idea of why this approach won’t work.)
The MGH paper proposes a very neat way to tackle this. They propose to test the functions on a few input values. More specifically, they propose checking that P(x) = H(x) for values of where q is an integer such that
. Here
represents the length of the encoding of program P in bits, and k is the scheme’s adjustable security parameter (for example, k=128).
What this means is that to trigger the backdoor, the attacker must come up with a program P that can be described in some number of bits (let’s call it n) , and yet will be able to correctly match the outputs of H at e.g., q=2n+128 different input points. If we conservatively assume that H produces (at least) a 1-bit digest, that means we’re effectively encoding at least 2n+128 bits of data into a string of length n.
If the function H is a real hash function like SHA256, then it should be reasonably easy for the attacker to find some n-bit program that matches H at, say, q=2n+128 different points. For example, here’s a Javascript implementation of SHA256 that fits into fewer than 8,192 bits. If we embed a Javascript interpreter into our signing algorithm — why not? ¯\_(ツ)_/¯ — then it simply needs to evaluate this given program on q = 2(8,192)+128 = 16,512 different input points, compare each result to its own copy of SHA256, and if they all match, output the secret key.
However, if H is a random oracle, this is vastly harder for the attacker to exploit. The result of evaluating a random oracle at q distinct points should be a random string of (at minimum) q bits in length. Yet in order for the backdoor to be triggered, we require the encoding of program P to be less than half that size. You can therefore think of the process by which the attacker compresses a random string into that program P to be a very effective compression algorithm, one takes in a random string, and compresses it into a string of less than half the size.
Despite what you may have seen on Silicon Valley (link is NSFW), compression algorithms do not suceed in compressing random strings this much with high probability. Indeed, for a given string of bits, this is so unlikely to occur that the attacker succeeds with at probability that is at most negligible in the scheme’s security parameter k. This effectively neutralizes the backdoor when H is a random oracle.
Phew.
So what does this all mean?
Judging by actions, and not words, the cryptographers of the world have been largely split on this question.
Theoretical cryptographers, for their part, gently chuckled at the silly practicioners who had been hoping to use random functions as hash functions. Brushing pipe ash from their lapels, they returned to more important tasks, like finding ways to kill off cryptographic obfuscation.
Applied academic cryptographers greeted the new results with joy — and promptly authored 10,000 new papers, each of which found some new way to remove random oracles from an existing construction — while at the same time making said construction vastly slower, more complicated, and/or based on entirely novel made-up and flimsy number-theoretic assumptions. (Speaking from personal experience, this was a joyful time.)
Practitioners went right on trusting the random oracle model. Because really, why not?
And if I’m being honest, it’s a bit hard to argue with the practitioners on this one.
That’s because a very reasonable perspective to take is that these “counterexample” schemes are ridiculous and artificial. Ok, I’m just being nice. They’re total BS, to be honest. Nobody would ever design a scheme that looks so ridiculous.
Specifically, you need a scheme that explicitly parses an input as a program, runs that program, and then checks to see whether the program’s output matches a different hash function. What real-world protocol would do something so stupid? Can’t we still trust the random oracle model for schemes that aren’t stupid like that?
Well, maybe and maybe not.
One simple response to this argument is that there are examples of schemes that are significantly less artificial, and yet still have random oracle problems. But even if one still views those results as artificial — the fact remains that while we only know of random oracle counterexamples that seem artificial, there’s no principled way for us to prove that the badness will only affect “artificial-looking” protocols. In fact, the concept of “artificial-looking” is largely a human judgement, not something one can realiably think about mathematically.
In fact, at any given moment someone could accidentally (or on purpose) propose a perfectly “normal looking” scheme that passes muster in the random oracle model, and then blows to pieces when it gets actually deployed with a standard hash function. By that point, the scheme may be powering our certificate authority infrastructure, or Bitcoin, or our nuclear weapons systems (if one wants to be dramatic.)
The probability of this happening accidentally seems low, but it gets higher as deployed cryptographic schemes get more complex. For example, people at Google are now starting to deploy complex multi-party computation and others are launching zero-knowledge protocols that are actually capable of running (or proving things about the execution of) arbitrary programs in a cryptographic way. We can’t absolutely rule out the possibility that the CGH and MGH-type counterexamples could actually be made to happen in these weird settings, if someone is a just a little bit careless.
It’s ultimately a weird and frustrating situation, and frankly, I expect it all to end in tears.
Photo by Flickr user joyosity.
Notes:
* Intuitively, this definition sounds a lot like “pseudorandomness”. Pseudorandom functions are required to be indistinguishable from random functions only in a setting where the attacker does not know some “secret key” used for the function. Whereas hash functions are often used in protocols where there is no opporunity to use a secret key, such as in public key encryption protocols.
** One particular hope was that we could find a way to obfuscate pseudorandom function families (PRFs). The idea would be to wrap up a keyed PRF that could be evaluated by anyone, even if they didn’t actually know the key. The result would be indistinguishable from a random function, without actually being one.
*** It might seem like “assume the existence of a secure signature scheme” drags in an extra assumption. However: if we’re going to make statements in the random oracle model it turns out there’s no additional assumption. This is because in the ROM we have access to “secure” (at least collision-resistant, [second] pre-image resistant) hash function, which means that we can build hash-based signatures. So the existence of signature schemes comes “free” with the random oracle model.
**** The “except with negligible probability [in the adjustable security parameter of the scheme]” caveat is important for two reasons. First, a dedicated attacker can always try to forge a signature just by brute-force guessing values one at a time until she gets one that satisfies the verification algorithm. If the attacker can run for an unbounded number of time steps, she’ll always win this game eventually. This is why modern complexity-theoretic cryptography assumes that our attackers must run in some reasonable amount of time — typically a number of time steps that is polynomial in the scheme’s security parameter. However, even a polynomial-time bounded adversary can still try to brute force the signature. Her probability of succeeding may be relatively small, but it’s non-zero: for example, she might succeed after the first guess. So in practice what we ask for in security definitions like UF-CMA is not “no attacker can ever forge a signature”, but rather “all attackers succeed with at most negligible probability [in the security parameter of the scheme]”, where negligible has a very specific meaning.
Article Link: https://blog.cryptographyengineering.com/2020/01/05/what-is-the-random-oracle-model-and-why-should-you-care-part-5/