Skip to content

draft: poseidon2 (plonky3) integration in benchtop #782

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

Closed
wants to merge 1 commit into from

Conversation

rphmeier
Copy link
Contributor

@rphmeier rphmeier commented Feb 5, 2025

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]

Copy link
Contributor Author

rphmeier commented Feb 5, 2025

@rphmeier rphmeier force-pushed the rh-node-hasher-labeling-abstraction branch from 65b00ac to a032f24 Compare February 5, 2025 19:13
@rphmeier rphmeier force-pushed the rh-poseidon2-benchtop branch from 237ef82 to c2fb840 Compare February 5, 2025 19:13
@rphmeier rphmeier force-pushed the rh-node-hasher-labeling-abstraction branch from a032f24 to 3d45b1e Compare February 6, 2025 21:50
@rphmeier rphmeier force-pushed the rh-poseidon2-benchtop branch from c2fb840 to 9eca1bc Compare February 6, 2025 21:50
@rphmeier rphmeier force-pushed the rh-node-hasher-labeling-abstraction branch from 3d45b1e to bdc1a2d Compare February 6, 2025 22:35
@rphmeier rphmeier force-pushed the rh-poseidon2-benchtop branch from 9eca1bc to 1fe03e4 Compare February 6, 2025 22:35
@rphmeier rphmeier force-pushed the rh-poseidon2-benchtop branch from 1fe03e4 to c9d69ac Compare February 7, 2025 00:08
@rphmeier rphmeier changed the base branch from rh-node-hasher-labeling-abstraction to rh-hasher-trait-refactor February 7, 2025 00:08
@pepyakin pepyakin changed the base branch from rh-hasher-trait-refactor to graphite-base/782 February 7, 2025 10:26
@pepyakin pepyakin force-pushed the rh-poseidon2-benchtop branch from c9d69ac to a2291a3 Compare February 7, 2025 10:31
@pepyakin pepyakin changed the base branch from graphite-base/782 to master February 7, 2025 10:32
@pepyakin pepyakin force-pushed the rh-poseidon2-benchtop branch from a2291a3 to 7fd6b1a Compare February 7, 2025 10:32
@rphmeier rphmeier force-pushed the rh-poseidon2-benchtop branch from 7fd6b1a to 3caba3b Compare February 21, 2025 19:20
@rphmeier rphmeier closed this May 29, 2025
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.

1 participant