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

Commit 6a24710

Browse files
committed
use pycryptodome for sha3_512 and sha3_256 in ethash
1 parent 343d161 commit 6a24710

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

ethereum/ethash_utils.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import sha3
1+
from Crypto.Hash import keccak
2+
sha3_256 = lambda x: keccak.new(digest_bits=256, data=x)
3+
sha3_512 = lambda x: keccak.new(digest_bits=512, data=x)
24
from rlp.utils import decode_hex, encode_hex
35
import sys
46

@@ -59,11 +61,11 @@ def to_bytes(x):
5961

6062
# sha3 hash function, outputs 64 bytes
6163
def sha3_512(x):
62-
return hash_words(lambda v: sha3.sha3_512(to_bytes(v)).digest(), 64, x)
64+
return hash_words(sha3_512(to_bytes(v)).digest(), 64, x)
6365

6466

6567
def sha3_256(x):
66-
return hash_words(lambda v: sha3.sha3_256(to_bytes(v)).digest(), 32, x)
68+
return hash_words(sha3_256(to_bytes(v)).digest(), 32, x)
6769

6870

6971
def xor(a, b):

0 commit comments

Comments
 (0)