Skip to content

truthixify/zk-merkle-proof

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ZK Merkle Proof

This project demonstrates a Zero-Knowledge (ZK) Merkle Proof using a Merkle Tree implemented in Solidity, along with a frontend to interact with the smart contract.

Project Structure

.gitignore
artifacts/
contracts/
circuits/
docs/
scripts/
test/
hardhat.config.js
package.json

Key Directories and Files

  • contracts/: Contains Solidity smart contracts.

MerkleTree.sol

: Implements the Merkle Tree.

Poseidon.sol

: Poseidon hash function library.

verifier.sol

: Verifier contract for ZK proofs.

  • circuits/: Contains Circom circuits and related files.

circuit.circom

: Main circuit file.

MerkleTree.circom

: Merkle Tree circuit.

  • circuit_js/: Contains JavaScript files for witness generation.
  • docs/: Contains frontend files.

index.html

: Main HTML file.

  • src/: Contains JavaScript and CSS files for the frontend.
  • scripts/: Contains scripts for deploying and compiling contracts.

deploy.js

: Script to deploy contracts.

compile-circuit.sh

: Script to compile Circom circuits.

  • test/: Contains test files.

merkle-test.js

: Test file for the Merkle Tree contract.

  • hardhat.config.js: Hardhat configuration file.
  • package.json: Project dependencies and scripts.

Prerequisites

  • Node.js
  • npm
  • Hardhat
  • Circom
  • snarkjs

Installation

  1. Clone the repository:
git clone https://github.com/truthixify/zk-merkle-proof
cd zk-merkle-proof
  1. Install dependencies:
npm install
  1. Compile the circuits and contracts:
npm run compile

Running the Project

  1. Start the Hardhat node:
npx hardhat node
  1. Deploy the contracts:
npx hardhat run scripts/deploy.js --network localhost
  1. Start the frontend:
cd docs
npm install
npm run dev
  1. Open your browser and navigate to http://localhost:5173.

Usage

Frontend

  • Connect Wallet: Connect your MetaMask wallet.
  • Insert Leaf: Insert a new leaf into the Merkle Tree.
  • Get Root: Retrieve the current Merkle root.
  • Get Hashes: Retrieve all hashes in the Merkle Tree.
  • Verify Proof: Verify a Merkle proof.

You can also view a live web UI here: zk-merkle-proof

Testing

Run the tests using Hardhat:

npx hardhat test

License

This project is licensed under the MIT License.

Acknowledgements

Contact

For any inquiries, please contact [[email protected]].

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published