pycryptodome icon indicating copy to clipboard operation
pycryptodome copied to clipboard

The existence of the factor was not verified in function inverse

Open ljahum opened this issue 4 years ago • 0 comments

The existence of the factor was not verified in function inverse() sometime get 1 as the return value maybe ..... we can compute gcd alg first ?

def inverse(u, v):
    """The inverse of :data:`u` *mod* :data:`v`."""

    u3, v3 = u, v
    u1, v1 = 1, 0
    while v3 > 0:
        q = u3 // v3
        u1, v1 = v1, u1 - v1*q
        u3, v3 = v3, u3 - v3*q
    while u1<0:
        u1 = u1 + v
    return u1

ljahum avatar Jun 09 '21 06:06 ljahum