Skip to content

Commit

Permalink
Signer should not define the relayer's message value.
Browse files Browse the repository at this point in the history
  • Loading branch information
cristovaoth committed Sep 28, 2023
1 parent 5bb10dc commit 3cb8754
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
8 changes: 3 additions & 5 deletions contracts/signature/Eip712Signature.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ abstract contract EIP712Signature {
bytes32 s
) = _splitSignature(msg.data);

bytes32 txHash = _transactionHash(msg.value, dataTrimmed, nonce);
bytes32 txHash = _transactionHash(dataTrimmed, nonce);

signer = ecrecover(txHash, v, r, s);
}
Expand All @@ -42,7 +42,6 @@ abstract contract EIP712Signature {
}

function _transactionHash(
uint256 value,
bytes calldata data,
uint256 _nonce
) private view returns (bytes32) {
Expand All @@ -58,7 +57,6 @@ abstract contract EIP712Signature {
keccak256(
abi.encode(
TRANSACTION_TYPEHASH,
value,
keccak256(data),
_nonce
)
Expand All @@ -74,8 +72,8 @@ abstract contract EIP712Signature {
0x47e79534a245952e8b16893a336b85a3d9ea9fa8c573f3d803afb92a79469218;

// keccak256(
// "Transaction(uint256 value,bytes data,uint256 nonce)"
// "Transaction(bytes data,uint256 nonce)"
// );
bytes32 private constant TRANSACTION_TYPEHASH =
0x04c518a746e9715fde6a6d3ebdf678ea51c6d591b95e35d73b7e312afa44dd71;
0x095b95bd4097eddc78a04047eaaf54c1bf5007ccce3f4f54118d21b4c01d9845;
}
3 changes: 2 additions & 1 deletion test/03_Modifier.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import hre from "hardhat";
import typedDataForTransaction from "./typesDataForTransaction";
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import { TestModifier__factory } from "../typechain-types";
import { keccak256, toUtf8Bytes } from "ethers/lib/utils";

describe("Modifier", async () => {
const SENTINEL_MODULES = "0x0000000000000000000000000000000000000001";
Expand Down Expand Up @@ -496,7 +497,7 @@ async function sign(
) {
const { domain, types, message } = typedDataForTransaction(
{ contract, chainId: 31337, nonce: 0 },
{ value: transaction.value || 0, data: transaction.data || "0x" }
transaction.data || "0x"
);
return signer._signTypedData(domain, types, message);
}
2 changes: 1 addition & 1 deletion test/06_Eip712Signature.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async function sign(
) {
const { domain, types, message } = typedDataForTransaction(
{ contract, chainId: 31337, nonce: 0 },
{ value: transaction.value || 0, data: transaction.data || "0x" }
transaction.data || "0x"
);
return await signer._signTypedData(domain, types, message);
}
4 changes: 1 addition & 3 deletions test/typesDataForTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,16 @@ export default function typedDataForTransaction(
chainId: BigNumberish;
nonce: BigNumberish;
},
{ value, data }: { value: BigNumberish; data: string }
data: string
) {
const domain = { verifyingContract: contract, chainId };
const types = {
Transaction: [
{ type: "uint256", name: "value" },
{ type: "bytes", name: "data" },
{ type: "uint256", name: "nonce" },
],
};
const message = {
value,
data,
nonce,
};
Expand Down

0 comments on commit 3cb8754

Please sign in to comment.