Skip to content

Commit

Permalink
Merge branch 'main' into ierc165-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
ly0va authored Jan 7, 2025
2 parents b2e5616 + f812470 commit 54ec2a3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/handlers/ERC1271Handler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity ^0.8.24;

import { IERC1271Upgradeable } from "@openzeppelin/contracts-upgradeable/interfaces/IERC1271Upgradeable.sol";
import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import { Transaction } from "@matterlabs/zksync-contracts/l2/system-contracts/libraries/TransactionHelper.sol";

import { SignatureDecoder } from "../libraries/SignatureDecoder.sol";
Expand All @@ -23,12 +24,18 @@ abstract contract ERC1271Handler is IERC1271Upgradeable, EIP712("Sso1271", "1.0.
bytes4 private constant _ERC1271_MAGIC = 0x1626ba7e;

/**
* @dev Should return whether the signature provided is valid for the provided data
* @dev Should return whether the signature provided is valid for the provided data. Does not run validation hooks.
* @param hash bytes32 - Hash of the data that is signed
* @param signature bytes calldata - Validator address concatenated to signature
* @param signature bytes calldata - K1 owner signature OR validator address concatenated to signature
* @return magicValue bytes4 - Magic value if the signature is valid, 0 otherwise
*/
function isValidSignature(bytes32 hash, bytes memory signature) external view override returns (bytes4 magicValue) {
if (signature.length == 65) {
(address signer, ECDSA.RecoverError error) = ECDSA.tryRecover(hash, signature);
return
signer == address(0) || error != ECDSA.RecoverError.NoError || !_k1IsOwner(signer) ? bytes4(0) : _ERC1271_MAGIC;
}

(bytes memory decodedSignature, address validator) = SignatureDecoder.decodeSignatureNoHookData(signature);

bytes32 eip712Hash = _hashTypedDataV4(_ssoMessageHash(SsoMessage(hash)));
Expand Down
4 changes: 2 additions & 2 deletions src/libraries/SessionLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ library SessionLib {
// most of the computation needed to validate the session.

// TODO: update fee allowance with the gasleft/refund at the end of execution
if (transaction.paymaster != 0) {
// If a paymaster is paying the fee, we don't need to check the fee limit
// If a paymaster is paying the fee, we don't need to check the fee limit
if (transaction.paymaster == 0) {
uint256 fee = transaction.maxFeePerGas * transaction.gasLimit;
spec.feeLimit.checkAndUpdate(state.fee, fee, periodId);
}
Expand Down

0 comments on commit 54ec2a3

Please sign in to comment.