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

Commit d176369

Browse files
committed
Merge pull request #295 from ethereum/pycryptodome
exclusively use pycryptodome for sha3_256 hashing
2 parents 5b9c10f + 6a24710 commit d176369

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

dev_requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ tox
22
coveralls
33
pytest
44
pytest-catchlog==1.1
5-
pytest-timeout
5+
pytest-timeout==0.5
66
https://github.com/ethereum/serpent/tarball/develop

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):

ethereum/keys.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
import binascii
2424
import struct
2525
from math import ceil
26-
from sha3 import sha3_256
26+
from Crypto.Hash import keccak
27+
sha3_256 = lambda x: keccak.new(digest_bits=256, data=x)
2728
from Crypto.Cipher import AES
2829
from Crypto.Hash import SHA256
2930
from Crypto.Util import Counter

ethereum/utils.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
try:
2-
from keccak import sha3_256 # pypy
3-
except ImportError:
4-
from sha3 import sha3_256 as _sha3_256
5-
sha3_256 = lambda x: _sha3_256(x).digest()
1+
from Crypto.Hash import keccak
2+
sha3_256 = lambda x: keccak.new(digest_bits=256, data=x).digest()
63
from bitcoin import privtopub
74
import sys
85
import rlp

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pysha3
33
PyYAML
44
repoze.lru
55
pbkdf2
6-
pycrypto
6+
pycryptodome>=3.3.1
77
scrypt
88
https://github.com/ethereum/pyrlp/tarball/develop
99
https://github.com/ethereum/ethash/tarball/master

0 commit comments

Comments
 (0)