diff --git a/src/ERC6538Registry.sol b/src/ERC6538Registry.sol index 925ab9c..c6b4df4 100644 --- a/src/ERC6538Registry.sol +++ b/src/ERC6538Registry.sol @@ -14,10 +14,6 @@ contract ERC6538Registry { /// @dev `nonce` will be incremented after each valid `registerKeysOnBehalf` call. mapping(address user => uint256) public nonceOf; - /// @dev EIP-712 Type hash used in `registerKeysOnBehalf`. - bytes32 public constant TYPE_HASH = - keccak256("EIP712Domain(string name,string version,uint256 chainId,address registryContract)"); - /// @dev The chain ID where this contract is initially deployed. uint256 internal immutable INITIAL_CHAIN_ID; @@ -76,7 +72,15 @@ contract ERC6538Registry { "\x19\x01", DOMAIN_SEPARATOR(), keccak256( - abi.encode(TYPE_HASH, registrant, schemeId, stealthMetaAddress, nonceOf[registrant]++) + abi.encode( + keccak256( + "RegisterKeysOnBehalf(address registrant,uint256 schemeId,bytes stealthMetaAddress,uint256 nonce)" + ), + registrant, + schemeId, + stealthMetaAddress, + nonceOf[registrant]++ + ) ) ) ); @@ -126,7 +130,13 @@ contract ERC6538Registry { function _computeDomainSeparator() internal view returns (bytes32) { return keccak256( abi.encode( - TYPE_HASH, keccak256("ERC6538Registry"), keccak256("1.0"), block.chainid, address(this) + keccak256( + "EIP712Domain(string name,string version,uint256 chainId,address registryContract)" + ), + keccak256("ERC6538Registry"), + keccak256("1.0"), + block.chainid, + address(this) ) ); } diff --git a/test/ERC6538Registry.t.sol b/test/ERC6538Registry.t.sol index 4165280..9906678 100644 --- a/test/ERC6538Registry.t.sol +++ b/test/ERC6538Registry.t.sol @@ -299,9 +299,6 @@ contract SigUtils { DOMAIN_SEPARATOR = _DOMAIN_SEPARATOR; } - bytes32 public constant TYPEHASH = - keccak256("EIP712Domain(string name,string version,uint256 chainId,address registryContract)"); - struct RegistrantInfo { address registrant; uint256 schemeId; @@ -312,7 +309,15 @@ contract SigUtils { // computes the hash function getStructHash(RegistrantInfo memory _info) internal pure returns (bytes32) { return keccak256( - abi.encode(TYPEHASH, _info.registrant, _info.schemeId, _info.stealthMetaAddress, _info.nonce) + abi.encode( + keccak256( + "RegisterKeysOnBehalf(address registrant,uint256 schemeId,bytes stealthMetaAddress,uint256 nonce)" + ), + _info.registrant, + _info.schemeId, + _info.stealthMetaAddress, + _info.nonce + ) ); }