Lit Protocol 🛠 SDK V3 and Resources for Builders
Pragma (ETHGlobal) — 2023·Pragma (ETHGlobal)·Mon, Oct 9, 2023, 12:00 AM
Join us for a Lit Protocol workshop! This workshop is part of ETHGlobal's flagship online event: ETHOnline 2023! ETHOnline 2023 has grown into one of the most exciting events on our calendar, anticipated by hackers all over the world. ETHOnline is a three week long online hackathon with over $200,000 USD in prizes as well as a series of curated summits, celebrating some of the most significant happenings & learnings from the past 12 months in web3. ----------------- Follow us: https://twitter.com/ETHGlobal Check us out: https://ethglobal.com Email us at: hello@ethglobal.com
Transcript
[Music] I'm Debbie and I lead developer experience Outlet protocol and today I'm going to go over a bit of our sdb3 as well as how you can find resources to build and I do want to say we're really excited to see what projects you're building and for the lit specific prizes we are only giving out four are folks building on lit's newest SDK which is in beta which you can see from our docs on that top header banner and so jumping into it um what is lit lit um from even just this overview section here you can see it says lit protocol lets you create and manage distributed cryptographic key pairs for condition-based encryption and programmatic signing um a decentralized key management Network Li can be used in place of centralized key custodians and other Key Management Solutions so what does that actually mean um some of the core use cases of a lit are decentralized access Access Control where you're able to set um access control and then encrypt content where based on that those Access Control conditions someone can decry that content um or on that programmatic signing piece F you're able to set some conditions saying okay I want to be able to sign or I want this I want someone else to sign on my behalf if these conditions are met so being able to use Letz Network to be able to do that and that's through um what we'll call programmatic signing or through our paral key Pairs and let actions if you want to learn more about that um you can see with in the docs page here uh decentralized access control so just a higher level concept view of what um you can build with lit in terms of decentralized access as well as on that programmatic side being able to set up a kind abstraction for and then one of our newest features which I'm really really excited for folks to build with we'll call it we do call it cable Keys which is essentially you're able to Det istically derived keys so that the public portion of the key pair is known before creating the full key pair so a use case with that is you might want to send um you want to create and Seed a wallet for someone with some amount of asset um let's say you want to put like 0.1 madic or you want to put like the lit test net token in there you're able to um kind of get they're they're able to come onto your platform input their off type so that might be email that might be SMS and then be able to generate um a claimable key and then after that generation process they're able to come back odsa platform and then claim that wallet so the claiming process would be associating their off with this um public key pair and then on the lint Network side fully connecting that through saying okay this person now has ownership over this key they have now claimed it this is theirs as well as program programmable signing so setting conditionals signing automations um as well as being able to set up NPC wallets where a pro programable key pair is essentially an NPC wallet um and NPC part is utilizing litz Network which which is a multi-party computation Network and then a public private key pair is the wallet component so how you would utilize lit let's go into this installation side so right now our V3 is in beta so be sure to when you're importing it either this is a general import or on server side through the node.js you're actually doing this tag where you're doing version 3 dot I think now it's actually not just to it's 5 3.0.5 or above on the server side you'd be importing the lit not client note JS package and so one thing to note is for general purpose use I think lit note client will fit most use cases we do have um we do have a mod Depo for our SDK so a lot of times like if you need something a bit more complicated or you need something more custom um please go into GitHub as well as let me pull up actually rjs API documentation for you all so you can see what this layout is so we have these modules where we have the jssd and underneath that we have um we have the access control conditions package off br browser all helpers BLS SDK core crypto so if you have more unique or Advance use cases um be sure to look through here to see what you need to include in your project so with the installation um you'll import the 3.
0 package or above and then make sure that when you're connecting to the L node client that you're passing in the L Network as Cayenne or B3 that is the only Network that um is supported and so make sure that that flag is added in and then for um we have different helpers on how to you authenticate through L either through oig or through session signatures be sure to read these part of the docs on getting that set up depending on what your use case is and then for Access Control I actually want to walk you all through a demo or um a code repo that I made for using um Access Control where if you've been with lit say V1 V2 we're and now we on V3 if you've been with us for V1 or V2 um we have changed how encryption works so encryption now is what we call ID encrypt and the import the usage of it is a little bit different where we are actually we don't have um symmetric Keys anymore we have a different way of interacting with the node so they're there are different calls um so let's actually jump into an example and this will all be linked in off of lit's page on eth global site for eth online so be sure to check that out as you're going along with this video so you can go into um my GitHub which I'm Debbie de and then to get here um go to my GitHub de you can find this on my homepage ipfs dlit and make sure that you're actually on the S lit scb3 Branch so we're on the sv3 branch where um this example has the most up to-date usage of ID encrypt and so from here um some Basics is you'll need to be you'll need to set up a project with infura where you'll need your project ID and project secret as well as making sure you're importing bullet node client um version 3.0.1 or above and then within the setup page um where you can find this within actually the lit do um TS or JS um file is setting up how do we use l and setting up making sure the Network's cayen and then connecting the lit node client which is necessary for interacting with the lit noes in general so having this async and 8 is really important here so don't forget that and then in this example um we just do like a fraction of 1 e as the access control condition and what the encryption looks like with ID encrypt is We call we get an Alig and then we call encrypt string with that data to encrypt and in this example it's a URL string pass the chain ethereum we have that a signature that we generated previously as well as our Access Control condition which is just that um fraction of the East and so what what gets passed back is this encrypted object so for lit. encrypt string um it'll pass back a cipher text and data to encrypt hash so just like the encrypted hash as well as the symmetric key from V2 version of using the lit SDK you also need to save both of them because you'll need both to decrypt and then for a decryption function of string it's pretty straightforward you need to pass in aess control kill condition Cipher text which is what we've received from that encryption step as well as that data to encrypt hash we received previously and then an off signature chain which in this example was ethereum and then also pass the lit note client um why we pass the L Note client is just this is more this um um function is a bit more closer to functional programming where you also do pass in that function or object so make sure to include that which is just a l climate Lo initiated for using in this project yeah and then that's pretty straightforward and so from this example you should be able to encrypt and upload to ipfs and then when you're decrypting you should be will see that file on display on this site and if you want to check out more examples we have another example that's actually within the um lit jssd Branch V3 and this is another example of just doing a simple encrypt and decrypt of just a string where you could change the string and you can see on the from base of the input on the left hand side kind of the code and output on the right right hand side yeah so excited for you all to use ID encrypt it is significantly faster than our previous encryption one San and jalapeno which are also the older test Nets and so encryption and decryption now should take about 2 milliseconds whereas before it took up to 100 milliseconds and so this is a really bigger Improvement on um yeah just like speed and like node interactivity if you want to do different types of Access Control conditions be sure to check out um types of conditions as well as certain like mly for evm or other chains um it's all documented here and then if you still have questions please go on Discord and ask us there then before I jump into claimable key claimable keys I'm going to actually talk a little bit about programmable wallets so programmable wallets are NPC wallets that can um that have an additional layer of usability that's built through the lit platform so you might be able to off in through a web off method like Google or Discord or apple Pass Key and which is all set up within lit system and if you want to do your own setup we have um more tutorials and tooling for you to set up your own relay server to do that so pral key pairs they can be used to sign transactions on blockchains or seat machines because the underlying um algorithm is ECS DSA for digital signatures and we have a lot of different methods for creating Wallets on evm and Cosmos based chains and then for that conditional logic of programable wallets we have a concept that we call lit actions which is the application logic that each Parable key pair should follow this is useful for defining signing automations handling off or Jing Jing conditional proofs because the lit action is where you like say only sign if um these certain conditions are mad or only sign if um this is true or we only we have these off methods so you can check out these different use cases as well as on the side here we have different off methods that are supported we support address lid actions web offin Discord Google um as well as one time passwords so onetime passwords are email or SMS log in we had that sorted through Stitch and then minting pkp so minting aailable key pair you can go on um our Network Chronicle and go and like get testet tokens and then mint pkps off Chronicle and then moving on from that I'm going to go a little bit into claimable keys and what that is so claimable Keys is what we'll refer to as also HD keys so homogeneous derived keys and so when you're creating a new provable key pair it's now possible to deterministically derive keys so the public portion of the key pair is neared before creating the key and these Keys work off a set of root Keys which combined with the key identifier allow the deterministic generation of new key pairs um be sure to go here for the vocabulary around how to use claimable keys so essentially you might be able to based on off like email or something else derive a the public key for someone's email and then when they're coming in they can claim that account that's associated with their email and so I want to go over a small actually demo here around using playable Keys okay so so I'm going to go over a short playb key demo mainly this will be all on the terminal and the I will leave the building at the front end for you but we're going to go through the process of creating a claimable key and then claiming it by looking up the prail key pair and then linking our email through that off so okay first things first where can you find this demo let's go on the search right now where we can actually find it through the lit protocol repo here um or Fe so we can find it here at the claim key demo nodejs I'll also link that within the ethon line um kind of resources for lit and so this all all the code is here um one thing you that is noted is that you will need to create a stitch account and get um a project ID and a secret from that Stitch account and then from there you should be able to do the same exact demo that I'm doing okay so jumping in we have our Stitch project ID secret and then the lit relay API key um be sure to follow or this get and get oh my God I can't talk today so you can find the form on lit site to be able to request a relay API key if not feel free to Jump On In Discord and ask about that so there's some setup here I'll go through a bit of the setup parts and then go through what's specifically um around play mobile keys and how to use that so this first part we're going to initialize the Stitch client and create the Stitch client so you're just passing your project ID in secret and then from here this is actually just taking in a prompt from that terminal command line where we're just asking for sence email so being able to pull in that email that we're going to associate that or create that claimable key for and then once we have that email we're actually going to call the Stitch um login or create which is actually just creating um an auth for that so we're passing in the email and then that actually will prompt um for that email that'll prompt them to check their email for a code so it's a onetime password code that's what OTP here means one time password and so then we input that code to confirm like yes I have access and authorization to this email and then from that we call the Au response where we're getting the authenication response where that method ID is that email ID we've received um and then the code itself is the onetime password code which is it is usually a string of numbers of like six numbers and then for the session duration I think generally it's set to be 5 minutes so someone has about 5 minutes to get that authentication code and pass that in and then we have session response which we call the Stitch client to get that session based on that user ID and then as well as we get a session status so this s session status we're actually calling s's client to authenticate based on that off response session token so that's just the Stitch side setup that we'll need and then on more of that Lit side we're going to jump into what we're building here where we have the lit node client and for this we're doing strictly J nodejs so we want to import the lit node client node.js um for other usage you might just be importing the lit node client and then we have the lit Network make sure that that is included in there especially because we're using the V3 SDK so then we connect our lit node client which is essentially we're connecting to the lit nodes and we want to wait for this connection to happen because that's how we'll be generating these lit specific parses calling the lit nodes and then from there we initialize um the lit off client which which will help us actually generate a prog look key pair so there we go back to our session and we calling stitch in order to get a session and we're passing the provider type which I think in this case is the Stitch OTP and then we have our user ID that we generated from previously from that session status and then the app ID which is actually just the project ID that we when we created did that Stitch project so from there um we call like off method to get the off method and from here that's gener is like email is that off method so we're just passing in um for the access token that session JWT that we got in from session status and then this line actually here this public key so this is actually where we are calling the to get our public key which is that public key generated from litz end in order when we're setting up Playmobile keys and so session.
compute public key from off method pass them that off method and then from here um we have kind of two ways to cross check that we've created the public key as well as that public key once we've authorized in that we're that is associated to that owner so that email address and so here where we do the claim flag we're actually saying like Okay can I see that claim response for that public key to know that it's being that it has been generated and the second one is a lookup which is we want to see if based on that public key let's look up um that program key pair and see that match that public key based on the email I'm passing in so let's take a look at that um let's start with the claim process email I'm going to enter in my lit email here oops okay sorry that my mistake I missed out an m on there we go to bite you now okay so then we have um from here we have the lit compute key local key public key computed great and then we can see from here the JWT body um that project ID and then what time is started what expiration as well as the Stitch unlo or what we call it the Stitch project ID okay so then um we're going to actually check our claiming or let's check like if that pkp is M upstop UNC the screen me really quickly we're going to do a look up here we will have to authenticate in again on this look cup and so I this account I've been testing a lot day so these are all just generated throughout the day as I've been testing it and we could see we have many different public keys and so from there I would encourage you to test this on your own as well and I would love to see folks building with claimable keys especially there are a lot of different use cases that we can we've thought about at lit where you can kind of send wallets to people much more easily especially folks who might not already have a wallet or to be able to um yeah create different kinds of bundles with claimable keys so yeah excited to see what y'all build and if you have any questions please jump in Discord we're active on Twitter as well all the links should be updated within e online page and I hope to see yall out there hacking
Automatic transcript — names and jargon may be misspelled.