make all T params final in User in java

This commit is contained in:
jacekpoz 2024-05-10 22:04:46 +02:00
parent 3efd0be63f
commit b73102513e
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8

View file

@ -19,18 +19,18 @@ public class User<T extends IGF, D extends IDHSetup<T>> {
return this.dh.power(dh.getGenerator(), this.secret); return this.dh.power(dh.getGenerator(), this.secret);
} }
public void setKey(T a) { public void setKey(final T a) {
this.key = this.dh.power(a, this.secret); this.key = this.dh.power(a, this.secret);
} }
public T encrypt(T m) throws IllegalArgumentException { public T encrypt(final T m) throws IllegalArgumentException {
if (this.key.isZero()) { if (this.key.isZero()) {
throw new IllegalArgumentException("key must be set before encrypting"); throw new IllegalArgumentException("key must be set before encrypting");
} }
return (T) m.multiply(this.key); return (T) m.multiply(this.key);
} }
public T decrypt(T c) throws IllegalArgumentException { public T decrypt(final T c) throws IllegalArgumentException {
if (this.key.isZero()) { if (this.key.isZero()) {
throw new IllegalArgumentException("key must be set before decrypting"); throw new IllegalArgumentException("key must be set before decrypting");
} }