diff --git a/lab3/zad1/include/DHSetup.hpp b/lab3/zad1/include/DHSetup.hpp index d31f437..217e06d 100644 --- a/lab3/zad1/include/DHSetup.hpp +++ b/lab3/zad1/include/DHSetup.hpp @@ -54,11 +54,11 @@ public: this->generator = T(num); } - T getGenerator() { + T getGenerator() const { return generator; } - T power(T a, uint64_t b) { + T power(T a, uint64_t b) const { T res = 1; while (b > 0) { if (b % 2 == 1) { diff --git a/lab3/zad1/include/User.hpp b/lab3/zad1/include/User.hpp index 88f4d3b..9cf3957 100644 --- a/lab3/zad1/include/User.hpp +++ b/lab3/zad1/include/User.hpp @@ -23,7 +23,7 @@ public: this->dh = dh; } - T getPublicKey() { + T getPublicKey() const { return this->dh.power(dh.getGenerator(), this->secret); } @@ -31,14 +31,14 @@ public: this->key = this->dh.power(a, this->secret); } - T encrypt(T m) { + T encrypt(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) { + T decrypt(T c) const { if (this->key == T(0)) { throw std::logic_error("key must be set before decrypting"); }