Skip to content

Fix Poseidon V1 suffix-zero collision#10

Merged
jayz22 merged 2 commits intostellar:mainfrom
jayz22:fix/poseidon-v1-full-rate-enforcement
Mar 11, 2026
Merged

Fix Poseidon V1 suffix-zero collision#10
jayz22 merged 2 commits intostellar:mainfrom
jayz22:fix/poseidon-v1-full-rate-enforcement

Conversation

@jayz22
Copy link
Contributor

@jayz22 jayz22 commented Mar 10, 2026

What

Fix Poseidon V1 suffix-zero collision vulnerability, where hash([x]) == hash([x, 0]) when using a sponge with T > inputs.len() + 1, by enforcing inputs.len() == RATE (full-rate) for Poseidon V1.

Matches circom's behavior where nInputs always determines T = nInputs + 1, so the rate is always fully used

Poseidon2 is unaffected (already uses IV = input_len << 64 for domain separation)

Copilot AI review requested due to automatic review settings March 10, 2026 22:02
@socket-security
Copy link

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedsoroban-sdk@​25.0.2 ⏵ 25.3.08110093100100

View full report

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() == RATE for 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-sdk to 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.

@jayz22 jayz22 merged commit ceb20d3 into stellar:main Mar 11, 2026
16 checks passed
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.

3 participants