A privacy layer for Web3: Unlock the potential of Web3 with the Oasis Privacy Layer with Nick Hynes
Ethereum Denver·Mon, Oct 9, 2023, 12:00 AM
Come learn about the value of privacy in Web3 and how easy it is to add it to your dapp using the Oasis Privacy Layer, a private Ethereum-compatible sidechain where state and transactions are encrypted and visible only to the user and the contract. The workshop explores the potential of the Oasis Privacy Layer, powered by Sapphire, for adding confidentiality to dApps on any EVM network. Nick will further demonstrate how this technology can help developers build privacy-focused applications on the decentralized web, discuss the challenges and opportunities in blockchain privacy and how to add confidentiality to dApps built on EVM networks within minutes. https://twitter.com/nhynes_ Nick Hynes Tech Lead Oasis Network - https://oasisprotocol.org/ Nick Hynes, the Tech Lead at Oasis is working on building the privacy layer for Web3 on Sapphire, the first ever confidential EVM, along with various blockchain applications. At Oasis, Nick has worked on projects such as building the first WebAssembly blockchain runtime that allows executing confidential contracts, created an SDK for authoring them in Rust and TS, and designed and built Parcel, a private data sharing and computation platform; deployed to a wide range of beta customers including Mollie, ADP, Headspace, and Frontend. While a PhD student at Berkeley, Nick worked on secure and private AI. He also holds a M.Eng degree from MIT in EECS with a focus on AI.
Transcript
Oasis privacy layer and then we're going to see a demo time permitting I wanted to do some live coding for you but um since the my laptop is a little weird I'm going to show you how the code works and we'll just walk through it rather than actually watching me code it up hopefully you'll get the idea all right without further Ado let us begin all right so The Oasis network is the basis of Oasis privacy layer I mean that's why it's called Oasis privacy layer it's based on Oasis so Oasis is a layer one scalability architecture That's Unique in that it can provide trusted execution environments to Smart contracts and what this does is it gives privacy to the code running in the code and the state that is in your contract so it does this using trusted execution environments so you can think of a trusted execution environment as a locked box inside of like you have a computer it's in a locked room and it has armed security guards out the outside the door not even the owner of the computer can see what's going on inside so in fact what this is is a special chip essentially inside of your processor that allows that encrypts everything going into and out of the processor and also provides the ability to tell the rest of the world using a cryptographic attestation that this is a very genuine trusted execution environment and that the software inside is correctly loaded and all that good stuff all right so we use trusted execution environments to enable The Oasis privacy layer we'll get into that but I want to let you know that as you build on the Oasis we have this huge grants program uh big ecosystem lots of different developers so there's a lot of interoperability you can use and that's one of the benefits of using trusted execution environments is that all these different apps can just Port directly without too much difficult you don't have to learn new programming languages you just use solidity and hard hat and it's all super fun so what we're going to offer you at so once you're on the layer one of it on Oasis so as a sapphire you get all these nice things like high TPS scalability but mainly privacy like that's what we're trying to offer you here today so now we have that building block which is the Oasis Sapphire layer one and we're going to then turn that into a layer two so we're going to be providing privacy to your layer one dapps with minimal changes to your code if so this is going to be useful for things like dows and so you have secret ballot you're going to see that in just a bit uh did things like keeping secrets on chain proving uh identity data and then having to be interoperable on Jane so like web3 did without the whole off chain in a synchronous component and then gaming things like uh randomized games of chance like where you have like Critical Hits um rewards lotteries and then things like fog of war and you can just easily code that up in solidity by just saying like require a person has like access like can view and then if they do they can return the data so it's a very convenient way to add privacy to your games and build like web 2 games in web3 and of course D5 so I like to say like Mev resistant D5 you can't front run or send which what you can't see so that's like one of those things that you can do if you have privacy all right so again the benefits of Oasis uh privacy layer that you the private variables are actually private and you can use them for your layer one dap you can use the exact same tooling that you've been using for ethereum like hard hat metamask I mean solidity Viper everything you've already know and love and although many many hours of developer experience put into that and you get of course low fees cool things like RNG for your games encryption for like end-to-end encryption and then it just completely easy to use so there's really no reason not to use it except if your layer one if you already have a layer one dap and it has tons of users and tons of tvl and you just want to add privacy without moving people over all right so now that brings in the Privacy layer so the Privacy layer is essentially you you keep your dap on your layer one and then on the Oasis side you have a you have the rest of your contract doing the the secret part so you can think if you're familiar with Hardware enclaves like Intel sgx that gives the untrusted host app this little confidential piece The Oasis privacy layer is like an enclave for web3 it's like an enclave for dapps so you can put the private state of your application on the Oasis side and use the osac private Oasis private layer to bridge back and forth to give your dot privacy without ever moving your dap and you can get started in this in under 15 minutes because of course it's super easy to use it's just solidity and evm and all that nice things so here's a diagram of how it works so you have you so on the on the left side you have the user and that's just your standard your standard web through user now they're going to not even know that Oasis even exists so like what we're going for is that there's no change to the user experience and we do that using a message passing Bridge which you see on the right and a gas relayer so what happens the flow with transaction is the user will submit some transaction on the home chain which I call it ethereum and interact with your layer one ethereum dap now they want to use they want to submit some things privately to the the private side of the of the of the of your entire dot right so what the user is going to do is pay using the gas tokens on that layer 1 chain so they don't even need to have the Oasis gas token and then submit their transaction through the gas relayer like metamask is just going to pop up like one little box say sign message not even sign transaction just sign message and they're going to hit sign not change networks just sign and that will get submitted through the gas relayer to Sapphire Oasis Sapphire where it will then process it with end-to-end confidentiality and then at some time later when you want the results back on your layer one dap Sapphire will send a message back over this message passing bridge to your layer 1 dot where you can do things like unlock tokens create contracts or or modify settings of the Dow doing a contract upgrade maybe so that's the basic idea of the Oasis privacy layer this is a diagrammatic form if you want to take a photo you can you can ask me about it too so soft Oasis privacy layer and Oasis Sapphire are on mainnet today you can use them right now I mean I'm going to show you on testnet because I don't like paying money for stuff but like if you want to use on mainnet you can just like bring your dop today so over here we have the uh the more links and then we also have the links to the Oasis privacy layer so I recommend that if you're interested you scan all of these QR codes and in a couple of weeks we've been doing a privacy for web 3 hackathon where you can win super nice prizes for building on the Oasis privacy layer so if you ask me it's actually pretty easy to get started and if you build a cool dap then you can make some good get make some good private prizes get a head start on the ecosystem fund get some grants should be pretty fun bring home Glory For Your Glory for your team all right so now I'm going to move over to the demo part like that was all very abstract but you got to get the idea I'm going to pause really quick for questions before we get into the demo yeah sorry one sec is it that essentially you need two contracts then one for the app and then one specifically just to handle your privacy on the on the other one thanks any other questions before we get into the demo all right the the crowd is going wild for the demo let's do it now all right all right so here we have the secret ballot demo so what we're going to see in this secret ballot demo is a Dao that's on binance Smart chain testnet and The Ballot Box is going to be on Oasis software so what's going to happen is the votes are going to be collected privately on Oasis Sapphire using the Oasis privacy layer and then only after voting has completed will the final result be sent back to binance Smart chain testnet the votes will not be revealed but actually this case they will because like let's say you want transparency for after voting has been done so what you're trying to avoid here is mainly the first mover Advantage like when the first person votes then everyone else follows so voting will be made public after this poll has been completed and like that's just like one actually three lines of code difference so you don't have to like think too hard you just like write solidity this like a literally require a statement like is voting done like if yes then return the actual vote so you can program literally whatever you can think of into these things like the Privacy is fully up to you as the developer okay so this is a live demo if you actually head to this you can vote too if you could somehow figure out how to get the voting token but anyway let's just begin so we're going to figure out which winter sport is the best and because we're in Denver and we want to I mean it's like a Hot Topic so the first thing we're going to do is push the vote wait so what this means is I have my voting my Dow voting token on binance Smart chain testnet and I need to tell the sapphire side how to like that I can vote so what's going to happen here is I'm going to send a message over the message passing bridge to Oasis Sapphire push vote wait and I'll be able to vote so this is actually going to go away pretty soon because we have this new zero knowledge um bridge that will just allow you to push this data directly it's like read only there's no reason to submit a transaction that's just how it is all right so what's happening right now is the transaction has been submitted to binance Smart chain test net it's a push the vote weight over this is going to invoke the message passing Bridge it's we're going to see the we're going to see the results over here in this on the sapphire side as a log very shortly all right so well if it didn't revert I promised this was working just a second ago it could be the internet being not so great he's like it looks right here that actually succeeded so I'm not really sure what it's going on about yeah I don't get it this looks like perfectly okay yeah see it look it's working this thing's just like gaslighting me all right so right now we were waiting for the bridge to do its thing um the message passing Bridge we're using right now using the um seller bridge but we also have the ability to support other Bridges like multi-chain the any call interface the um the Wormhole one and also um the chain link the chain link Bridge all right so the vote 08 has been pushed we'll see how that looks so the transaction has popped up on the the Dow side all right and now we're going to vote so I need to switch Network to Sapphire really quick just because like this my wallet's a little buggy um but you won't actually have to do this because of the gas really are you going to submit the transaction directly to uh directly through the um to Oasis half Arby's to the gas relayer all right so I'm just going to vote and so the choices are skiing snowboarding and neither I prefer the beach and because I came here from Miami and I'm not interested in this cold weather I say neither but you may have different opinions that's okay all right so I'm going to submit this transaction now to the sapphire test net so it's going to be sending and we should see the transaction pop up um over here okay great so the voting has completed now what's going to happen the voting has actually closed because I was I the termination conditions have been met like I'm voting with a huge amount of Quorum so what's going to happen now is that the message is going to go back over the bridge saying this vote has been closed please record the final result the votes don't actually the voting the actual vote has not been revealed so I want to show to you that the um the data is actually completely private so over here we have the transaction that we just submitted to Sapphire this was the voting transaction so let's look into it so the beauty of Oasis Sapphire is that you we're just doing like this trickery so that we pack encrypted data into the transaction field so that the metamask and stuff continued to work they don't actually look at this data field so I'm going to go into cyber chef and decode what's in this transaction so normally when you're submitting solidity transaction it's just like ABI encoded data so in this case it's actually the seabor struck that's been packed into the data field and it contains the encrypted data um the public key so that we can do uh diffie-hellman key exchange so it's intend encrypted and then the actual encrypted data as well as the nonce for um for security okay so that's so that's how you can see that the data on Sapphire's end end encrypted and how you get confidentiality all right so the bridge has finished its action and it's come back and you can see on the logs that the bridge has sent back the event unfortunately the internet sucks whatever I'll get back to that anyway so that we can see when we go back to the main page ignoring this that very shortly the past the polls will line up and we'll see that the poll has been executed and that will have our ballot back on the Dow contract so here we are which winter sport is the best and the outcome is I prefer the beach sorry guys all right so here's the Brit here's what the bridge does so it's coming from the bridge and then you have that option two was the winner so that was the beach option all right so that's like basically how it works pretty cool well I mean if you ask me but like maybe I mean I built it so of course I like it all right so once again I'll pause for questions because like maybe I lost some people um but otherwise we'll like go into some of the code on GitHub and see how you can integrate into your dap all right so I had actually intended to like code up a doubt for you like live but my computer is too weird so I can't do that so I'll again walk you through what's going on here okay so the back end is super clean for this secret ballot demo the front end is a pile of garbage because I'm not a front end coder but like the back end's super nice all right so check out what's going on so we have The Ballot Box that's the that's the sapphire side contract and the Dow that's the BSC test net side contract all right so here's the way though that the Oasis privacy layer works so you simply import The Oasis privacy layer from our Oasis privacy layer contract and then you say contract Dao is Host this is the host application so you can consider Enclave Host this is the host and all you have to do to set this up is in the Constructor pass in the address of the allenclave side contract on Sapphire and then call this method called register endpoint so it takes a string that's the name of the endpoint and a callback function so it's just like JavaScript so this one in particular is the ballot close callback and it's going to be executed to like record the results of the of the the poll right so over here we have opal ballot clothes this is internal function and all it does is decode the arguments um the library itself checks the security the sender and make sure all like the the context is correct but then all you have to do is decode the arguments and like basically do the thing so the only extra lines that you're doing due to like the Oasis privacy layer are like this function the definition the decoding and returning the results so like three extra lines of code all right so now let's look at the other side on the other side we have The Ballot Box and it's going to be basically the same thing so the interface between these two is this post message interface we're gonna be posting messages back and forth so again we register our endpoints and these are coming from the host and the host is going to be doing post message so one the ballot closed if you recall when I was executing the ballot I voted the ballot has reached the termination conditions so it closes so if the sapphire side is going to post a message calling about called ballot closed back over the bridge to the host side so all you need to do is this extra one line of code saying ballot closed then you ABI encode the arguments and then it sends it over so again another like three lines of code to add confidentiality to your dop pretty nice so what you're not seeing here is like all of the um the checking the network switching and and like gas relayer context stuff all done by the library so it has like first class support for gas relaying first class support for like erc2771 context and also if you want to run this locally you just need to put in this thing called auto switch so you do auto switch BSC so if you deploy locally it doesn't use like a local bridge you can deploy to a test net it uses the test and Sapphire test then if you deploy to mainnet then it uses the maintenance so it's actually super convenient for developers to use all right so that's like basically the staff Oasis privacy layer in a nutshell and then in terms of like just getting this into your adopt it's just you just need to figure out how to split your dap into like the public part and the private part and that's just the hardest part I think the Syntax for it is super easy so you just need to think about how it's done and of course we also have these um the web the hackathons the docs and the grants program so we can very gladly assist you getting these things done because we really want web3 users to have privacy like it's a fundamental right that's what we're trying to make happen through the convenience of the Oasis privacy layer cool thank you for watching everyone I hope that you enjoyed the presentation and if you have any questions you can ask now or you can come up to me after and I mean everything is good yeah so let me the question was do you pay the fees on Oasis when you send the price yeah so you the user pays using the um gas relay so if you're familiar with the eve Gas Station Network the you pay you you approve some erc20 tokens the gas relayer will then send the transaction using their own rows token to Sapphire and then deduct some balance on like the the main net side so basically users don't even need to know that Sapphire exists they just need to approve the gas relayer yeah like it's like really annoying getting these gas tokens so like we're definitely trying to make it so you don't like kyc go to your exchange like no that's that's way too inconvenient yeah good question do you take some basis points or how do you keep the lights on Oasis takes absolutely nothing so this is a completely free service um I mean like all you're like you're paying gas to the validators but otherwise no okay the gas relay or might take a little bit but you can run your own gas reel air it's like no big deal like Oasis actually offers one it's subsidized so any transaction going into and out of sapphire there's just completely at cost yeah we don't make any money thanks cool thank you everyone so much really appreciate you coming to watch this
Automatic transcript — names and jargon may be misspelled.