Skip to content

Commit 8b97b60

Browse files
authored
Update hd.py
1 parent 294abd2 commit 8b97b60

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

cryptofuzz/hd.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
re,
1414
HD_W,
1515
BTC,
16-
ETH,
1716
TRX,
1817
DGB,
1918
DOGE,
@@ -110,13 +109,23 @@ def hex_addr(self, hexed: str) -> str:
110109
:return: str - address
111110
"""
112111
if is_valid_hex(hexed):
113-
hd: HD_W = HD_W(ETH)
114-
hd.from_private_key(hexed)
115-
return hd.p2pkh_address()
112+
keybytes = bytes.fromhex(hexed)
113+
sk = ecdsa.SigningKey.from_string(keybytes, curve=ecdsa.SECP256k1)
114+
key = sk.get_verifying_key()
115+
KEY = key.to_string()
116+
Keccak = keccak.new(digest_bits=256)
117+
Keccak.update(KEY)
118+
pub_key = Keccak.digest()
119+
primitive_addr = b'\4' + pub_key[-20:]
120+
hashaddr = primitive_addr.hex()
121+
chkSum = hashaddr[0:2]
122+
if hashaddr[0:2] == "04":
123+
return "0x" + hashaddr[2:]
116124
else:
117125
ValueError("hex format invalid check again.[format: hex][64 length]")
118126

119127

128+
120129
class Tron:
121130
def __init__(self):
122131
super().__init__()
@@ -538,7 +547,6 @@ def _userFriendly_to_rawAddress(userFriendly_addr: str) -> str:
538547
# -- Create the final raw address in the format [workchain_id]:[account_id]
539548
return f"{workchain_id}:{account_id_hex}"
540549

541-
542550
def publickey_to_address(self, publickey: bytes, bounceable: bool = True) -> str:
543551
"""
544552
Convert public key to a user-friendly TON address.

0 commit comments

Comments
 (0)