Fix ledger sign message (#7004)
there was an around ~1/128 chance of creating an invalid signature when signing a message with a ledger
This commit is contained in:
@@ -334,7 +334,12 @@ class Ledger_KeyStore(Hardware_KeyStore):
|
|||||||
if sLength == 33:
|
if sLength == 33:
|
||||||
s = s[1:]
|
s = s[1:]
|
||||||
# And convert it
|
# And convert it
|
||||||
return bytes([27 + 4 + (signature[0] & 0x01)]) + r + s
|
|
||||||
|
# Pad r and s points with 0x00 bytes when the point is small to get valid signature.
|
||||||
|
r_padded = bytes([0x00]) * (32 - len(r)) + r
|
||||||
|
s_padded = bytes([0x00]) * (32 - len(s)) + s
|
||||||
|
|
||||||
|
return bytes([27 + 4 + (signature[0] & 0x01)]) + r_padded + s_padded
|
||||||
|
|
||||||
@runs_in_hwd_thread
|
@runs_in_hwd_thread
|
||||||
@test_pin_unlocked
|
@test_pin_unlocked
|
||||||
|
|||||||
Reference in New Issue
Block a user