Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit db10f3a

Browse files
author
Jan Xie
committed
use utils secp256k1 helpers only
1 parent 0ece25b commit db10f3a

File tree

2 files changed

+3
-22
lines changed

2 files changed

+3
-22
lines changed

ethereum/specials.py

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# -*- coding: utf8 -*-
22
import bitcoin
33
from rlp.utils import ascii_chr
4-
from secp256k1 import PublicKey, ALL_FLAGS
54

65
from ethereum import utils, opcodes
76
from ethereum.utils import safe_ord, decode_hex, encode_int32
@@ -29,28 +28,11 @@ def proc_ecrecover(ext, msg):
2928

3029
if r >= bitcoin.N or s >= bitcoin.N or v < 27 or v > 28:
3130
return 1, msg.gas - opcodes.GECRECOVER, []
32-
33-
signature_bytes = [0] * 64
34-
msg.data.extract_copy(signature_bytes, 0, 64, 32)
35-
msg.data.extract_copy(signature_bytes, 32, 96, 32)
36-
signature = b''.join(map(ascii_chr, signature_bytes))
37-
38-
pk = PublicKey(flags=ALL_FLAGS)
3931
try:
40-
pk.public_key = pk.ecdsa_recover(
41-
message_hash,
42-
pk.ecdsa_recoverable_deserialize(
43-
signature,
44-
v - 27
45-
),
46-
raw=True
47-
)
48-
except Exception:
49-
# Recovery failed
32+
pub = utils.ecrecover_to_pub(message_hash, v, r, s)
33+
except:
5034
return 1, msg.gas - gas_cost, []
51-
52-
pub = pk.serialize(compressed=False)
53-
o = [0] * 12 + [safe_ord(x) for x in utils.sha3(pub[1:])[-20:]]
35+
o = [0] * 12 + [safe_ord(x) for x in utils.sha3(pub)[-20:]]
5436
return 1, msg.gas - gas_cost, o
5537

5638

ethereum/transactions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from rlp.sedes import big_endian_int, binary
55
from rlp.utils import str_to_bytes, ascii_chr
66
from ethereum.utils import encode_hex
7-
from secp256k1 import PublicKey, ALL_FLAGS, PrivateKey
87

98
from ethereum.exceptions import InvalidTransaction
109
from ethereum import bloom

0 commit comments

Comments
 (0)