make more functions const in c++

This commit is contained in:
jacekpoz 2024-05-10 22:06:49 +02:00
parent 228258221c
commit 3a4b761e2a
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8
2 changed files with 5 additions and 5 deletions

View file

@ -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) {

View file

@ -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");
}