@@ -53,8 +53,16 @@ def verify(self, message, signature):
53
53
sig_bytes = _helpers .to_bytes (signature )
54
54
if len (sig_bytes ) != 64 :
55
55
return False
56
- r = utils .int_from_bytes (sig_bytes [:32 ], byteorder = "big" )
57
- s = utils .int_from_bytes (sig_bytes [32 :], byteorder = "big" )
56
+ r = (
57
+ int .from_bytes (sig_bytes [:32 ], byteorder = "big" )
58
+ if _helpers .is_python_3 ()
59
+ else utils .int_from_bytes (sig_bytes [:32 ], byteorder = "big" )
60
+ )
61
+ s = (
62
+ int .from_bytes (sig_bytes [32 :], byteorder = "big" )
63
+ if _helpers .is_python_3 ()
64
+ else utils .int_from_bytes (sig_bytes [32 :], byteorder = "big" )
65
+ )
58
66
asn1_sig = encode_dss_signature (r , s )
59
67
60
68
message = _helpers .to_bytes (message )
@@ -121,7 +129,11 @@ def sign(self, message):
121
129
122
130
# Convert ASN1 encoded signature to (r||s) raw signature.
123
131
(r , s ) = decode_dss_signature (asn1_signature )
124
- return utils .int_to_bytes (r , 32 ) + utils .int_to_bytes (s , 32 )
132
+ return (
133
+ (r .to_bytes (32 , byteorder = "big" ) + s .to_bytes (32 , byteorder = "big" ))
134
+ if _helpers .is_python_3 ()
135
+ else (utils .int_to_bytes (r , 32 ) + utils .int_to_bytes (s , 32 ))
136
+ )
125
137
126
138
@classmethod
127
139
def from_string (cls , key , key_id = None ):
0 commit comments