Embed intent hash within permit #85
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This makes the
entrypoint.depositToIntentWithPermitflow only require a single signature.intent_hash0xffpermit_deadlinefor the permit callpermit_deadlineacting as a nestedintent_hashSetting the top byte of the
intent_hash(i.e.permit_deadline) to0xffmakesintent_hash > block.timestampalways true, without significantly impacting the chance of a hash collision.As all intent parameters are hashed and included in the signed permit call, we can trust that the intent is approved if the permit signature is valid.
Caveat: The user will be signing
Permit(owner=wallet_addr, spender=trails_entrypoint, value=uint256.max, nonce, deadline=permit_deadline)which hides the intent parameters from the user's wallet when signing.Caveat: This removes front run protection added here: #75. If we want to re-enable this protection, we could perform a duplicate of the ERC20's permit signature validation on the entrypoint itself. This would require duplicating the permitNonce too. I think this is overkill as the front run attack is unlikely to be exploited in practice. The user can re-sign and use
depositToIntentinstead.Potential caveat: The user must sign a Permit call with a higher deadline than they may want. This could be replayed or frontrun directly to the ERC20. This should be fine, since those approved funds are still only accessible with a user signature (either the same one if committed through
entrypoint.depositToIntentWithPermitor a second one if accessed viaentrypoint.depositToIntent). Theentrypoint.depositToIntentWithPermitcall is still only valid for the intent deadline and not the extendedpermitDeadline.Consider: For
depositToIntentWithPermit, signature validation is entirely done by the ERC20 token. This means a buggy or overly permissive permit validation will allow approved funds (for this buggy token only) to be exploited via the entrypoint. I don't think this is a concern. If the user is using a buggy ERC20 then that's not really our fault...