dmihal / eth-permit

Lightweight library for signing ERC-2612 permit signatures.
https://www.npmjs.com/package/eth-permit
139 stars 30 forks source link

Appears who is the signer has no effect #7

Closed thanpolas closed 2 years ago

thanpolas commented 2 years ago

Hello there,

I am a bit confused as to the validity of a signer. On synthetix v3 implementation of EIP2612 I authored a test that permit() should reject a non-owner signed digest.

However, that's not the case, and I needed your assistance on this.

Using hardhat, I setup the following test case:

  let holder, spender;

  before('identify signers', async () => {
    [holder, spender] = await ethers.getSigners();
  });

And then use the "spender", who is not the "owner", to sign a digest on the owner's behalf. A case that should throw:

    it('Should reject non owner signature', async () => {
      const { deadline, v, r, s } = await signERC2612Permit(
        spender,
        ERC20.address,
        holder.address,
        spender.address,
        value
      );

      await assertRevert(
        ERC20.permit(holder.address, spender.address, value, deadline, v, r, s),
        'INVALID_PERMIT_SIGNATURE'
      );
    });

However, the contract accepts the signed "v, r, s" and the test fails.

Am I missing something obvious here?

Thank you

thanpolas commented 2 years ago

hey @dmihal, did you have time to look into this? 👋