Managing Secrets in your DApp with NuCypher by Justin Holmes
ETHGlobal·Fri, Oct 9, 2020, 12:00 AM
NuCypher engineer Justin Holmes delivers a remote talk at ETHBoston, an ethereum focused hackathon that took place Sep. 6-8 at Northwest Building, Harvard Campus. The talk covers how and why secrets exist in DApps. ETHBoston was a hackathon organized by ETHGlobal and a team of hackers, developers and enthusiasts interested in building and creating in the ethereum ecosystem. The ethereum focused hackathon took place for 3 days at Northwest Building, Harvard Campus in Cambridge, MA. For more information visit: eth.boston or ethglobal.co
Transcript
let me start by observing that because you have come to this workshop you probably already have some notions somewhere in your head that there's something secret somewhere in the ecosystem of your DF and you're trying to keep that secret across nodes within the politics of your distributed application and that's if that's true that's great whether or not that's true what I want to explore with you over the course of the next 25 minutes is in addition to that the how and why secrets exist in d apps in the first place in other words you don't have to identify as a security application or a privacy application as an application with sensitive data or in some sort of controversy where in one one party has to keep a secret as part of the essence of the app well that the kinds of secrets that you have in your D app are not a function of the the feature set of your DF at all but instead are sort of very rudimentary mundane secrets like wanting to be able to share key is wanting to be able to share access to files that are or maybe in-game elements if you happen to be building a game where the strategy is ruined if other characters don't know them so the reason we call this workshop the the reason that we call the the workshops that we do handling secrets in your in your DF with new cipher is because we are looking to serve D apps that are doing things that we haven't even thought about and we think probably there are secrets to be handled in all kinds of distributed applications not just the ones that may be rushed to our mind thinking about developing new cipher so with that in mind my name is Justin I am I'm in a school bus here in Portland Oregon I don't know if you look for second tour of my surroundings this is my home and I am surrounded by you know various distributed technology here and and musical instruments and I I spend a lot of my days thinking about the ways in which we can bring cryptography and particularly novel cryptographic primitives to usability in particularly mainstream usability for distributed applications um give me just one minute here I'm not I'm not super used to zoom the software here and I'm often forgetting how to do how do I share my screen the green button you're all still there right yeah I think I heard something like a yes there we go how's that can you all see that now you see the new cipher slide I'm sorry I know this is awkward I'm just not very used to zoom yeah great I'm not gonna I'm not gonna do a ton of slides you know decks are not my thing I'd like to show code a lot more than I like to show a deck but I do want to just walk you through a few things so you know here's essentially our vision in new cipher we think privacy is a fundamental human right and we build the tools that developers need to make privacy-preserving applications and again with the proviso that I just went through that precise privacy-preserving applications don't need to be privacy-preserving applications as we know them they also can be applications where privacy is is only an issue sort of on the side as part of the mechanics rather than part of the feature set today we're going to talk to you about our initial tech offering our Ursula character and Ursula provides data privacy and access layer control for D apps and blockchains using threshold split key purakh Siri encryption and a high-level understand that what we do in new cipher is we dredge the world of cryptographic primitives particularly the academic papers from the past 20 years or so when we find something that's interesting and that's never really made its way to the forefront we ask ourselves hmm in a collusion resistant Centene fault atmosphere like the blockchain can this cryptographic primitive be useful in a way that it wasn't useful before the answer for this particular cryptographic primitive again threshold split key proxy encryption we believe is yes and when we find the answer to be yes we build a character that has the power of that cryptographic primitive and when I say a character I'm talking about a friend of Alice and Bob you probably all know Alice and Bob in the traditional public key infrastructure narrative Alice sends a message to Bob using Bob's public key and Bob can retrieve the message using his private key so we've expanded this narrative of characters by thinking about beyond simple public key infrastructure what happens when you have different characters interacting each of whom has different powers so for today because we're gonna talk about our proxy Ari encryption offering I want to talk to you about these four characters Alice Bob and Rico and Ursula Alice is the authority Alice decides who is and is not Bob Alice makes a policy public key everybody that encrypts in the new cipher cryptology while the new cipher proxy der encryption cryptology encrypts not for Bob not for the public key of an individual but for the public key of a policy Alice decides who can and cannot decrypt items that are encrypted with that policy public key okay let's go down to Enrico in the lower left corner Rico is the encrypter Enrico encrypts the data and Rico just continues to dispassionately encrypt data for the policy public key Enrico never knows who Bob is never knows how many Bob's there are doesn't know when Bob was granted access when whether Bob was were revoked access so Enrico just continues to encrypt for the policy public key in a totally permissionless way you know enrico has from you know right permission but not necessary permission from you know other Enrico's Bob or we say Robert the retriever can retrieve secrets on the new cipher Network but only those to which he's been granted access and you could also subsequently say only those to which he's been granted access and not revoked and then the interesting one in the lower right corner Ursula Ursula the untrusted Ari encryption proxy Ursula is capable of rien data without ever seeing a plaintext from having been encrypted for the policy public key to being encrypted for Bob's private key so only Bob only all of the Bob's are able to decrypt data that's encrypted this way and Rico encrypts for the policy public key Ursula re encrypts so that Bob can decrypt it with his private key okay and this is just a very quick overview glance of proxy encryption I'll give you about 20 not even 15 seconds just sort of taken the directionality this diagram and then we'll walk through it you see Ursula in the middle kind of the star of the show alice gives a piece a RK therefore rekey alice gives a piece of cryptographic material called a rekey to Ursula actually to end Ursula's because this is an M of n scheme but that's not necessarily important for your hackathon this weekend we'd love to talk to you about it if you want to understand more the mechanics then Ursula is able to take a secret and re encrypt it for here we show Bob and Charlie Charlie is not a character in the new cipher cryptology is just as often is the case a word that we use for another ball you might imagine for example a decentralized Netflix and I don't want to get so deep into this because I don't want to prejudice what might be your use case but you can go back through and watch this talk and take a look at the slide it's pretty simple here's our website or github our Docs and our discord we'd love to see and hear from you on on our discord sure let's see at Eve Berlin just now we did not get any solid submissions and that made us sad so if you are considering if you're sitting in the room you must be considering her the case we'd really we are really hoping to get some interesting projects this time feel free to jump in the discord even if you don't want to you know you end up not hacking that's fine we'd really love to talk about about new cipher and about what we think are interesting not just interesting use cases because you know that's your creative angle but what we think are the interesting advantages of this proxy encrypting free encryption offering over the public key infrastructure [Music] the song of storms has been on my mind a lot recently because you know the illustrious and highly effective leader of our state I don't know if you heard this recently drew with a sharpie the path of the hurricane that he insisted was going to hit Alabama modifying the path so that it would indeed fit Alabama and there's something about that it's sort of as arbitrary as making it rain by playing an ocarina I'm right except that this is a grown man okay let's look at some code this is the fun part you're all still with me there right yeah awesome so $2,500 bounty for the coolest thing or things you know sometimes we divided up that are made with new cipher we have a few different ways that you can go about that we have a browser extension that we're in the middle of rolling out right now so if what you're making is browser-based definitely hop on into our discord and we will support you and getting the browser extension filled out we have inter-process communications interface you know standard I can see interface if you're doing sort of get stuff oh wait a minute I forgot to switch that's right I need to do zoom to switched you over to you can't see my code right you still see the let me get you over here yeah you see my pycharm now yeah good okay great um so you know the reason I bring up the bounty of now is because I'm you know we we'd love to have people building on our new browser extension and that lets you retrieve secrets so you can like load a web page and you can you know click on something that is a new cipher secret which is to say encrypted by Enrico and then you can load the webpages Bob click on it and then behind the scenes that connects to the new cypher network and and retrieves that secret and so that if you know if that's your angle we'd love to talk to you about hacking on that we also have a you know IPC you know standard inter process communication we have a JSON RPC endpoint and then we also have probably our sort of cleanest and most feature-rich interface is the one I'm going to show you right now which is our Python API so here this is we call this our Finnegan's Wake demo we will recreate one line at a time the James Joyce novel Finnegan's Wake and let's get we've just got sort of some boring setup stuff up here so let's get down here here's where again sort of the star of the show oh I actually you know what I do want to mention to you because I showed you that that the chart there of the four characters that can you see are you still seeing my PyCharm or you see my browser okay am i the only one who doesn't like zoom okay now you see I wish I could see what you see on my screen you know what I mean do you see my browser now yeah okay so this is a we did that this is just a screenshot from our East Denver this is all in our YouTube this is a screenshot from East Enver where I walked through the CLI interface and as you can see there I put Alice in one window Bob and another Enrico and another and Ursula in another so if you're thinking about hacking with new ciphering you want to sort of dig down into the actual CLI commands which gives you a really good overview of sort of which data is needed for each character you might go back and watch this Ethan bird demo and I just wanted to mention that because I you know the little chart that I had in the slide is sort of the same shape there and so here's a way that you can actually get a CLI view of that a super simple chart on the slide okay let's hop over to pycharm now in here okay so we've got you all can see my pocket charm right I have a green green box run it so I assume that's a yes you here here's our slot the trusted the untrusted Ari encryption proxy in this particular Python module what we're simulating here on line 47 is the existence of our test Network now in the real world we have a test net running on Gourley that's been pretty solid and we invite you to hack using that you'll find that the documentation in our hackathons channel of our discord invites you to use that test net and we can also help you to use that it's actually super duper simple to do the test net that way and that allows you to ignore to not even need to do anything comparable to what you see happening on line 47 but here what I'm trying to show you is sort of the full gamut of how the Python API works to share these secrets here's some policy details we're gonna say hey five days from now is going to be our end time our M and end values are going to be two and three which means that Bob Alice will give fragments of that rekey to three Ursula's and bob needs to visit any two of them and so in a way this is sort of reminiscent of Shamir's secret sharing if you're familiar with that technology but again in a to be super clear ursula never sees the plaintext neither those two Ursula's nor all three if they collude are able to see the plaintext so it's different in that sense from some extreme ear secret sharing and here we have a label when we say secret files and stuff and in you know these purposes i've made it look like a file path because i think that's sort of an interesting way to use the label so shares are per label Alice grants Bob on one label that doesn't give him access on another label so thinking about it like a file path this means that you can share one file path with with Bob one and two and five and a different file path of Bob two three and four and so on here we have Alice okay Alice takes Network rest middleware domain which we're actually deprecating now that we're our domains I think are probably just gonna follow test nets we say ow she already knows about Ursula again in the real world our test net serves there and for the purposes of this demo and perhaps if you're using a Python API and trying to sort of tune things you can tell Alice whether discover nodes on the same thread that's an example of sort of the sort of performance knobs that we have in the Python API that aren't available elsewhere and here we say federated only in federated only means that Alice doesn't have to pay and and the nodes are just sort of altruistic that's not how it is in in the real world but for if you want to run if you want to grab our repo and run this particular demo you know it's easier to run it this way since you can run all the characters on locally without needing a you know watch-chain node now Alice can get the public key even before creating the policy in other words before Alice has any notions of granting anybody access on the network Alice can get the public key that all the data sources again can we call enrico I will need to use to encrypt so here you see we get the public key by doing get policy encrypting key from label okay once again that label which is kind of like a file path a different label will produce a different public key for the policy and later we'll see enrico use that here's Bob Bob takes essentially all the same all the same arguments as Alice nothing interesting there Alice starts discovering the network in our CLI and json-rpc and browser extension this happens automatically but in the Python API you get to decide when the nodes start discovering each other which is maybe useful you know that's not an easy thing really to do via the CLI because you have to sort of double dip I don't know we haven't found an interface that we love for that and now Alice grants this is sort of the first interesting thing Alice grants access to Bob on the particular label for those values of M and n we had and the policy expires at the policy end date time two things I want to point out here at this line the first thing is that this it makes a network call which does a whole bunch of interesting things it goes out and sees which Ursula's are staking the new cipher token and the proper amounts to be able to have hold the policy it lines n of them it sends the K flags out and gets receipt responses so that so you know there's there's sort of a lot going on and packed into this grant command but we've tried to make it feel like it's just access management as if you know it the other interesting thing I think to point out here at this stage we've gotten this far is there Alice and Bob these are actual classes in our code base and we think that this is a we think this is really an ideal way to abstract cryptographic primitives in a way to make them useful and we'd love to hear from you about how we're doing in that respect here and we have our lawful characters in in character our new cipher characters lawful dot py and we have here you can see Alice and Bob and Ursula and Enrico are our four main lawful characters again they each have different powers stemming from different cryptographic primitives we also have unlawful characters so we have sort of an alignment structure borrowed from classic tabletop role-playing games here we have Vladimir that serves as an unlawful Ursula Vladimir tries to break the rules of the network and some either a selfish or destructive way and so when we think of an attack that can be performed by one of our nodes we put that attack here on this class and so you can feel free to sort of read what this what this character is capable of doing and how we prevent those attacks on the network that's something that you know I think is really important for anybody that is ostensibly working on privacy attack I think it's really important for them to wear on their sleeve how an attack works and particularly I think it's important to codify that attack in a way that mirrors the proper functionality of the network in other words this is essentially a mirror this class is essentially a mirror this clubber salon you know and so I think that's that's it's very important it's something we're proud of and we invite you to take as deep a dive as you like so back to the narrative here we've got Alice ranting we make a quick assertion we show that the public key on the policy object is the same as the one that was returned here now Alice puts her public key somewhere for Bob to find later Wright takes the takes the bytes of her personal public key which we call a stamp and then we say she just disappears disappears from the internet starting with line 92 you're gonna see something that public key infrastructure cannot do right think about this if you're using public key infrastructure the same party that has the secret looking at the secret ready to encrypt it for the recipient they have to be online at the time that it's encrypted right here we don't have that the party that decides who gets the secret can leave never to be seen again and yes yet still devices that are maybe under Alice's control sometimes we imagine Alice controlling and Rico sometimes not can continue to encrypt for the policy so here line 95 some time pass it is [Music] time to get our time passing and now we have Bob doing sort of the interesting part and say here I'm on line 103 Bob the bit ler because we imagine that what happens in the next few lines is sort of what happens and the internals of your app this is the interesting part where your user gets a secret and can do something within the context of your distributed application so the first thing we do here for Bob is we have him join the policy this is another step that you'll see in the Python API that is not in the others and the other API is you Bob just retrieves that it's sort of all in one step but here we show the granularity of our Python API breaking it down again it just to be clear I'm talking up the Python API because we think it's cool but our CLI interface our IPC interface our JSON RPC our browser extension they're also all fully featured and we are happy to put development investment time into whichever one is is gaining traction in a particular hackathon so over the next couple days if you are wanting the other features built into those other interfaces that aren't there you know let us know we're constantly working on these things you know we're really really excited about each of the interfaces but you know I'm showing you the one that's the most mature of course okay now that bob has joined the policy we're gonna show how when recode the encrypter can share data with the members of this policy and how bob retrieves it we say here we only read some lines in this demo yeah it is limited to 25 lines because we were having people run this and you know encrypting the whole book starts to get computationally expensive you know when you run this demo we'll only do 25 lines but of course you can change that number so here we're going to enumerate the entire book and iterate through it with each line is plain text and we make a new and reco each time so in other words the encrypt you don't have to do that you can use the same enrico over and over again and check that signing feed if the source is in some way important to you a in represents some element of validity but you don't need to you can make a new one for every line and here we encrypt the message and we leave the public key and now we delete enrico just like we deleted Alice now let's go back to Bob okay Bob is gonna reconstruct enrico from its public keys again just to show that what's happening here is we've deleted this object but Bob can still reconstruct it using the policy public key which at first Bob needs and using it's it's this is essentially it's the the public part of its signing key which we're trying to push the words verifying key for and now Bob can retrieve the original message so Bob somehow restores alice's pub key from an ancient scroll wherever you know in your side channel beer app you've got that and then he gets the clear text by here bob dot retrieve and he gets the single single passage here and asserts that it indeed it is the same original plaintext and again in the other other than in the python api you only need to do bob dot retrieve you don't need to do the join policy stuff that also means that you don't have as much control over when the network traffic happens so you know there you get a sense of the the new cypher narrative we are just about out of time so I'd love to quickly switch gears to questions and if I may put a question to you I'd love to hear what it is that well if there's anything we can do in 30 seconds or less what can we do to really get you hacking on new cipher we'd love for a cool project to come out of e Foss and again partly because we now have a browser extension a CLI interface IPC the JSON RPC the Python API we'd love to start seeing these get used now that they're really ready you know a new cipher hasn't really been ready for the big time until recently now we have our GUI test setup and we have these all of this tooling so again I'd love to hear questions from you and and I'd love to hear from you what what what we would need to do to get you hacking oh I'm told we're actually out of time I'm sorry I went a little bit over please do hop into our discord discord new cipher comm really really look forward to talking to each of you and I you know we're we definitely will be around to support you hacking all weekend long if you have any other questions that's a great place to take them up we also can switch over to do both based on disk or it a little later if you like but thank you very much for for your time and we look forward to seeing your projects again $2,500 bounty for you know either the best one or maybe we'll divide it across a couple if there are couple good ones so thank you [Applause]
Automatic transcript — names and jargon may be misspelled.