Exemplo n.º 1
0
    print "A                = ", hex(A)  # 1027-bits
    print "B                = ", hex(B)  # 1027-bits
    print "A - B            = ", hex(C)  # 1028-bits

#####################################################

if operation == 3:

    print "Test Vector for Windoed Montgomery Multiplication\n"

    M = helpers.getModulus(1024)
    A = helpers.getRandomInt(1024) % M
    B = helpers.getRandomInt(1024) % M

    C = SW.MontMul(A, B, M)
    # D = HW.MontMul(A, B, M)
    D = HW.MontMul_2bW(A, B, M)

    e = (C - D)

    print "A                = ", hex(A)  # 1024-bits
    print "B                = ", hex(B)  # 1024-bits
    print "M                = ", hex(M)  # 1024-bits
    print "(A*B*R^-1) mod M = ", hex(C)  # 1024-bits
    print "(A*B*R^-1) mod M = ", hex(D)  # 1024-bits
    print "error            = ", hex(e)

#####################################################

if operation == 4: