diff --git a/optik/common/abi.py b/optik/common/abi.py index 2aa7ab1..148bbf9 100644 --- a/optik/common/abi.py +++ b/optik/common/abi.py @@ -1,7 +1,7 @@ from itertools import accumulate from typing import List, Union, Any, Optional -import sha3 +from Crypto.Hash import keccak from eth_abi.exceptions import ABITypeError, ParseError from eth_abi.grammar import ABIType, BasicType, TupleType, parse, normalize from maat import Cst, Sext, Value, Var, VarContext @@ -396,7 +396,7 @@ def func_signature(func_name: str, args_spec: str) -> str: def selector(function_signature: str) -> Value: """Return the first 4 bytes of the keccak256 hash of 'func_signature'""" - k = sha3.keccak_256() + k = keccak.new(digest_bits=256) k.update(function_signature.encode()) digest = k.digest()[:4] return Cst(32, int.from_bytes(digest, "big")) diff --git a/optik/common/util.py b/optik/common/util.py index 4a7c8da..5391900 100644 --- a/optik/common/util.py +++ b/optik/common/util.py @@ -4,7 +4,7 @@ import os import rlp -import sha3 +from Crypto.Hash import keccak from .exceptions import GenericException @@ -233,7 +233,7 @@ def compute_new_contract_addr(sender: int, nonce: int) -> int: """Compute a new contract address as generated by the CREATE instruction originating from 'sender' with nonce 'nonce'""" - k = sha3.keccak_256() + k = keccak.new(digest_bits=256) k.update(rlp.encode([sender.to_bytes(20, "big"), nonce])) digest = k.digest()[12:] return int.from_bytes(digest, "big") diff --git a/pyproject.toml b/pyproject.toml index 8061795..175724f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ dependencies = [ "wheel", "pymaat>=0.6.7", "eth_abi", - "pysha3", + "pycryptodome>=3.4.6", "rlp", "crytic-compile", "slither-analyzer",