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

V6 eip712 libs #20

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

V6 eip712 libs #20

wants to merge 14 commits into from

Conversation

108356037
Copy link

  • Add code regarding EIP712 signature of V6
  • Run npx hardhat test --grep "Generate V6 EIP712 signature examples" at project root to generate EIP712 payloads, these data may be used in foundry test

@108356037 108356037 requested a review from pilagod August 24, 2023 03:14
Comment on lines 64 to 65
options: SigningOptions,
signForV6?: boolean,
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about making type optional in the SigningOptions? If the type is provided, do the composition, otherwise just return plain signature.

In this way signForV6 could be removed, it would be better for bottom layer class to be version agnostic.

Copy link
Author

Choose a reason for hiding this comment

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

Added a legacy boolean param to SigningOptions. If true, then signature is set for v5, else signature is for v6.

src/v6/signing.ts Outdated Show resolved Hide resolved
Comment on lines 31 to 36
private keccak256 = (data: string | Uint8Array, encoding?: "utf8" | "hex"): String => {
if (typeof data === "string" && encoding === "utf8") {
return "0x" + Buffer.from(keccak_256(this.toBuffer(data, encoding))).toString("hex")
}
return "0x" + Buffer.from(keccak_256(data)).toString("hex")
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think ethers.js have keccack256 util, did you try it before?

https://docs.ethers.org/v5/api/utils/hashing/#utils-keccak256

Copy link
Author

Choose a reason for hiding this comment

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

Refined getXXXEIP712Typehash for each type and used keccak from ethers

test/v6/GenerateEIP712Payload.ts Outdated Show resolved Hide resolved
@108356037 108356037 requested a review from pilagod August 25, 2023 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants