我需要一种计算的方法:
(g^u * y^v) mod p
在Java中。
我找到了一种计算(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; // squaring the base
b /= 2;
}
return (int) x%c;
}
它工作得很好,但我似乎找不到一种方法来做到这一点。
(g^u * y^v) mod p
由于我的数学技能不是很好,因此需要翻译。
为了让您更好地理解,这是一个“简化”的DSA的Java实现 - 验证部分需要解决这个问题。
BigInteger
而不是长整型。 - Roland Illig