Fix y_parity signature for eip1559 and eip2930

This commit is contained in:
pscott
2021-07-31 13:33:45 +02:00
parent aa2415125e
commit d0a540f683

View File

@@ -28,20 +28,28 @@ unsigned int io_seproxyhal_touch_tx_ok(const bagl_element_t *e) {
sizeof(signature),
&info);
explicit_bzero(&privateKey, sizeof(privateKey));
// Parity is present in the sequence tag in the legacy API
if (tmpContent.txContent.vLength == 0) {
// Legacy API
G_io_apdu_buffer[0] = 27;
if (txContext.txType == EIP1559 || txContext.txType == EIP2930) {
if (info & CX_ECCINFO_PARITY_ODD) {
G_io_apdu_buffer[0] = 1;
} else {
G_io_apdu_buffer[0] = 0;
}
} 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;
}
if (info & CX_ECCINFO_PARITY_ODD) {
G_io_apdu_buffer[0]++;
}
if (info & CX_ECCINFO_xGTn) {
G_io_apdu_buffer[0] += 2;
// Parity is present in the sequence tag in the legacy API
if (tmpContent.txContent.vLength == 0) {
// Legacy API
G_io_apdu_buffer[0] = 27;
} 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;
}
if (info & CX_ECCINFO_PARITY_ODD) {
G_io_apdu_buffer[0]++;
}
if (info & CX_ECCINFO_xGTn) {
G_io_apdu_buffer[0] += 2;
}
}
format_signature_out(signature);
tx = 65;