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.
.gitignore
artifacts/
contracts/
circuits/
docs/
scripts/
test/
hardhat.config.js
package.json
MerkleTree.sol
Poseidon.sol
verifier.sol
: Verifier contract for ZK proofs.
circuit.circom
MerkleTree.circom
: Merkle Tree circuit.
circuit_js/
: Contains JavaScript files for witness generation.
index.html
: Main HTML file.
src/
: Contains JavaScript and CSS files for the frontend.
deploy.js
compile-circuit.sh
: Script to compile Circom circuits.
merkle-test.js
: Test file for the Merkle Tree contract.
- hardhat.config.js: Hardhat configuration file.
- package.json: Project dependencies and scripts.
- Node.js
- npm
- Hardhat
- Circom
- snarkjs
- Clone the repository:
git clone https://github.com/truthixify/zk-merkle-proof
cd zk-merkle-proof
- Install dependencies:
npm install
- Compile the circuits and contracts:
npm run compile
- Start the Hardhat node:
npx hardhat node
- Deploy the contracts:
npx hardhat run scripts/deploy.js --network localhost
- Start the frontend:
cd docs
npm install
npm run dev
- Open your browser and navigate to
http://localhost:5173
.
- 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
Run the tests using Hardhat:
npx hardhat test
This project is licensed under the MIT License.
For any inquiries, please contact [[email protected]].