Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slight improvement #30

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions contracts/Account/EIP712SignerRecovery.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ import "@openzeppelin/contracts/cryptography/ECDSA.sol";
/// @notice https://github.com/ethereum/EIPs/pull/712
contract EIP712SignerRecovery {

uint256 internal immutable CHAIN_ID;
bytes32 internal immutable DOMAIN_SEPARATOR;

constructor (uint256 chainId_) {
CHAIN_ID = chainId_;
DOMAIN_SEPARATOR = keccak256(abi.encode(
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
keccak256("BrinkAccount"),
keccak256("1"),
chainId_,
address(this)
));
}

/// @dev Recovers the signer address for an EIP-712 signed message
Expand All @@ -20,14 +26,7 @@ contract EIP712SignerRecovery {
// generate the hash for the signed message
bytes32 messageHash = keccak256(abi.encodePacked(
"\x19\x01",
// hash the EIP712 domain separator
keccak256(abi.encode(
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
keccak256("BrinkAccount"),
keccak256("1"),
CHAIN_ID,
address(this)
)),
DOMAIN_SEPARATOR,
dataHash
));

Expand Down