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

add Poseidon&MiMC7 test vectors, Poseidon multiHash&hashBuffer, MiMC7 hashBuffer #19

Closed
wants to merge 0 commits into from

Conversation

arnaucube
Copy link
Contributor

This PR adds some test vectors for Poseidon&MiMC7 and some functions in order to make the library more usable from external repositories and to ensure compatibility with other implementations (such as go and rust):

  • Poseidon

    • poseidon.hash: exposes generic Poseidon hash function with nRoundsF=8, nRoundsP=57, t=6
    • poseidon.multiHash: splits the bigint array into chunks of five elements and performs the Poseidon hash over chunks of five elements
    • poseidon.hashBuffer: performs Poseidon hash over a buffer array, first splitting the bytes into 31 bytes bigints, and then performing the multiHash
    • added test vectors in test/poseidon.js
  • MiMC7

    • mimc7.hashBuffer: performs MiMC7 hash over a buffer array, first splitting the bytes into 31 bytes bigints, and then performing the multiHash
    • added test vectors in test/mimc7.js

Question about the multiHash:

  • in src/mimc7.js (line 55) the multiHash does the cycles and at the end of each cycle does:
r = F.add(
            F.add(
                r,
                arr[i]
            ),
            exports.hash(bigInt(arr[i]), r)
        );

Why is doing r = ( r + arr[i] ) + hash(arr[i], r) instead of r = r + hash(arr[i], r)?
(https://eprint.iacr.org/2016/492.pdf page 5)

@CLAassistant
Copy link

CLAassistant commented Sep 9, 2019

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

arnaucube added a commit to arnaucube/circomlib that referenced this pull request Dec 25, 2020
@arnaucube arnaucube closed this Dec 25, 2020
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

Successfully merging this pull request may close these issues.

None yet

2 participants