project screenshot 1
project screenshot 2
project screenshot 3
project screenshot 4
project screenshot 5
project screenshot 6

SkaffoldMACI+ZkOSIOS

Introducing a user-friendly voting system UI (powered by Skaffold) for sports fans using MACI for enhanced security and privacy. Our platform allows fans to vote on team decisions like jersey designs, ensuring privacy.

SkaffoldMACI+ZkOSIOS

Created At

ETHGlobal London

Winner of

Chiliz - Pool Prize

Prize Pool

Ethereum Foundation - Best use of MACI 2nd place

Project Description

This project focuses on developing a comprehensive, user-friendly, and reusable UI for secure and private voting with MACI. Built on Skaffold 2.0, the interface facilitates debugging and interaction with all MACI-related contracts. I later repurposed this template to develop a specific project, creating a voting application called Zkosios in the sports and entertainment sector. Inspired by Socios, it is deployed on Chiliz to ensure privacy and collusion resistance, leveraging ZK proofs. Key components and features include:

  • Skaffold Integration: A reusable deployment script efficiently deploys all necessary MACI components. Utilizing Skaffold 2.0, the script facilitates effortless testing within the debug environment and enables rapid prototyping. It also provides working examples with all the necessary contract hooks to manage the signup and voting. While the MACI CLI is ideal for interacting with pre-deployed solutions or deploying standardized solutions, this solution is designed for more experimental applications. It offers flexibility to modify and adapt existing MACI contracts for new applications or to test their integration with other contracts.

  • Custom MACI Wallet Management: The interface features a custom solution for generating and managing MACI addresses. These are created directly in the browser, allowing users to store them locally or upload them via local storage. The wallet manager also includes an autogenerated avatar dependent on the address, is exportable via QR codes, and stores the state index for voice credit top-up operations.

  • Poll Information: Detailed poll information is available, including status, details, and coordinator info. The interface allows users to approve voice token credit and tokens for use in MACI.

  • Voting Interface: This interface enables users to select from valid options and cast votes. It displays the amount of credit to be used for voting. Admin Functionality for Poll Management: Post-poll, the coordinator can merge signups, process messages, and generate a local state. I adapted the CLI scripts for browser use. However, for generating proofs, the iden3 function, which parses ‘zkey-files’ using bin-utils, could only accept a path. All the attempts to fetch ‘zkey-files’ and wasm from a public folder were not possible. To generate proofs, I created an off-chain script that utilizes the MACI CLI to perform all required operations, publish the proofs, and allow users to verify results online against the verifier.

  • Adaptation for Chiliz Integration: Leveraging this template, I developed a new simple voting app for sports-related polls like Socios. This allows users to create and share polls on social media, stemming directly from the fanbase. Unlike Socios, it also maintains privacy within the community (assuming trust in the coordinator) and enables the creation of more sensitive, community-driven polls. This approach preserves privacy and is resistant to collusion.

How it's Made

I started my project by forking the MACI repo project. After that, I created a script using the maci-cli to run various end-to-end testing scenarios https://github.com/GaetanoMondelli/ETH-GLOBAL-LONDON/blob/main/cli/onboarding.sh. In this process, I found and fixed a minor bug, for which I submitted a pull request (PR #1304) https://github.com/privacy-scaling-explorations/maci/pull/1304

Then, I created a dev environment using Next.js and Hardhat. This part of the project focused on developing a configurable version for onboarding, which is essential for deploying all contracts necessary to create a functioning test environment with Hardhat. This setup included building and deploying all involving contracts, linking the Poseidon hash library with MACI contracts and the other contracts in Hardhat. It also includes the creation of a poll and some test interactions (signup and voting)

I focused on developing simple UI components and hooks for managing common use cases of voting and MACI addresses. I used QR codes and robohash (https://robohash.org/) for showing avatar pictures based on the maci addresses. This also displayed the public key address and the state index if the address had signed up for the poll. Initially, I tried storing this information in a Metamask snap but used local storage for convenience. However, I recognize the need for a more secure interaction in the future, possibly through encrypting the MACI wallet.

After local testing, I moved to a more concrete use case by deploying the entire set of MACI contracts on the Chiliz network. This required some modifications as deploying all the contracts on the spicy network was expensive. I made a few optimizations to ensure the test funds were sufficient and replaced the voice contract with the fan token address to integrate them into the MACI poll system. For the live testnets, I replaced the poll expiration condition with a variable that could be set to end the poll. This allowed the use of fan tokens for voice tokens and enabled the coordinator to end the poll. In this example, I set up a simple poll inspired by Socios where fans could choose the away jersey of their team for the next season and included a feature to share the poll and results on Twitter.

background image mobile

Join the mailing list

Get the latest news and updates