Skip to content

Insomnia501/zk_merkle_tree_case

Repository files navigation

Sample Zero Knowledge Merkle Tree Proof Case

This project demonstrates a basic ZK-based MerkleTree use case. It comes with a circuit and smart contract, a test for that contract, and a script that test that contract.

Try running some of the following tasks:

Circuit

The merkle tree circuit is circuits/merkle_tree/merkle_tree.circom, and here's some related scripts:

cd circuits
// compile circom
circom ./merkle_tree/merkle_tree.circom --sym --wasm --r1cs -o ./build
// gen zkey
snarkjs plonk setup build/merkle_tree.r1cs build/pot16_final.ptau build/merkle_tree.zkey
// gen verifier sol
snarkjs zkey export solidityverifier build/merkle_tree.zkey ../contracts/Verifier.sol

SmartContract

The smart contract includes Verifier.sol which generated by snarkjs, and ZKMerkleTree.sol to do the full prove process.

Testing

A test script(test/test.ts) to verify that certain addreess is in the set of addresses Each leave node is hash(secret, address), and we use '123' as secret.

// install npm package
npm install
// compile the contract
npx hardhat compile
// test verifys
npx hardhat test

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published