Managing secrets in your DApp with Derek Pierre
ETHGlobal·Fri, Oct 9, 2020, 12:00 AM
Managing secrets in your DApp with Derek Pierre from NuCypher
Transcript
hi everyone sorry about the wait my name is Derrick Pierre and I'm a head of business development at new cipher I know you're wondering why business guy is doing this talk but I'm also a software developer so new cipher lets me do both I'm here with my colleague Ryan Caruso so you can come check us out throughout the weekend and I just want to talk to you a little bit about new cipher today we are the rehab of privacy layer for decentralized apps so for those of you wanted to build privacy-preserving apps we are the go-to solution for that at least we think so and so just a bit about us I mean a lot of you guys hopefully we're at the opening ceremony so on labor on this for too long but basically we build cryptographic infrastructure for privacy preserving apps and you know sort of specific to blockchain we have our data privacy layer which is our new cipher network which helps with secrets management and dynamic access control so management of sensitive data and so you know I'm sure most of you want to you know build a D app this weekend but you know I just going to go through sort of where we fit in this space and why apps tend to need us especially when they're dealing with sensitive data so how do you how would you share data in a scalable trust trusted way or trust this way sorry and so usually you know people start off and they say well I'll just use public key cryptography that's great you know we all know buddies symmetric crypto private public keys if you are Alice and you have data encrypted for Alice has data encrypted for herself under her LAN public key if she then wants to share that data with Bob she has to decrypt it first and then encrypt the data with Bob's public key and you know same goes for Charlie if there's multiple recipients and that's all well and good but if you dig into that a little bit more you'll see some some limitations so the first question is you know does it scale so maybe if you just have to encrypt for Bob and Charlie that's sufficient but if you have to do that for a hundred a thousand ten thousand people that would be very cumbersome also think about if you know each of these people wanted to access that data from x Alice would have to sit down and do this a bunch of a variety of times throughout the day clearly the it just doesn't scale very well oh and feel feel free to ask questions as I go through here so the next problem is you know the ability to do this decryption you know where does that happen so you know the most secure thing is probably for Alice to do this on her client so Alice would decrypt the data locally and then send that encrypt send the data encrypted for Bob you know after she's done that but you know that obviously means that Alice has to be online to do this so that's not really convenient and so usually what happens is that use a service so that's like your Google Drive your Dropbox etc and you have this service share this data for you so like share with the link in Google Drive which I'm sure you guys let me use earlier and so now what you're doing is you're really trusting a server to with your data because at some point that data is decrypted so at some point that it is decrypted on the server you have malicious actors trying to get in and hack into the server or maybe even malicious actors working for the service right so you know that's not ideal and then you're in this sort of decentralized arena or environment and now you no longer have a centralized service to do this for you so now maybe you're using IP FS to store your data in a decentralized way but if you're storing data on an IP FS node that node is somebody's computer in their basement and server-side decryption is just not going to cut it in this case the malicious actor is the node or could be the node itself so them seeing your data and playing taxes on not ideal so then you're like well like what the heck do I do now and that's where sort of new cipher comes in so we use something called proxy re-encrypted and all that is it's just a more scalable form of public key cryptography that so still asymmetric crypto but it basically allows this untrusted entity a proxy to transform or rekey encrypted data from being under a particular public key into being under a different public key and it does this without that decryption step nor does the proxy have to know private keys right so it just is this ciphertext a ciphertext transformation and the proxy never sees plaintext data so you might be wondering well you know that's strange how the heck does it do that well the only way that proxy can Rhian crypt the data is by the data owner Alice creating this thing called a rien Krypton key that rien Krypton key is generated from Alice's private key and the recipients public key so you generate one of these per recipient essentially and once generated you can't like derive Alice's private key from it so Alice will generate this rien Krypton key is Shu it through the proxy and the proxy says okay now that you've given me this rien Krypton key it means that you know let's say it's a rien Krypton key for Bob it means that I can now reinforce pub Alice's public key into being encrypted under Bob's public key and again that's the only thing the proxy can do the proxy never sees plaintext data and the same can be done for Charlie so basically you can encrypt data once under your own key and then delegate access to your data by issuing this Rhian kripp ssin now the other part of it is that you might be wondering well you know what about data size right like what if I have a gig of data that needs to be reinforced unreason does that take longer than a kilobyte and that would be a valid question so what we've done instead is you can encrypt data with a symmetric key and then encrypt the symmetric key with the public key so that encrypted symmetric key we call a capsule so you basically have an encrypted key and then the actual encrypted bulk data so now if you think about it the only thing that needs to be rien is just the capsule yeah the symmetric key so the symmetric is just so the symmetric key is symmetric key cryptography it's the same key used for encryption and decryption right so you encrypt data with this symmetric key and then you encrypt that symmetric key with your public key and so now the thing that gets transformed by proxy encryption is just the capsule so now the recipient would then encrypt the capsule get that so now the capsule is encrypted under their public key they decrypt it to retrieve the symmetric key and then use the symmetric key to decrypt the data right hopefully that makes sense so it's a little bit of indirection but what it what it enables is that it's now a fixed size because the symmetric key is bytes so whether your data is a kilobyte or a gigabyte because you're only to re-encrypt in the capsule not the data itself you're always Rhian cryptid in the same size and so let's just go through sort of how how that would work so you're the sender the sender has to bulk data that bulk data is encrypted with a symmetric key the symmetric key is encrypted and you store that data in storage somewhere like we're storage agnostic it doesn't matter where you store the data and then the sender decides I want to delegate access to this recipient so the sender will obtain the recipients public key to then generate that Rhian krypton key and then issue that Rhian krypton key to the proxy now the sender's already granted access so the sender can go away doesn't have to be online that's how we solve the Alice having to be online problem and now when the receiver wants to actually access that data they go to storage get the data that was encrypted obviously that data was encrypted for them so they don't have access to it they did you see garbage they then take the capsule send that to the proxy the proxy Rhian crypts the capsules that now that capsule is encrypted under the recipients public key the recipient then decrypt the capsule gets the symmetric key decrypt the data and you know bro you could do this over and over again for you know bulk data for you know chunked however you decide and the beautiful thing about proxy encryption unlike public key cryptography is that you could actually revoke as well now just to clarify what I mean by revoke is that regardless of what crypto scheme or crypto system you're using you can't revoke access to data that's already been obtained right if I see your address you can't revoke access to your address right this is more along the lines of if you think about continuous data so if you think about things like let's say you have a heart rate monitor and you're monitoring your heart rate every minute or every second or whatever what revoke means is that you're know from from the point at which the revoke happens any further data can no longer be access any data that you access before that that's fine you've already seen it we can't you can't unsee it but from that point forward data is no longer going to be Rhian cryptid so the way that revoke works is that the sender just says hey proxy delete the re encryption key now the proxy can't Rhian crypt for the receiver anymore and therefore the receiver can't access your data and if any data from now onward yeah so we sort of look at it as there's a there's three main benefits of using proxy encryption one is that now Alice can go away and have the prop like Alice issues access policies and then can go away the proxy handles enforcing those accesses to those access policies the next part which I'll talk to and I'll talk about it a little bit is that you can disaggregate the data owner from the data producer because of this axis you can sort of issue access policies but still have data be generated in the backgrounds and the other part is revocation so those are the three big benefits of proxy encryption I thought I saw hands Riaan computing yeah so you're gonna see that in a few few slides but great great question you'll see like I'll talk about the incentives for the proxies so what we've done is instead of having one proxy so if you think about if you just had one proxy you have an availability problem right like if that proxy goes down your data is not now not going to be Rhian cryptid and therefore you're kind of screwed so what we've done is we've sort of we've created a scheme called umbral and umbrellas a threshold split kiri encryption so that's a lot of words all it does is that instead of having one Rhian Krypton key go to one proxy you take that one rien Krypton key and split it into a number of shares is to each share to a different proxy and then require a quorum of those proxies to come together to have to re-encrypt the data so to explain that let's say so you could do something like a 305 threshold where you say I'm gonna split the Rhian Krypton key into five shares those five shares are gonna go to five different proxies and now I'll require any three of those five proxies to be needed to get the data re encrypted and so that's how you create this like DS relized kind of network of proxies yeah so that quorum you specify as that policymaker so you're Alice you say I wanna issue this access policy for Bob and I want to force Bob to have to require three out of five or two out of ten it doesn't matter it's tunable so you could tune it to your threat model so the quorum is what bob has to do so instead of talking to one proxy to get the capsule Rhian cryptid bob has to talk to those exactly he has to talk to multiples of them instead yeah yep and III any three not five you could say five oh five but again you still an availability problem if one of those proxies goes down your data is not gonna get ripped it right because you could only get four out of the five so don't don't yeah don't don't think about it as peace you know one two three four or five it's five pieces and only three are needed so if you think about it in mathematical terms if I took if you had two variables like you have a system of equations you needed to figure out how to solve for two variables but like I can I can create five different equations and you can take any two of those equations and solve for two variables if it's a two variable equation so that's sort of the underlying math of it but that's what we mean by don't think about it as like piece one piece two like each piece only provides information that you can exactly so the way we do it is with Shamir's secret sharing but instead of like sharing a secret the secret is the Rhian shinky and so this M event threshold and so we use this key encapsulation mechanism that's the capsule that I was talking about earlier and one of the interesting thing is remember that the proxy is taking in ciphertext pushing out ciphertext so if you think about sort of security with encrypted data you're not supposed to be able to tell the difference between ciphertext and garbage so you might be wondering well what if a proxy produces garbage right like if a proxy just returns garbage to Bob Bob how would Bob know that that's the data was correctly re encrypted so each proxy when they do a rien krypton produces this cryptographic proof that proves that they have performed the correct Rhian ship and so Bob can check that to ensure that the proxy is produced correct data and so what we've done at new cipher is we have a decentralized or recreating a decentralized network of nodes that act this decentralized network of proxies essentially that perform this Rhian krypton for apps so it's just like a it's like a service a decentralized service that apps can use to facilitate data sharing and so it's decentralized permissionless and censorship resistant all we mean by that is this threshold allows proxies to go down but you can still use it it's decentralized in that we as a company we only run a subset of the nodes but the general public can run nodes on our network and provide this ring krypton service so if you have some machine you can provide the reinsert us if you run our code and we have a like an incentive model for that which I'll talk about in the next few slides it's extensible in that you know right now we provide proxy encryption as a service but potentially you can add Shamir secret sharing like just raw your secret sharing has another service on the network that the nodes just run and one of the cool things is if you decide to use their API we've written it as characters so in typical cryptography you hear about Alice and Bob we added two more characters and our code is written as in Alice grant to grant access or bob dot retrieve to get the data and I'll show you that in a little quick demo time permitting so we have Network characters there's Alice and Bob Alice's typically your data owner or Bob as a recipient we added two more characters one is enrico so that's what I mean by proxy encryption allows you to separate the data owner from the data producer and the way to think about a real good easy way to think about it is think about if you have a smart watch on and that smart watch is producing data for you you could tell that smart watch hey encrypt data with a particular encryption key and all that smart watch does is produces data and encrypts it with that particular encryption key but it's encrypted for me and I can decide who I am Alice I can decide who has access to that data so there's that difference and then Ursula who's the character name for the proxy right so this is the this is the example of Enrico and Rico could be like anything it could be like an IOT device it could be your car it doesn't really matter all you do is you tell Enrico encrypt data with a particular key and Rico doesn't know anything about data sharing doesn't know who Bob needs to be all it knows is that it's encrypting data with this key and Alice decides who has access to that encrypted data Ursula does the Rhian Krypton as you mentioned earlier and so also with instead of just having like rien Krypton Keys you can build policies around this and what do I mean by policies that you can make it things like time base so I can say let's say you're working with a contractor you're only working with them for a month you only want to grant re-encrypt into them for a month so you could say here's an expiration on the access policy only allow this access policy for a month and once the month is done Ursula will get rid of the key no longer re-encrypt for the the contractor that's the end of it later down the road we're looking into you know you do things like conditional proxy encryption so only re-encrypt if payment was made so like you could think of you know somebody paying you for your data he said and then you could do things like execute this check this smart contract to see if conditions are perfect for rhe encryption or some condition has been met and so you're wondering how do we trust the Ursula nodes so we trust these little nodes two ways one is we have a token so all nodes on our network have to stake or token or our projects is a bit different than other projects we don't use our token for payment it's purely for staking so that stake acts as like a security deposit so if Ursula nodes ever act maliciously or incorrectly re-encrypt data their deposit gets slashed so that's believed that economic incentive for them to act appropriately it also reviews a proof of proof of stake mechanism so you know work is allocated probably probably probabilistically based on stakes so if you stake you know 5% of our nodes of our of our tokens sorry you probabilistically get 5% of the work in terms of rien krypton work and this zero knowledge proof that I mentioned earlier Bob can issue that can send that proof to a smart contract and that smart contract will slash that Ursula if it's verified that they that they are encrypted incorrectly and some of that is based on the key so if if we detect that data is still being rien cryptid for a key that's been revoked it'll get slashed and so this is sort of an just an overall architecture of what it looks like Alice can issue a policy to the if they're in blockchain she then sends out these policy arrangements to the to the our network here she could then provide enrico with an encryption key and reco produces data of some sort or Alice can produce the data herself talk to her Bob then tries gets the data has to get it rented from the network and then the Ursula's get paid essentially and fees for Ursula's are paid in 'if not in new right so the new work token is only for steak some early users you'll notice a lot of medical data so if you could think of something like patient control medical records let's say you're a patient you go to see your doctor you can selectively grant access to your doctor for that visit or for some period of time if you decide you want to go you want to change doctors for some reason you can revoke access the doctor and then grant access to your new doctor there's this concept of data market places like datum where you can sell your data to marketers or advertisers like for instance Facebook makes money off of you right now but you could decide I want to sell my browsing history to some advertiser for some reason because I fit their demographic I could say okay if you pay me I'll then selectively grant grant you access to my data sharing economy you can think of like a decentralized air B&B where if you pay to rent the the property then that data gets selectively re-encrypted for you because now that you've paid you deserve to get information on the property so I just want to show you a quick demo we have a we're on public test net on Gourley so we have a network of nodes so this is nodes on our network I don't know if you guys can see that we have about 91 active nodes right now all staking new these are a bunch of the nodes here this is one of them one interestingly that I run and so what I'm going to do is I'm going to use this network to re-encrypt some data so what I did beforehand just to save time on this demo I have a Gore Lee a Gore League F node running here this is alice alice has granted access to a Bob using this command to save time executed the command beforehand so what alice is doing here she's granting access this is how she learns about the network this is Bob signing key that's how you prove Bob is who he says he is this is Bob's public key is encrypting key this is a label so what labels are like logical groupings of data so you could say things like a label could be like a folder or my health data or my work data for instance I set an expiration on it for two days from now this is the threshold I just used one of one for demo purposes this is just to connect to the network and this is me specifying the payment I'm gonna make two Ursula's that control this policy and so Alice basically issued this policy and now I can so this policy hasn't associated encrypting key here so now I can say when I say our our stuff is written as characters you'll see what I mean here so this is new cipher this is new cipher commands I have Enrico commands here by the way our cold use quote is written in Python this is just a CLI to the Python so I can just say Enrico encrypt I can specify a policy encrypting key for him to use which was the key that Alice just specified and I can provide a message says eath I lose fun right so that produced this message kit so this message kit is that capsule and data that's been encrypted right so that data would typically be stored somewhere on some storage you know for demo purposes it's not and so now again written as characters you can see what Bob can do so Bob can do a few things I can say Bob retrieve in other words this is Bob to go get the data re encrypted and and decrypt it himself so what do I need I need a label which I had as eath Waterloo I believe I need the policy encrypting key which is here I need Alice's verifying key that's to prove that alice is who she says she is that's here whoops obviously I need to provide the message kit that needs to be rien right because Bob can actually read that I need the special specify the teacher on the network and I'll put debug so you can see what's going on yep exactly so Enrico encrypted for that policy key that I specified that Alice created based on the label and so that data is encrypted under that key and now what Bob is doing he's gonna take that data get it Rhian cryptid get the capsule re-encrypted by the proxy and so that now he can decrypt it himself exact he's gonna get the symmetric key exactly the capsules gonna get Rhian cryptid symmetric key is gonna be obtained symmetric key to get the data right so what Bob's doing here is just learning about the network we have sort of a slow learn of the network network right now but that's going to be improved so but Bob number two has to have Bob's private key to be able to get it right because remember the data gets reinforced wall needs a private key to then decrypt the data right so sorry this is so this is the the data that's been Rhian decrypted by Bob's private key it's in base64 because data can be in bytes right so so if I do if I show you that base64 decode and that's that data right so so yeah so feel free to use our stuff check us out we're on the eath Waterloo discord to be honest our devs are on our own discord I'll show the link in a second so you can talk to our devs there if you have any questions we have a bounty here for twenty-five hundred US dollars and that can be split across teams potentially it doesn't have to be one person but just for cool use cases and cool implementations and here are some some cool links to check out we have like a hackathon repo for you to get caught up on proxy encryption and some of these demos and our Doc's dockside Cybercom has a lot more information on there yeah maybe I'll take a few questions before we stop this cuz we started a bit later yeah so disappearing Alice we like to call it exactly you can dump the data you can you can even grant access before you dump the data because you know what key you're gonna use so you can issue an access policy and then Alice can issue an access policy go away she can configure Enrico to continue to produce data and she can go away exactly exactly so that decoupling between the data owner whose Alice and the data producer who's Enrico that's it I mean it's kind of like Alice can go away as well and have Enrico and crit but that's what that's what we called Enrico and then the last one is replication we have a really cool article sorry when you say replication rap vocal yeah yeah we have a really cool articles outlying those three things on our blog if you check it out I'm Justin Justin wrote it he likes to call it disappearing Alice and Rico interrupted yeah scalability yeah so so remember in this case alice is encrypting data once and then granting access to it right so instead of having to encrypt data for each individual person that she's sharing with she only encrypts the data once issues an access policy to to the proxy and then all the other data owners just end up getting the data encrypted without Alice having to do anything yeah she read encrypts per person yeah per per recipient but you remember and again you're only encrypt in that capsule right but that's not something that Alice has to worry about that's why Alice can go away and the capsule is small exactly whoo right so so we don't have remember in that process we don't handle private keys at all right like Alice only issues are' encryption key so the proxy never sees her private key Bob never sends his private key to the proxy either Bob gets back data that's encrypted for his public key so the management of the private key is up to you and your your app yeah well yeah I mean yeah that that's what you want for a private key right like only Alice and Bob Alice and Bob she can control always have control over their own private key and never expose it to any external entity yeah we were we started a bit late but yeah maybe one more brush yeah yeah yeah right yeah yeah so that's where Alice has to think about the labels right because label if you're granting access per label essentially so what she got what she could do is if she wants a per song granularity each song should be its own label and then she creates policies per song exactly yeah exactly so you can think of just think about it like a folder right like if you grind out if you do the label as the folder then everything in the folder is accessible if you do it per file and I'll need he's father right so Ryan and I around feel free to come to our table and ask us more questions if you like and thanks guys [Applause]
Automatic transcript — names and jargon may be misspelled.