Exploring Privacy Pass

05 Jan 2019 - Kobi

This post explores Privacy Pass, a protocol which “lets users prove their identity across multiple sites anonymously without enabling tracking”. We will go through the protocol components and eventually see a fully-compatible implementation of Privacy Pass in Rust.

Privacy in the internet

Privacy for users in the internet is often advocated for, and just as often, compromised. This happens for good reasons - creating social networks (i.e., Facebook), allowing smarter usage of our data (i.e., Gmail), convenience of usage (i.e., OAuth - “Login using Google”), Security (i.e., Cloudflare’s HTTPS-for-every-site and Denial-of-Service protection) and many other reasons.

The privacy loss is usually not absolute - it allows privacy against some adversaries. For example, while Facebook has access to your personal data, it takes the responsibility of not exposing it to other users, and does it pretty well.

It makes me glad when these services which potentially compromise privacy also take additional steps to re-introduce it in creative ways.

Cloudflare’s Crypto Week

One of the companies whose trade-offs I like is Cloudflare. I’ve been using their service for many years to easily introduce HTTPS to my websites without having to go through the usual complex processes of obtaining and managing an HTTPS certificate.

A few weeks ago, Cloudflare had a Crypto Week, where each day they posted about newly-developed features, who use cryptography to improve their services, in aspects such as privacy.

Although not part of the Crypto Week, this exposed me to a protocol Cloudflare supports since 2017 - Privacy Pass. This protocol has been developed in collboration with academic researchers and is provided as a service by Cloudflare.

Privacy Pass

The Privacy Pass protocol, as implemented in Cloudflare, attempts solving the following tension:

Cloudflare would like to give access to websites to humans rather than, let’s say, mal-intentioned bots. To do that, Cloudflare requires users to solve a CAPTCHA when they have suspicion. On the one hand, these challenges protect the websites - no non-humans may access the site. On the other hand, false-positives cause inconvenience to users. That puts the burden on Cloudflare to improve their human-detection capbalities without compromising on security too much.

This is where Privacy Pass comes in. It allows a user to solve a CAPTCHA once and use this “proof-of-humanity” later on.

The protocol

Rather than outlying the protocol directly, I’d like to build it step-by-step, to highlight the importance of each of the components in the protocol, and why stopping at that level might not be enough.

Methodology

Methodology-wise, I believe the best way to understand a topic is being able to teach it. In teaching, there are multiple levels. Two of these are teaching another human (outlying the theory, proofs, math) and teaching a machine (implementing it so it can be used).

While teaching another human is highly valuable, some aspects are more readily exposed and understood when teaching a machine. This is one of the reasons I’ve chosen to implement Privacy Pass in Rust - in this way I could see the nitty-gritty details of how Cloudflare and the researchers made Privacy Pass work in practice.

Detecting a human

Cloudflare uses CAPTCHAs to detect humans when suspicion arises. Essentially, Cloudflare presents a challenge with weird-looking letters and numbers:

CAPTCHA

The user then provides the solution to what they think is the solution. If Cloudflare approves it, they allow the user through.

Recall that the goal of Privacy Pass is to carry this “proof-of-humanity” to other situations where the user might be suspected.

So why not, let’s say, when Cloudflare receives a correct solution, make Cloudflare send multiple “passes” which can be used in other sites?

The answer lies in tracking. When Cloudflare would send these passes to the user, they will know that these passes are related to the original CAPTCHA solution, and by so, to the original website where the user saw the challenge.

If Cloudflare would have liked, they could track the user across multiple sites. To show a concrete example:

  • The user, being at home, would have gone to kobigurk.com, see a challenge and solve it, let’s denote the solution . They would send the solution to Cloudflare, containing the solution and natually their home IP.
  • Cloudflare would approve the solution, and send passes . Additionally, they would store in their database the connection between , each and the user’s IP.
  • Next, when the user uses one of the passes in other websites, maybe from a coffee shop having a different IP, Cloudflare would be able to correlate the usage of pass with the user.

Cloudflare could obviously not store this data, and that would require putting the trust in Cloudflare. While they might deserve it, you can do better.

Discerete Logarithm Problem

What if Cloudflare could provide the passes without being able to track their usage forward? Apparently, with some elliptic-curve cryptography, it is possible.

Without diving too much into elliptic-curves, I’ll remind some basic facts.

