Created on 9th December 2024
•
The Problem This Project Solves
This project addresses critical challenges in secure, private, and decentralized voting systems, leveraging zero-knowledge proofs (ZKPs) and blockchain technology to enhance trust, transparency, and privacy in democratic processes. Traditional voting systems, whether online or in-person, often face the following issues:
The project enhances security by using blockchain to create a tamper-proof and decentralized ledger.
Implementing cryptographic methods (ZKPs and Merkle proofs) to validate voter eligibility without exposing sensitive data.
This project integrates zkVerify’s efficient Groth16 verifier to minimize the costs associated with proof validation and enable practical and affordable implementation of ZKP-based systems.
Compatibility Between Curves (BLS12-381 vs BN128)
Challenge: Initially, we aimed to use the BLS12-381 curve due to its strong cryptographic properties. However, the Poseidon hash function implementation for Merkle proofs resulted in mismatched roots when using BLS12-381. Additionally, the proof generation failed outright with this curve.
Solution:
Switched to the BN128 (also known as BN254) curve, better supported by the zkVerify framework and compatible with the Poseidon hash implementation we were using.
Confirmed that the circuit was optimized for the BN128 curve, ensuring all computations (proof generation and verification) aligned with this elliptic curve.
Mismatch in Merkle Roots
Challenge: The Merkle root calculated off-chain did not match the root generated on-chain in Solidity. This mismatch prevented successful proof verification.
Root Cause: Discrepancies in public input encoding between the off-chain and on-chain environments.
Solution:
Endianness Adjustment: Ensured that all public inputs were properly converted to little-endian format on the EVM side, as zkVerify requires big-endian inputs while Solidity processes inputs in little-endian.
Misalignment of Proof Generation and Verification
Challenge: The proof generated using snarkjs off-chain failed validation when submitted to zkVerify due to input misalignment.
Solution:
Debugged the proof submission by logging all public signals, root values, and nullifiers, verifying their consistency across all stages of the process.
Validated the trusted setup files (.zkey and .wasm) to ensure they matched the circuit and verification key (vkHash) deployed to zkVerify.
Confirmed that the public.json file used for proof generation was hardcoded correctly in the Solidity contract.
Tracks Applied (2)
Horizen Labs