-
Notifications
You must be signed in to change notification settings - Fork 795
fix: eip712 signing with ledger hw #518
fix: eip712 signing with ledger hw #518
Conversation
This commit fixes the way a EIP712 derived struct is sent to the Ledger HW to obtain the signature. It also checks if the Ledger ETH app is at least 1.6.0 since this is a requirement.
7b79f3b
to
d4cc4ed
Compare
This PR resolves the issue #516 |
Nice work @sebastinez! Looks great! |
Can we add a test case to the tests module? |
Yeah should be no problem, the thing I'm missing is since I'm not able to mock a Ledger (at least I think so) it's kinda hard to assert something. Did you have some specific test in mind? |
I think just writing a simple test for any 712 struct that you ignore by default with the Ledger signer is sufficient. Just want something that I could run locally and check that it works! |
Okay understood, np 👍 |
ethers-signers/src/ledger/mod.rs
Outdated
let version = semver::Version::parse(&self.version().await?)?; | ||
|
||
// Enforce app version is greater than EIP712_MIN_VERSION | ||
if !req.matches(&version) { |
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 suggest we move the version check to the sign_typed_struct
method, as it should be checked there as well if the method was used instead of sign_typed_data
.
In b5587ba I moved the version check and the parsing of If we are able to merge let me know and I squash some commits and sign the remaining ones. |
we need this to compile ethers-contract as a standalone package
OK this looks great. Thank you for the work on it. I made the test slightly tighter and manually verified that it works! |
Motivation
This PR fixes the way a EIP712 derived struct is sent to the Ledger HW to obtain the signature.
Solution
Based on the following specification: https://github.com/LedgerHQ/app-ethereum/blob/master/doc/ethapp.asc#sign-eth-eip-712
INS
variant =SIGN_ETH_EIP_712
self.sign_message
withself.signed_typed_struct
signed_typed_struct
creates a payload consisting of the domain separator and the typed data hash.PR Checklist
I tested the generated signature on a deployed contract on Rinkeby and it works great.
Please let me know if you have any feedback @gakonst @prestwich @Ryanmtate.