New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

How to do something to some state in some contract by José Pedro Sousa | zpedro | Devcon SEA

DevconTue, Oct 7, 2025, 12:00 AM

Speaker

José Pedro Sousa

Smart contracts are changing. So far, they needed every transaction to be public in order for nodes to agree. Zero-Knowledge came in to change things a bit: you can actually make your transaction client-side and just broadcast a proof. In this workshop, we will use Noir and write a simple Aztec and/or Ethereum contract that allows for most of the execution and state to remain private. Speaker(s): José Pedro Sousa | zpedro Skill level: Intermediate Track: Applied Cryptography Keywords: DevEx, Privacy, Decentralization, Cryptography, Mobile, proving Follow us: https://twitter.com/efdevcon, https://twitter.com/ethereum, https://warpcast.com/devcon Learn more about devcon: https://www.devcon.org/ Learn more about ethereum: https://ethereum.org/ Visit the https://archive.devcon.org/ to gain access to the entire library of Devcon talks with the ease of filtering, playlists, personalized suggestions, decentralized access on Swarm, IPFS and more. Devcon is the Ethereum conference for developers, researchers, thinkers, and makers. Devcon SEA was held in Bangkok, Thailand on Nov 12 - Nov 15, 2024. Devcon is organized and presented by the Ethereum Foundation. To find out more, please visit https://ethereum.foundation/

Transcript

