-
Notifications
You must be signed in to change notification settings - Fork 8
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
fix: don't apply eip155 to v anymore #23
base: develop
Are you sure you want to change the base?
fix: don't apply eip155 to v anymore #23
Conversation
I need to read more about the app that basically uses this one. https://github.com/LedgerHQ/blue-secure-sdk On the other hand, I would also keep the +2. The recoverId, or ´v´ could be [0, 1, 2, 3] actually.
So actually, v could be: I don't actually know how probable is to have 2 and 3, or if maybe the signers in general retry this until having something without 2 or 3, but it is an actual possibility and this code is taking this into count, so I would let that as it is right now. |
After reviewing the implementation and considering the points raised, here are some insights and recommendations:
// Simplified: Typed transactions only (EIP-1559/CIP-64)
G_io_apdu_buffer[0] = 0; // Start with parity even (0)
if (info & CX_ECCINFO_PARITY_ODD) {
G_io_apdu_buffer[0] = 1; // Adjust for parity odd (1)
}
if (is_modern_transaction()) {
// Typed transactions (EIP-1559/CIP-64): Use parity only
G_io_apdu_buffer[0] = 0;
if (info & CX_ECCINFO_PARITY_ODD) {
G_io_apdu_buffer[0]++;
}
} else {
// Legacy transactions: Include chain ID and parity/magnitude
if (tmpContent.txContent.vLength == 0) { // Legacy API
G_io_apdu_buffer[0] = 27;
} else { // New API
G_io_apdu_buffer[0] = (v * 2) + 35;
if (info & CX_ECCINFO_PARITY_ODD) {
G_io_apdu_buffer[0]++;
}
if (info & CX_ECCINFO_xGTn) {
G_io_apdu_buffer[0] += 2;
}
}
}``` |
else { | ||
// New API | ||
// Note that this is wrong for a large v, but the client can always recover | ||
G_io_apdu_buffer[0] = (v * 2) + 35; |
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.
The v constant is not used anymore so you need to delete line 93. "uint32_t v = getV(&tmpContent.txContent);"
if (info & CX_ECCINFO_xGTn) { | ||
G_io_apdu_buffer[0] += 2; | ||
} | ||
// Unsure what this does |
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.
You can delete this commented code
replace by #24 |
Checklist
develop
After investigation with the ledger-live team we came to the conclusion that the newest (1.3.1) version of this app returned an EIP155 formatted
v
that the ledgerjs sdk (@ledgerhq/hw-app-eth
) doesn't expect for typed transaction (see https://github.com/LedgerHQ/ledger-live/blob/develop/libs/ledgerjs/packages/hw-app-eth/src/utils.ts#L107), it expectsv
to represent to yParity as either a 0 or a 1. This PR aims to fix this issue.However, I'm not a C developer and there's a line I commented out that I believe is not used anymore but would like to clarity on what it did and if my assumptions are indeed correct.