thebojda / zk-merkle-tree Goto Github PK
View Code? Open in Web Editor NEWJavaScript library for anonymous voting on Ethereum blockchain using zero-knowledge proof
License: MIT License
JavaScript library for anonymous voting on Ethereum blockchain using zero-knowledge proof
License: MIT License
I want to use this library with React (and Next.JS). But I got error:
Module not found: Error: Can't resolve 'fs'
Steps to reproduce:
yarn create react-app my-app --template typescript
yarn add zk-merkle-tree
src/App.tsx
: import {generateCommitment} from "zk-merkle-tree"
useEffect(() => {
generateCommitment().then()
}, [])
src/App.tsx full file example
5. Start project yarn start
6. Get errors:
ERROR in ./node_modules/ejs/lib/ejs.js 46:9-22
Module not found: Error: Can't resolve 'fs' in '<...>/node_modules/ejs/lib'
And much more, here is full error message
Is there possibility of security issues by directly using this library and all of the variables without changing to custom ones.
I am new to ZKP.
Hey, thanks for putting together such a useful resource! I found this really easy to import and spin up my own ZK-enabled repo using Hardhat.
Do you have any plans to make this more Foundry-friendly? I'd love to help out if so!
Dear sir,I firstly learn this kind of knowledge and feel hard so could you show me a detailed steps for running this project for voting?
thank you every much
My hash fn sometimes returns odd length strings and returns them as the hash of two leaves. Then behind the scenes this string probably gets turned to a buffer before it gets sent to the fn again. The problem is that a buffer from a hex string needs to be even in order to remain untouched. If its odd length it will remove the last digit. Is there a solution?
Hello,
I am trying to use the MerkleTreeWithHistory.sol
smart contract, and I am trying to pass address
type (converted to bytes32), as _insert function expects, and raise an error, when reaching the hashLeftRight
. The error states: "_left should be inside the field"
, which means that the uint256 representation of an address produce a number greater that the FIELD_SIZE.
Is this possible to change? And if yes, how?
I am trying to use the circom-ecdsa circuit located here. The circuit expects as input a ethereum private key, extracts the public key and calculates the eth address as the BigInt representation, which later this BigInt is going to be passed to a Merkle Tree as leaf.
Meaning that if we pass an address 0x7c5E44C6074Fb29B309f4AbAE9bF790ba338A208
, the circuit returns 710017116651888399609443089319006059204116521480
.
Now I managed to do the same with solidity, but the MerkleTreeWithHistory.sol return the aforementioned error. The circuit works fine without problems. A solution would be to incread the FIELD_SIZE, but I do not know whether it is feasible or not.
Thanks in advance.
Hello, thanks for your earlier reply to the issue I raised.
The project worked perfectly on my local computer as expected.
Then, I decided to move it to testnet.
The voter validation aspect worked perfectly, but when to vote, it shows an error: "exceed maximum block range: 5000". I did some search, and I discover the error is due to "event" that is needed to be retrieved for computation. What can be done.
I think this code portion is the issue, there should be a way to mitigate.
export async function calculateMerkleRootAndPathFromEvents(mimc: any, address: any, provider: any, levels: number, element: any) { const abi = [ "event Commit(bytes32 indexed commitment,uint32 leafIndex,uint256 timestamp)" ]; const contract = new Contract(address, abi, provider) const events = await contract.queryFilter(contract.filters.Commit()) let commitments = [] for (let event of events) { commitments.push(BigNumber.from(event.args.commitment)) } return calculateMerkleRootAndPath(mimc, levels, commitments, element) }
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.