[Music] uh okay uh I'm sorry uh yeah um let's yeah yeah I was can shpt or I don't know what to do I'm bit lost no I'm just kidding I actually know what I'm doing so uh let's um talk about Aztec so namely how to how can you do things to state in some contract or just make the chain say that something happened I'm Z I'm a Deval engineer at atic Labs I'm very glad to be here I'm very this is a big deal to me so it seems like my clicker is not still thing uh okay oh yeah to turnning on so yeah there's this person um I guess someone that likes ethereum it was like thinking whether ethereum is actually the real life or not and I met someone else that was also the same I would say conference and they were thinking if it's actually just fantasy um and there was also like someone that CH oh mama I'm kidding okay this is too much um I'm going to you I'm going to yeah I just came out of bed anyway but uh what I want to do is just that you actually can't represent the real life in a global Ledger because causality in real life is private but let's okay let's start from the beginning this is too much let's start how can you represent the real life if you're using the world's most expensive clock which is ethereum so let's start with some agenda yeah I even have an agenda it's really cool so let's talk about the secret to success this is something I know I'm give it going to give it to you then I'm going to tell you who you are and then finally oh tell about the world's uh most expensive time stamp machine which again is ethereum and then I'm going to explain to you how can you keep your secrets when you shout them out loud there's going to be a demo at the end um at the end most most of the time is going to be a live demo for you to also uh try in your own machines so the secret to success and happiness I know what is the secrets to success and happiness and I'm going to give it to you for free because I like you and there are only two simple steps right first one is you have to tro on yourself okay you're going to take all the real life facets you're going to put them in a global immutable public Ledger okay if it seems like something you've seen before that's just a coincidence nobody's doing this right publicly nobody's doing this right and then uh you just became a dictator I mean it's perfect like you just can be happy be successful you can do whatever you want uh it's amazing right uh but if you're not a dictator I'm not and if you want to be a dictator then who do you want to be who are you you need something right so I asked some worldclass scientists about this uh except not but anyway I would talk I for example I talk with some physicists they said yeah definitely I can represent people as uh having a deterministic position velocity I have actually have some code here you can write uh a stru that has a position and velocity but actually do you need that do I need that to see that you are here you you do have a position in velocity but it's private I don't actually need to know that as long as we agree what time is it and that there's a common time I don't need to know that I can actually see the consequence of a cause without knowing the cause the same for biology you can have some blood pressure pressure you can have I mean whatever glycose levels um again as long as we agree on a common sense of time I know that you are here you are alive so so again this struct is completely private can be private psychologists say the same thing you have some memories memories are important because they they rule the way that you uh you engage with the world and still I can see that you are engaging with the world so you are social being so this is also something that affects the real life and now you're like why what does this has to do with with azc right you're just talking about random stuff I said no because actually so far all blockchains imply full knowledge of all the public inputs everyone needs to agree on everything and everyone needs to know everything and that's what Astic the couples so actually the world is actually not random it's just like you just see a ton of private execution that happens in our brains and even in nature and we just don't know about it and it still affects our environment so privacy is quite a big deal isn't it it's it's kind of also a human right and this is I mean this just little book that says that you actually privacy is actually human right it's I mean it's just a universal Declaration of the human rights right so it's kind of a big deal you can't just ignore it you also cannot like just ignore it you cannot uh ask someone to keep privacy to say oh I'm piy promis that I'll I'll keep your data there's even laws like gdpr that says that there are people saying oh yeah yeah I'm trust your your password will be safe with me please yeah don't you can trust me etc etc etc but actually if you go and think about the blockchain blockchain without privacy is a a willing nightmare so there's a problem here that we need to figure it out right here's a tweet about about privacy on guard that I really like it it's like everyone is oh there's this new new uh thing blockchain we're going to rule the world it's going to crack down on financials uh it's going to be a big deal but then let's just put everything publicly on a public Ledger what right are we mad like this is just this is just wrong right so in short we are encoded with our secrets in real life uh this is an example I hate brokoli so that's something I can add to my representation I actually I don't have to tell you that if we're going to go to a restaurant or something I'm going to choose a plate that has no broccoli because I know that I don't I don't like broccoli and I actually I can even influence you to choose another plate that it's not broccoli because I don't know you just found that whatever I chose is best and you would you would choose broccoli if I wasn't there so I just kind of shouted that I hate broccoli without revealing anything I I'm not leaking any any any information about me you just you just see the consequence of an action without knowing the causality and with blockchains everyone is leaking everyone is leaking your data and this is something that your data just can't leave your machine if it leaves your machine it's not private anymore so let's do something um I promised there's going to be a workshop this is a workshop a real Workshop you can drive with your machines um so here's an an agenda um going to boot up like this world's most expensive clock then write some programmable privacy and then run it maybe it's not uh yeah maybe I should do it in a put more information here so yeah we're going to set up this development environment we call it the sandbox because it comes with pxc and everything inside um we also going to like generate some useful typescript bindings okay I'm kidding we're going to deploy with a with a CLI but then we're going to write the Cs bind because they are useful but that's that's fine you can leave now no questions asked right um then we're going to write our deployer which it's I mean it's also typescript but that's fine there's a script that does most of the most of things for you then writing a contract which is going to be very useless it's the voting contract that everyone can see what the tally is right it's completely useless but still interesting because there's still some private execution because no one can see uh who you voted for I think that's Ah that's okay for workshop and then some uh bonus points for for testing just just seeing that it works I mean maybe it won't maybe I'll make some mistakes some yeah anyway um then I'm going to go on the good stuff which will be private native account abstraction which is kind of amazing like it it is re really really good stuff but yeah maybe for another day just I just wanted to say that we have native private execution native private counstruction which is really amazing um for uh private Network and then enough memes we can hack um this is the QR code for the Noir docks for the Aztec dog sorry um there's a link tree right here with the dogs as well yeah so that's the azc Discord you can join I hope the link is still active and there's the link to the documentation we'll probably have that as well and then yeah my link tree has my socials and also some Workshop resources there's a kind of a sheet sheet you can you can use for stuff that I'm going to just copy paste so you can run it on your machines as well if I didn't forget anything and I think we're good like to to start just going to wait to stop having phones in the air Okay cool so I hope you can hear me now still cool so let's hug um here's the so LinkedIn here you can have a code space if you for whatever reason like you're using Windows or something and you don't have a Linux or a Mac machine you can use this code space should work uh it comes with the sandbox so the first part actually already done for you um there just code Snippets you can go and this is just going to open this page uh which has uh most of the stuff that you you will need um yeah actually I should have these notes here as well so if I there's also like some sheets here at the end probably going to use those if I if I miss something uh so the first thing we're going to do just open a new project um I can start the sandbox so to install the sandbox you can go and just run this that's the first snippet you go here you install it and this will install some uh useful uh CLI tools um just say Yes um it will install the wallet the nargo which is compiler and Aztec which is the chain basically just sticking track of time and once that's done most of just Docker images as you probably recognize that I think the font should be is it can you read it or should I make it bigger uh bigger yeah cool is it good now all cool thank you so yeah now you can start the sandbox you can go Aztec start most of the commands are actually here already for auto complete so you can go astec start SL sandbox and this will start the sandbox sandbox is just envil okay no big deal um a layer one pretending to be a layer one and then there's the layer two the Aztec uh node that is starting we'll kind of register some accounts I mention native account abstraction um mostly because so you know that any contract is actually uh any account is actually a contract so that could be useful um in a bit so then we can start with the writing an app so I can go npx x a up in it and actually this didn't didn't work for me yesterday so I may have to write the whole thing anyway this a up in it will hopefully it will probably ask you to install a app this is just um yeah it's it didn't work I don't know why there's something here with get sorry yeah yeah yeah I can wait yeah yeah um so yeah there's something here um that is um not correct so I'll probably have to write most of the stuff um actually since I'm since we are waiting I can actually go to the astec uh GitHub and just go and copy that so we can start quickly some boxes and then there's uh okay not boxes is uh um in it yeah here and yeah this is what it should be cloning but for whatever reason it's not actually I'm going to put this in the resources here as well so you can follow along if you're looking into sorry the QR yes uh here you can look at that is it good the sandbox or still still downloading it's low yeah that's we can wait a bit more that's fine um yeah I'm just going to copy this so so just take care of what this was not cloning and yeah you see there's some scribble errors and this is because I haven't um added the the dependency I actually want to talk a bit about dependency so this is uh there's some questions around what is the the relationship between and Astic and this is a good question like this is actually Noir if you've written any Noir you know how it looks like why is it why did it copy twice I don't know um this is nor um but you see some things like this macros and what what are these and this is uh stuff that is going to be injected by the Aztec dependency so Aztec NR ASC NR is just a dependency that you can import just like any other Library so you do that in nargo dol and here is the the path which is wrong I think that's why it it wasn't cloning correctly so but I actually I have here the dependency so this is just importing this particular dependency um from the from the cult Snippets um so yeah it's just just a library right no big deal and so once you save that you'll hopefully this will stop screaming at you yeah okay uh more or less anyway there's as you can see there's a an LSP so uh it actually help you autocomplete stuff uh which is really cool still kind of in the works but um I mean it's useful anyway so yeah to turn on lights is it can can we turn on the lights just these lights to make it easier to read thank you ah perfect cool so yeah I hope the sandbox is downloaded um if not you can use the the code space it's going to probably be faster and actually can even use the the sandbox it's will port forward to your machine um so yeah going back to the code Snippets I'm going to import this depend CES as well these are just um things that we'll need that we want to import from the Aztec um dependency again this is no so we want to be sure that you want you're not importing the whole thing you just import what you're actually going to be needing and this is what we're going to need we're going to get the public keys this is to get the Notifier and and also uh the initializer function internal private public those are like macros that we going to be needing uh storage and then the types of the stuff we're going to be storing which is going to be just the Aztec address a map just like a map on ethereum and then public mutable which is as the name says it's something that is actually public and everyone can change or it can be changed in public so we are going to actually know and Define our storage so storage you go and say storage right no no big deal uh and just Define storage so there's there was this context thing that we need to pass wasn't here now wasn't here before nowadays that's something we need to I guess figure out how how to get rid of this context kind of annoying so this is where our structure comes into play so the way that we're going to be doing this is our election or voting thing will have an admin admin will be will'll see everyone's votes it's really cool uh there's probably going only going to be one candidate because that's that's how democracy works I'm just kidding um and then there's going to be a tally Tally everyone can see that so actually all the staries is going to be public which is fine it's just as easy as make it private actually it's even sometimes harder to do stuff in public than it is in private uh so going to Define an admin I'm going to say admin is going to be a public mutable um Aztec address so this is going to be us right the deployer and then tally um this is a map so yeah map is just like in etherum I'm going to use what we call a Phill which is um um a native type in in just kind of represents you can think of it as just representing a number I would probably H probably going to be killed by saying this but it's you can treat it as a bit of a kind of a big integer yeah yeah I hope there's no ASC team members to kill me now anyway uh and this map will be just uh mapping between a number that will be representing a candidate and then the number of votes um so fi and this is going to be public mutable because all the votes are Public public mutable field uh this is where I think I need to pass the context somewhere everywhere uh I think here context and I think as well here context um cool and so that's that's how it goes the way that we're going to okay let's just actually start with initializer so let's make it I think uh public yeah it's fine I think uh initializer uh you can actually call it anything uh you don't have to call it Constructor um I'm just going to call it Constructor because that's how usually people call Constructors but uh and I'm going to pass the ASC address as the as the initializer and this will just set me as the admin so I'm going to say storage um admin and then wres uh admin okay I don't need to return anything so this should actually compile if I didn't do anything wrong let's just try it let's just try compiling um a nargo so asek nargo is nargo is if you know Noir is just the compiler for for no so aak Naro I hear it's actually now it's the same thing it wasn't the same thing some time ago but it is now but for some reason still call Astic Naro so yeah just it's t of warnings warnings are not there so just ignore it I'm just kidding but yeah we got to eventually have to fix the warnings as well um but yeah compile like you can see here like there's the there's the here's the in main thing that seems to be working so yeah I'm I'm happy for now um so yeah it's kind of useless that it just deploys and that's that's it so let do something else um me me see my notes uh if I didn't forget anything no I didn't cool so we're going to write the logic the logic is not very complex we're just going to write a private function so private function executes client side and the only thing that goes out is just a proof and that's what's going to be screaming out loud you're going to be screaming out loud actually they're going to be calling a public function and say oh add another vote to the to the to this candidate and you're like oh but the candidate is going to be public no it's not like I mean the candidate is but who who voted is not so your your privacy is still reserved even though we're just saying to the note yeah please add another vote to this candidate so that's that's part going to be working in in public which is really cool so to define a private function you just do the same thing you just Define private and then just right let's so write cast vote cast vote and this should be um I'm going to have a candidate it's going to be also filled um because it's just like 1 two three four five whatever um so good uh now we want to basically the way we're going to do be doing this is there's a nullifier we're going to create for this specific app there's going to be a nullifier and this nullifier will actually be um so you can't nullify twice right for this app you only can nullify once with your key uh surely you could rotate keys and that's something that was actually in our road map but I think uh we're going to drop that um but yeah it's kind of useless right You' have to do a do a different logic so let's call it um NPK MH this just a nullifier uh [Music] key and just call it get public Keys that's what we defined before for account so going to use context message sender here this is just basically me right and then just get the Notifier key um uh hush you see the auto complete here doing its job thank you because I definitely forget it so now I have that I need to create the Notifier for this specific app you know want to use the nullifier for everything otherwise people could actually track and see where are you adding your nullifiers and it could be a leaking privacy so you want to have one specific for for app so say like NPK um app yeah something like that and this could be um uh how do I how do I with this last last time it was like uh I think NPK M HH npm no NPK M hash and then I note it anywhere I don't want to mess it up okay it says I think it's here no it's not this one um let me check my notes um I actually I have the sheets here in the sheet sheet sheet so I don't forget around here yeah okay yeah it's a context yeah I know it was something that was already there so context yeah you get of course it's context because it's like the private context um you're just saying yeah in private please get the nullifier for this specific app so you get uh where is it request and and NSK up and just send the master um Nar key and this should I think that's fine and this should be um good to nullify so to nullify basically I'm just going to do something that can can't be hopefully uh replicated or just attacked in any way so I'm going to Define like a secret let secret and do that secret uh it's going to be a hash this is actually Noir so you can use whatever hash is in the standard Library so I'm going to do that uh for example I think the easiest one is is Pon going has has and then um pson and pson hash yeah and then it's going to be context um need context uh this could be message sender uh two field right yeah it needs to be a field and then another field could be uh D npkm I think yeah this is a fil cool looks good so now I have a secret uh um oh wait not not secret nullifier um yeah that's this one is a secret um so now I can push this nullifier to my uh private execution environment so private execution environment is actually aover that is running on your machine because again if your private inputs leave your machine they're not private anymore so going to say context private context context is a real really cool word because if I if I call context in in a public function like an initializer it will actually look different um so it's um it's a cool one so I'm going to say context and then I think it's push nullifier uh nullifier uh read request I didn't have those in my note maybe it was a new version see yeah I hope this works still um I'm pushing this nullifier and then um um weird we I get that and then we're good like we have an nullifier we can basically say I can't V vote twice because if you try to vote twice it will say uh already the secet is already the the this app so you can unless you have a different counter you can rotate your keys then you can vote twice and if you can't vote twice that means that you already voted so if this function calls the public function then you're good it will means that your vote is actually not be able you're not going to be able to do it twice so I can Define here now a public function going to call public function uh just want to be sure I do the same naming because of the the interface uh oh yeah I called it a to add to and this will take the candidate which will come from the other function and say uh storage this is the the easiest function ever just going to get the tally at the candidates and just read it okay going add that to like call it preview or something previews and then this will basically it's a public it's public so I can read it tell is completely public I said at candidate this mapping just get the number of things and then just write that plus one right storage um wait what what is happening here storage um tally at candidate uh right right uh preview plus one right this should be okay we want to call this function so I'm going to call that in a previous function say the name of the contract is composable so I could actually have two contracts that's fine as long as I had an interface just like ethereum so I can go Main in this case I don't need it's the same contract so I can say main ad um this is going to be I think context and then uh this address I think um and then I think it's the name of the ad candidate it's that candidate and then I need to inue this because I'm going to ask the I mean I could have different one different um public functions it will just go so so I'd say in q and then I'm going to pass uh public mutable context not public yeah it's private actually cool I think this should compile if I didn't mess up anything okay aho happy uh now there's just one thing that we need which is to read it right and to read it it's actually not hard because your private execution environment is synced with the network it should be synced with the network so just read from that it's just like a view function on on ethereum except you're not calling anything to get your function you're actually getting it yourself because you're synced with the network really cool isn't it like you an un constr function it's actually a view function is actually just calling your own machine so so I go unconstrained this means that there's not this is not even a circuit it's just uh just computation so like plain conversation uh so I'm constrain function and I can call uh how do did I call it last time just H I don't have that just like like get T maybe this should be get t for one candidate it's could be filled I have to I want to return that I want to say public fi so in Noir you always have to make returns public because they are actually inputs so and just read and say storage um T at candidates read returning that so no need to add the return also no need to add the semicolon at the end so this should be compiling cool so we have our contract we can deploy this let's do that uh let me just check the time okay we're good so to deploy we can use astec wallet astec wallet is CLI tool um we are actually working with uh people to actually make this an actual wallet but we just developed the C tool there's one person that has building that um but yeah you can use the CLI tool and basically just same thing just need to add a a a graphical interface and there's obviously the question or where is your pxc running that's another that's another discussion uh in this case the private execution environment is running inside your sandbox and this is important because later on we're going to actually be instantiating a a a um pxc client and you're going to say how is this how is this private it is because the sandbox already has um a private execution environment uh but in a test net that's that's another thing because there's no there's you're not running your own network so you want to keep that the pxc private um the name implies right private execution environment cool um so let's just start a wallet um a wallet is really really cool the way um the team has been building this so just open this a bit more because you can actually do pretty much everything and most of all you can define an allias allias are cool because you can for example deploy two contracts or two accounts and again give them different different allias and then just refer to them later on instead of having to copy weird um like weird exod decimal strings of the addresses and stuff so I'm going to ask like Wallet create account uh I'm actually going to reuse the same so I don't I don't mess it up um so yeah I'm defining here a is going to be the lias and say my account so when it deploys it will actually so here's the account public key Etc and then just like start in a local database saying this is the my account also an allias called last so you don't if you don't Define it it'll just like assume that it's the last one this is also really really cool so to deploy this I'm there's another say another one that says deploy again reusing what I've done yesterday so I didn't okay there's just here I need to change so it says Astic deploy from the account that we just created that has the lii accounts you just say from this account I'm going to deplay uh I'm going to I'm going to deploy the one called init main so it will you can actually use the name of the package and then the name of the contract like this init at Main it will figure out its own thing and then just send the the the arguments so that's the initializer we we're saying that initializer takes the admin which is us so I'm going to pass that and then also can create an another allas calling this my contract so it's save under this address so is deploying to my network through my pxc and that's stored in database so it's called like now it's called my contract so at this point you're like okay maybe I can get to tally right now I can I can see should be zero right hopefully uh so we can try we can say uh as quallet and then simulate because see why do you want to simulate it because you're actually not calling another another note you're write you're getting it from your from your pxc so it's just simulating uh simulating transaction no need to call anything because also that would reveal data you don't want to reveal like who are you asking for and you don't want that you just want to get your own stuff so we just pass the contract as address as your contract the contract was just deployed from I'm making this call from my account so and then just get the t is it called get t uh yeah get t oh okay just saying like for candidate one for example so that's going to be arguments one and hopefully this will get me zero okay cool zero that's a big end we like big ends so that's a big end um now I want to vote let me see an wallet uh send because here I'm sending a transaction I'm I'm executing a private transaction that will actually make a call uh on the public side later on so same here I'm just saying contract address it's the same contract address from my account and I'm casting a vote with for candidate one just doing that uh cannot find the leave for nullifier oh I think this is probably because of that thing that is with request personal fire let me see if this works should work and need to compile yeah I don't know the so I have an account so I can deploy from yeah I can deploy oh I think yes okay so now I can send it uh what's happening I'm uh I compiled just get my just going to copy the cheats from for this I know this work I tried that yesterday so oh yeah uh I forgot the internal which is cool otherwise you could actually call this public function and add random votes not probably what we want [Applause] so and try to compile that again and toly please work okay it works yeah I don't know I think it was an internal thing that was missing anyway uh now it says like yeah I did make a transaction actually transaction has an allias so if you want to get like the transaction hash or stuff that that's fine you can you can do that so now if I call the get T again I can where is this uh simulate if I get the tally it should add one and just to prove that it works I can actually try to vote again and hopefully it will fail yeah it says that it's it's the it's unable to be added to the state and it's Evol I think it doesn't even like do anything because it can prove it can't make false proof it just says yeah can't can't go further than this so so far so good I'm actually happy for this and let me see just the time cool we're going to have some time for questions which is really really cool um so do doing the wallets is cool you probably want to do this in a browser so first thing you want to do is install button right okay this is if you don't like JavaScript if you don't like typescript if you're like me just use bun okay it's really cool you just use a typescript you write script and it works okay so if you want to do that just go and it's the last time you're going to run an npm command so go npm I G and then burn right and this will install burn okay please please do that it will yeah it will save yeah first thing you should do in any machine um so now that we have burn we can go like actually start a new project and say just uh just create index.ts um yeah I think I can I can go with the browser already uh don't need to um yeah just just let just immediately start with the browser I could show like a little test script but I really want to show you the browser maybe it will fail there's many things that can fail with the browser but still could be cool to to show you how can you actually use um an app like an actual web browser app and use it to vote privately isn't that amazing like it's really cool so uh for that I'm going to use npx uh or yeah let's called B BX which is the same thing I just I just don't like npx okay I'm kidding npx that that works as well um npx and then create VD and here is the command it just starts um it's a template so I mean I can actually do this create VD and just like this and they ask me uh what I want I said yeah just ignore and just add your files to here just going to choose react and then choose tab script react and here I have a like very simple app that's just uh hopefully works and I can actually try to run it B runev and uh okay what is B randev is not here oh okay for I forgot to install dependencies so here I have I mean it should be working like just the normal bur app just want to be sure okay cool so let's start writing some some stuff I want to do two install two kinds of dependencies the first one is the Aztec dependency so Aztec JJs and Aztec accounts these are Aztec JS is the interface to Aztec uh it allows you to call contracts to interface with your pxc so that's what it does and atic accounts provides you an easy way to create accounts we're actually going to use a testing account because I mean it's just a a workshop no need to actually using test accounts is cool because it creates a new one every time so you can actually have more than one vote if you just restart the app um so yeah and install that um one thing is like ascj is not yet really optimized for browser so we're going to be using some polyfill so if you know a bit of JavaScript you you know that JavaScript can be run on the browser and and the not at the same time which is cool but also a bit annoying because I mean JavaScript was made to make things FL flashing the screen and we actually suddenly make it in the browser in the in the node um so yeah we're just installing some po poly fills to say I've written this for note but I also want it to work in the browser so to do that I'm going to install some VD plugins oh here they are top level weight and the PO fills top level weight I don't even know why isn't there like by default most browsers already allow you to use top level weight which would mean like just writing a weight here um but yeah for some reason I need to use a a plugin for that and then node polyfills it's just what I just mentioned some stuff that is in the node but not in the browser so I want to have that so let me call top level weight from vit top level weight and then import I think this is a named import um which is a node polyfills uh from V node polyils and just using that as plugins top level and then not polyfills okay so I'm good I think it won't break um so we're good to actually write some um some Noir code um oh one thing I I need to do uh I mean I don't need to but I want to do is to create an interface so really cool about uh things in a is like you can actually create a typescript interface that makes it very easy to interact with the contract so if you go Aztec Cen I'm going to point this Cen to my target which which is here so this stuff has actually all it's a bit of an an AI as you can see it also has all the bite code and everything so it's there's a point where it just can't yeah it's not human rual but the first part is and so it can actually use that to generate an interface to say oh you can call these and these and these types um to these functions and so that's what is going to be doing into the artifacts folder so look at this really really cool like you can you can call this function this is a class you can call this class and get like pointed at the different addresses that deploy it and and most of all it allows you to call these functions so you could just import that that uh this this file and just use it as as you want it so uh Codine is really really powerful so um I'm going to actually kill this uh index TS um also going to I deploy this I'm going to deploy again just because I I need I want a fresh contract deploy um so we don't see we only see one vote hopefully um so I have here the deployment just called I mean add a new file say deploy text just so I I don't lose it in the in the history the terminal history so now I'm going here to my my uh I think app. TSX it should be okay and I'm going to um instantiate a new wallet and say oh here's a new wallet again it's kind of stupid because if I redeploy if I just refresh the page I'll get a new wallet because it's a testing testing world so if you're probably if we restart we're going to be seeing like two V three vs that's fine um and so here's like uh import and um I want to import the stuff from so um I guess create pxc client um from astec JS I want to create an account so create account uh from Aztec accounts going to call the testing ones so if you see here is really cool like it just creates a random random account um and then I one of my interface uh import main I think this is also named main contracts uh from uh what is it artifacts M right is it called main contract yeah it is cool so um first thing I want to entiate my pxc so I'm going to so say pxc create pxc clients I'm going to pass the URL so as I mentioned PX is running on my machine because it's part of the sandbox tooling so HTTP Local Host 880 now you see what's the problem with pxc where where does it run if it has your public in your private inputs where does it run it needs to run in your machine right if you're using Aztec you want your public your private inputs to remain private and they need to run on a phone they need to run on a desktop whatever you're using your wallet your inputs can't leave this place so in my case it's not leaving my place it's just calling my own server um so that's why 880 but where is the sandbox is running so I can go pxc create pxc client Etc now I want to create an account so just going to say let go this wallet actually and say create account oh create account create account and passing the pxc so it registers in the pxc and says here's here's my account so no I should have a wallets I can I'm good to actually go and uh I already have deplo the contract so let's just go on the stand standard um oh wait standard react development here um as with every react uh development you just remove everything right first thing that's because you don't care and you're going to write three functions those are like uh starting just to getting my my my contract address and everything um and interface and I'm going to also uh be able to vote and then I'm going to be able to see the votes and that's enough so I'm going to write uh an init function called a sync um this is uh okay for example contract con contract and I say a wait main contract at uh the address that we here uh we have stor here I mean usually we actually deploy with JS which is also like just main contract. deploy not big deal I'm going to pass that here also my wallet it's probably yeah it's going to complain because it says oh it needs to be an ntec address that's fine just C that to an ntec address and say from from string and it says cool I just get a string and just pass it just convert it to an nasc thing also I think I need to wait here cool so I have contract here I'm going to store that in in my in my state set contract use State uh it will complain about the types I'm going to pass the type main contract just make it B zero then I can set it here set contract contract so if you know react this is the kind of standard thing you would do also this is the first thing I want to do so I'm going to use effect create create an effect so it starts that's the first thing is it does but I can't I can't use asynchronous functions in use effect they need need to be synchronous so I'm going to call in it here and and then when I render that's when I'm going to say if there is T I'm going to go ahead so to get the tally I'm going to say get T um same thing I think pretty much the same kind of development flow but now I should have the contract uh actually I may not have the contract so I'm going to go contract hope it doesn't break um contract and methods right I want to call these methods and as you can see I have all the methods except the one that it's public because it's in journal so I get cast vote I'm going to pass one that's my candidate I'm going to send is a not simulate it's a oh no sorry simulate yeah simulate um then that's it I'm simulate just as long as I wait that I should be able to get a tally and wait and yeah you know what I'm going to also add that to the state and say t set T this point I think I'm my fingers already know how to write this you know just uh it's a big end and just make it a zero n does it work yeah yeah this this thing is new the end thing um so I can set it here I set t tell and this is cool uh so it works should work right now I finally I want to vote so vote uh sync you probably know what I'm about to do it's just the very same thing I'll just say a wait contracts methods cast vote oh wait it's not cast cast vote here get T um cast vote one going to send I'm going to wait for it wait for it yeah uh I'm going to update this the tally right I'm going to wait get tally because I want just having it shown on screen easily so now I'm good to write our good old HTML so uh just call it uh voting contract um just make it a a paragraph I'm going to say uh Chie uh Chie cannot be there right so I'm going to maybe Chie here then say um I yeah tell so T is um that's why it says so string because T is a is a begin so I need to go to string and maybe cast it to base 10 um yeah I think this will work otherwise it will complain it can't really render begins and I'm going to add a button as well so like on click I'm going to go click and vote and just get so vote for the candidate other candidates are not available it's democracy cool so I think this is it like right I never forget anything um so I can actually go and try bur run def I'll be surprised if this works oh yeah yeah it's complaining it says that it can't resolve FS promises I think um I may have been too optimistic about the node polyfills I'm going to exclude that so exclude just the fs see if it works this way yeah okay all very surprised so let's try it uh it could take a while I think the JS it's kind of big so that is probably why or oh cool did I get zero nice so what happens if if I vote I'm going to open the console because it's probably going to error voting for the candidate there's no spinner or anything like that cool I have one wo so what happens is I I try again so hopefully also fail yeah it fell cool so let's just restart this and see it should actually go and see twice if I start a new new one because uh like the app is it's going to be um it's going to create a new account so this should should actually have one at first like immediately because it it thinks that someone has voted already um okay no it's zero oh because it's zero at the beginning I don't get the T at the beginning so that's why but voting it should be two maybe yeah cool yeah so it works but if I try again it will just say oh that key has already voted that you can do it wise how cool is this like it's really cool this doesn't leave your a machine like actually I think the pxc is not proving because there's a flag that I need to pass uh these guys should know if I need to pass a flag so but the proof is not in this case the proof is not even too big so it shouldn't it wouldn't even take a long long time um let me see how how much time do we have so we can maybe look at some other code let's see yeah do you have a lot of questions or okay I'll say yes so yeah just I'll leave like 10 minutes at the end should be enough yeah so let's look at some some stuff that has been done here um first of all we want to look at the look at the contracts uh so one one thing that you may want to know it's um what about ethereum what's the thing about ethereum you never touch etherum apart from using Anvil um but if you look at the at the actual sandbox here um you can actually see that there was a rollup being made um you see there is there was a rollup being being being sent into Anvil and if I do get the the Anvil logs I should I should say I should see it um I should see the logs there the thing is like you can actually pass messages from L2 to L1 quite easily so if you see the documentation um docs. a.

Network you can see here in the references you can see um how to do that so I think there's even an example with that so here where we will be able to make a token Bridge so there's an actual example on what we call portal contracts this allow you to make message passing very easily it's done via the sequencer um so you can basically make it quite easy to by deploying your contract on L1 and another contract on L2 you can actually pass messages it will take some time because I mean there's there's message passing takes time for blog time but still it's really interesting you can actually move funds into into L2 make whatever you want to do and then maybe pass into a different L1 uh if you want to because that's not even like it it's unrelated with the kind of um um Network you want to connect to but obviously there's going to be a rollup so at the end if you see the architecture and the resources here you're going to see that there's going to be a a rollup that will be done um by with all the transactions so the architecture kind of implies that there's the sequencer the sequencer will kind of ordered all the transactions as they want um like I think there's going to be a like a a roll back solution with the making it a base rollup or something um but yeah there's going to be this transaction ordering and then the sequ will say oh I need to prove this now uh who's who's who's available that's pretty much that the sequencer can actually prove it something if they want it's going to be a big proof with all the transactions will be proven and be red up uh into this roller prooof and will be again be verified by the by the sequencer which will post the proof on L1 and verify the uh transaction verify the whole block in one in in one proof which is really cool um or the sequencer can say yeah I have a Marketplace um for example and I can delegate my approving to a Marketplace and whoever beats the most then cool I'm going to go with that or a the list in this case I'm going to pay the list to prove my block so it's really cool the the way that the thing works so it's actually a ZK ZK thing uh ZK in the sense of there's privacy and also ZK in the sense of all the transactions are going to be rolled up um so this is probably my favorite thing on on on Portals uh you also have another really cool thing which is try to find it uh not portals where is it maybe here Concepts star partial notes so partial notes is really cool because you can actually did I say that you can do the real life represent real life in Aztec it's really cool because if I make a trade with you like a swap it's actually going to be a two transaction thing I I give you something and then I wait for money for example if I'm send if I'm selling you something and so uh we actually want to do better than that in in ASC where there's no two transactions because if I'm selling you something I can also we can also trust a third party and just say oh please hold that for me and then when when you get the money then give it back to me so just kind of an escrow but they're like we can do better and so we buil this uh idea of kind of AIC Tomic swap that they just run it at once you get you you can um you can have someone uh actually pay the fee for you for example for for this for this situation um and so you basically you're making some computation in private um and then the whoever is paying for the fee can actually um update that that that point in in public and say oh um even though you said some random value for the gas fee for example I'm actually going to update that and and pay uh the gas fee for you and then send you back the the the remaining or just yeah create another note for you so this there's some cryptography involved but this is really cool for again uh private swaps that you could do it at once so um paral notes is also quite interesting and cool um so as far as other contracts go you can actually um start really easily and I could make this Workshop very small if I just deployed one of the boxes and just call A in it and then create uh either a react app or just a vanilla app this was very very cool to write this is just I really I like JS like the real real JS like like real stuff no Frameworks no no stuff like that so I I built this that just use actual event listeners and everything just to prove that actual there's no black magic here this is just JS the purest thing you can find uh it's actually typescript and anyway this is this is an example of um something that works if you just want to have a very very very simple thing that comes with most of most of what you want on the browser but you don't like react for example um you can also see on the repository you can see in our projects and then get um some example contracts and here you have some really really cool examples some of them we actually need them some of them were written by us like for example in um in a internal hackathon so for example this crowdfunding contract was written by us in a hackathon um the reason we did that is because if you probably remember the Constitution now where people were actually donating to a contract so that contract could buy a a unit of the Constitution um yeah one one yeah one constitution of of the US uh and so there was someone that actually go to the and bid or or click to bid uh for that for that document but because the donation cont request public was on ethereum everyone could know how much money was on the on the Dow so basically there was just someone that just knew okay these guys will only beat up to points so they just beat $1 more and they got the Constitution and that's not cool that's that's just not cool like that kind of tells you how useless it is like if everything is public so what these people did was basically this contract allows the bidder to be able to know if he can beid but not know how much she's in there so it's like oh I'm going to try to bid oh it works I I'm going to try to be okay run out of money that's it that is really cool of an example um so I thought I thought you be could be interesting um let me just see if we can go to questions yeah I think I think we can have questions and maybe expand a bit on that um Michael do you have question you were about to ask yeah the micro yeah Oh you mean the to add to the privates oh uh to yeah I mean you can yeah usually you would have like some kind of Merle tree for example that would say only these people can vote because right now as the contract is like this is a very stupid contract where like anyone with an account can create can can vote so you can just create a different account and vote that's that's fine yeah definitely you could use like yeah I mean you're from you're from ZK passport team so you could actually use your passport to like you can use your you can use your passport to create an account that sounds amazing it is amazing yeah you definitely could create an account like um soir is is a really nice language so you can actually verify um random signatures or different signatures in a inside a contract without revealing with what the signatures are so what these guys did was just like oh I'm going to elic passports have an RSA signature so what I can do is just get that signature from the passport and then be sure that uh you can uh you are you you have one you have one account one passport one vote oneport compl private Anonymous exactly like everyone you can vote if you have if you can prove some things about that passport but um like for example your nationality would be kind of important for voting uh or whether you have more than 18 years old 18 years old if you could vote in at least in Europe uh it's 18 years 18 year old maybe I don't know I think it varies but yeah roughly so yeah that's that's really cool you could use your face ID for a v you can actually since every cont is a is an is a is a contract you can actually use different um recovery mechanisms or your passport you lost your passport you're oh now I lost my my my my wallet no you didn't because you can can actually recover it by ZK email or you could basically have an email be sent to you and just prove that you receive that and things like that that um are really really powerful and again you can see you can see their contract ZK passport um I think I mean it's not here obviously but there's somewhere in GitHub um you can tell him later uh and.org passport if anyone's interested to see the no contracts yeah um but there also an example of um a different account contract that uses in this case for example ecdsa secp 256 R1 signatures and this is for those who don't know this is um actually it doesn't tell what the what the curve is but this is like for example face ID signatures the so you can have a wallet by using your face using like apple apple uh security uses um sep6 R1 signatures also some passports and some citizen cards so you could use that to create an account for example and the are the the Portuguese national ID I believe also supports this curve yeah definitely I was yeah I I managed to lose my my my identity card which conveniently let me get the new card which has a sep2 R1 signature totally unintentional uh to so I could actually should play with it and to see the the new signature using L curves uh so some citizen cards again will I guess over the next uh few years will uh start having a I would say better or easier signatures to verify but that's fine because we can do RSA signature verification very fast as well so that's fine one cool feature of this might be you could add the the national ID the national ID card as like a count recovery option yes yes you could do you could do something like that using the same mechanism which is again very powerful um cool any other questions yeah sorry sorry sorry I need the the I can hear uh can I compile your contract and deploy it to L1 no uh I mean you know because like every function in this contract is a smart is a is a is a zero knowledge circuit so this one is a zero knowled circuit this one is also a zero knowled circuit this one isn't a Zer knowled circuit because it's un constrain um so these are actually this is going to be run on the client side uh there's the only difference between private and public not the only but I mean it's the biggest difference is where do they run so if you deploy this on L1 um you can actually I mean you wouldn't be able to um Define private things in L1 uh I mean maybe you could for example do something some kind of compiler from solidity into Noir and maybe for example add The Decorator into solidity I think there's a newi team that has been doing that I think Starlite has been doing that where you can actually add The Decorator to solidity contract and out comes the circuit uh so this could be something like that but to do the other way around to have a zero not circuit and make it into Sol contract it's it's hard what you could do is for example write denir circuits and then generate a solidity verifier for denir cirquit and then verify that proof in solidity that's that's possible but not with this I don't know what H what would happen if I go here and try Naro contract will fail in many ways because I don't think it it knows anything about what what you're trying to prove uh the maros will probably ask for something that something you don't have um but definitely if you use a circuit just any Noir circuit um you could just generate an an AE contract I can show you later on it's strictly in our development but um so basically you write something you some of the inputs are are private some are public but then you send to the to the to the smart contract only the proof and the public inputs if needed I mean usually the solid contract has the public inputs and then the thing will verify you can use that for example to create a uh um a safe for example that uh uh doesn't reveal who are the owners of the safe so I I did that me and and ta some time ago that was an example of just using no as a really cool um authentication mechanism where you have a safe and you don't actually don't actually verify the message sender to know if if you can or not can or cannot uh change to save or make transactions so it's a really cool one cool do we have um any more questions okay see if we have time otherwise we'll just I guess stop here uh you see yeah that's fine cool no other questions last call cool just uh feel free to visit Aztec um docs. aztec. Network we are going to be launching a test net soon TM uh when I mean soon it's really soon it's not like it's not like soon but in in three months no it's it's going to be we we already tried some some things with the uh you can check on our Twitter we usually post about this about a test net that Pro test net where people really went way way overhead uh um yeah over the moon to try to prove blocks uh yeah we made a little uh insignificant competition we thought it would be kind of friendly but people when are like racking up with big provs to try to be the fastest and they're like okay this people are going crazy with with proving nasc Network so we try that we also tried a a development Network that's also distributed where you can actually create contracts even even send uh uh dummy tokens to people and that was really really cool uh to see it went down quite often and now it's currently down because we just care about keep building and not maintaining uh some some other test net um but yeah now we're going to be doing everything some some test net that will do everything it will prove it will uh I think uh Public public thing will not be proven yet because we're working on that still um here you have some tutorials um that you can try private voting the CR funding I was mentioning uh an Contra contract counter contract and probably one that you like to see the private and public token contract which would be a it's a nice example um there's also stuff about the DAP that I kind of covered in this workshop and finally Unis swap bridge this cool if you if you used Aztec connect you're like oh can I have can I have a connect on Aztec I mean that's that's just a contract right that's how powerful atic is we can basically have functionality that's that was before you can actually write a contract and have the same thing so this is an example of how you how you do that with architecture and everything we know quite a lot about this uh because of built it so um that's that's an example uh you should follow our Twitter uh you should apply to our U alpha build programs which are um yeah basically they are programs you can you can apply to build some specific thing about the about the network I think we had like three editions so far uh about creating wallets about creating tooling about creating dexes um and so these are like actual competitions where there was actual some some actually some grant money for that speaking of Grants there's there's also grants you can you can apply for if you're building tooling if you're building um things for rasc these are uh you should look into grants um and finally if you are more into the into the infrastructure we have a ton of things that we are basically wanting the company the the the community to do like writing clients writing WS writing blog explorers writing I mean everything that goes around the net Network we only are developing the cor core stuff so everything else is up for you and up to you to grab and this is posing a big opportunity for people trying to get into probably the biggest next chain that uh they will be uh so there's uh yeah don't don't don't don't tell me I didn't I didn't warn you just kidding uh that's that's a that's a big one but if you're into the into that and exactly how things are being built you can actually check also the Forum forum. aztec.

Network and this will it's basically yeah just a forum but it is really cool it will uh tell you how for example this is a very important discussion no disc Discovery um because you don't want your pxc to be trying to decrypt all the notes and trying to see which ones it can decrypt so this is an example of a ongoing discussion that I want you to and give your input and and to be part of discussion your request for proposal can be part of the Aztec network uh your input is very very valuable so everything from um from learning resources to actual um proposals on how can we how are we building the network are here in the in the Forum and I think that's it for for today um let me know if you have other questions reach me here in this link tree um send me a message uh on Signal preferably but I mean it's fine fine if you contact me on on Twitter I'll just tell you to contact me on Signal um and cool hope you liked it [Applause] hello

Automatic transcript — names and jargon may be misspelled.