openzeppelin-contracts icon indicating copy to clipboard operation
openzeppelin-contracts copied to clipboard

Use SignatureChecker inside Permit to allow smart contract wallets to use it

Open k06a opened this issue 3 years ago • 7 comments

I see current implementation of EIP-2612 (aka Permit) is not supporting smart contract wallets and they are required to invent own signature-based operations to execute token approve by smart contract wallet owner signature (pseudocode example: https://ethereum.stackexchange.com/a/142814/3032). Trying to fix it without violating EIP-2612 specification.

First (EIP-2612) defines signature as following:

r, s and v is a valid secp256k1 signature from owner

But if owner is smart contract wallet, can we consider signature to be valid secp256k1 signature but of wallet owner() of ERC20 owner?

I think it's possible and doesn't violate EIP that much. Let's discuss.

k06a avatar Jan 12 '23 14:01 k06a

Hello @k06a

This was already discussed (can't find the issue though :/) and we decided against doing it for the following reasons:

  • smart wallets are likely to support meta transaction (and batch transactions), therefore the approve-transferFrom is not as bad for them as it is for EOA
  • some smart wallets want to limit daily/monthly transfers (that was raised by argent). If the transfers are done by the smart wallet, directly calling the ERC20.transfer function, then its possible to enforce that onchain. However, if the transfers are the consequence of an permit, then the quota can no longer be enforced.

Amxx avatar Jan 12 '23 14:01 Amxx

The issue is https://github.com/OpenZeppelin/openzeppelin-contracts/issues/2845.

The main reason is that EIP-2612 specifically says v,r,s a sepck256k1 signature by the owner.

frangio avatar Jan 18 '23 22:01 frangio

But if owner is smart contract wallet, can we consider signature to be valid secp256k1 signature but of wallet owner() of ERC20 owner?

I think it's possible and doesn't violate EIP that much. Let's discuss.

I see this comment now. It's true that it doesn't violate the EIP that much... EIP-1271 goes beyond these signatures though. For example, Gnosis Safe's implementation wouldn't work with this. What wallets would be enabled by this change? There is Argent as mentioned in https://github.com/OpenZeppelin/openzeppelin-contracts/issues/2845. Are there others?

frangio avatar Jan 18 '23 22:01 frangio

@frangio I think smart contract wallets will be able to let receiver claim their tokens without performing transaction. In case of permit to other wallet (EOA or SC).

k06a avatar Jan 18 '23 23:01 k06a

BTW Uniswap’s permit2 supports EIP1271: https://github.com/Uniswap/permit2/blob/ca6b6ff2b47afc2942f3c67b0d929ca4f0b32631/src/libraries/SignatureVerification.sol#L43

k06a avatar Jan 18 '23 23:01 k06a

Interresting: they also support both 65 and 64 bytes signatures

Amxx avatar Jan 19 '23 10:01 Amxx

Interresting: they also support both 65 and 64 bytes signatures

I think they support any length and effectively support Gnosis Safes

k06a avatar Jan 19 '23 12:01 k06a