ZK-Dapp-Templates
I created two repos that can be used by developers as scaffolding templates to get their zk-dapp up an running very fast.
Screenshots



Problem Statement
My goal was to create a zk-demo dapp that is well integrated into modern development frameworks (such ashardhatand has important scaffolding elements already set up (such as connections to metamask/walletConnect/wagmi).The repo (https://github.com/DOBEN/Hardhat-with-Circom) uses the ```hardhat-circomplugin. This combines the multiple steps of the circom and snarkJS workflows into your hardhat workflow and simplifies development of the circuits. There are several example circuits in the repo and everything is set up to easily switch between development/production using the commandyarn circom:devor yarncircom:prod`. The Read.me explains how you can add your own circuits, how to compile them and how to deploy the verifier smart contract on chain, or verify proofs locally.The repo (https://github.com/DOBEN/SnarkJS-Front-End) is a zk-dApp front end to showcase how to generate ZK-SNARK proofs (groth16 algorithm) in the browser and verify the proof in the deployed verification smart contract. The front-end interacts with the ``average.circomcircuit from the first repo. It calculates and proves that the average of 5 numbers was computed correctly. TheRead.meincludes a gif showing the front-end flow. The project is anext.js` dapp that has the components to connect to metamask/walletConnect/wagmi already integrated.
Solution
https://github.com/DOBEN/Hardhat-with-Circom It uses thehardhat-circomplugin. This combines the multiple steps of the circom and snarkJS workflows into your hardhat workflow and simplifies development of the circuit. Hardhat deployment scripts are set up to deploy the verifier smart contract on-chain. The repo is set up to switch between development/production using the commandyarn circom:devor yarncircom:prod.https://github.com/DOBEN/SnarkJS-Front-End The project is anext.jsdapp that has the components to connect to metamask/walletConnect/wagmi already integrated. It usessnarkjsto generate a zk proof. The folder./publicincludes the verification key/proving key (average.vkey.json, average.wasm, average.zkey) from the first project as generated from theaverage.circomcircuit. Theaverage.wasmfile is used together with the proving key in thesnarkjslibrary to generate a zk proof that given the witness input, the average of 5 numbers was calculated correctly. The generated proof and the public inputs are displayed at the front end. The user can submit the proof on chain and verify that the proof is valid. The return value (valid/notValid) of the smart contract is displayed at the front end.
Hackathon
Circuit Breaker
2024
Contributors
- DOBEN
5 contributions