_PERMIT_TYPEHASH in ERC20Permit

Hi OZ team,

Quick question:

Why is the 'P' in the string of _PERMIT_TYPEHASH capitalized? Shouldn't it match the function signature 'permit(...)'? Perhaps it does not matter, but I think if you build the digest off-chain then you have to ensure this capital 'P'match right?

The hashes obviously are different, though I also see UniswapV2 implementation carried this 'Permit(...)' convention.

ethers.utils.keccak256(ethers.utils.toUtf8Bytes("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"));

'0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9'

ethers.utils.keccak256(ethers.utils.toUtf8Bytes("permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"));

'0xc37f48d561f695e45cda56fc3e5954d7a14f6898128008ba6c2d484db7869e4c'

1 Like

I may have answered my own question, but I believe is due to EIP2612 ?

The capital P doesn't come from the permit function (as you can see the parameters in the string do not match the permit's signature). It comes from the Permit structure that is signed using EIP712.

This is defined in https://eips.ethereum.org/EIPS/eip-2612 and https://eips.ethereum.org/EIPS/eip-712

Capture d’écran du 2022-08-18 12-20-43