Skip to content
Merged
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
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@
"solc = solc_select.__main__:solc",
]
},
install_requires=[
'pysha3'
]
)
9 changes: 5 additions & 4 deletions solc_select/solc_select.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import argparse
import hashlib
import sha3
import json
from zipfile import ZipFile
import os
Expand Down Expand Up @@ -107,7 +108,7 @@ def verify_checksum(version: str) -> None:
# calculate sha256 and keccak256 checksum of the local file
with open(ARTIFACTS_DIR.joinpath(f"solc-{version}", f"solc-{version}"), "rb") as f:
sha256_factory = hashlib.sha256()
keccak_factory = hashlib.sha3_256()
keccak_factory = sha3.keccak_256()

# 1024000(~1MB chunk)
for chunk in iter(lambda: f.read(1024000), b""):
Expand All @@ -116,14 +117,14 @@ def verify_checksum(version: str) -> None:

local_sha256_file_hash = f"0x{sha256_factory.hexdigest()}"
local_keccak256_file_hash = f"0x{keccak_factory.hexdigest()}"

if sha256_hash != local_sha256_file_hash and keccak256_hash != local_keccak256_file_hash:
if sha256_hash != local_sha256_file_hash or keccak256_hash != local_keccak256_file_hash:
raise argparse.ArgumentTypeError(
f"Error: Checksum mismatch {soliditylang_platform()} - {version}"
)


def get_soliditylang_checksums(version: str):
def get_soliditylang_checksums(version: str) -> (str, str):
(_, list_url) = get_url(version=version)
list_json = urllib.request.urlopen(list_url).read()
builds = json.loads(list_json)["builds"]
Expand Down