Elliptic curves, being curves, have points. You can define the operation on points, such that given points and on the curve, you will get a third point which is the result of . To see how to define this visually, you can see it, for example, here.

You can also define adding a point to itself times ( with additions). Call this operation .

You can ask, given points and , “how many times would I have to add to itself in order to get ?” That is, what is the such that ? This is a hard problem in elliptic-curve cryptography, called the Discrete Logarithm Problem.

Blind signatures

Now we begin solving the problem of tracking. First, let’s expand our protocol and describe it in more detail.

Let’s say the secret key of the Privacy Pass server is the number and there’s a publicly known point on the curve called and execute the protocol as follows:

  • The user, requesting passes, will create a random token and send the server the point , denoting it . The server will not be able to know because of the Discrete Logarithm Problem.
  • The server will create the point . Let’s call it a signature and denote it . The user will not be able to uncover because of DLP.
  • The server will send the signature to the user, which later on will be able to use this signature to prove they received it from the server. Since only the server knows , only the server could create , and so the server will know they have created these signatures.

This has the problem of tracking, since the server will be able to store all this data and correlate it to the user when the s is used by the user.

The user, instead of sending directly can use a blinding factor to create . We call this a blinded token. Now, when receiving the signature over each , the user will unblind the signature by multiplying by the inverse of : . Let’s denote this result .

Although the user could cacluate , they could never generate it by themselves - since they don’t know . Presenting the server and allows the server to verify they indeed the ones who generated this signature, and the server will not know which blinded token this signature relates to since they never knew the blinding factor .

The protocol now looks like this:

  • The user, requesting passes, will create a random token and a blinding factor and send the server the point , denoting it .
  • The server will create the point . The server generates a signature .
  • The server will send the signature to the user, and the user unblinds the signature, calculating and storing .
  • The user later on presents and to the server when they would like to prove their humanity.

It sounds very good! Unfortunately, this doesn’t solve the problem of tracking, which might not be immediately obvious.

Assuming the server uses the same secret key for all the users requesting passes, this works well. What if the server uses a different for every user? We’re right back to square one - the server, when verifying the signature, will be able to iterate over all the different s they generated and thus identify the user.

This is why it’s important for the server to show it indeed uses the same secret key for all the users. This is done by using a Discrete Logarithm Equality Proof.

Discrete Logarithm Equality Proof

The server already publishes one point publicly - . The server could publish publicly an additional point . This is essentially a commitment to the secret key .

The construction of how DLEQ works requires a bit more math, and I prefer not getting into it in this post. That said, I would like to give a few points to those interested:

  • It is similar to the Schnorr identification scheme, proving that the server knows the secret key - essentially proving knowledge of “”.
  • It uses the non-interactive variant of the scheme using the Fiat-Shamir heuristic, which also has an IETF RFC, converting it from an honest-verifier zero-knowledge scheme to a non-interactive zero knowledge argument.
  • Instead of only proving knowledge of , it also shows that the same proof applies to . This means that the publicly committed secret key, as shown in , is the same one used to create for , proving that the server used the same secret key to generate the signature.

A nice description of DLEQ and some of these details are described in this post by Matthew Green.

If you would like more details on the math inolved, feel free to reach out.

Finalizing the protocol

By requiring DLEQ, the server now can’t cheat and use different secret keys to track users. To make this protocol usable in practice, some other aspects should be considered:

  • Instead of sending a single token, the user could send multiple tokens to be signed at once.
  • The server should limit the amount of tokens the user can request for each CAPTCHA solution, to prevent abuse by a user dispensing these tokens to other users, essentially making the protection useless.

Implementation

The original open-source implementation of Privacy Pass by Cloudflare and the researchers is available here.

My implementation of Privacy Pass in Rust is available here. Some details about it:

  • It is fully-compatible with the reference implementation, both as a server and as a client.
  • It uses amcl for elliptic-curve cryptography.
  • It uses RocksDB for storage.
  • It is probably compilable to WebAssembly or other architectures with minor modifications.

Additionally, it is easy to modify it to support any kind of challenge-solution use-case: login to systems, voting and many more.

Conclusion

Privacy Pass allows adding privacy to a system where initially it seems impossible, by the use of cryptography. It’s awesome to see that some companies, which have all the means to disregard privacy at the cost of convenience, still go through the R&D and risk required to re-introduce privacy to their systems.

If you found this interesting and have more questions or suggestions, feel free to reach out, I’d love to hear from you!