Skip to content

Commit

Permalink
update: black
Browse files Browse the repository at this point in the history
  • Loading branch information
olivmath committed Jan 18, 2024
1 parent ab55430 commit 7832820
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "keccaky"
version = "0.2.4"
version = "0.2.5"
description = "Secure and easy-to-use keccak"
authors = ["Lucas Oliveira <[email protected]>"]
repository = "https://github.com/olivmath/keccaky.git"
Expand Down
3 changes: 3 additions & 0 deletions tests/benchmark/test_compare_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def keccaky_hash():
result = k.digest(result)
return result.hex()


def pycryptodome_hash():
keccak_256 = cryptodome_keccak.new(digest_bits=256)
keccak_256.update("keccaky".encode())
Expand All @@ -22,11 +23,13 @@ def pycryptodome_hash():
result = keccak_256.digest()
return result.hex()


@pytest.mark.benchmark(group="KeccakyHash")
def test_keccaky_hash_speed(benchmark):
result = benchmark(keccaky_hash)
assert result == "8e9efbfab4a6693f61778ca0cc7401af1685912f7ffb4dc946eae43b4384dc14"


@pytest.mark.benchmark(group="PyCryptodomeHash")
def test_pycryptodome_hash_speed(benchmark):
result = benchmark(pycryptodome_hash)
Expand Down
3 changes: 3 additions & 0 deletions tests/benchmark/test_keccaky_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
import pytest
import time


@pytest.mark.benchmark(group="HashCreation", timer=time.time)
def test_create_10_hash(benchmark):
k = Keccaky()
benchmark(lambda: [k.digest(str(i).encode()).hex() for i in range(10)])


@pytest.mark.benchmark(group="HashCreation", timer=time.time)
def test_create_100_hash(benchmark):
k = Keccaky()
benchmark(lambda: [k.digest(str(i).encode()).hex() for i in range(100)])


@pytest.mark.benchmark(group="HashCreation", timer=time.time)
def test_create_1000_hash(benchmark):
k = Keccaky()
Expand Down
5 changes: 2 additions & 3 deletions tests/keccaky/test_check_state_file_KAT_256.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from tqdm import tqdm
import os


@mark.slow
def test_check_state_file_KAT_256():
state_file = "./tests/keccaky/test_state.txt"
Expand All @@ -14,9 +15,7 @@ def test_check_state_file_KAT_256():
lines = f.readlines()

if not lines or len(lines) < 2:
raise ValueError(
"The state file does not have enough lines for verification."
)
raise ValueError("The state file does not have enough lines for verification.")

initial_message = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmno"
hash_obj = keccak.new(data=initial_message.encode(), digest_bits=256)
Expand Down
1 change: 0 additions & 1 deletion tests/keccaky/test_extremely_long_loop_msg_KAT_256.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def run_test(k, start_loop, initial_result, state_file):
assert result.hex() == expected



@mark.slow
def test_extremely_long_loop_msg_KAT_256():
k = Keccaky()
Expand Down

0 comments on commit 7832820

Please sign in to comment.