Giter Club home page Giter Club logo

zk-merkle-tree's Issues

React JS incompatible

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:

  1. Create fresh React app: yarn create react-app my-app --template typescript
  2. Add zk-merkle-tree dependency yarn add zk-merkle-tree
  3. Import zk-merkle-tree in src/App.tsx: import {generateCommitment} from "zk-merkle-tree"
  4. Call generateCommitment:
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

Feature Request: Foundry Support

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!

If a hashFn returns an odd length string, the buffer removes the last digit

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?

FIELD_SIZE need to change. Is this possible?

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.

Deployed this zk-tree-vote project on testnet but encountered error

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) }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.