From c716d612243efe99037b3a4b8d1bd5d85c056a1b Mon Sep 17 00:00:00 2001 From: Giacomo Pope Date: Wed, 21 Aug 2024 15:50:40 +0100 Subject: [PATCH] use ruff linter --- README.md | 1 + benchmarks/benchmark_dilithium.py | 14 ++++++-------- benchmarks/benchmark_ml_dsa.py | 6 +++--- pyproject.toml | 3 +++ src/dilithium_py/dilithium/__init__.py | 2 ++ src/dilithium_py/ml_dsa/__init__.py | 2 ++ tests/test_dilithium.py | 1 - 7 files changed, 17 insertions(+), 12 deletions(-) create mode 100644 pyproject.toml diff --git a/README.md b/README.md index 425c030..7655995 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ [![License MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](https://github.com/GiacomoPope/dilithium-py/blob/main/LICENSE) [![GitHub CI](https://github.com/GiacomoPope/dilithium-py/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/GiacomoPope/dilithium-py/actions/workflows/ci.yml) +[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) # CRYSTALS-Dilithium Python Implementation diff --git a/benchmarks/benchmark_dilithium.py b/benchmarks/benchmark_dilithium.py index 6dcb502..377c65b 100644 --- a/benchmarks/benchmark_dilithium.py +++ b/benchmarks/benchmark_dilithium.py @@ -33,9 +33,9 @@ def profile_dilithium(Dilithium): def benchmark_dilithium(Dilithium, name, count): # Banner - print(f"-" * 27) + print("-" * 27) print(f" {name} | ({count} calls)") - print(f"-" * 27) + print("-" * 27) fails = 0 keygen_times = [] @@ -68,10 +68,8 @@ def benchmark_dilithium(Dilithium, name, count): if __name__ == "__main__": # I used 1000 calls for the README, but you might want to - # shrink this down if you're playing + # shrink this down if you're experimenting count = 1000 - # benchmark_dilithium(Dilithium2, "Dilithium2", count) - # benchmark_dilithium(Dilithium3, "Dilithium3", count) - # benchmark_dilithium(Dilithium5, "Dilithium5", count) - - profile_dilithium(Dilithium2) + benchmark_dilithium(Dilithium2, "Dilithium2", count) + benchmark_dilithium(Dilithium3, "Dilithium3", count) + benchmark_dilithium(Dilithium5, "Dilithium5", count) diff --git a/benchmarks/benchmark_ml_dsa.py b/benchmarks/benchmark_ml_dsa.py index bf8de9f..261e452 100644 --- a/benchmarks/benchmark_ml_dsa.py +++ b/benchmarks/benchmark_ml_dsa.py @@ -33,9 +33,9 @@ def profile_ml_dsa(ML_DSA): def benchmark_ml_dsa(ML_DSA, name, count): # Banner - print(f"-" * 27) + print("-" * 27) print(f" {name} | ({count} calls)") - print(f"-" * 27) + print("-" * 27) fails = 0 keygen_times = [] @@ -68,7 +68,7 @@ def benchmark_ml_dsa(ML_DSA, name, count): if __name__ == "__main__": # I used 1000 calls for the README, but you might want to - # shrink this down if you're playing + # shrink this down if you're experimenting count = 1000 benchmark_ml_dsa(ML_DSA_44, "ML_DSA_44", count) benchmark_ml_dsa(ML_DSA_65, "ML_DSA_65", count) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..f0f104d --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[tool.ruff.lint] +# Avoid enforcing Ambiguous variable name (`E741`) +ignore = ["E741"] diff --git a/src/dilithium_py/dilithium/__init__.py b/src/dilithium_py/dilithium/__init__.py index 9944dcc..940f672 100644 --- a/src/dilithium_py/dilithium/__init__.py +++ b/src/dilithium_py/dilithium/__init__.py @@ -1 +1,3 @@ from .default_parameters import Dilithium2, Dilithium3, Dilithium5 + +__all__ = ["Dilithium2", "Dilithium3", "Dilithium5"] diff --git a/src/dilithium_py/ml_dsa/__init__.py b/src/dilithium_py/ml_dsa/__init__.py index bbe936a..2e883c7 100644 --- a/src/dilithium_py/ml_dsa/__init__.py +++ b/src/dilithium_py/ml_dsa/__init__.py @@ -1 +1,3 @@ from .default_parameters import ML_DSA_44, ML_DSA_65, ML_DSA_87 + +__all__ = ["ML_DSA_44", "ML_DSA_65", "ML_DSA_87"] diff --git a/tests/test_dilithium.py b/tests/test_dilithium.py index e7f0b83..8a76f7a 100644 --- a/tests/test_dilithium.py +++ b/tests/test_dilithium.py @@ -126,7 +126,6 @@ def test_dilithium5(self): class TestKnownTestValuesDilithium(unittest.TestCase): def generic_test_dilithium(self, Dilithium, file_name): - entropy_input = bytes([i for i in range(48)]) drbg = AES256_CTR_DRBG(entropy_input)