# MACI Workshop | ctrlc03 | Private on-chain voting: technical introduction to MACI | ETHDam 2024

- Channel: [CryptoCanal](https://streameth.org/cryptocanal)
- Date: 2024-10-07
- Duration: 21:07
- Watch: https://streameth.org/watch/yt-AimgqnMjG0o
- YouTube: https://www.youtube.com/watch?v=AimgqnMjG0o

## Description

Workshop with ctrlc03 - “Private on-chain voting: technical introduction to MACI” from ETHDam 2024. 
https://twitter.com/ctrlc03 https://maci.pse.dev/ https://twitter.com/zkmaci https://twitter.com/PrivacyScaling https://pse.dev/en 

James Campbell - MC of ETHDam, Hackathon Organiser, and Web3 Developer.

ETHDam - a conference and hackathon held in the heart of Amsterdam, Netherlands from April 12th to 14th, 2024, celebrated its second edition, gathering more than 600 participants. 

In the dynamic space of ETHDam, privacy and security took center stage, featuring groundbreaking discussions on hacks, recovery, and the revolutionary work of figures like Pertsev. Privacy is dead in crypto, people that know, know. People who don’t know, should know. 
ETHDam is powered by CryptoCanal, an education and events platform growing in Amsterdam, spreading its roots to Rotterdam and Zürich.
Keep up with us to see updates on future events: https://www.cryptocanal.org/ 
Follow CryptoCanal on X: https://twitter.com/CryptoCanal
Join CryptoCanal TG Community: https://t.me/CryptoCanalCommunity 
Join CryptoCanal Discord: https://discord.com/invite/XJVjpCqQBz

We would like to thank our partners that made this event possible. 🌷
Battleship Partner 
🛳Oasis Network https://oasisprotocol.org/

Jet Ski Partner
🛩⛷  NEAR https://near.org/

Canoe Partners
🛶WAKU https://waku.org/
🛶Trail of Bits https://www.trailofbits.com/
🛶Avalanche https://www.avax.network/
🛶Privacy + Scaling Explorations https://pse.dev/en
🛶Threshold https://threshold.network/

Our Canoe Partner & Official Node Provider
🛶dRPC https://drpc.org/

Sponsor
🤝EF Ecosystem Support Program https://esp.ethereum.foundation/

Paddle Partners
🚣ChainSecurity https://chainsecurity.com/
🚣Lido https://lido.fi/
🚣Cyber Capital https://www.cyber.capital/
🚣Diva https://www.divastaking.net/
🚣Firn Protocol https://firn.cash/
🚣Beefy https://beefy.com/
🚣0xbow https://www.0xbow.io/
🚣Obscura https://obscura.build/
🚣Panther https://www.pantherprotocol.io/
🚣Maven 11 https://www.maven11.com/
🚣Zama https://www.zama.ai/
🚣zkSync https://zksync.io/
🚣Secret Network https://scrt.network/

ETHDam AfterParty Fren
🥳Bitvavo https://bitvavo.com/en


Timestamps: 
0:00 - Introduction 
0:44 - Explanation of Minimal Anti Collusion Infrastructure (MACI)
1:00 - Key Properties of MACI
1:35 - Importance of Private Voting
2:06 - Influence of Public Opinion on Voting
2:42 - Architecture of MACI
3:34 - Overview of MACI Repository
4:00 - User Interaction with MACI
5:24 - Role of the Coordinator in MACI
6:14 - Trust Assumptions in MACI
7:42 - Use Cases for MACI
8:30 - Potential Applications for MACI in DAOs and Gatekeepers
9:13 - How to Build on MACI
11:07 - Deploying the Poll and Extending Functions
11:27 - Claiming Funds and Adding Funding on Top of Voting
11:55 - Introduction to Frontend Builds and Hooks
12:22 - Importance of Digital Voting and MACI's Role
13:18 - Q&A Session Begins
13:30 - Discussing the End Game for MACI
14:20 - Navigating the Open Source Landscape and MACI Unique Offering
15:06 - Organizing a Movie Night with MACI: Cost per Vote
16:01 - Understanding the Voting Process and Result Visibility
17:09 - Discussing the Role of the Coordinator in Off-Chain Processing
18:33 - Future Possibilities with Homomorphic Encryption for On-Chain Processing
19:05 - Use Cases for Macy in Retroactive Funds and Planning Horizon for Implementation

## Transcript

[Music] next up we have not Sam alesandro talking about uh Massie macki I Macy maybe yeah I get that works right depends yeah it's something I've only ever seen written down uh private onchain voting sweet all right thanks for introduction um right so I'm a software engineer in PC um just a quick agenda uh we're going to be going through what Mac is uh why we think is important how it works and given we offer like bounties for the aaton what you can build with it if you wish to do so and how you can build with it so Ma just stands for minimal anti collusion infrastructure and in a nutshell it just enables you to run uh private polls the main properties of Macy are collusion resistance so there's only a coordinator which can be certain of the validity of a vote uh receipt freeness so you cannot really prove how you voted Beyond any reasonable doubt privacy uh just yourself as the voter and the coordinator can decry the vote um even a coordinator cannot censor any vote um and while you cannot edit or delete a vote you can just nullify it by sending a new one and even a coordinator won't be able to produce a false output of the of the of the poll round um so yeah we think that priv voting is important and especially we seen like um quary funding or voting protocols that if because you give power to the people it's so much easier to bribe and when there is a financial incentive to do so it's very likely to happen um so yeah like quity funding people collude and all the funds go instead of going to wish should go go to like just a few projects and even kind of related to that if in general if you're voting and you maybe not have inform like your idea yet if you can see how other people vote you could technically get um condition so like you see on Twitter everyone is voting on XY Z and you might feel okay maybe it makes sense to do that but you cannot trust them with Macy that they actually voted for this uh project and and from a briber perspective why would I want to bribe you if you cannot just prove to me how you vot it so I cannot be sure of that uh the architecture is divided into um three parts so we got evm compatible uh smart contracts written in solidity uh we got a set of circuits uh written in circum this enabled you to run quadratic voting and non quadratic voting rounds and the main the two main main ones are the ones that allow to process messages and prove correct execution and T votes for the results of the poll and then we got like a bunch of typ skrip utilities uh they can be like just Primitives um like the keys that we use the encryption algorithm hashing algorithm an SDK that you can use to interact or to just build something with the protocol and then a clone of the smart contracts which I used to do the process in which cannot be done on chain um if you do deite to ha Macy that's what the repo looks like you probably want need touch the circuits what you see in blue is all the JavaScript typescript stuff that you can use to uh build on top of it and then we got a contracts which uh you might want to touch if you want to build some new anti ways of registering to Macy or just extend that to do whatever you like really um right as a user there's three main things you can do um you can see here on the top is um is a Macy keys so basically uh they should not be confused with your evm um address like of course it doesn't look like that but uh that's just because he calized this really is a point on in LIF tip curve uh but let's not talk math but basically that's your identity if you lose that once you register well it's you know it's kind of like your private key for your wallet you don't want to lose that nor sell it uh you register you interrupt the smart contract and you send this public key uh you can send votes to polls that are available um you don't need to be signed signed up to send the vote but your vote just won't be counted if you don't sign up so that kind adds to the anonymity of the protocol uh everything that you send on chain is encrypted so the method that you send um just is just random blog the data and this is encrypted using a share key so that the coordinator uh can actually decrypt the of chain uh you need to sign your vote with your private key your Macy private key and that way just no one else can send a vote on your behalf finally once everything has been processed and the results sted you can just verify them on chain um this is what the coordinator does um so just imagine run around everyone voted we happy and the poll is ended no more votes are accepted uh the coordinator then is in charge of taking all the data from uh the blockchain uh merging this trees so we use some sort of like meracle trees like structures a bit more optimized for user usage uh but it require some extra step on the coordinator side anyway we just get all the data we save it locally and basically generate a representation of the poll in typescript and you can use this to process the messages and then you'll be able to generate um CK snack proof using the circum circuits uh because of the constraints of the circuits which can be quite a lot like in the millions uh we do stuff in batches so you would submit every time a proof that a bunch of messages has been um processed correctly once you process the messages is submit approves and commitments on chain we can t the vote and again generate approves submit on chain and that's when you as a user can just take the public data that is made available to you and just verify that everything looks uh done correctly there are some trust assumption so I mentioned the coordinator quite a lot we do assume that this is honest but yeah they could decrypt messages sell them if they want want to they could just be like hey I don't want to conclude the round cuz whatever reason they have or just delay or they could collude with brius um there will be work in the future to hopefully uh get rid of a coordinator but at this time it is needed but the good stuff is that they cannot really censor your vote so that is thanks to the smart contract so all of the votes you send are St in this Miron chain so uh they just cannot avoid um not processing some of them in the circuits and as well um they just Yeah just they cannot perform any incorrect uh processing the source of Truth um we talked about this miracle tree so you have a rout on chain Mak can we verify that um everything has been included we record for each poll however many users signed up how many messages um were sent so if you a Coordinator would be like right I'm just going to I don't know process 99 out of 100 messages they won't be able to submit the proof and chain so you as a user would know that something is up um so yeah this is right uh for the aaton just some ideas of what people can build um there's few pity funding uh apps that already built on top of Macy like most notably SAR fun um so yeah you may choose to build out or just try something new we we think could use for like um Dow toolings um that's something we've not tried yet ourselves or Gatekeepers so basically it's just the way that you prevent users from signing up uh to the contract uh just something simple like a front end for like voting on which movie to watch at work and if you want to do privately for whatever reason or yeah some stuff that would be very useful to us and to the project is also how to talk eyes mayy so that it can just be run on any system there's a discussion I'll share this later so you can just click on that and you see all the projects that we suggest but feel free to uh really do whatever you think uh M can be used for uh just quickly how you can build on it so here we're looking at how you uh will inter up the smart contracts and the stuff that you might want to change just as the user you the green one you interact with Macy and you can sign up there's a contract here the gatekeeper it just says right can i s up yes or no whatever reason proof of personhood on NFD uh you choose it Voice credit proxy is like how many voice credits do I get the Voice credit is just representation of your voting power uh so user you sign up this data is returned by the smart contracts which you may extend as you wish and the data store in numerical tree and then coordinator comes in you deploy poll um when you deploy poll this free smart contracts would have been deployed USD user kind of really have to B with the poll uh that's where you submit your votes the coordinator will then go into processing the messages using the message processor and tally for submitting uh the tally results and the proofs and then as a user just go and verify that so do some example of um some code that extends Macy so this is like a very very simple um prority funding protocol you just see here just extend Macy call The Constructor save how many variables do you need extra because it's prority funding here we just need a token for people to save money and as well in the sign up we overwrite the function so what we call the original sign up function and trust it to do whatever is supposed to we can also add extra logic like taking like a contribution from the user and store anything in case there's need for a refund um as well here that's where you deploy the pole if you wanted to anything extra in it you can just extend this function store the addresses and in this case um I've added a initialize function to the T contract because I want it to do more stuff and that that's where you can do it really and again here just a function that you can use to like claim funds so we added the funding on top of voting uh you as a project come you send the proof that uh okay this is the proof that this project what what option index got I don't know uh 50 votes so maybe 50 token whatever and here if the proof validates the tokens can be transferred that's just an example we do have like a frontend Builds on top of it as well uh so you can just go and copy like Hooks and whatever you think might be needed there'll be linked at the end um yeah just the bounties um we at 2K dividing into three uh so first one is 1,000 and it just goes down until 250 uh we have a boot downstairs so feel free to come down and ask if you need help even just validating an idea um yeah just to conclude we we're focusing on this because we really believe it's important uh we we're seeing a shift into like digital world and hopefully voting can be done in a private way and we hope the masing can make a difference it's not perfect far from it so that's why we're here hackathons or you know in general if don't want to hack here you just want to contribute we're always open uh to enable people to do whatever they think is best and try help us everything we do is open source so yeah just link to joining Discord um but yeah if think that's it really yeah there's some links I'll sh I'll share this later but if you have any questions uh we can just go through them now thank you very much does anyone have any questions yes it's a quick hand no I will be quick here what's the end game for Macy well I think in now Roma right we got a elections at some point why not maybe like a small country you know just to start with but you know I think um ideally this could be could be you know when improved enough could be used for like elections yeah and the followup um in Istanbul uh the OD has made a talk and then published M research on different uh PR with voting protocol Solutions how you define or navigate yourself within the socalled competitive oper Source landscape like where you fit in and how do you see your trajectory like what will be different in your case instead of whatever Aragon zik research is doing and others yeah I mean um I think we are one of the few if not the only that uh offers the briber resistance uh by incorporating CK not really familiar with all the other projects I did have a a quick re through that but yeah I mean we're actively working on this um not sure whether these other projects are but you know we we love for like collaboration so if mayy doesn't make it you know we op that we build something that any of these other projects can pick up or the opposite like is is a public good in the end so yeah with you know calling a competitors or anything it's just shouldn't yeah yeah if I want to organize a movie night with 20 friends yeah uh how much does a vote cost about per person any IDE yeah I think now it's yeah if you deploy an optimism arbitrum now is like sent maybe it'll cost you to deploy the contracts yeah a little bit more but you ask your boss to do that he just he just send the vote um yeah a sent to I don't know nice yeah if the vote is a transaction and you do the sender by the result I mean you see a transaction and you see the outcome how the votes changed like the or you don't see the result you no you wouldn't see that no as a result what you see is like I let's say there were 10 options you just see like how many votes each option got you don't really see like how each vote was decrypted but you can be sure that it was done correctly because of the TK part but you can request the result of the poll like for how many votes and you can check it immediately after the trans action went through well no because the the actual um results would be at the end so like there's a voting phase and then there needs to be certain processing done but yeah like in the end only the coordinator could go and make um a connection between that we assume it's honest but you know one way is also you just because you can vote from any address we just create a new address a new wallet and you just vote from there that's it that's your anity as well okay so you only see the result of the bll at the very end not correct ah okay yeah that's clear thanks uh thanks for the talk uh I have one question around kind of the coordinator like what's the main reasoning why it's like of chain right now I mean one obvious reason might be like historical gas costs right but I can imagine that if we like um you know we're doing everything that the process is doing through another contract that like anyone could call say like after the round is concluded to compute the results we could so probably do something like that like for like a 50 bucks or like 100 bucks on optimism I like or is there other reasons why it's happening offchain that's because of the privacy of the vote so the vote is encrypted and if you were to process it on chain then everyone could see the vot being decrypt it right so you know yeah so that's the reason why um maybe like if you introduce like you know f mark encryption at some point you might be able to do that but at this time you want the coordinator the cryp the vote and process the content of it and if you do on chain then I see would you see right so that would only work with like some moric encryption thing eventually I guess I'm just assuming it's not something we tried uh I know I know zero about work encryption but I just assume that could be uh yeah something but yeah I see thanks and I'm not sure it might be still uh worth doing on chain you could still do it off chain and verify still in a snark uh to make it more um but yeah if anyone could do it because you know you process the data while it's encrypted then you wouldn't need a coordinator exactly yeah so yeah yeah it might be nice to get there eventually of like so yeah [Music] actually I remember one so I seen recently lots of proposals on Forum on using Mai for like um retro active funds and stuff like that and then I remember one thing which is which you don't talk much but it's interesting to think about like what's the kind of planning Horizon for these use cases or these solutions to be really implemented well tested so then we can uh use them and why I'm asking here because once I know like almost two years ago I was talking with attec and they were saying yeah in a year everything will or it was scrolled something like that and then year passed and still like and this is okay within their R&amp;D so the question is like all those use cases that you're pulling kind of online and making them public and uh going forward what's the road map for the real implementation so we do have a demo for the rpgfan doesn't have to be optimism but it was kind of tail of them uh we just run like a test round a few people try from the foundation as well there's a proposal on the Forum uh feel free to comment there as well if you have any ideas of improval but it's there like it's it's not perfect but it's a demo and we do hope that it might be used uh whether is for the next optimism round or like whoever else wants to do like retroactive um Public Funding but in terms of like public fun I mean quadar fun in itself it is been used like s fund and has been running rounds in production just most recently in uh eam um so yeah it is been used uh but yeah for the thank you [Music]
