Repository navigation
fix: use abi.encode in calculateMultiRequestId - #416
Open
OBrezhniev wants to merge 1 commit into
Open
OBrezhniev wants to merge 1 commit into
OBrezhniev wants to merge 1 commit into
Conversation
abi.encodePacked of two dynamic uint256[] arrays is ambiguous, so e.g. ([1, 2], [3]) and ([1], [2, 3]) produced the same multiRequestId. Matches the Verifier contract change (iden3/contracts VerifierLib). BREAKING CHANGE: ids now differ from the previous formula. Use with Verifier contracts that hash multiRequestId with abi.encode (UniversalVerifier >= 3.1.0). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
daveroga
approved these changes
Sep 29, 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.
Summary
calculateMultiRequestIdhashed(requestIds, groupIds, creatorAddress)withsolidityPacked, which isabi.encodePacked. Packing two dynamicuint256[]arrays is ambiguous, so different splits of the same IDs collide:[1, 2][3]37295…7698466503…32039[1][2, 3]37295…7698491988…61768(creator
0xf39F…2266)This PR switches to
AbiCoder.defaultAbiCoder().encode, matching the Verifier contract fix in iden3/contracts: iden3/contracts#464.IDs differ from the previous formula. Use this version with Verifier contracts that hash with
abi.encode(UniversalVerifier ≥ 3.1.0). Against a contract that hasn't been upgraded, and vice versa,setMultiRequestreverts withMultiRequestIdNotValid(expected, given). Existing multiRequests are unaffected, because the ID is only checked when a multiRequest is created. Suggest releasing as a major version, close to the contract upgrades on each network.Tests
Added
calculateMultiRequestIdcases totests/utils/utils.test.ts: fixed vectors, and a check that different splits give different IDs. Locally I could only check prettier and tsc on the changed files. vitest couldn't run because of a local dependency-install issue, so this PR's CI is the first test run.🤖 Generated with Claude Code