BigInteger如何计算(ae + r)mod q?

时间:2012-06-08 07:57:05

标签: java biginteger

我正在实施Schnorr识别协议。 我有一本书“应用密码学手册”的例子10.37。 一切都没有效果。

(p = 48731, q = 433, B = 11444) - public params.
v = 7355 - public Key.
a = 357 - privateKey.
t = 8 - identification certanity,

协议行动

A choses r = 274 and sends to B x = B^r mod p = 37123.
B sends to A e ( 1 <=e <= 2^t), e = 129.
A sends to B y = (ae + r) mod q. - this doesn't work. should be 255.
B comutes z = ((B^y)(V^e)) mod p. if z == x then identity is ok.

所以,我有(ae + r)mod q的问题,应该255和我有429。 代码:

BigInteger ae = a.multiply(e);
ae = ae.mod(q);
y = ae.add(r);      
y = y.mod(q);

结果y = 429 如果我要计算

BigInteger ae = a.multiply(e); 
y = ae.add(r);      
y = y.mod(q);

结果是一样的。

请帮帮我。 感谢。

1 个答案:

答案 0 :(得分:0)

q=433不正确,它应该是p-1的除数。正确的值是443.