Skip to content

Commit

Permalink
Merge pull request #417 from BoostryJP/feature/#416
Browse files Browse the repository at this point in the history
feat: Deprecation of direct use of pysha3
  • Loading branch information
YoshihitoAso authored Nov 7, 2022
2 parents 3a90246 + 01a1751 commit d3f1a02
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
9 changes: 4 additions & 5 deletions app/routers/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@
from pytz import timezone
from sqlalchemy.orm import Session
from sqlalchemy.exc import IntegrityError as SAIntegrityError
from sha3 import keccak_256
from coincurve import PublicKey
from Crypto.PublicKey import RSA
from eth_utils import to_checksum_address
from eth_utils import to_checksum_address, keccak
import eth_keyfile
import boto3

Expand Down Expand Up @@ -106,11 +105,11 @@ def create_key(
if AWS_KMS_GENERATE_RANDOM_ENABLED:
kms = boto3.client(service_name="kms", region_name=AWS_REGION_NAME)
result = kms.generate_random(NumberOfBytes=32)
private_key = keccak_256(result.get("Plaintext")).digest()
private_key = keccak(result.get("Plaintext"))
else:
private_key = keccak_256(secrets.token_bytes(32)).digest()
private_key = keccak(secrets.token_bytes(32))
public_key = PublicKey.from_valid_secret(private_key).format(compressed=False)[1:]
addr = to_checksum_address(keccak_256(public_key).digest()[-20:])
addr = to_checksum_address(keccak(public_key)[-20:])
keyfile_json = eth_keyfile.create_keyfile_json(
private_key=private_key,
password=eoa_password.encode("utf-8"),
Expand Down
9 changes: 4 additions & 5 deletions app/routers/e2e_messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@
aliased
)
from sqlalchemy.sql import func
from sha3 import keccak_256
from coincurve import PublicKey
from Crypto import Random
from Crypto.PublicKey import RSA
from eth_utils import to_checksum_address
from eth_utils import to_checksum_address, keccak
import eth_keyfile
import boto3

Expand Down Expand Up @@ -121,11 +120,11 @@ def create_account(
if AWS_KMS_GENERATE_RANDOM_ENABLED:
kms = boto3.client(service_name="kms", region_name=AWS_REGION_NAME)
result = kms.generate_random(NumberOfBytes=32)
private_key = keccak_256(result.get("Plaintext")).digest()
private_key = keccak(result.get("Plaintext"))
else:
private_key = keccak_256(secrets.token_bytes(32)).digest()
private_key = keccak(secrets.token_bytes(32))
public_key = PublicKey.from_valid_secret(private_key).format(compressed=False)[1:]
addr = to_checksum_address(keccak_256(public_key).digest()[-20:])
addr = to_checksum_address(keccak(public_key)[-20:])
keyfile_json = eth_keyfile.create_keyfile_json(
private_key=private_key,
password=eoa_password.encode("utf-8"),
Expand Down
3 changes: 1 addition & 2 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ pycryptodome==3.15.0
pydantic==1.8.2
PyMySQL==1.0.2
pyrsistent==0.19.2
pysha3==1.0.2
python-dateutil==2.8.2
python-editor==1.0.4
pytz==2021.1
Expand All @@ -58,7 +57,7 @@ s3transfer==0.3.7
shared-memory-dict==0.5.0
six==1.16.0
sniffio==1.3.0
SQLAlchemy==1.4.42
SQLAlchemy==1.4.43
starlette==0.20.4
toolz==0.12.0
typing_extensions==4.4.0
Expand Down
20 changes: 10 additions & 10 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
SQLAlchemy>=1.4,<1.5
psycopg2-binary==2.9.3
web3==5.31.1
alembic==1.5.6
boto3==1.17.12
coincurve==17.0.0
eth-keyfile==0.5.1
eth-utils==1.10.0
pysha3==1.0.2
coincurve==17.0.0
pydantic==1.8.2
fastapi==0.85.0
uvicorn==0.18.3
gunicorn==20.1.0
boto3==1.17.12
alembic==1.5.6
psycopg2-binary==2.9.3
pycryptodome==3.15.0
pydantic==1.8.2
PyMySQL==1.0.2
pytz==2021.1
requests==2.25.1
shared-memory-dict==0.5.0
requests==2.25.1
SQLAlchemy>=1.4,<1.5
uvicorn==0.18.3
web3==5.31.1

0 comments on commit d3f1a02

Please sign in to comment.