Skip to content

Use abi.encode for multiRequestId hash - #464

Merged
OBrezhniev merged 1 commit into
masterfrom
fix/multirequest-id-abi-encode
Sep 30, 2026
Merged

OBrezhniev merged 1 commit into
masterfrom
fix/multirequest-id-abi-encode

Conversation

@OBrezhniev

Copy link
Copy Markdown
Member

Summary

VerifierLib.setMultiRequest checked multiRequestId == keccak256(abi.encodePacked(requestIds, groupIds, sender)). With two dynamic uint256[] arrays the packed encoding is ambiguous: ([1,2],[3]) and ([1],[2,3]) produce the same ID, so they collide. Slither reports this as High encode-packed-collision. The practical impact was limited to self-DoS, because sender is part of the hash, but the ID didn't commit to how the IDs were split between requests and groups.

  • VerifierLib: abi.encodePacked → abi.encode. This is a hard switch.
  • UniversalVerifier.VERSION 3.0.0 → 3.1.0 (and helpers/constants.ts).
  • test/utils/id-calculation-utils.ts: calculateMultiRequestId uses abi.encode. The verifier tests now import this local helper instead of js-sdk's, so they don't depend on a js-sdk release.
  • New tests: the legacy packed ID is rejected with MultiRequestIdNotValid, and different splits give different IDs.

⚠️ Breaking change for multiRequest creators

  • Existing multiRequests keep working. The ID is only recomputed in setMultiRequest. Reads, proof submission and status checks all use the stored ID, and the storage layout doesn't change.
  • New multiRequests must use the new formula. An ID computed the old way reverts with MultiRequestIdNotValid(expected, given).
  • js-sdk counterpart: fix: use abi.encode in calculateMultiRequestId PrivadoID/js-sdk#416. Release it close to each network's UniversalVerifier upgrade.
  • Downstream contracts inheriting Verifier, such as IdentityVerifier in attestations-registry, pick this up when they bump @iden3/contracts.

Tests

npm run test → 481 passing. solhint clean.

🤖 Generated with Claude Code

multiRequestId was keccak256(abi.encodePacked(requestIds, groupIds, sender)).
With two dynamic uint256[] arrays the packed encoding is ambiguous, so
e.g. ([1,2],[3]) and ([1],[2,3]) produced the same id (slither
encode-packed-collision). Switch to abi.encode.

Breaking for multiRequest creators: ids computed with the old formula
now revert with MultiRequestIdNotValid. Existing multiRequests are
unaffected, since the id is only checked in setMultiRequest.

- UniversalVerifier VERSION 3.0.0 -> 3.1.0
- Tests use the local calculateMultiRequestId helper instead of js-sdk's
- Add tests for legacy id rejection and split collision

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@OBrezhniev
OBrezhniev merged commit 2294d18 into master Sep 30, 2026
5 checks passed
@OBrezhniev
OBrezhniev deleted the fix/multirequest-id-abi-encode branch September 30, 2026 11:22
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.

2 participants