I need a way to calculate:
(g^u * y^v) mod p
in java.
I found this algorithm to compute (g ^ u) mod p:
int modulo(int a,int b,int c) {
long x=1
long y=a;
while(b > 0){
if(b%2 == 1){
x=(x*y)%c;
}
y = (y*y)%c;
b /= 2;
}
return (int) x%c;
}
and it works fine, but I cannot find a way to do this for
(g^u * y^v) mod p
since my math skills are dull.
To put it in context, this is for the Java implementation of the โabbreviatedโ DSA โ the validation part requires that it be allowed.
source
share