Aleo 🛠️ Private dApp Development
ETHGlobal·Wed, Oct 9, 2024, 12:00 AM
Join us for an Aleo workshop! From November 17-19 2023, ETHGlobal welcomed developers from around the globe to take part in shaping the future of Ethereum at ETHGlobal Istanbul. Over $600,000 USD in prizes were given away at the prestige Istanbul Congress Center... thanks for an amazing weekend hackers! ----------------- Follow us: https://x.com/ETHGlobal?s=20 Check us out: https://ethglobal.com/ Email us at: hello@ethglobal.com
Transcript
[Music] this is going to be pretty unstructured today no no presentation no slides um we're just going to hang out we're going to talk a little bit about Alo um I know some of you if not all of you are probably like hacking um so I think my my biggest goal really is to just get you guys the materials you need to be able to successfully hack earn an Alo Bounty um etc etc um hopefully you'll also learn something while we do that I guess the main the main thing that I'll show off today that I think is is probably most useful to people at of hackathon um one of course are the developer docs and two is a new addition to our web SDK that we recently launched called create Alo app um and this works very similar to create RCT app I know many you're probably all familiar with that um just just pulling the room how many of you guys are are planning on working with Alo this weekend cool uh so you guys are probably interested in ZK or or new to ZK or something like that um and I think that's exactly uh you know the kind of like hackathon participant that we're looking for uh you know the main thing uh you know as you can see here on the screen uh you know what Alo allows you to do easily is is build full stack private apps on ZK layer one uh and the way that we make this easy for you is abstracting away uh welcome guys uh the way that we make buildings apps easy is abstracting away all the underlying details so that you don't have to think about which prime number do we need to choose what curve should I use um you know what what proving system should I use right um and I think those are having to understand all those individual decisions how they work um you know what can go wrong if you choose one or the other I think is one of the big barriers of Entry to being a ZK developer um and so we're looking to abstract those away and and make things easy uh you know for your everyday Dev uh to get started by the way my my name is Craig I'm the lead Devo here at Alo um so if you do have any questions you know kind of the rest of the weekend I'll I'll put my Telegram and Twitter up on here afterwards uh and and we can check it out um so so with that said I I I mentioned that I would would check out at least two things right so I think number one your your number one place to go if you want to learn if you have a question the first place you should go to like you know figure out if your you know questions already been answered or it's been documented is is developer. al.org um this is there's a wealth of information here both about Leo about uh you know Alo instructions Etc so we can jump in here and kind of let's just take a quick look at what are the docs look like um you know they're they're nice and colorful they have syntax highlighting uh you know we love to see that uh you know we kind of it's what you'd expect from docs right we outline all the various features that are available some of our data structures um you know some of them are a little more complicated so we we talk about that for example records right uh if you're familiar with our architecture then you would know that it's not based on an ethereum like account model however uh instead if if you're familiar with zcash or Bitcoin um our model we call the record model looks a lot like ux where you have an input record that is spent to execute a transaction and there's end number of resulting output records right um a really important and very important feature is uh you know we like to say that Alo is ZK by Design right so you get privacy for free just by building on the infrastructure stock however you might want to do public stuff too right and so we do support both public and private use cases um and and the way that that is achieved is is via these functions that I'm going to go over real quick so the the number there's two important function types that um if you're going to take anything away from this talk today the these are the two things I'd like you to understand uh one is a transition function a transition function we can think of as the way that we do private computation in Alo we have a decentralized priver network that does offchain executions wraps those executions up into a proof sends it back to the client the client signs it with their key and then submits the signed proof to a consensus Network that are regular proof of stake validators using bull shark and narwhal like you might already be familiar with if you've looked into Aptos Oru right so we have a proof of work style execution Network you can think of this as like our compute layer generating proofs which are being signed by users and then sent to validators welcome hi everybody who just walked in thanks um so transition functions are how we achieve private computation so I mentioned the pro Network when we execute a transition function this is sent to the prover and it generates a proof right running a transition function will generate a private record which is wrapped into a proof encrypted signed and sent to validators so what about public state if we want to manage some kind of public state if we want to do a public transaction um you know maybe we don't want everything to be private uh we can do that with a function called the finalized function uh you can see a little more bit of the syntax on your own time I'm not going to go over this too much um but we can look at as an example of how could we Implement a um like a private transfer public to private transfer right um so we want to publicly initiate some transfer but privately transfer the balance so that the resulting sender we have no idea how many tokens that he received or how many um you know where they go from there and so the way that can be achieved is by using this finalized function right so we can store things in a mapping this example doesn't have all of the things I'd like to see so I will jump into a we'll talk about a token in a minute when I I jump to a more full-fledged example um so finalized functions essentially are just onate actions um you're submitting this proof along with a bunch of metadata to be validated and what is validated is it the proof yes and then the metadata are essentially the onchain actions that you want to do that the validator will execute um which will result in in state changes to the network so let's uh you know if we wanted to implement a private token uh let's let's check out what that might look like uh let's I'm going to pull up vs code here and I have a handy set of workshops which you can find if you're curious uh I will Google this uh so aloh hqw Workshop uh there's a repo that's full of these workshops that I'm going to go over real quick um so if we wanted to implement let's say uh a private token right uh there's two components to this one is is mapping addresses to balances publicly um if we H our token has a public component and then there's also handling private transfers between users if they're interested in that right and so we're going to go over how to do both of those real quick um so one we need to define a token record this is essentially the data structure that we'll be using um you know it's pretty straightforward we have an owner and we have an amount uh you know this is like the most barebones token possible uh you could imagine we might also have a trading symbol or something like that right um you know this this would look like erc20 or or whatever have you uh so let's first Implement minting tokens publicly uh the way that this would work uh I mentioned before that in finalized functions that's where we're going to be doing public on stain on state public onchain State transitions so we would simply get the amount that we're intending on sending ouri our transition function just forwards it to the finalize function and then we set this onchain mapping with the appropriate addresses the receiver and the balance now if we wanted to do a private we don't include a finalized function at all and notice uh one one thing to point out about Transitions and finalizers finalizers must always follow a transition and so the way that think about that mentally is we do something privately in a transition and then there is something public about this private transaction that we might want to put on chain maybe we store an ID maybe there's a hash whatever have you um so it's do the transition then finalize um and so finalized functions always overload their respective transition um so in a in the private minting case all we need to do is just return this token record and because it's all encapsulated in this transition function we'll have a private record wrapped in a proof that no one can see who it was Meed to no one can see who owns it other than the receiver this owner flag here in records is like a reserved word and essentially what this is saying is that whatever address is the owner is the only one on the network who can decrypt the record and see the plain textt of that record um so of course you can look at any records that you've interacted with and you own but no one else can decrypt them because yeah they're encrypted um so you can imagine uh transfers are pretty straightforward if we wanted to do a public transfer you know again we're not doing anything privately so we're kind of just forwarding to the finalized function here you know we calculate the sender amount we calculate the receiver amount and you know we calculate the difference we set the new balance of the sender and similarly we calculate the difference uh you know we add the new amount and the old balance and we set it private transfer looks very similar except for we're doing it completely in a transition function right so this is pretty high level uh this is this is Leo the language that you would be using to to write circuits um you know this gets compiled into an intermediate representation that we call Alo uh that looks very much like assembly uh it's still pretty high level for assembly uh but and then ultimately this gets uh executed as circuits um so let's look at a more interesting example real quick uh this is token again you can check this out at aloh hqw Workshop um but uh what about like private voting how could we do that by the way is this large enough for you guys to see is that better that's it's too big this is too small right um so if we want to do private voting right uh how can we do that so the the idea is that we want to be able to publicly store proposals like you should be able to go on the website and see the proposal read the text of it right and and make a decision on hey this is cool I want to vote on this I'm involved in this Dow or this community um but I shouldn't be able to see how you vote or and you shouldn't be able to see how I vote um but you should be able to see how many yeses how many Nos and and ultimately what is what is the result of the vote um so we're going to build that or this Workshop implements that idea um so first we have a data structure to store The Proposal information um you know simply title content and the original proposer and then we also have a private record that maps The Proposal info to an ID um so publicly what we're going to store are the proposal info right and then we also need to implement like a way to vote privately so to submit a vote um and we're doing that with this ticket data structure here and then we have public mappings for agrees and disagrees um so if we want to propose a proposal uh first we're going to to Hash the ID the title and that's how we're creating a unique ID um you know maybe not the best way to create a unique ID but in this case uh you know it's an example don't use this in your production app um and then we return a private record that is then finalized so we're just mapping the ID to a private record if we want to create a vote we create a new ticket record um and then we finalize this ticket that can so it can be used later when you actually make a vote right so this ticket doesn't yet have a yes or a yay or n attached to it right so we're here and then we create our new ticket we add it to this tickets mapping because we do want to publicly keep track of how many votes were made we want to keep track of how many yeses how many NOS publicly um it's the decision and the individual voters that we keeping private and that's this part right here right the owner of the ticket is being returned as a private record so no one can see that but you can see the proposal ID of course that you're voting on um and so in the case where we agree with something um right we're just the owner of the ticket is already private so we don't need to do anything with that but we do want to store for that proposal ID and this voting ticket increment the number of agree votes by one similarly with disagree the exact same thing right but just to disagree um cool so I I want to stop right here before I get into anything else it's a super short Workshop I only have 20 minutes uh I will show off one more thing which I think is useful if you're hacking with Alo this weekend and what that is is create Alo app this is how I would recommend that you get started with your project uh it looks just like create react app the only requirement is you have node installed so let's just run through this real quick right let me find another so we run mpm create Al w at latest there's a couple templates in here um so we make an aler project in this case I'm going to use react JavaScript plus Leo let's go into I'm going to go into the project and open it up into vs code and we're just going to go over what I just did what did this generate uh so what this generated you was and while we wait so while that goes we have a Leo file a Leo contract right uh and we also have a node app it's a node react app that implements some functionality to interact with the program that is in this repo here uh and so once this install is done I'll show you that we can spin up the react app and we can interact with the contract very quickly um and really the idea here was to just reduce the barrier to interacting with a contract that you might write on chain so if we wanted to execute hello world go in here right I think they uh recently removed this function so it's actually called run now well while I was sleeping the other night I had a workshop that I gave yesterday uh and they pushed a new version of the SDK that removed something my workshop used while I was sleeping um I love the the time difference here is is very fun uh and so we we debugged it live uh it was an hour Workshop so we had the time to do that um but essentially yeah like uh what we have here is a simple react app and a simple you know kind of hello react hello uh Leo but they're connected to each other and they're talking to each other right um so that this is the main thing that I really wanted to show off other than the docs and just talk a little bit about Leo uh 20 minutes is pretty hard to go over everything so I'm just going to you know let you guys kind of guide the rest of this and and ask any questions that you might have thank you any any questions uh in in case you have any yeah please what kind of math functions do you support like can you doting numbers all of that uh there so we can check out the docs to answer that question right um there are lots of there are a bunch of arithmetic operators uh so you can see more detail exactly what data types their syntax um Etc so we do have square roots inverses squaring Etc and what is a field is that not an uh it's it's like an arithmetic field right so like an elliptic curve cryptography um and you can uh you can read a little bit more about that uh in the data type section yeah so all this information is is there on the docs the docs are very extensive highly recommend you check them out um there's also uh the SDK I went over I don't have a lot of time to go over but there's a whole tutorial you can follow if you go under the SDK docs that'll guide you through it show you how to use it etc etc etc uh one last thing if you need to get a Leo wallet uh go to bit.ly Leo Workshop because the faucet uh faucet's been a little unreliable lately uh so go here I I created a whole yeah yeah I I wrote some Python scripts to automate wallets I filled like hundreds of them and then wrot a Google form automation to like send you guys a wallet and your email of course like don't use this private key in your like production app but for your hackathon purposes it should be fine there's already credits in these wallets uh you'll just get one in your email uh I'll show you how it works uh so if I just do Craig ad.org I go to my email just maybe not it's the wrong email right got to email uh yeah it's not working so I will fix it in the next five minutes but uh I'll show you an example of one of these when it works uh let's see it looks something like this yeah so how many uh it's like 25 credits which should be more than enough to to deploy a program to uh you know do some executions um and if you need more like please reach out uh my contact information is uh Craig Json on pretty much all platforms you can follow me on Twitter you can follow me on Telegram um you know feel free to just like reach out uh and I you know I'll try to help you as best as I can I'll also be hanging out at the venue for a little bit um as well so if you want to come and find me in person happy to chat uh but I think with that I am just about out of time so I think I have time for like one more question uh if anyone has one uh mayet is coming early q1 so right now we're looking at late January to February uh so right now we're in like late stage test net uh but you can deploy you know you can pretty much all of the features you'd expect are there uh where we're we're currently like onboarding external validators right we've been running the nodes but we have two validators that are onboarded and we're working on uh you know kind of fully decentralizing the network before we go into mainnet so pretty exciting stuff C uh like a box counter like an Explorer yeah yeah uh so there's a few of those one that you can check out is called Alo 123 uh another is Hamp Explorer there's also explore.
al.org uh and there's a Hamp explorer. H.A so three options all have different features uh recommend you pick your favorite yeah yeah thank you also I believe we have a $5,000 pull prize this weekend maybe it's 10,000 I actually forget uh but uh we have some bounties as well so check them out um you can find them on the E Global website um um yeah and thanks for coming I appreciate you guys thank
Automatic transcript — names and jargon may be misspelled.