Lit Protocol 🛠️ A Decentralized Key Management Network
ETHGlobal·Mon, Oct 9, 2023, 12:00 AM
Join David Sneider, Chris Cassano and Debbie Ly from Lit Protocol for a workshop titled "A Decentralized Key Management Network". Welcome to ETHGlobal Waterloo, where it all began! Returning to Canada's tech hub, we're thrilled to bring together international enthusiasts and local talent for an unforgettable hackathon experience. Don't miss out on this exciting opportunity to showcase your skills, collaborate, and innovate with the power of Ethereum. Be a part of the journey that continues to shape the Ethereum ecosystem. Secure your spot today and let's build together at the heart of Canada's tech scene! ----------------- Follow us: https://twitter.com/ETHGlobal​ Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com
Transcript
foreign [Music] hi there my name is David Snyder I'm one of the co-founders at lit protocol and over the course of the next hour you will hear from me Chris Cassano and Debbie as we talk about what is a lip protocol how does it work and how to get started and so the big questions to think about here at the start of this is It's All About keys today we're going to talk about ease key management and the use cases for distributed keys so some of you may know who this is if you have seen The Matrix trilogy this is known as the key maker in that in that film in that film series um but from the perspective of keys if you're familiar with that story what this individual is is a centralized trusted custodian a holder of keys and so if you've seen that film spoil alert it is the centralized holder of keys that gets compromised and in the story lets Neo into the machine um back end so to speak and so I use this example just as a fun example from fiction to illustrate the idea that a centralized holder of ease in our networked era that we are all living in really doesn't make sense and we've been addressing this problem quite specifically over the past few years and so it really comes down to a big question of where are Keys stored and so another way to say this is can the internet keep a secret and what we're going to see today is that the answer is yes and we'll talk about the methods for doing that I'll give a brief overview and then Chris will dive into some more detail but in short lit is a key management Network that uses something called multi-party computation and a threshold secret schemes to hold a key in distributed custody um then developers can use that distributed custody key for the same thing that you use these for in general because encryption and signing and we'll take a look at a number of examples in a moment and some of the core processes at the heart of this are things like distributed key generation proactive secret sharing and secure encrypted virtualization and this is the methods for Distributing the key and protecting the private key material to ensure even the node operators don't have access to it and the really kind of the key Insight here no pun intended is that nobody ever has the whole key the whole nation notion of a distributed key generation is you can have a bunch of parties holding something called a p share and this is a threshold crypto system where you need a threshold of the network work in the case of lit that's two-thirds in order to authorize any decryption or signing with that underlying p so let's talk about the two use cases here um the first one that we'll talk about is decryption so these hexagons here in the middle represent the nodes which are custody in this distributed key again none of them is a centralized custodian none of them have the whole key and these nodes can read data from public State like blockchains and then determine if a rule is correct in provision access to another person so an example of how this might be used is Alice let's say Alice is a content creator Alice can write a book and can encrypt it client-side and then say anybody who buys my nft they should be able to decrypt my book and Alice can take that encrypted blob and store it on a blockchain or store it on a distributed storage Network like filecoin or rweave or ipfs based system like ceramic and when Bob shows up later on he can sign a message and broadcast that to the node that says hi I'm Bob I own Alice's nft please give me the key to decrypt the book and the nodes can validate in this case against the chain data does Bob hold Alice's nft and if yes each of these nodes creates an authorization known as a decryption share and sends it down to Bob and Bob collects those on his machine client-side in order to perform that decryption and so what we've got here is really quite cool because there's client-side encryption client-side decryption but the two parties never had to meet because lit is this network this distributed Network that is validating the rules and provisioning the keys and so another way that this is conceptualized is something called identity based encryption which definitionally at least before this uh offering did require a central Authority here you can see the definition from Wikipedia but again lit is the distributed Network alternative to doing a central Authority identity based or rules-based or conditional based encryption and so let's look at a couple specific use cases if you're familiar with lens protocol it is a social media protocol where everything is an nft what I mean by that is like liking following Etc are all on-train nfts the lens protocol team has integrated lit inside of their SDK in order to create gated posts so when you go and post on lens protocol you can say only collectors can view this which is like the equivalent of liking the post you collect it or only people who follow me can view this post and the encrypted blob is stored on ipfs and only the parties that meet these rules can perform the decryption so all of a sudden this creates like a patreon like benefit to these creators that are are using lens this is also um live in orbis.club for token gated messaging which is another kind of cool use case quite similar but in this case it's more about chat content rather than social content and we can also look about look at this in the context of verifiable credentials so what we're looking at here in this video is um on an application called credit where a user is doing using a third-party service to do kyc or know your customer validation when that proof uh that in this case of some that somebody is over 18 is sent back to the user it's the same process again where the user is going to encrypt that proof client side is going to encrypt that proof client side and um is going to encrypt that proof client side and then can set a rule of selective disclosure around who is able to see that proof looks like there's a little bit of video trouble here but the just a repeat again get some data in cryptic client side it can be kyc data in this example and this is quite interesting because it's also a verifiable credential so it's some signed Json linked data that in this case is encrypted and stored on ceramic and then the user in this case the individual who's over 18 can have the selective disclosure in the form of provisioning decryption rights via lit um to that data let us proceed here and the other ways that this um encryption mechanism is being used is for things like data marketplaces so this is the logo of a project called streamer Network that uses lit to let data producers in create data encrypt it store it on the open web and then set a rule like you must buy this nft in order to decrypt that data set again having it be rules based or condition based is kind of the main Insight around conditional encryption and as mentioned earlier it's not just chain data that you can use for the rules for who can decrypt this but really any data on the web whether you can get it from an API an app request whatever it might be any statement that can be made true or false can be used as an input for this encryption data and it's also worth noting that things like cross-train support Boolean logic all that sophistication if you wanted to implement that in your conditional decryptions you could and those are all in the lit Docs now let's talk about the other part of keys so as you know public key cryptography in general basically has two core features which is encryption we just talked about conditional encryption and signing signing is really interesting because like you have to sign a transaction in order to make an on-chain interaction in order to log something to the distributed Ledger that we call blocking to that state machine and so what we're looking at here is a very similar kind of diagram as you can see it's the same underlying architecture but in this case there is some code some JavaScript code and Chris will talk more about this that dictates when this distributed key should sign um and then the nodes can process that JavaScript and output in this case rather than an authorization to decrypt an authorization to sign and so there's a distributed key that is being managed by this network that is signing based on rules and again it's not just one node that is authorizing a signature but a threshold of the nodes so 20 out of the 30 nodes in the network and so let's take a look at some examples here like one pretty excellent use case for leveraging this is for user onboarding where you can do things like set up Discord or Google or web often as the authentication method where the private key is held and lit in this distributed network but the user's credential in this case oauth from Google or Discord can basically the network can validate that in that 20 out of 30 model that we discussed before and functionally create an authorized transaction from that distributed key so that is pretty exciting as it relates to onboarding if you're building a product that is maybe for non-webtree natives this is also really interesting around decentralized Finance automation so what we're looking at in this video is a project called dot labs and underneath the hood here um there are two parties which are represented by these two windows and there is one of these pkps these programmable key pairs because this programmable key that's cut that's managed by lit that we just discussed and so what is happening here is this team has programmed that pkp or programmable key pair to act as an automated escrow agent for cross-train swaps so Alice is on arbitrum and Bob is on ethereum they can both send tokens to this wallet and when they both approve a swap happens to the other person's address and so as we kind of look along here we can see Alice has set everything up oops we'll go back to that we see Alice has set up the swap and now Bob is sending in from his side and the swap is ready on Alice's side and now the swap is ready on Bob's side and then they can receive the tokens once they've they've sent them to that escrow agent this is really interesting certainly it can apply to swaps but it may be also interesting to explore using this capacity to program keys for structured Financial products such as liquidity loss prevention on dexes um dollar cost averaging stop loss orders on state tokens definitely a lot of room for creativity here and then one more example from credit what we're looking at here is a video where the lit pkp which has the capacity to sign programmatically is being used to issue a verifiable credential so verifiable credential is some signed data some sign Json LD typically and in this case the user is signing into Discord then a lit is validating that that user uh it has has generated that JWT that oauth token if you will um from Discord and lit is essentially signing that and says yes this address in this case is in fact this user but what's nice about the way that this team has implemented it is that um that verifiable credential is encrypted and stored on ceramic in this case so once again it uses that private data it uses that encryption aspect that we talked about before and if you want to look at these demos more in depth you can find them all at theprotocol.com blog and so that about wraps it up for my section um uh I'll include a request for startups if you need some ideas in terms of thinking about what you can build with lit but really the thing before I kind of pass it off to the next person that I'd like to stress here is that like this is really a new primitive that you can think very creatively with if you're familiar with how like Lambda functions work um in or serverless functions uh essentially what lit is is like a Lambda service function and a key management solution but network based that's distributed and fault tolerant I'm really looking forward to seeing what gets built in this event and and interacting with a number of you um and with that I will pass it off to Chris thanks so much hello my name is Chris casano and I am here to talk to you about how lit protocol works lit protocol is a decentralized and programmable Key Management Network what does that actually mean what that actually means is that um lit protocol is a a network of node operators similar to like Bitcoin nodes or ethereum nodes or something like that uh but what the nodes actually do instead of running a blockchain is they provide Key Management Services and that means things like giving you Keys providing access to Keys when certain conditions are met um signing for you all kinds of things like that and it is a generalized programmable Network basically the goal of lit protocol is to take this amazing new technology of threshold cryptography and put it into your hands as a developer and we really want to make it as easy as possible to use this technology and uh fully programmable so you can do whatever you want with it and you know the thinking is that you could set up your own threshold cryptography network of nodes but it's a huge pain right who wants to manage nodes so instead you can use our nodes and write programs that run on them and do whatever you would like with that so if you're not familiar with threshold cryptography the general idea is that you perform a process called distributed key generation and for this example let's say that we have a network of 30 nodes and we're going to set a threshold of two-thirds which means that you need 20 out of the 30 nodes to participate in order to use Keys within this network um and so you have 30 nodes and they come together they perform this process called distributed key generation and what this does is create a public and private key pair just like the one in your ethereum wallet but nobody knows the private key instead each node operator only has a private key share and they're able to do the same things with that private key share that you are with a regular private key like sign and decrypt things but the difference is that somebody has to combine the resulting signature shares or decryption shares above the threshold to get out a decryption key or a signature and so in our case of a 30 node network with a two-thirds threshold you have to get a signature share from 20 out of 30 nodes you can combine those signature shares into a final signature um and there's kind of like two broad areas of use of lit protocol one is decentralized Access Control and in this case um the threshold cryptography is generally used for encryption and decryption and so some really cool use cases of things like this are um let's say you are in a dow and you want to encrypt some content upload it to ipfs or rweave or some kind of public storage but you only want your Dow members to be able to read it you don't want everybody else in the world to be able to read it if you think about this right it's actually kind of a hard problem if you just use some encryption key that you made up then you just share that encryption key with every member of the Dao right maybe you go on Discord you share it with them on there um but then what happens when somebody leaves the Dow right now all of your content is encrypted using this key you have to rotate the key give everyone a new key right it's like a huge headache you can imagine right every time someone joins or leaves you have to do like a whole operation basically um and instead what you can do is encrypt your content using lit you can set an access control condition that says user has to be a member of a dow and what that means is that um somebody on the right here this is like a user in a web browser or something can make a request to the lit nodes the lit nodes are these hexagons in the middle and they can say hi I'm in this Dow I would like to decrypt this content and they present a wallet signature from their wallet um just a signed message and uh the lit nodes check that signed message and say okay this user does actually own this wallet and then the lit nodes each individually check with the blockchain to see okay does this wallet actually meet the condition AKA is it actually in the Dow still right um and if it is then each lit node will use its private key share to create a decryption share the user will collect all of these decryption shares above the threshold and then they are able to uh decrypt the content and lit supports tons of Access Control conditions uh it's not just like if you're a member of a dow that's just an example you could also do things like does the user hold an nft um you can basically like anything that lives on chain you can use as an access control condition and you can use any smart contract function it's like if you want you could make a smart contract that says like you know that checks is EK proof and says like only let a user in or only let user decrypt content if they present a ZK proof that that's valid that meets some condition right anything that you can imagine you can basically use as an access control condition and we also support um essentially using JavaScript as an access control condition where you can say only let the user decrypt if a JavaScript function returns true um and we'll talk a little bit more about those JavaScript functions later which we call lit actions so what is this useful for um it's really cool for permission and private data on the public web so you could imagine if you're using a cool fancy new decentralized Social Network and it stores its data on ipfs awesome right anybody can get the data um it's this beautiful open system but wait that also means that anybody can read all of your posts right there's no privacy um what you can do is encrypt your posts with lit protocol and you can set your Access Control conditions such that all of your friends are allowed to decrypt it and that's great because now you don't have to self-host the data right it's hosted on ipfs on the public web but it's permissioned and private in that you can still control who is able to access it and when another use case for lit protocol um is essentially signing um so the first case we talked about was reading from blockchains in order to decrypt something this use case is talking about writing two blockchains and the way that you write to a blockchain is with a signature the lit nodes hold private key shares and they're able to create threshold signatures that can be used to write to a blockchain and the way that the lit nodes actually do this is that you are able to upload some content some JavaScript code to ipfs um and this is called the lit action and once it's on ipfs it's immutable because ipfs is content addressable so you can kind of think of these like lit's version of smart contracts but they're in JavaScript so they're really easy to use and these lit actions are allowed to uh also read from the web they can make HTTP requests so you can pull in data you can do all kinds of things that uh that would be really hard to do on traditional blockchain um and so like basically kind of how this actually works is a user shows up and says to the lit nodes like hi I would like you to run this program on ipfs and each lit node pulls this program down and runs it and if the program um asks for a signature each node creates a signature share the signature Shares are collected uh by the user the user combines them and is then able to broadcast them to uh or broadcast the resulting signature to a blockchain and so that's how you can use lit to write to a blockchain in addition to read um and we think that this is like a really powerful new primitive that you can use for all kinds of things in cryptography um and one thing that I haven't really talked about yet um is when you're writing to this blockchain when these nodes are signing using a private key share whose private key is this right like is this the Network's private key like which which private key uh shares is it using and that's where the concept of a programmable key pair comes in a parallel key pair is an ecdsa key pair which is the algorithm that Bitcoin ethereum and Cosmos use and the lit nodes hold the private key shares that correspond to this key pair you can create a programmable key Pair akaa pkp by inventing an nft that represents ownership over that pkp and then whoever owns that nft can ask the lit nodes to sign anything on their behalf using the private key shares that correspond to that pkb including ethereum or Bitcoin transactions and um I'll show you how this works right now so this is a lit action very basic lit action and what it does is it defines something to be signed this is just a simple array that contains the string hello world but this could be a transaction that you want to sign this could be a right to ceramic anything that requires a signature you can you can sign it's very very flexible and what you see here is um that we are requesting that the lit nodes sign this data using this key and store it in the result of uh named sig1 and basically like what's what's happening is the lit nodes hold the private key shares that correspond to this public key and so when you ask the each lit node to do this it's able to create a signature share and the signature shares I'll get returns to the user who's able to combine them into a final signature um so here's like sort of a basic overview of how that works the user creates some kind of Authentication uh you know that could be a wallet signature it could be an oauth token we support Google and Discord um and we're working on adding um phone and email authentication as well and they make a request to the lit nodes they talk to every single lit node in parallel and they present their Authentication and they also present an ipfs ID and they say hi lit node please run this code for me the lit nodes pull down the code from ipfs right and load it into a JavaScript runtime the JavaScript runtime executes the code and it actually checks that the user is authenticated and allowed to actually use the pkp and the lit action is also allowed to pull down any data from anywhere on the web using an HTTP request so you can use it like in Oracle you can pull in data from anywhere in the world and use it in your computation and then if your lit action wants to sign it can request that the lit nodes use their threshold private key share to create a signature share which is then returned to the JavaScript runtime and what happens is the user down here is is running this request across all the nodes and collects signature shares from all the nodes the user is able to combine those signature shares into one signature and then can then broadcast the signed transaction or use that signature for whatever they want to use it for and we have a typescript SDK that um you can use that basically like does all of this for you and abstracts it all away where you just kind of like create a request pass in what you need and you get back a signature at the end another cool pattern that you can use is the mint Grant burn pattern this is really interesting because um a pkp because it's created as an nft on um on a blockchain you can basically um create the nft and mint it you can grant the access for it to use like some lit action and then you can burn it um and what that essentially does is lock the pkp such that it can only be used by this lid action forever now uh interesting like kind of toy use case of this right is suppose you have a lit action so you have some JavaScript code that given a number as input we'll check if that number is prime um you can mint Grant burn a pkp on that Lit action and then you can pass numbers in and um if the number is prime then you know each lit node is running this independently um it will sign using its private key share the user collects all the signature shares combines them into a signature that signature essentially proves that any given number is prime because the corresponding uh programmable key pair can only ever be used to run that program and so what you kind of end up with is something that functions similarly to a ZK proof in the sense that you have a signature that proves that all of the nodes in the network got the same result and now you don't have to check if a number is prime if it's signed instead you can trust the signature because you know that the only way that the signature could have been produced from the corresponding pkp is if the lit nodes ran the program correctly and that you got the the result that it expected right which is the number is actually Prime and you can use this for anything right you could use this like to certify or to prove prove that like you know suppose like you have to prove that you're in a city but you don't want to prove like where in that radius uh that you actually are you just want to prove that you're in a radius without giving away your real attitude and longitude you do something like that you could prove like that the weather was a certain temperature on a certain day in a certain place and time um you could because you can pull in data from the web using HTTP requests you can essentially like create proofs of anything on the web um very very easily and very very quickly and the proofs are ecdsa signatures so you can pass them right into a smart contract which is able to check those and and verify them a couple other cool use cases you can use a pkp as a vault um what this means is that a pkp um you know is a uh public private key pair it's a wallet you could send 100 nfts to it right and then um you can trade all 100 nfts at once because you can actually sell the pkp nft itself which is the nft that controls the pkp um to another user and you effectively have just sold the underlying private key that owns all of those nfts and remember the private key never exists it never uh it never gets like created anywhere instead the the lit nodes only have private key shares and so you can effectively like trustlessly trade a private key um in a way that you never could before this basically like breaks things like Soul bound tokens um a lot of anti-civil mechanisms like uh for example git coin passport or polygon ID can can be broken by this because now you can actually sell the wallet that owns the Soul Bond nfts right um that something that you could even never do before because in order to do that with a regular private key that that you are just like looking at you would have to prove that you've forgotten the private key right and and you can't prove that it's impossible to prove that um but with lit since the private key never exists you are able to actually uh to actually trade that um you can also use a pkp as a cloud wallet um lit supports a ton of different auth methods and so you know I talked a little bit about like if you hold the pkp nft you can ask the lit nodes to sign using that pkp that's just one of a ton of different auth methods that we support we also support um oauth with Google and Discord we support web often uh we're working on email and phone soon we don't have that yet but we will soon um and that that basically means that you can use any of those things as auth and there's a smart contract on chain that you can use to set up your auth for a pkp so you could like say uh I'm gonna onboard new users and all they have to do is log in with Google using Google oauth and I'm just going to pass that Google oauth access token to the lit nodes as proof the lit nodes can verify that access token and let the user sign using that pkp you know assuming that you've set up that user to auth using that Google account so it's great for onboarding like you don't need to do seed phrases you don't need to worry about anything like that you can get people a wallet very quickly like with one click um you can also use pkps for Automation and signing so this is a super cool use case it's like uh imagine like you're in some cool like 10 000 apy farm and you're like this is great I'm making tons of money but if the token price tanks then like I'm gonna lose all my money uh it sure would like it if there was some kind of way to set up a stop loss order but your tokens are staked you can't sell staked tokens with lit you could set up a lit action that checks the price of the token if the price of the token drops below a certain level then um it creates a transaction to unstake the tokens and then it creates another transaction to sell them on uniswap and you could basically like be pulling this right like have this lid action run every you know 10 minutes or something right and if the token price starts to tank then this will unstake and sell your tokens and this is really cool because it's just using raw ecdsa signing you can do anything you could do with a regular wallet with this so you could do things that are cross chain you could use Bridges um literally like whatever you can imagine you can build um and you know in order to do this in a sort of traditional way you would have to set up a hot wallet on a server um you know kind of like a trading bot type setup it's very very prone to uh to error you know having a private key on a server and and you know as a hot wallet is really scary like it's a huge Target for attacks um and so this kind of like using lit for this instead gives you the protection of the decentralization right like somebody doesn't need to hack one computer to steal your money they need to hack two-thirds of the lit nodes and the lit nodes run inside of a trusted execution environment powered by AMD Seb SNP it's actually a secure encrypted virtualization environment so node operators can't see what the uh what their nodes are actually doing they you know they're it's fully opaque um and so it's very very hard to uh to hack into um and that's part of why we've built it that way so anyway here's some really cool ideas of what you can build with lit um and check out the docs at getlit.dev if you have any questions pop into Discord um we're always around and we are so excited to see what you build thank you Abby and I lead developer relations at lit protocol and I'm going to do a quick overview around Chronicle as well as how to start minting pkps and getting test tokens so previously um a bit of what Chris covered Chris rcto covered was around before we moved to our rollup and so with this roll up um we have a lit test token to serve as gas for transactions and so that'll be built on Chronicle which is our evm roll-up built on optimism so first is we're going to go to actually the faucet to get the lit test tokens so here we're going to put in our water dress we're gonna tell them we're not a robot we're an actual person ready to claim these tokens and you'll notice in this wallet I already have some the test tokens so I already have two lit test tokens and from there going back to the docks the docs are the home of everything you'll need to build with us um you can go down to the programmable key pair section go to the introduction and go to minting a pkp so you can mid via contract to our lit Explorer page and then we have all these different other ways of minting as well so right now we're going to do mint via contract so clicking here and we're going to go to our lit Explorer and from here we're going to go mint a parallel key pair so great we've minted our pkp and then from there we have this pkp public key which Chris has got over some different ways of using lit actions like and really need to use that pkp public key to sign any conditions as a result of lit action or to authorize additional methods so it's very quick if I hope you had fun learning this and we are excited to see what you built for youth Global Waterloo and we'll see you there
Automatic transcript — names and jargon may be misspelled.