- Install the Circom install
- Writing circuits in folder
circuits
compile tocircuites/build
folder - Compiling
circom ./withdraw_multiplier.circom --r1cs --wasm --sym --c -o build
- Download the "Powers of Tau trusted setup file" select
powersOfTau28_hez_final_13.ptau
file from here and place it in thecircuites
folder - Back to root folder and Run
yarn snarkjs plonk setup ./circuits/build/withdraw_multiplier.r1cs ./circuits/powersOfTau28_hez_final_08.ptau ./circuits/build/proving_key.zkey
to generate thegenerate proving key
file that we will use to generate the proof using the R1CS and ptau
- Run
yarn snarkjs zkey export solidityverifier ./circuits/build/proving_key.zkey ./contracts/src/WithdrawVerifier.sol
to generate thecontracts/src/WithdrawVerifier.sol
file
- Run
yarn snarkjs plonk fullprove circuits/witness.json circuits/build/withdraw_multiplier_js/withdraw_multiplier.wasm circuits/build/proving_key.zkey circuits/build/proof.json circuits/build/public.json
to generate theproof.json
andpublic.json
file
** Optional step ** We need a verification key that can be generated from the proving key to verify the proof. Here’s how to get that:
- Run
yarn snarkjs zkey export verificationkey circuits/build/proving_key.zkey circuits/build/verification_key.json
to generate theverification_key.json
file
We use the this command to verify the proof, passing in the verification_key we exported earlier.
If all is well, you should see that OK has been outputted to your console. This signifies the proof is valid.
- Run
yarn snarkjs plonk verify circuits/build/verification_key.json circuits/build/public.json circuits/build/proof.json
to verify the proof
- Run
yarn snarkjs zkey export soliditycalldata circuits/build/public.json circuits/build/proof.json
to cut and paste the result directly in the verify function in theWithdrawVerifier.sol
contract
And voila! That's all there is to it :)
forge install
forge test --match-path ./test/SimpleTornado.t.sol -vvv
- https://github.com/iden3/rollup/blob/master/circuits/rollup.circom
- https://hackernoon.com/protect-yourself-from-identity-theft-by-using-zero-knowledge-proof-solidity-and-ethereum
- https://github.com/zkBob/zkbob-contracts
- https://github.com/nalinbhardwaj/snarky-sudoku/blob/main/client/lib/util.ts
This is a Next.js project bootstrapped with create-next-app
.
First, run the development server:
- Copy
proving_key.zkey
andwithdraw_multiplier.wasm
to thepublic/zksnarks
folder
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
Open http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying app/page.tsx
. The page auto-updates as you edit the file.
This project uses next/font
to automatically optimize and load Inter, a custom Google Font.
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.