Implement session call digest for v3 sessions#362
Open
Agusx1211 wants to merge 1 commit into
Open
Conversation
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.
This implements the digest that a session key has to sign for each call of a v3 payload, needed for waas smart-sessions (7193). The old
hashCallWithReplayProtectionwas a leftover stub, unexported and with no callers, so I replaced it with an exportedHashCallWithReplayProtectionthat matchesSessionSig.hashPayloadCallIdxin wallet-contracts-v3:keccak256(Payload.hashFor(payload, wallet) ++ uint256(callIdx)).Note that the digest scheme the stub hinted at (
chainId ++ space ++ nonce ++ callHash) is no longer what the contracts verify, it was removed in the audit fix for partial payload replay (0xsequence/wallet-contracts-v3#89), so implementing it as described would produce signatures that never pass on-chain.The test vectors in
session_digest_test.gowere generated fromSessionSig.hashPayloadCallIdxitself, with a forge test constructing identical payloads, so the test asserts parity with the on-chain verification. I also checked that a signature produced over this digest recovers to the right signer through plainecrecover, which is the exact path the contract uses (no EIP-191 prefix).