Skip to content

Rea7per-r/POLYGON-CIRCUIT-IMPLEMENTATION

Repository files navigation

🔐 Hardhat Circom Zero-Knowledge Workflow

A Hardhat template integrating Circom and SnarkJS via the hardhat-circom plugin. This workflow simplifies zero-knowledge proof (ZKP) development by automating the compilation of circuits, generation of proofs, and deployment of Solidity verifiers.

🚀 Features

  • ✅ Compile Circom circuits
  • 🔒 Apply final trusted setup beacon
  • 🧠 Output .wasm and .zkey files
  • 📜 Generate Solidity verifier contracts
  • 🧾 Create and verify proofs on-chain

🛠️ Getting Started

1. Install the Plugin

Install the required plugin in your Hardhat project:

npm install hardhat-circom

2. Compile Circuit & Generate Verifier

To generate intermediate files and the MultiplierVerifier.sol contract, run:

npx hardhat circom

This will output:

  • circuit.wasm
  • circuit_final.zkey
  • MultiplierVerifier.sol (or a verifier for your custom circuit)

3. Prove and Deploy

To generate a proof and deploy the verifier contract, run:

npx hardhat run scripts/deploy.ts

This script will:

  • Deploy the Verifier contract to the configured network
  • Generate a zk-SNARK proof via generateProof()
  • Generate Solidity calldata using generateCallData()
  • Call verifyProof() with calldata to verify it on-chain

🧩 Using Custom Circuits

To work with your own .circom files:

  • Place your .circom file in the circuits/ folder
  • Update circuits.config.json with your circuit name and path
  • Modify hardhat.config.ts to match your new circuit entry

🌐 Network Deployment

This project is compatible with all EVM-based networks.

  • ✅ Tested on Sepolia Testnet

To deploy to your preferred network, update the Hardhat network configuration with your RPC URL and private key.

📁 Project Structure

├── circuits/                # Circom circuit files
├── scripts/deploy.ts        # Deployment and proof generation script
├── contracts/Verifier.sol   # Auto-generated Solidity Verifier
├── hardhat.config.ts        # Hardhat configuration
└── circuits.config.json     # Circuit and zkey configurations

📊 Example Output (for Multiplier.circom)

After completing the workflow, expect the following:

  • Compiled circuit files: .wasm, .zkey
  • Solidity verifier: contracts/MultiplierVerifier.sol
  • Proof and calldata JSON
  • On-chain verification result: ✅ true

📧 Author

Suraj R
Email: surajwork.aug28@gmail.com
LinkedIn: linkedin.com/in/suraj-r

🙌 Acknowledgements

This template is built using the excellent hardhat-circom plugin by Project Sophon.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published