Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poseidon hash has changed #14

Open
nanaknihal opened this issue Sep 18, 2022 · 0 comments
Open

Poseidon hash has changed #14

nanaknihal opened this issue Sep 18, 2022 · 0 comments

Comments

@nanaknihal
Copy link

Similar to issue #13
Old and new versions of circomlibjs give different Poseidon functions with different outputs for the same inputs. Perhaps this is intentional, as I see it passes test/poseidon.js. However, the old version seems to be more compatible with other Poseidon implementations, whereas the new version does not pass tests when comparing to other Poseidon implementations.

To reproduce:

npm i circomlibjs-old@npm:[email protected]
npm i circomlibjs-new@npm:[email protected]
const { buildPoseidon } = require("circomlibjs-new");
const { poseidon } = require("circomlibjs-old");
const { ethers } = require("ethers");
const oldIsNew = async () => {
    const oldPoseidon = await buildPoseidon();
    const newPoseidon = poseidon;
    console.log(
        ethers.BigNumber.from(oldPoseidon([1,2,3,4,5])),
        "is",
        ethers.BigNumber.from(newPoseidon([1,2,3,4,5])) 
    )
}

oldIsNew()

Output:

> BigNumber {
  _hex: '0x6e2f2d34107fa746e4ac7bfdf5cceafa076c606db07e7391806811e85434bb01',
  _isBigNumber: true
} is BigNumber {
  _hex: '0x0dab9449e4a1398a15224c0b15a49d598b2174d305a316c918125f8feeb123c0',
  _isBigNumber: true
}

As you can see, it gives a different value for poseidon([1,2,3,4,5])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant