Skip to content

Poseidon hash has changed #14

@nanaknihal

Description

@nanaknihal

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:circomlibjs@0.0.8
npm i circomlibjs-new@npm:circomlibjs@0.1.7
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])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions