From 1b6be035726d9d56add05f3ee19cda272c2f7f73 Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Fri, 10 May 2024 22:08:48 +0200 Subject: [PATCH] make more function params const & --- lab3/zad1/include/DHSetup.hpp | 2 +- lab3/zad1/include/User.hpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lab3/zad1/include/DHSetup.hpp b/lab3/zad1/include/DHSetup.hpp index 217e06d..cb3302e 100644 --- a/lab3/zad1/include/DHSetup.hpp +++ b/lab3/zad1/include/DHSetup.hpp @@ -29,7 +29,7 @@ class DHSetup { return primes; } - bool checkGenerator(T a) { + bool checkGenerator(const T &a) { uint64_t p = a.characteristic() - 1; for (uint64_t q : sieve_of_eratosthenes(std::sqrt(p))) { if (p % q == 0 && a * (p / q) == 1) { diff --git a/lab3/zad1/include/User.hpp b/lab3/zad1/include/User.hpp index 9cf3957..b85f504 100644 --- a/lab3/zad1/include/User.hpp +++ b/lab3/zad1/include/User.hpp @@ -27,18 +27,18 @@ public: return this->dh.power(dh.getGenerator(), this->secret); } - void setKey(T a) { + void setKey(const T &a) { this->key = this->dh.power(a, this->secret); } - T encrypt(T m) const { + T encrypt(const T &m) const { if (this->key == T(0)) { throw std::logic_error("key must be set before encrypting"); } return m * this->key; } - T decrypt(T c) const { + T decrypt(const T &c) const { if (this->key == T(0)) { throw std::logic_error("key must be set before decrypting"); }