Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: revised LightAccount v2 1271 sigs #614

Merged
merged 1 commit into from Apr 23, 2024
Merged

Conversation

dphilipson
Copy link
Contributor

@dphilipson dphilipson commented Apr 22, 2024

Updates the signMessage and signTypedData implementations for LightAccount v2. The updated version no longer attempts to use nested typed data to display the original message to the user, as doing so creates a security risk in which valid signing requests can be disguished in a way that concels their original contents.

Instead, the new LightAccount v2 uses the same signing mechanism as v1.1.0, except that it also prepends an enum indicating if the owner is an EOA or smart contract account, as a way to both save gas and to provide more accurate gas estimates.


PR-Codex overview

This PR refactors the createLightAccountBase function in base.ts to remove usage of getErc1271SigningFunctions and directly call signWith1271WrapperV1.

Detailed summary

  • Removed getErc1271SigningFunctions import and direct calls to signWith1271WrapperV1.
  • Updated signature handling for different account versions.
  • Removed unused functions hashDomain.ts and hashTypedData.ts.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Updates the `signMessage` and `signTypedData` implementations for
`LightAccount` v2. The updated version no longer attempts to use nested
typed data to display the original message to the user, as doing so
creates a security risk in which valid signing requests can be
disguished in a way that concels their original contents.

Instead, the new `LightAccount` v2 uses the same signing mechanism as
v1.1.0, except that it also prepends an enum indicating if the owner is
an EOA or smart contract account, as a way to both save gas and to
provide more accurate gas estimates.
Copy link
Contributor

@denniswon denniswon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but do we need to remove the files for 1271? no big opinion. wdyt? @moldy530

Copy link
Contributor

@jaypaik jaypaik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐐

@@ -242,7 +231,7 @@ export async function createLightAccountBase({
case "v1.1.0":
return signWith1271WrapperV1(hashMessage(message));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be awaited too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return x and return await x do the same thing (unless in a try-block), so the linter would probably complain at me.

@@ -242,7 +231,7 @@ export async function createLightAccountBase({
case "v1.1.0":
return signWith1271WrapperV1(hashMessage(message));
case "v2.0.0":
const signature = await signMessageV2({ message });
const signature = await signWith1271WrapperV1(hashMessage(message));

This comment was marked as resolved.

@moldy530
Copy link
Collaborator

moldy530 commented Apr 23, 2024

but do we need to remove the files for 1271

yea we should delete them and ideally open a pr with viem to have them export them

@dphilipson
Copy link
Contributor Author

Yeah, no need to include functions we're not using, we can always get them back from version control if we need them again.

@dphilipson dphilipson merged commit 378c83b into main Apr 23, 2024
2 checks passed
@dphilipson dphilipson deleted the dp/revise-lav2-signing branch April 23, 2024 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants