New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

Secret Contracts: Private Data in dApps – Victor Grau Serrat

Ethereum DenverFri, Oct 9, 2020, 12:00 AM

This talk is from ETHDenver, the world’s largest Web3 BUIDLathon and Community Gathering. ETHDenver’s content is crypto and blockchain focused. Subscribe to our channel to learn more + connect on Twitter: https://twitter.com/EthereumDenver. Speaker: Victor Grau Serrat of Enigma Abstract: Enigma’s Director of Engineering, Victor Grau Serrat will give an introduction to Secret Contracts and demonstrate how to include private data in your decentralized applications. This will take users through installing the Developer release, writing Secret Contracts in Rust, and interacting with secret contracts via Enigma JS. This talk was recorded Friday, February 14, 2020. ETHDenver 2020’s content themes included DeFi; DAOs and Token Engineering (TE); Gaming and Usability; Protocols and Interoperability; and Public Good and Social Impact. Industry experts also weighed in on topics like decentralization, privacy, identity, non-fungible tokens, scaling, governance, diversity, and arts and culture in blockchain technology. The 2020 event was February 14-16 in Denver, Colorado and hosted 2000+ blockchain enthusiasts, developers and community members from 50 countries and 50 U.S. states. 🔴 SUBSCRIBE ETHDenver’s YouTube https://www.youtube.com/channel/UCgz9NU06t_FkT0Py1Vadczw 💡 LEARN ETHDenver’s Official Website https://www.ethdenver.com/ 👋 CONNECT ETHDenver Twitter https://twitter.com/EthereumDenver 📖 READ ETHDenver News on Medium https://medium.com/ethdenver 🛍️ SHOP ETHDenver Official Merchandise bufficorn.com 💬 CHAT Telegram https://t.me/Ethdenver Discord https://discord.gg/jteMn5c 📱 FOLLOW LinkedIn https://www.linkedin.com/company/ethdenver Instagram https://www.instagram.com/ethdenver/ Facebook https://www.facebook.com/ETHDenver/

Transcript

