11from .utils .compatibility import *
2- from .utils .compatibility import intTypes
32from .utils .base import Base64
43from .utils .binary import BinaryAscii
54from .utils .der import encodeSequence , encodeInteger , removeSequence , removeInteger
@@ -10,16 +9,16 @@ class Signature:
109 def __init__ (self , r , s , recoveryId = None ):
1110 self .r = r
1211 self .s = s
13- self .recid = recoveryId
12+ self .recoveryId = recoveryId
1413
1514 def toDer (self , withRecoveryId = False ):
1615 encodedSequence = encodeSequence (encodeInteger (self .r ), encodeInteger (self .s ))
1716 if not withRecoveryId :
1817 return encodedSequence
19- return chr (27 + self .recid ) + encodedSequence
18+ return chr (27 + self .recoveryId ) + encodedSequence
2019
2120 def toBase64 (self , withRecoveryId = False ):
22- return toString (Base64 .encode (toBytes (self .toDer (withRecoveryId ))))
21+ return toString (Base64 .encode (toBytes (self .toDer (withRecoveryId = withRecoveryId ))))
2322
2423 @classmethod
2524 def fromDer (cls , string , recoveryByte = False ):
@@ -28,6 +27,7 @@ def fromDer(cls, string, recoveryByte=False):
2827 recoveryId = string [0 ] if isinstance (string [0 ], intTypes ) else ord (string [0 ])
2928 recoveryId -= 27
3029 string = string [1 :]
30+
3131 rs , empty = removeSequence (string )
3232 if len (empty ) != 0 :
3333 raise Exception ("trailing junk after DER signature: %s" % BinaryAscii .hexFromBinary (empty ))
@@ -36,7 +36,8 @@ def fromDer(cls, string, recoveryByte=False):
3636 s , empty = removeInteger (rest )
3737 if len (empty ) != 0 :
3838 raise Exception ("trailing junk after DER numbers: %s" % BinaryAscii .hexFromBinary (empty ))
39- return Signature (r , s , recoveryId )
39+
40+ return Signature (r = r , s = s , recoveryId = recoveryId )
4041
4142 @classmethod
4243 def fromBase64 (cls , string , recoveryByte = False ):
0 commit comments