fix(1271): separate policyData and signature#177
Open
highskore wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull Request Overview
Separates concatenated policy data from the validator signature in ERC-1271 flow by introducing an explicit length-delimited policyData segment inside the aggregated signature format. Updates test construction of composite signatures and parsing logic in SmartSession to extract policy data and remaining validator signature.
- Introduces new signature layout: permissionId | policyDataLength | policyData | validatorSignature
- Adjusts isValidSignatureWithSender to parse and dispatch policyData and validator signature separately
- Refactors tests to build signatures following the new structured layout
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| test/unit/base/ERC1271Base.t.sol | Updates test helper to construct new composite signature with embedded policyData length and blob. |
| contracts/SmartSession.sol | Parses new signature structure: extracts policyData length, slices policyData for ERC1271 policy checks, and separates remaining validator signature. |
Comments suppressed due to low confidence (1)
test/unit/base/ERC1271Base.t.sol:1
- [nitpick] Hard-coded length literal (uint256(32)) and an opaque bytes32 constant reduce clarity of the new signature structure; consider introducing named constants or helper builders (e.g., mockPolicyData(), POLICY_DATA_LENGTH) to document intent and avoid duplication across tests.
import "../../Base.t.sol";
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
zeroknots
reviewed
Oct 15, 2025
| requestSender: sender, | ||
| hash: hash, | ||
| signature: signature, | ||
| signature: signature[64:remainingSignatureOffset], // extract policy data from the signature |
Contributor
Author
|
added some bounds checks & consts @zeroknots |
filmakarov
approved these changes
Dec 19, 2025
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.
There's a bug in 1271 where we pass the whole signature to both the policy and validator, meaning that both the validator and the policy would need to know how to destructure the same data, which obviously doesn't work with OwnableValidator etc.
This PR fixes this by extracting policyData from the signature before passing it to the policy and then passes the signature data to the stateless validator.