add Poseidon&MiMC7 test vectors, Poseidon multiHash&hashBuffer, MiMC7 hashBuffer #19
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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=6poseidon.multiHash
: splits the bigint array into chunks of five elements and performs the Poseidon hash over chunks of five elementsposeidon.hashBuffer
: performs Poseidon hash over a buffer array, first splitting the bytes into 31 bytes bigints, and then performing themultiHash
test/poseidon.js
MiMC7
mimc7.hashBuffer
: performs MiMC7 hash over a buffer array, first splitting the bytes into 31 bytes bigints, and then performing themultiHash
test/mimc7.js
Question about the
multiHash
:src/mimc7.js
(line 55) themultiHash
does the cycles and at the end of each cycle does:Why is doing
r = ( r + arr[i] ) + hash(arr[i], r)
instead ofr = r + hash(arr[i], r)
?(https://eprint.iacr.org/2016/492.pdf page 5)