File tree Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Original file line number Diff line number Diff line change
1
+ # Changelog
2
+
3
+ ## 6.0.0
4
+ - Offset the recoverable ID by 27 in the signature returned by ` eth_sign_msg() ` .
Original file line number Diff line number Diff line change 16
16
from __future__ import print_function
17
17
import sys
18
18
19
- __version__ = "5.3 .0"
19
+ __version__ = "6.0 .0"
20
20
21
21
if sys .version_info .major != 3 or sys .version_info .minor < 6 :
22
22
print (
Original file line number Diff line number Diff line change @@ -774,8 +774,16 @@ def eth_sign_msg(
774
774
) -> bytes :
775
775
"""
776
776
Signs message, the msg will be prefixed with "\x19 Ethereum message\n " + len(msg) in the
777
- hardware
777
+ hardware. 27 is added to the recID to denote an uncompressed pubkey.
778
778
"""
779
+
780
+ def format_as_uncompressed (sig : bytes ) -> bytes :
781
+ # 27 is the magic constant to add to the recoverable ID to denote an uncompressed
782
+ # pubkey.
783
+ s = list (sig )
784
+ s [64 ] += 27
785
+ return bytes (s )
786
+
779
787
request = eth .ETHRequest ()
780
788
# pylint: disable=no-member
781
789
request .sign_msg .CopyFrom (eth .ETHSignMessageRequest (coin = coin , keypath = keypath , msg = msg ))
@@ -800,9 +808,10 @@ def eth_sign_msg(
800
808
if self .debug :
801
809
print (f"Antiklepto nonce verification PASSED" )
802
810
803
- return signature
811
+ return format_as_uncompressed ( signature )
804
812
805
- return self ._eth_msg_query (request , expected_response = "sign" ).sign .signature
813
+ signature = self ._eth_msg_query (request , expected_response = "sign" ).sign .signature
814
+ return format_as_uncompressed (signature )
806
815
807
816
def reset (self ) -> bool :
808
817
"""
You can’t perform that action at this time.
0 commit comments