hi everyone and welcome to this talk by enigma happy to be here I'm based in Boulder down there or up the road but I acknowledge that some of you might be traveling for from near and afar and it's always good to see to talk to people in person and be on on the same room so welcome to this talk hopefully you'll you'll get something out of it there's this quick link that points to an article where there's a bunch of resources that you will be relevant to most of these talk so I just want to start with a quick comment in that research shows that people attending talks like this usually walk away retaining at most three key ideas so I want to make it really easy for you and explicitly say those three key ideas that I like you to walk away from from this talk and one is that privacy equals Enigma in the etherium ecosystem and that's about the first third of my talk key idea number two is that analogous to theorem smart contracts we have this notion of secret contracts where we'll talk about privacy and those secret contracts are written in rust and then finally in order to develop those secret contracts we provide a truffle like environment so if you are familiar developing contracts in in aetherium you should feel like a very familiar environment here to hack on enigma so we acknowledge that block chains have a privacy problem in that all all all information that we commit to blockchains are public by default and we believe that these greatly limits the potential applications or limits potential applications in that you cannot compute over sensitive data so this is enigma is solving exactly these this problem where we enable using sensitive data in your applications without compromising on decentralization so and we provide these two layers you can think of a sidechain to aetherium in which we have the Enigma network that runs on node with prostate execution environment which is a special highway technology that it's now fairly commonplace on Intel all inter machines that enables the network to compute over encrypted data and then we use etherium for for verification and reaching reaching consensus and this separation of computation on one layer and verification on etherium allows for greater stability scalability than what is what is possible right now so enigma discovery gonna be the first launch of our network that will publicly enable secret contracts and that happens on a permissionless network it's economically incentivized like in a proof of stake type of network and most important to this talk and this event is that is fully compatible with the theorem so you can develop your standard depth that you might be already working on but have a privacy need and you can offload those privacy computations on to enigma there so first I want to introduce how enigma works and I believe that the best way to how to do this is by telling the story from the perspective of the different stakeholders that participate in in the system so very much like aetherium we we care about about care a lot about the users that participate or that use these tabs the developers that deploy those tabs on on the network and analogous to to the miners we have the workers that execute the tasks so we start with developers writing secret contracts that I alluded to before compile them to bytecode and send them to the Enigma network and those contracts that live on the Enigma network are registered on the on a smart contract on the cerium blockchain that manages them so these are the two the two layers that I mentioned at the beginning where we have a computation layer and a verification layer the way that users interact with the Dubs is by submitting encrypted data to the network that creates tasks then a hash of the metadata of the task is also sent to the enigma contract and aetherium for for for housekeeping purposes or for accounting purposes and then the task is sent to the network then workers in the network receive tasks based on us on a stake weighted lottery the selected workers execute those tasks and disseminate the results across the network and the worker submits the results to the etherium and once that task is verified then payment is released to the to the worker for compensation for computing that task let's talk about the execution model a little bit more in depth so for every secret contract there's an encrypted state that is maintained in in the network and the user encrypts their inputs to the network which are only decrypted inside this trusted execution environment you can think of as a black box that lives within the processor of that computer that not even a person who has absolute and physical control of the machine can access into it so it's a pretty neat technology that Intel introduced about four or five years ago but I we believe that it hasn't really reach mainstream in terms of applications and this is a really interesting use case for for that technology and I believe that for any laptops and computers manufacturer after 2015-2016 it's already comes in by default to the unit to the CPU so then the worker is able to decrypt those inputs with a key that only it knows and updating the estate send it encrypted to the network and then send an encrypted output to the user if that computation produces any outputs and also you can you can have aetherium callbacks where depending on the output of that task or that computation you can trigger events on on a serial so acknowledging that this is you know a hackathon and you might be thinking about what to build I want to come a think about or talk a little bit about what can you build here in November with enigma technology and we are sponsoring three prizes one specific two games one specific to a coin mixer that we have developed and then another one that it's based essentially open to whatever ideas you might have so think about games that require you to hide actions like in the simplest form rock paper scissors or battleships quiz or work competitions like jeopardy or hangman scavenger with secret locations or secret messaging and I want to highlight so here an enigma there are four five of us here at his number I wanna highlight two people hit there in the back Inslee and John who are from our business development team and the people who are constantly thinking about potential use cases and applications of this technology so if you have any ideas I highly highly highly encourage you to run them by them and have a little bit of a brainstorming session because they will be able to provide a lot of feedback they probably have thought about similar ideas before and will be able to support you in in many ways so because this is a hackathon and you know we want to get our hands dirty with this technology I what I want to do now is guide you through the steps of developing a secret contract and I might run out of time before I go over the interaction with the secret contract but so secret contracts I mentioned that it's in rust and you know I we have it we are we are following the is number circuit we were at East Boston 8th Waterloo here we are again and typically developers is like rust why another language it might not be the easiest to hack on to in a hackathon but as you might expect if we are building a cryptographically secure protocol that gives a lot of privacy guarantees we have to choose a language that is good for that not that is easily hackable so hopefully you appreciate that that choice on our part most important so rust is similar to see but is memory safe you cannot have buffer overruns you cannot have memory overflows you just can't you could you don't lose track of pointers the language doesn't allow it it has a very good performance again similar to C it has a great package manager and a wonderful community so you know I think it's worthwhile mentioned that it's the most loved programming it must be for something so if you are getting into Russ over this weekend I can assure you that you'll find a lot of support through online forums and a lot of documentation and a lot of people out on Chad's and such that will be more more than happy to to help you out in addition to the support that we can provide so I want to work I want to walk through the example of building on the millionaire's problem for those of you not familiar with it it's also known as the hours millionaire problem in which you have two or more parties that want to know how who's the richer but they don't want to disclose the amounts to each other right so this is a schematic of the problem where we create secret contract for a millionaire's problem Bob submits his entry with his wealth encrypted to the to the to the contract then comes Alice and also does the same and the contract decrypt those encrypted inputs computes the richest and returns the output in this case the output is not encrypted so that each of them know the result another good thing that you should know is that we have 9/10 secret contracts already developed and on our repo so even if you know nothing of rust and you are not willing to learn much of rust this weekend I can almost guarantee that almost by copy pasting you can get a long long way so just browse these other examples where we have tried to cover most of the functionality that secret contracts can do and just hack your way along by copy pasting so this is one of the contracts that we have there and I want to go almost line by line demystifying how hard this can be if I remove the comments I think it's about 20 lines of code so I think that you know anyone can deal with 20 lines of code so rust the version of Russ that runs inside those enclaves does not provide all the standard functionality of rust so in the first line we remove the standard libraries then we bring packages into scope and this is the glue between the runtime and the contract Eng wasum allows allows reading writing and reading and writing from the state then this other package allows interactions with etherium and and this third package allows serialization and deserialization of custom data structures in and out of the secret contracts so these 23 these lines you just copy/paste don't have no questions asked so then we're going to use we will going to make use of the encrypted state which and we need a key we need a string that will act as a key to that hash map on the state and then we declare we declare our data structures and we do this in this fashion where this truck will have two fields an address and an in an integer that we hold the address of the the user and the net worth of that user and there's a one-to-one mapping to these are age 256 is a hash of 256 to 256 bits that's 32 bytes which is equivalent to the solidity address fill and the other one is an unsigned integer of again 32 bytes similar that maps to one dancing and sign integral of solidity there's we there's a one-to-one equivalency of most of the types as you know in our documentation then we declare the public functions that will be accessible on this contract there will be two one is to add a Millionaire takes two arguments and then is the computer reaches that takes no arguments but returns an address we initialize the public struct that will contain both the public and private functions we declare private functions in this way where we will get a millionaire we will read from the state to get the millionaires that have may have been stored in the state and then we declare the one of the two public functions add a millionaire that takes the anatra sauna and and the amount and we first read into the state get all the billionaires if any that are we create a new millionaire and then we push it into that vector that we got from the state and we write it into the state so it's fairly logical you might need some help with the semantics of specifics to rust but again following examples most of the functionality that you will need is read and write from the state run your computations and return a value so that's a good example and then again at the end we're going to compute the reaches so we here we make use of some very specific rust language where we iterate we get the millionaire's we iterate of the array that we get we find the maximum by by the amount key and we'll return that in the address and if we get nothing out of that search because maybe we are calling this function before we have entered any millionaires we just return an empty address so as I said so that covers writing a secret contract in rust then we provide a development environment a docker network that you can launch into your own machine I mentioned before that enigma network relies on these trusted execution environments that that are specific to some hardware but we provide a simulation environment where you don't need any specific hardware you don't need to worry about that you know you can develop freely without worrying about hardware requirements and knowing that the privacy guarantees will come when you deploy this contract on on test net or maintenance so that's what a detour environment looks like when you launch it by discovery start and analogous to truffle as I said before you run discovery compile and or discovery migrate to compile those secret contracts and to migrate those contracts over the network where you can interact with them so I'm gonna leave it here when I have making sure that I have time for questions will we have a table up there some of us will be there all the time so if you need any help come and talk to us any questions rado clear I hope you got those three ideas privacy equals in enigma in aetherium secret contacts are written in rust and we provide a truffle like development environment to make it easy for you for those of you who have been developing smart contracts to start hacking on enigma thank you Thank You Victor [Music] you

Automatic transcript — names and jargon may be misspelled.