diff --git a/greed/TAC/TAC_parser.py b/greed/TAC/TAC_parser.py index ece651b..b64d232 100644 --- a/greed/TAC/TAC_parser.py +++ b/greed/TAC/TAC_parser.py @@ -2,7 +2,8 @@ import json import logging import os -import sha3 + +from eth_utils import keccak from ast import literal_eval from collections import defaultdict @@ -291,9 +292,8 @@ def parse_abi(self): funcs = [e for e in abi if e['type'] == 'function'] for f in funcs: f_proto = f['name'] + '(' + ",".join([i['internalType'] for i in f['inputs']]) + ')' - k = sha3.keccak_256() - k.update(f_proto.encode('utf-8')) - sig_to_name[f"0x{k.hexdigest()[0:8]}"] = f_proto + hexdigest = bytes(keccak(f_proto.encode('utf-8'))).hex() + sig_to_name[f"0x{hexdigest[0:8]}"] = f_proto # Set the function names for f in self.factory.project.function_at.values(): diff --git a/greed/TAC/special_ops.py b/greed/TAC/special_ops.py index b27ea49..396fd72 100644 --- a/greed/TAC/special_ops.py +++ b/greed/TAC/special_ops.py @@ -1,6 +1,6 @@ import logging -import sha3 +from eth_utils import keccak from greed import options from greed.utils import encoding @@ -75,10 +75,8 @@ def handle(self, state: SymbolicEVMState): if not state.solver.is_formula_sat(NotEqual(state.memory.readn(offset_sol, size_sol), buffer_sol)): # Everything has only one solution, we can calculate the SHA - keccak256 = sha3.keccak_256() buffer_sol = bv_unsigned_value(buffer_sol).to_bytes(bv_unsigned_value(size_sol), 'big') - keccak256.update(buffer_sol) - res = keccak256.hexdigest() + res = keccak(buffer_sol).hex() log.debug(f" Calculated concrete SHA3 {res}") # Constraining parameters to their calculated solutions diff --git a/setup.py b/setup.py index b168d44..a3b1ba4 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,6 @@ install_requires=[ 'ipython>=7.16.3', 'networkx>=2.5.1', - 'pysha3>=1.0.2', 'pytest==7.2.1', 'solc-select>=0.2.1', 'sympy>=1.9',