Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove pysha3 dep. and replace w/ pycryptodome #96

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions optik/common/abi.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"))
Expand Down
4 changes: 2 additions & 2 deletions optik/common/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os

import rlp
import sha3
from Crypto.Hash import keccak


from .exceptions import GenericException
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies = [
"wheel",
"pymaat>=0.6.7",
"eth_abi",
"pysha3",
"pycryptodome>=3.4.6",
"rlp",
"crytic-compile",
"slither-analyzer",
Expand Down