From 882fc95756e876f93c4248dd6050c16d6a5a5c41 Mon Sep 17 00:00:00 2001 From: alpharush <0xalpharush@protonmail.com> Date: Tue, 28 Jun 2022 12:30:00 -0500 Subject: [PATCH 1/3] replace pysha3 with pycryptodome --- setup.py | 2 +- slither/printers/summary/function_ids.py | 2 +- slither/utils/function.py | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 0b67d50705..169ed65cf3 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ python_requires=">=3.8", install_requires=[ "prettytable>=0.7.2", - "pysha3>=1.0.2", + "pycryptodome>=3.15.0", "crytic-compile>=0.2.4", # "crytic-compile@git+https://github.com/crytic/crytic-compile.git@master#egg=crytic-compile", ], diff --git a/slither/printers/summary/function_ids.py b/slither/printers/summary/function_ids.py index 368a81382b..ca02dd7549 100644 --- a/slither/printers/summary/function_ids.py +++ b/slither/printers/summary/function_ids.py @@ -9,7 +9,7 @@ class FunctionIds(AbstractPrinter): ARGUMENT = "function-id" - HELP = "Print the keccack256 signature of the functions" + HELP = "Print the keccak256 signature of the functions" WIKI = "https://github.com/trailofbits/slither/wiki/Printer-documentation#function-id" diff --git a/slither/utils/function.py b/slither/utils/function.py index b86d8f4ebc..1c3741cc7a 100644 --- a/slither/utils/function.py +++ b/slither/utils/function.py @@ -1,4 +1,4 @@ -import sha3 +from Crypto.Hash import keccak def get_function_id(sig: str) -> int: @@ -9,6 +9,6 @@ def get_function_id(sig: str) -> int: Return: (int) """ - s = sha3.keccak_256() - s.update(sig.encode("utf-8")) - return int("0x" + s.hexdigest()[:8], 16) + hash = keccak.new(digest_bits=256) + hash.update(sig.encode("utf-8")) + return int("0x" + hash.hexdigest()[:8], 16) From 44a45e75a4036fa51c076f20d7fd2c04168156f3 Mon Sep 17 00:00:00 2001 From: alpharush <0xalpharush@protonmail.com> Date: Sun, 6 Nov 2022 20:40:43 -0600 Subject: [PATCH 2/3] fix "redefine builtin" lint error --- slither/utils/function.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/slither/utils/function.py b/slither/utils/function.py index 1c3741cc7a..34e6f221bb 100644 --- a/slither/utils/function.py +++ b/slither/utils/function.py @@ -9,6 +9,6 @@ def get_function_id(sig: str) -> int: Return: (int) """ - hash = keccak.new(digest_bits=256) - hash.update(sig.encode("utf-8")) - return int("0x" + hash.hexdigest()[:8], 16) + digest = keccak.new(digest_bits=256) + digest.update(sig.encode("utf-8")) + return int("0x" + digest.hexdigest()[:8], 16) From 99c973d3e2124f1e80aff33f11b5552e0e56e19a Mon Sep 17 00:00:00 2001 From: alpharush <0xalpharush@protonmail.com> Date: Mon, 7 Nov 2022 08:54:13 -0600 Subject: [PATCH 3/3] more compatible version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 169ed65cf3..e7ffc87587 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ python_requires=">=3.8", install_requires=[ "prettytable>=0.7.2", - "pycryptodome>=3.15.0", + "pycryptodome>=3.4.6", "crytic-compile>=0.2.4", # "crytic-compile@git+https://github.com/crytic/crytic-compile.git@master#egg=crytic-compile", ],