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

Commit d740d59

Browse files
committed
Support py keccak lib and pypy
1 parent 3603a57 commit d740d59

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ethereum/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
try:
2-
import Crypto.Hash.SHA3_256 as _SHA3_256 # from pycryptodome
3-
sha3_256 = _SHA3_256.new
2+
from keccak import sha3_256 # pypy
43
except ImportError:
5-
from sha3 import sha3_256
4+
from sha3 import sha3_256 as _sha3_256
5+
sha3_256 = lambda x: _sha3_256(x).digest()
66
from bitcoin import privtopub
77
import sys
88
import rlp
@@ -102,7 +102,7 @@ def int_to_32bytearray(i):
102102

103103

104104
def sha3(seed):
105-
return sha3_256(to_string(seed)).digest()
105+
return sha3_256(to_string(seed))
106106
assert sha3('').encode('hex') == 'c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'
107107

108108

0 commit comments

Comments
 (0)