initialize all res in power to 1

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

View file

@ -59,7 +59,7 @@ public:
}
T power(T a, uint64_t b) {
T res = a;
T res = 1;
while (b > 0) {
if (b % 2 == 1) {
res *= a;

View file

@ -74,7 +74,7 @@ public class DHSetup<T extends IGF> implements IDHSetup<T> {
@Override
public T power(final T a, long b) {
T aCopy = this.constructor.apply(new GF.Params(a.getCharacteristic(), a.getValue()));
T res = this.constructor.apply(new GF.Params(a.getCharacteristic(), a.getValue()));
T res = this.constructor.apply(new GF.Params(a.getCharacteristic(), 1));
while (b > 0) {
if (b % 2 == 1) {
res.multiplyAssign(aCopy);