draft: poseidon2 (plonky3) integration in benchtop #782
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.
I'm opening this PR as a placeholder, but it was interesting to integrate Poseidon2 with NOMT.
This creates a custom Poseidon2 hasher for nodes and uses the Legendre Symbol (Residue/Non-Residue)
rather than the MSB of the hash to indicate leaf/internal nodes.
This is not optimized at all but still comfortably achieves 40k+ TPS on a benchmark with 2^25 items.
Hashes are of the form
[KoalaBear; 8]
. I convert blake3 value hashes into this type by taking each 32-bit word modulo the KoalaBear prime.Key-paths are treated specially. Because NOMT internals require that the key-path is encoded as a bit-string, I instead limited the length of the key-path to 240 bits and treat them as 8 densely packed 30-bit limbs. i.e. a KeyPath is a
[KoalaBear; 8]
where none of the field elements (when treated as a 32-bit number) use more than 30 bits, and which are densely packed into the[u8; 256]