简体   繁体   English

DSA签名验证和BigInteger类

[英]DSA Signature Verification and BigInteger class

I have been given a (very) simple DSA problem, and have already found the key and other variables. 给我一个(非常简单的)DSA问题,并且已经找到了关键和其他变量。 To verify the signature I need to somehow translate the equation: 为了验证签名,我需要以某种方式转换方程式:

V = [( y^u1*h^u2 )mod p] mod q V = [( y ^ u1 * h ^ u2 )mod p] mod q

into a BigInteger operation. 进入BigInteger操作。 Is this even possible on java? 在Java上甚至有可能吗? I have been using modPow successfully so far however all problems so far have been in the form: 到目前为止,我一直在成功使用modPow,但是到目前为止,所有问题都以以下形式出现:

r.modPow(exponent, modulus); r.modPow(指数,模数);

I have no idea how to do the above equation (in particular the bold part) via BigInteger and I'm wondering if it's even possible. 我不知道如何通过BigInteger做上述方程式(尤其是粗体部分),我想知道是否有可能。 Does anyone have any ideas? 有人有什么想法吗?

How would I go about putting this equation through Pari if BigInteger can't do it? 如果BigInteger无法做到,我该如何通过Pari来解决这个问题?

I think you just need to use the identity that 我认为您只需要使用以下身份即可

(a*b) mod p == ((a mod p)*(b mod p)) mod p

So to calculate y u1 × h u2 mod p: 因此要计算y u1 ×h u2 mod p:

  1. calculate y u1 mod p, using modPow , 使用modPow计算y u1 mod p,
  2. calculate h u2 mod p, using modPow , 使用modPow计算h u2 mod p,
  3. multiply together the results of steps 1 and 2, 将步骤1和2的结果相乘
  4. reduce the result of step 3 mod p. 减少步骤3 mod p的结果。

Step 4 is necessary because the results of steps 1 and 2 may multiply together to produce a value greater than p. 步骤4是必需的,因为步骤1和2的结果可能会相乘以产生大于p的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM