This repository was archived by the owner on May 23, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,25 @@ def consume_length_prefix(rlp, start):
67
67
l = big_endian_to_int (rlp [start + 1 :start + 1 + ll ])
68
68
return (list , l , start + 1 + ll )
69
69
70
+ def optimized_decode_single (x , pos ):
71
+ z = safe_ord (x [pos ])
72
+ if z < 128 :
73
+ return x [pos : pos + 1 ], 1
74
+ elif z < 184 :
75
+ return x [pos + 1 : pos + z - 127 ], z - 127
76
+ else :
77
+ ll = big_endian_to_int (x [pos + 1 : pos + z - 182 ])
78
+ return x [pos + z - 182 : pos + z - 182 + ll ], z - 182 + ll
79
+
80
+ def optimized_decode_list (rlp ):
81
+ o , pos = [], 0
82
+ _typ , _len , pos = consume_length_prefix (rlp , pos )
83
+ while pos < len (rlp ):
84
+ x , inc = optimized_decode_single (rlp , pos )
85
+ pos += inc
86
+ o .append (x )
87
+ return o
88
+
70
89
#
71
90
if sys .version_info .major == 2 :
72
91
encode_optimized = _encode_optimized
Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ def bytes_to_int(value):
85
85
86
86
87
87
def ecrecover_to_pub (rawhash , v , r , s ):
88
- if secp256k1 :
88
+ if secp256k1 and hasattr ( secp256k1 , "PublicKey" ) :
89
89
# Legendre symbol check; the secp256k1 library does not seem to do this
90
90
pk = secp256k1 .PublicKey (flags = secp256k1 .ALL_FLAGS )
91
91
xc = r * r * r + 7
You can’t perform that action at this time.
0 commit comments