Search code examples
pythonmathcryptographydsa

DSA verification calculation


Am I missing something? from FIPS180-2, on page 25, it gives the values of u1, u2, g^u1 mod p, y^u2 mod p and v. i have calculated all the values except v. yet, when i do the math, my calculations refuse to be v = 0x8bac1ab66410435cb7181f95b16ab97c92b341c0. instead, i get v = 0xc5a54698ae8e5b94661134260594ff4e3f488e26, which is not equal to r, from before. im doing (pow(g, u1, p) * pow(y, u2, p)) % q to do the calculation, where pow is the builtin function, not the math module function


Solution

  • You're skipping one mod p calculation. You should compute:

    (((pow(g, u1, p) * pow(y, u2, p))) % p ) % q