Ethereum Foundation 🛠 Make data portable with TLSNotary
ETHGlobal New York 2023 · 26 Sept 2023 · 13:48
Sinu and Hendrik from the TLSNotary team, part of the Ethereum Foundation's privacy and scaling work, explain how to make data from a TLS session portable. Using multi-party computation between a prover and a notary, the protocol lets someone prove what a web server sent while redacting sensitive parts. A live Rust demo proves receipt of a Discord message without revealing the authentication token, then verifies the proof. The workshop ends with ideas for hackathon projects and tooling.
Topics
From ETHGlobal New York 2023, hosted by ETHGlobal.
Transcript
Hello ETH Global. Um, we are Sinu and Hendrik from the TLS Notary team, which is a part of the privacy and scaling solutions from the Ethereum Foundation. So, first I'm going to introduce you TLS Notary, show you why we built it, how it works, and then Sinu will give a demo of how you can use it for your for your projects. So, first, why do we build TLS Notary? So, I assume everybody knows what TLS is, the Transport Layer Security. So, it allows for a secure way for Alice to get data from a from a web server. And TLS
guarantees that the data indeed originates from the origin and that the data was not tampered with, so that the data is authentic. But, what TLS does not help you with is make that data portable, so you can share it with somebody else. And so, that's where TLS Notary steps in. So, TLS Notary gives you a way to make your data portable and also use your data with with a third party. So, this is more or less what TLS Notary looks like. So, the magic sauce is that we introduce multi-party computation.
So, before we go move further, no um confusion here, so it's not man in the middle. So, it's not that the verifier Bob gets in the middle. No, instead, multi-party computation, Alice and Bob have to work together. They each have a key share to communicate with the server. That way um, Bob um, knows that Alice follows the protocol and cannot cheat about the content of the data and at the same time Alice knows that Bob only sees encrypted information, um, so that Alice is in full control of what she shares with Bob in a later state. So this is also something very
important for TLS notary, is privacy. So TLS notary also supports selective disclosure. So Alice can redact parts from the data before sharing the plaintext data with Bob. And this can also be further enhanced with zero knowledge tools so that you don't uh, that you also can share information about the redacted parts in a way that Bob only knows statements about it instead of seeing the the actual text. Uh, the concept of uh, checking the TLS, um, communication can also be generalized so that you can get generic notaries that check that the data is authentic and in that way, uh, Bob only
checks the content of the data but in this scenario, of course, Bob has to trust the notary before he accepts, uh, the that the data is, uh, trustworthy. So that was very quickly but now the more interesting part, uh, how you can use it for your project. Everyone, I'm just going to give a relatively short demo on how to use our project to uh, query a server for some private information and generate a, uh, cryptographic proof that can be used to selectively disclose a Discord DM to someone else without revealing, uh, the prover's authentication token when doing
so. Um, so first let's hop over to our repo here. So this example is in our repo and you can follow along if you want to. Um, so it's under TLS and examples Discord and we have a read me here for what's going to happen. Uh, so yeah, I'm a prover. I want to prove to someone that I received a private DM. Uh, I don't want to use OAuth. Uh, I don't want the server's help. Uh, but nonetheless, I want to be able to selectively disclose that I received a DM and uh, to someone else. So, here's the Discord web app. Uh, I'm logged in already and I received a message from myself here, "Hi, if Google my joke."
Uh, so what I'm going to do to just get the access token here is refresh and I'm going to go into the browser and I'm going to find an API request that contains my authentication token. And you could definitely hijack this account right now if you wanted to once you see this, but please don't do that. So, here's my authorization token. Uh, so this is what the the browser sends along with my request to the Discord server. I'm just going to grab that. I'm going to pull it out into my example here. So, we just have an environment uh, variable file here. I've already got my access token load loaded into it.
Um, and one more thing that I'm going to need here is the um, the channel ID or like the conversation um, relevant to this message. So, I'm trying to prove this message here from me um, and the conversation ID is just up here in the URL. So, I'm going to generate a um, yeah, cryptographic proof that I received this message and I'm going to show it to someone else. Um, so to do this, we need two different things. So, there's going to be the prover and there's going to be a notary. So, the notary's going to essentially help me do this um, and uh, so yeah, I will just fire that up over here. So, I just started up a notary server. It's kind of generic. It just sits there listening for requests. And on the left side here, yeah, I'm just going to yeah, clear this up.
The left side here will be the the prover flow. So, before I run this, I'm just going to quickly walk through what this actually looks like and how um, you could modify this to do something more interesting than disclosing a DM message. Essentially, you can query anything on the internet and generate a cryptographic proof of its office authenticity, disclose like portions of it to a verifier. So, any web server that supports TLS and any data that you can think of. So, yeah, I'm just going to use our prover library here. So, yeah, we're going to connect to Discord and we're going to connect to the local notary that I have running in that other panel there.
And we're just going to use basically just generic rust tooling the hyper library to construct a request and send it off to Discord server. But, what we've done is we you're essentially exposed to like a generic TLS connection. So, from like your perspective, you just get this TLS connection, you pass it into the request library and you can just interact with APIs as you normally would with any any other connection. But, then afterwards, we're going to finalize it and get a proof. So, yeah, I'm going to just set up some generic configuration for the prover here and it will connect to the notary. They'll perform some MPC-related setup at the beginning
and then after that we're going to actually connect to the application server, send off the request and then get the response back. So, yeah, let's walk through that a little bit here. So, here I'm just constructing the request. This is just the the API endpoint for for Discord's API and I'm going to query for this specific conversation. And I'm going to pass in like the user agent and off token that I just pulled out of the browser. Once I do that, I'm just going to get the response. I'm just going to print it out. And uh from there we will finalize, I guess, the process with the notary and from from there you we essentially do a bunch
of finalization of MPC behind the scenes for you. What you get is this kind of succinct proof of the transcript of all the communications with the server. And then once we um once we get that proof, we can selectively disclose portions of it to a verifier. So I'll just run it here. You're not really going to see any anything interesting, but hopefully it works. This is a live demo, so I'm querying Discord's API right now. And done. So yeah, I just connected to a notary. You see an error there. It's let's just sweep that under the carpet for a second.
It did actually successfully complete. Um So yeah, now it's saved this JSON file here. This is essentially just the the notarized session. So this contains all the private data of the session as well as a signature from the notary. And using all this data, you can construct proofs from it. Um I will go down to the actual proof generation section of this code. Um and you can see that we essentially um Where's the token?
Yeah, here. So we're identifying all the ranges in like the TLS transcript that actually contains like public data and private data. We need to differentiate between that when it when it actually commits. So essentially what I've done is just implemented a simple helper function here, but it just looks for the off token in the TLS transcript, identifies like the ranges in the transcript there. And then we we commit to like the surrounding data as well as the off token itself. And we get like a bunch of different commitment IDs from this. And then later when we actually generate our proof down here, we just say "Okay we want to reveal like the data that corresponds to only only the public ranges and we're going to redact specifically just the off token from the proof.
Um, so yeah, it builds the proof and that also just gets saved down to a a JSON file here. It's a once again, just a small JSON file that uh just contains uh essentially just the proof itself. And then we have another example here is what does the verification process look like for a proof like this? This is just a simple verifier. Uh it just deserializes the proof um from the JSON file and it's um it verifies it for you. So that it's it's pretty simple. You essentially just need to provide like the notary's public key. So in this situation uh we used a notary.
Um so the verifier actually doesn't need to trust the notary that the data is authentic. So we pass in its public key and it essentially verifies the server certificate. Um and then uh it also uh is going to print out uh the redacted TLS transcript. So I'm going to run the verifier and it's done. And I'll just show you the output here. So you get the general gist of what has happened.
Uh so this is the entire like TLS transcript that occurred with the Discord server. Um so uh the prover revealed essentially everything except here you can see that the authorization uh header in the request, which would allow you to hijack their session if they had this, this has been redacted and replaced with X's. Um So the verifier here has done a few things. One, they verified the identity of the server. They checked the server's TLS certificate so they know that this actually came from Discord server. They verified the notary's pub key and in this case they trust the notary so that they know that the data is authentic. Uh and now you can just parse this data out and um I guess your application here could be
like a DM verifier. Uh and it would just look it would just parse the contents of the server response and say, "Oh, look, this this message was in fact sent to this account at this time, and this is the content of it." So, again, you can think of replacing this DM flow with basically any inner uh uh any information on the internet. And uh yeah, that's essentially the demo. I'm glad that it worked for the most part. Um so, yeah, you can go to go to our our um GitHub repo. We have a couple other examples. We have a Twitter DM example, and just some example code for like how to set up like a notary and such.
And then uh Yep that's essentially it. We're also uh yeah, our repo you can find our docs and stuff. And where's the uh Let's Tishon. Here we go. Yeah. So, tlsnotary.org, you can find us there. And uh you can also find our docs as well. Uh great. Thank you. Do you have a question? Yeah. Do you separate the private and wet data app?
Um Y- Well, you have to commit to it first. So, before the notary gives you the signatory signature, you essentially say, "These are the ranges that I'm going to commit to." The notary doesn't see any of that private data. You still have to like identify where it is and then commit to it. Then the notary will sign your commitments, so then you can take those commitments over to a verifier and open specific commitments to the uh to the verifier. Yeah. Are there any other questions? Oh. I think I only got 5 more minutes or so. So, we do have a prize here. Uh hackathon, we have 5K. Our project is very early stages, so you're going to be pretty brave uh and ambitious if you're going to try to use our libraries, but we thought that we'd come here and see if anyone has any cool ideas. You can
just hack on it, see what you can do. Um and yeah, any kind of application, of course, will be super interesting, but any sort of tooling as well, if you want to build anything that just complements or integrates with the protocol generally, that would be extremely helpful as well. And all right, I think I can end it there.
