Polygon 🛠 The Future of Identity is Self-Sovereign: Build a dapp with Polygon ID - Steph Orpilla
ETHGlobal Bogotá 2022 · October 2022 · 25:25
Steph Orpilla of Polygon asks why proving who you are online should mean handing over all your data. The workshop compares centralized, federated and self-sovereign identity, explains the issuer, holder and verifier trust triangle, and introduces Polygon ID with zero-knowledge proofs verified on chain. A live demo creates an age credential in the wallet app and uses it to claim a ZK ERC-20 airdrop without revealing a birthday, followed by hackathon prizes and resources.
Speakers
Topics
From ETHGlobal Bogotá 2022, hosted by ETHGlobal.
Transcript
foreign [Applause] [Music] welcome to my workshop it's called the future of identity is self-sovereign build adapt with polygon ID first of all I want to say a big shout out to the polygon ID team a bunch of the ID team is here can you guys stand up we've got people back there woo they've built a really really cool product and I'm excited that you're all going to get to start developing daps this weekend I think these are going to be some of the first steps on polygon ID ever so you're you're really early which is exciting
but first of all GM GM I'm Steph I'm a developer relations engineer at polygon along with my lovely co-worker Rahat in the front row another round of applause for a hot because why not Vibes are good today um I'm also oceans 404 on Twitter uh but right here in this slide I gave you one two three four five pieces of my identity so my name my job title my company and also my Twitter and my profile picture so you know five things about me from this uh but how do we know that those things are true we don't really right you can kind of trust me but when I think about identity
um I think about things that I recognize immediately uh like SpongeBob and I know this is SpongeBob and maybe these police come up to him and ask him who are you and he says I'm SpongeBob and maybe they look at him like are you really how do we know that we've never seen the show but if you have done kernel or read a lot of things on bitcoin there's this proverb that says don't trust verify so you can see in this image SpongeBob is wearing a name tag and you can see that it's written maybe in handwriting so we think that he has self-identified as SpongeBob but we still don't know for sure if that's his real name or if that's really who he is or if he's just
saying that's true so if SpongeBob had a driver's license that would be better proof that he is actually who he says he is this driver's license is issued by the city of Bikini Bottom uh it has his address it has his sex his hair color his eye color his date of birth uh but if the police came up to SpongeBob in bikini bottom and said what's your name why should he have to show his full driver's license if they only need to know one part of it why do we need to show all this other data if we only need to prove one piece at a time so kind of ruminate on that as we get into the rest of the presentation this isn't just a problem for SpongeBob
right we all have digital authentication that we have to do to have access to all kinds of different apps including big tech apps social media apps like Facebook you have to sign up and give your first name your last name a lot of personal data so like your mobile telephone number your email uh you set your birthday your sex just a lot of information and no one really knows why they need that they say it's to improve the algorithm and things like that but what are you really getting back for all of that that you're giving so getting into identity Solutions there's three different types of identity Solutions today the first one is centralized identity uh like I said
if you're logging into Facebook you use your email or phone number and a password a centralized identity system is a single purpose identity so you would need to create a new account every time you use a new app so you're kind of siled right because that identity isn't portable as you go from app to app you can't use this Facebook login to log into let's say tick tock at least I don't think you can I really doubt those systems talk or that there's Synergy there because of competitiveness but every app is storing this information for you separately which could lead to a lot more security risk right like if one of these gets hacked they have your data if another one is hacked they have your data but it's also a huge headache for
managing all of your passwords and accounts across apps I know I have a password manager and even that is a pain because there's always like one password that isn't in there and then I don't know what my password is because it's a centralized identity system The Next Step Up is Federated identity who has a Federated identity login for work stuff I know I do and everyone at polygon probably uses I think it's OCTA or okta I'm not sure but it's a way to sign into a bunch of different apps that are all within the same Federation so at least then you can use one single account and reuse your login across all of those different apps that makes this type of identity a little bit more
portable but unfortunately like it doesn't work for every single app out there and another drawback is if you log in with let's say Google one big tech company has access to all of your data across all the different apps you're logging into so it knows what you're looking at it knows what you're accessing and I remember I used to use Facebook login a lot and one time I decided to delete my Facebook and then I realized I was locked out of Spotify which I didn't even realize was connected so I immediately got my Facebook back but I was just like oh no so enter decentralized self-sovereign identity this is a multi-purpose and portable type of identity where you can prove pieces of your identity to use on
any app this is really powerful because you as a user retain the control over your personal data and also your digital identity and you also eliminate the middleman that's holding on to your identity in all of these different systems so you don't have to give up your data to prove access rights to the things you need to log into so these Concepts come from this really Incredible Book that the polygon ID team recommended to me it's called self-sovereign identity and the two main takeaways I had from this book were that SSI or self-sovereign identity empowers us to receive digitally signed credentials store them in private wallets and securely prove our online identities and we as individuals or even
organizations like maybe Dao's or workplaces have that sole ownership over our digital digital identities and we can decide how our personal data is shared and stored or if we don't want it stored or shared at all so going back to my SpongeBob references um a big idea in SSI is this trust triangle so we have an issuer a holder and a verifier so in the SpongeBob situation the issuer is Mrs Puff who has a boating school and gives out a driver's license the holder is SpongeBob who is getting that license and the verifier is a police officer and so this kind of explains the issuance of a
verified credential and also its usage so the verified credential in this case is the driver's license and Mrs Puff issues it to SpongeBob and in this new self-sovereign identity system instead of the police officer having to see the verified credentials they can just accept a proof and they can do that because they trust the issuer and they trust that the issuer has given the holder a proof that is authentic so the issuer has to be trustworthy in doing the right things to make sure that whatever the verified credentials that they're giving out to a holder are actually legit so we already see that
happening with governments and also in cases with like covid passports or vaccine passports so someone is issuing you a verified credential maybe it's a nurse giving you a shot and they're saying I gave Rahat this second covid vaccine and so if there was a way to have a proof instead of having to show that actual covid vaccine card that would be off awesome and we're getting into that enter polygon ID so polygon ID is a scalable blockchain ID with ZK based privacy we have a really nice architecture diagram on the right and then the left has different tenants and things about it so it offers Universal
identity you get to prove your access rights rather than giving up your data or identity and it also enables Advanced on-chain verification through ZK snarks so these are four of the guiding principles and I think these come from that self-sovereign Identity book and just other extremely smart people on the team but polygon identity polygon ID is decentralized it's private by default it uses ZK for uh trust and reputation and it's also open and permissionless so going back to the SpongeBob thing we're going to switch that to what this
looks like in polygon ID so instead of Mrs Puff or like someone from the government creating claims you use an issuer to create a claim and that issuer can give the claim as a verified credential to a holder me within my polygon ID Wallet app and then I can generate a cryptographic proof that is verified on chain with a smart contract to check against my signature to make sure that that is actually my proof so if we go back to kind of some of the problems that we've seen in social media apps and other different things on the left I logged into Instagram a few weeks
ago and it said add your birthday it said to continue using Instagram you have to add your birthday and I was wondering why is that so I looked at the why and it's because you need to be 13 years old so they need to know my birthday to make sure that I'm 13 years old but I'm going to show you how we can use polygon ID to prove that I'm over the age of 13 and I can use Instagram without actually having to like swipe around and put in my real birthday so this all starts with issuer so I'm gonna oops click into issuer so this is uh the UI that is used to create these claims that you can give out to holders
I'm going to sign up sign up it's actually more of a sign in and I have the polygon ID Wallet app on my phone I'll show you more about that in just a second but I'm just going to log in with this QR code and I see something that just says connect my wallet so I'm connecting my wallet authenticating and now I'm logged in and I can create a claim so I'm going to create a claim um and there's some different default schemas that are drop downs I'm going to do a kyc age credential because remember I want to prove that I'm older than 13 so I can use the app I'm not going to tell you all my real
birthday but I'll say 1990 8 24 so August 24th 1990 that make that would make me way older than 13. and I'll submit that so this has created um a claim that I can give myself so since you can't really see it on my phone I'm going to open up a notion page uh that shows this or actually I'll start with the slides so I'm I'm interacting with this issuer within my polygon ID Wallet app so these are just some screenshots from the app again you can prove your access rights without revealing your identity um and what I just did in that issuer UI was I created a claim so now I have to
give this claim to myself so that um I know that that was my fake birthday it's not my real birthday but you get it so to do that I'll show you a video of how that looks okay so we just created a claim which is this screenshot next up we have to generate the claim so when you accept the claim by scanning that thing the the QR code it goes through this flow where it adds the claim to your polygon ID wallet so once that claim is added you can see it in your data so you can see now I have this kyc age credential within my polygon
wallet so when I screen recorded this earlier I said my birthday was January 1st 1990 but now this exists in my wallet and I can check anything against this so the demo app that we worked on was a ZK erc20 airdrop so what we want to do is airdrop tokens to anyone who's over the age of I can't remember what the age was but let's just say it's 13. I think it was a specific birthday but in order to do that we need to check against that claim that we just created that said that my birthday was the first in 1990.
so what you would do is you would scan that proof request or you would scan that QR code it would generate a proof against the information you already had stored so it's generating the proof a cryptographic proof would appear and then you would click generate proof it uses biometric ID or a password and it pops open your meta mask and allows you to claim that erc20 token claim based on the fact that you were over the right age so it's generating the proof and then if this is successful we'll see
that the airdrop gets added to my wallet so you can see that in the screenshot it confirmed that contract interaction and now I have five ERC zkp which is just the token drop that we created inside of that wallet so that's kind of a high level overview of how this works but I'm also going to show you some of the code for the verifier and all of this is in different links that you'll be able to check out so you can look at how the smart contract works and also how the front end works okay so this is the tutorial example
um Implement a ZK uh erc20 airdrop in 20 minutes so it really does only take 20 minutes if you follow these instructions and just deploy your own smart contract and update like three different variables uh but what you would do is download that polygon ID wallet setup either from the Apple store or the Google Play Store and then you would get it right into the code so if you were just cloning this repo all you would have to do is install the dependencies and then compile the code that already exists there and then run the deploy script this would result in one smart contract and what you would
have to do after that where all of the magic with the proofs and everything happens is that you have to run something called scripts set request and this is where we're actually submitting all of the things that make the proof work so let me get into that So within this set request we have a validator address this is the already deployed smart contract that is doing the validation and this is something you can reuse for any of your polygon ID examples all of the specific stuff happens below so there's an age query
and the part where we're actually checking against the age is on line 14 with the value so we're checking that your date of birth is happened before January or January 1st 2001 and so I already proved that with my claim that I was issued so this should work for me um the other thing is that we also have a ERC verifier address so this is the address of the erc20 token uh that you can deploy using those instructions above and so the ZK proof request checks against that validator and also the age query to make sure that you're actually
over the age that you said you were so back in the readme we have two different contracts uh within contracts so this is the erc20 verifier that I was just talking about and this extends an erc20 contract as well as a zkp verifier contract that exists in this repo and there's a couple interesting things going on there's a before proof submit and after proof submit hook as well as a before token transfer hook so this is where all of the custom logic is happening to make the actual airdrop
happen so before you submit that ZK proof it's checking that the challenge input of the proof is equal to the sender so you need to make sure that the user who's saying I'm over the age of 13 is actually the person who is submitting the transaction and then after the proof submit there's one more require statement and this is just making sure that you don't claim the airdrop multiple times so that's just a little extra logic and then this is where the airdrop is executed so this is kind of just like classic airdropping a token stuff um but before these tokens are actually transferred there's one more check and it's just making sure that you as the
person who provided the proof are allowed to receive the tokens and so once you have all of these smart contracts deployed all of these meaning just two the last thing that you need to do is design a proof request so there's a query based requests language or not language but um structure so you can read about that more on the polygon ID documentation and in the GitHub but I'll show you the one that I created so mine is in QR proof so this is just a big Json blob and I'm
going to pass this to the QR code it's going to live in the QR code so when someone scans the link it understands that this is the contract and this is what we're querying so on line 21 and 22 you can see what we're querying we're querying the birthday and on line 22 we have LT Which is less than and then 2001 0101 so we're checking that the birthday that the proof is submitting is less than January or January 1st I can't say January January 1st 2001 and mine definitely is so this should be successful and like I said this needs to live in a QR code so on our front end we have to have some
type of QR code that you can scan that has this data so that it kicks off the whole smart contract process I created a little code sandbox for you all so that when you deploy these on your own all you have to do in the code sandbox once your contracts are deployed is update this deployed contract address and then you should be able to test with this front end to look at the QR code and see if you can actually claim the ZK airdrop but that Big Blob of Json that we saw before lives in the QR code request so it's just this big it's the same exact thing it has the deployed contact
address and that little check down here birthday less than January 20 or 2001. and that just lives in a little QR code component so it's just passing the value of that to here so when we scan this code from the polygon ID app since I already have a claim it should kick off an airdrop to me so I see something come up that says proof request in my app so I've scanned and I'm just going to sip or submit continue for the proof request it's generating the proof on my phone
foreign and then once it's done generating the proof I'll click one more button and then it'll kick off the transfer of that airdrop to my account and you can see where that happened before if you look at this poly scan link I think I'm the only person who's claimed on this contract yeah but five of that ZK erc20 token were airdropped to me about six hours ago so I should get another airdrop pretty soon um but yeah that's how you would do this with an airdrop that was the code
okay did I lose everybody I know that's a lot you can you can look at the code um on my GitHub I'll give you the links towards the end but I just wanted to talk about some of the prizes that polygon is doing for the hackathon so we have twenty thousand dollars in prizes and four thousand of that is for the best use of polygon ID so you could create an app like the one I just showed you or something totally different to help people prove parts of their identity without actually giving up their data we have three other prizes we have four thousand for the best public goods and refi projects hopefully they're going to be like local projects
that help the latim ecosystem we also have four thousand dollars for the best social adaps on lens protocol and four thousand for the best user experience and user onboarding to whatever Dap You built and last but not least we have a four thousand dollar prize pool for everyone who deploys any type of contract on polygon we ask that you have two transactions to that smart contract so that we can see you've actually used it um and then these are just some of the benefits of develop developing on polygon I'm sure a lot of you know speed cost scalability flexibility all great it's a great developer experience and we're also asking that if you do submit for our pool prize by deploying something on polygon that you tweet your
smart contract at us and tell us what you're building and why you're excited about it we love hearing developer stories it really fuels our entire team to keep going just because we want to see what you're building and we want to amplify that work and maybe give you a grant or put you through our accelerator eventually okay so these are all of the different resources that I covered um in this talk uh you can take a picture of this or I'll have a screenshot at the very end or a QR code at the very end so that you can get all of these um when you're developing during the hackathon uh but we'll also be at the booth and we have lots of different members of the polygon ID core team here that can also help you develop their awesome super friendly and some of
the most talented Engineers I've gotten to work with so I highly recommend stopping by but thank you so much for listening to all of the things that I just said um all of the slides and the GitHub repo and everything is on this QR code so feel free to scan it and you'll have all of the links to get started building really excited to see what you build this weekend and wag me we're all gonna make it thank you [Applause]
