Browse Source

Fix ledger sign message (#7004)

there was an around ~1/128 chance of creating an invalid signature when signing a message with a ledger
patch-4
Gordan Nekić 4 years ago
committed by GitHub
parent
commit
9c4807644b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      electrum/plugins/ledger/ledger.py

7
electrum/plugins/ledger/ledger.py

@ -334,7 +334,12 @@ class Ledger_KeyStore(Hardware_KeyStore):
if sLength == 33:
s = s[1:]
# 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
@test_pin_unlocked

Loading…
Cancel
Save