-
Notifications
You must be signed in to change notification settings - Fork 2
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
base: main
Are you sure you want to change the base?
V6 eip712 libs #20
Conversation
src/signing/signing.ts
Outdated
options: SigningOptions, | ||
signForV6?: boolean, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
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") | ||
} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
npx hardhat test --grep "Generate V6 EIP712 signature examples"
at project root to generate EIP712 payloads, these data may be used in foundry test