Achieving composability between public and private state by Rahul Kothari (Aztec Network)
Nethermind Summit Istanbul 2023 · 7 Dec 2023 · 18:32
Rahul Kothari of Aztec Network explains how Aztec combines private and public state in one ZK rollup. Private functions run on the user's device and produce proofs, while public functions run on the sequencer, so calls can move between the two. He covers UTXO-based private state, L1 to L2 portals, account abstraction, use cases such as payroll, identity proofs and airdrops, and the Noir-based contract framework.
Speakers
Topics
From Nethermind Summit Istanbul 2023, hosted by Nethermind.
Transcript
[Applause] it's a little bit soft keep it close uh what is this that's the yeah all right hello everyone um there's been a lot of talks today my goal simply is if by the end you don't follow the meme which says um didn't listen I'm either happy for you or sorry for you then I've won my then I've achieved my goals but um I'm here to talk about Aztec which is a ZK ZK rollup or a public private rollup or many other names that we've been given in the past six years of our existence uh the tldr is Aztec is trying to make a rollup such
that you have privacy inbuilt on the network um because of that some people have called us the actual ZK rollup because existing ZK rollups don't have privacy as such um and because of the way we do it we don't just believe in privacy uh because the real world is actually quite private whereas ethereum and existing blockchains are completely public uh we realized that unlike other private projects there isn't much value to be fully private for example if you think about make orow and liquidations you need something you need to know how much money you put in in public to be able to liquidate someone or during the recent FTX Luna problems
it was so cool to see everything transparent but at the same time much like the real world where things are private we do need a layer of privacy in built so I'm going to talk about how Aztec will enable not just fully private not just fully public but a spectrum where you could start in private go to public go back to private and not just for States but also functions so not just for knowing what assets you do or do not have but also what execution you are or you aren't running um um to achieve this however we had to break in break compatibility with the evm um which enables us to create a lot of super cool features things that just weren't possible on blockchains
before Aztec um but how does that actually work so um if you're familiar with ethereum architecture it's like you have a giant Merkel tree and all the data is stored into that Merkel tree and we call it account model where as soon as things transactions happen state gets updated um you have the exact same thing for Aztec public sites if there G Mar things keep getting updated when you do the transaction goes to the sequencer but what happens in the private State we have yet another surprise surprise Mar but this time it's all utxos like Bitcoin or Fiel if you're familiar with them um they enable a bunch of super interesting things uh that I want to
talk about today uh for example you have this composability between public and private um you also have something that we call which is my favorite feature we call them portals uh portals are super interesting if anyone's familiar with Aztec connect here um you for the first time you have a composability between layer One apps and ler two apps we all are used to seeing defi Legos in layer one we all are used to also seeing the same defi Legos copy pasting the contracts on L2 see L2 Legos but we never see a mix of both of them for example how cool would it be if you could like deposit e on L1 on makor and just get D straight up on L2 how cool
would it be if you had die on L2 and just swap it on eth on L1 because liquidity fragmentation is happening but L1 will always have the most liquidity right um and how cool would it be if you could do that all on L1 with privacy even though you're not actually using L1 under the hood um and because it's the biggest Buzz word of the last few months we also unable account obstruction which means there are no like externally owned accounts there no private Keys you kind of decide how you want to do it you could make it such that um you use your face ID as your signature scheme you could be old school and use your seat phrase or you could be djen extra djen and just not have any verification
scheme and just let your account do anything without any security but anyway this talk is not about all of that this talk is about this new paradigm that Aztec is going to create around public State private State and our two different kinds of functions right so how do they exactly work right on the private the way we keep things private is all the functions and ethereum when you create a transaction you don't actually execute the transaction you just you kind of give your intents to the sequencer and then the sequencer kind of executes these transactions for you right and that's why you pay all the guas the sequencer because they're doing work for you um how do we make things PR
what we do instead is you execute everything locally on your own machine and then whatever outputs that happen new utxos that you created utxos that you destroyed new contracts that you created um or l12 L to messages that you sent you kind of just send that to the sequencer along with the proof that hey man I promise I'm not lying if you execute this private function that you don't need to know about these are the outputs and all I want you to do is update it on the Merle cre that I showed earlier so no one actually ends up learning the sequencer even though will add your outputs it doesn't actually learn what function to execute it on the
public side you have something exactly like a theorem you send your call data to the transaction sequence or executes everything and then it creates proof where ZK rollup this side is exactly like a ZK rollup create a proof send it to L1 okay that's great I kind of get how it works but what do I do with this R uh well why would you use private function more generally why would you need private execution why would I want a state where I don't want anyone to know what I'm doing many things for example if you're working with private s for example as as a company I don't want everyone to know how much I'm paying all
of my employees I kind of want to do this privately um private St private functions good idea we can finally do salaries of on chain without people knowing what it is kind of similar to The Real World um the other idea is when you're working with sensitive data that can be on or offchain we all have heard you shouldn't put your passports on chain this is why digital identity hasn't caught up yet cuz you can't put anything personal on chain well asset kind of changes all of that because here you don't need to put things on chain everything is like private stored for you and you can just create proofs that hey I promise I'm above 18 without you needing to know that I'm above 18 this could open a whole sleuth of apps that
want to be more regulator focused that want KY without having to create a whole offchain component to them um if you're a hedge fund or someone who wants to really make sure that no one knows what I'm doing private function is a great idea cuz because the sequencer will add all your outputs but no one will know what you actually were doing were you transferring eth were you creating a contract we'll never know um additionally one of the one of the really interesting use cases is airdrops and everyone's going to listen to me now um basically air drops are interesting because currently the way you do it is you have this public blockchain and everyone creates the SQL database of everyone that tried and then you kind of
you get listed on the SQL database or you know GitHub list saying hey you're eligible go claim but instead you could do something like proving that you owned an nft or own or interacted with the application at a random block X and so now as an app developer you don't need to create all these fancy SQL like queries anyone can just come create a proof and voila you're kind of done um yeah and as I said it's not like we just have private State and only public function in the two different worlds um you kind of mix things up you could have a private function a private State and you sometimes want to interact in public
for example un swap before I swap I kind of want to know how much volume there is how much liquidity there is so I know I'm not getting rubbed all of that stuff is public which means I need to go to the public domain to kind of swap my assets um another beautiful thing so oneliner answer to what what's private about it is someone did something to some state in some function of some contract or something happened um what's next public function similar to ethereum we don't need to go into too much depth but um something interesting to note is in the private
function you kind of don't have access to the Head of the State and that's because everything's happening locally in the user's device so we can't trust the user to run a full node because that's bizarre and know everything that's happening at the end so if you want like Cent time SS current block numbers you use uh public functions um and if you're thinking hold on Rahul all of defi uses public like current block stamps and stuff well remember in private you kind of can create proof against historic data so liquidity mining looks kind of different You just prove that you had put in data into a pool at block X and that's it you don't need to create like complex time related algorithms anymore um so exactly like you ask a sequencer to execute a
function and they kind of pro to ethereum that they did it correctly um but as I said the Real Genius behind Aztec is that you can compose you could do public calls to private you could do private from public you could do whatever you want U but how does that actually work in the ZK world of circuits and where I'm saying the private functions execute on the user's device well basically you have you write a smart contract as you always do it it's private functions public functions we'll go through some code examples maybe um and basically first on the user's device you kind of execute all of your private functions right and then you just tell the sequencer hey here are
some public functions for you to execute the sequencer would just find the contract address and the parameters for the public side remember we can do cross contract calls so it doesn't necessarily would even know which contract the original private call even started from we'll go through like some actual examples to make it more obvious what's happening the tldr is the sequencer does public user does Private and that way you kind of can have a mix of both current time SS and private and do the seamless composability of state and functions um but like all of this sounds quite abstract will this ever be live what are the trade-offs can this even happen what does this even mean um so here's here's a beautiful example let's
say you have some tokens that you have in the private state for whatever reason you want to now make them public to interact with Unis swop to interact with a random public function or whatever um so we call that unshielding because you had assets and now you want to unshield you want to make sure everyone sees them right um notice that you kind of Let's ignore the first few lines of like the if and else and just notice you have a new two address that means you don't need to give it to the same current address you can give it to anyone you want that's how we increase our privacy and autom um and then all you do is you kind of remove your balance from your private storage and then at the end notice how you call a public function called
increase public balance uh so private storage and Public Storage are quite different to each other you can't talk to them in the same function so if you want to talk to Public Storage you do it in a public function this this way uh reduces like mistakes from App developers you also reduce the chances of leaking privacy when you don't want to um and notice the things we actually send to the public function is just the two address and the amount so the sequence of when executing this does not even know where it started from like who message. sender was if you're familiar with solidity it doesn't know who from was it just knows who deserves the balance and how much which is exactly what we want to do in this function right we want to tell that this address
now has this much the way we do this under the hood if people are curious is we have different Markle trees for everything uh we have a different tree for public we have a different tree for private we call it the note hash tree cuz commitments utxos and are notes um and then we have a nullifier tree which is like Z jargon for basically saying anytime you create utxos you create new ones those are notes you destroy some those are not nullifiers by keeping nullifiers separate from the notes you can't if you just look at the notary you don't know which ones are actually valid anymore we really increase our privacy set this way so the more people use astec the more privacy but even if only
one person use it you still have the same privacy because you don't know which notes they actually have and all of these are hashes so you still don't know the pre-images or the data within them um but if they are indiff trees does it mean that I cannot talk to them we just saw private can talk to public but can we do the reverse public can talk to private so let's do that um you have tokens in the public domain and you kind of want to Shield them you want to make them private I don't want people to know what how much I have Let's ignore the first if L statement for now but basically what you do is you create you take your story public balance notice how the public balance
called storage. public balance in the previous one was story clear separation between what's private and what's public so anyway you read your public balance anyone can do this it's public um and then you kind of create a utxl for private we call it transparent Noe because anyone can see the creation of this utxl but notice what we put into this etx so we put in the amount that's not leaking any privacy because everyone knew you had that balance and you put in a secret hash why is the secret hash interesting the secret hash is interesting because basically when I want to redeem The Shield at a later time I just put in the secret and this code computes the hash of the secret and then checks if this
transparent node actually existed in the bending Shields map um and then it sees that it existed and then removes the node and adds it to your private storage so remember that private functions are executed first public are done later here we're going from private from public to private that means the user first does one transaction for public and then at a later time they can do it in private right um this creates like a whole new set like here you need two transactions but it's really interesting because you can now do private to public but also public to private notice in the private domain you are passing the two amount two address as well but it
doesn't matter it's all private the sequencer doesn't know who is actually getting it uh but the two address is still nice because here you can see who the message. sender is the person who actually has the balance but you cannot know if it's the same address that'll receive the balance again one of our Nifty tricks to increase the Privacy set by the way um I want to say that this is not something that's possible 500 years from now when we eventually launch our code because we are in a ZK research company uh two months back we launched our sandbox sandbox is a fancy word for a local veler environment a ganache an anal or truffle if you will um in the last two months we've seen hundreds of developers hundreds of companies
actually building on top of Aztec and experimenting with our unique execution environment our unique features and our new smart contract language so if anyone has worked in ZK they would know about Noir which is our own custom language that Aztec has created to make it easier to write all this ZK stuff without knowing any of the ZK stuff um two months back we announced that that we added a framework on top of Noir to make it a smart contract language so the same Noir all of this is actually a ZK circuit but it reads kind of like solidity and our point is to make it super easy to onboard ZK devs our point is make it super easy to onboard solidity devs into z um just so you can do that so all of this stuff is actually
live we will be launching fully decentralized on day one when we do main that so there's a lot of work to be done we have to launch decentralized sequencing from day one we have to do decentralized proving from day one you have to do upgrades with minimal multi capabilities Things That No rollups have done today so we have a lot of super interesting things even things as obvious as fees which we take for granted because in 1559 doesn't quite work exactly in the private domain uh what I mean by that is for example in 1459 you can get refunds if um you overpay how do you do refunds in the private domain more importantly if the user is executing private functions locally the sequencer doesn't do much
does that mean that for private the fees will be much lower compared to public and therefore for because the sequencer can make more money in public it will always priortize public we'll find out we're doing a lot of thinking about this um those are our documentations if you want to try out astec it's our GitHub and if you want to talk to me that's my Twitter on my way to the Moon uh not literally like to stay on Earth for a while but thank you for having me [Applause] you
Related talks
- Ultrasound Privacy: How to Harden Web3 with Aztec
- Aztec - Joe Andrews (CPO) and Zac Williamson (CTO) | Meet the Nation
- Privacy on x402
- 852zkNight Part 3 - 用Noir語言構建零知識證明ZK dApp - Aztec Network
- 'Achieving Practical Programmable Privacy with Noir' - Zac Williamson
- Scalability is Boring, Privacy is Dead: ZK-Proofs, What are They Good for? by Ian Miers
- zkPACT: ZK Private Crosschain Token Transfer Framework
- Privacy is Sooner Than You Think
- "Aztec 2.0 - A new layer 2 built with privacy at its core" - Joe Andrews
