Fix Poseidon V1 suffix-zero collision#10
Merged
jayz22 merged 2 commits intostellar:mainfrom Mar 11, 2026
Merged
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR mitigates a Poseidon V1 suffix-zero collision (hash([x]) == hash([x, 0]) under partial-rate usage) by enforcing full-rate input absorption (inputs.len() == RATE) to align with circom’s T = nInputs + 1 behavior.
Changes:
- Enforce
inputs.len() == RATEfor Poseidon V1 (reject partial-rate and empty inputs via the same invariant). - Improve Poseidon2’s rate-exceeded panic message and update tests accordingly.
- Update public docs/README to reflect the Poseidon V1 full-rate requirement, and bump
soroban-sdkto 25.3.0.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/poseidon/sponge.rs | Enforces full-rate (== RATE) absorption for Poseidon V1 and updates panic/docs accordingly. |
| src/tests/poseidon.rs | Replaces partial-rate behavior tests with partial-rate rejection tests; updates panic expectations. |
| src/lib.rs | Updates Poseidon V1 API docs to require T == inputs.len() + 1. |
| README.md | Documents Poseidon V1 full-rate constraint vs Poseidon2’s <= rate constraint. |
| src/poseidon2/sponge.rs | Adds a clearer assert message when inputs exceed the Poseidon2 rate. |
| src/tests/poseidon2.rs | Updates the expected panic message for the Poseidon2 exceed-rate test. |
| Cargo.toml | Bumps workspace soroban-sdk dependency to 25.3.0. |
| Cargo.lock | Lockfile updates corresponding to the soroban-sdk bump. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
sisuresh
approved these changes
Mar 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Fix Poseidon V1 suffix-zero collision vulnerability, where
hash([x]) == hash([x, 0])when using a sponge withT > inputs.len() + 1, by enforcinginputs.len() == RATE(full-rate) for Poseidon V1.Matches circom's behavior where
nInputsalways determinesT = nInputs + 1, so the rate is always fully usedPoseidon2 is unaffected (already uses
IV = input_len << 64for domain separation)