From f105c1d573991e4347daac8a315c844cefd6637b Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Sun, 2 Jun 2024 01:40:30 +0000 Subject: [PATCH] style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf This commit fixes the style issues introduced in 748d451 according to the output from Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf. Details: None --- core/algorithms/quantum_resistant_crypto.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/algorithms/quantum_resistant_crypto.py b/core/algorithms/quantum_resistant_crypto.py index ee80722..f0aac76 100644 --- a/core/algorithms/quantum_resistant_crypto.py +++ b/core/algorithms/quantum_resistant_crypto.py @@ -3,6 +3,7 @@ import numpy as np from scipy.linalg import qr + class NTRUCryptosystem: def __init__(self, n, q, p, d): """ @@ -28,7 +29,7 @@ def keygen(self): f = self.poly_ring.random_element() g = self.poly_ring.random_element() F = f * g % self.q - h = F * g^-1 % self.q + h = F * g ^ -1 % self.q public_key = h private_key = (f, g) return public_key, private_key @@ -55,10 +56,11 @@ def decrypt(self, ciphertext, private_key): :return: Decrypted message """ f, g = private_key - a = ciphertext * f^-1 % self.q + a = ciphertext * f ^ -1 % self.q b = a * g % self.q return b + class PolynomialRing: def __init__(self, n, d): """ @@ -121,6 +123,7 @@ def __truediv__(self, a, b): q, r = qr(a.c, b.c) return np.poly1d(q) + def main(): n = 512 q = 2048 @@ -140,5 +143,6 @@ def main(): print("Ciphertext:", ciphertext) print("Decrypted Message:", decrypted_message) + if __name__ == "__main__": main()