Beispiel #1
0
def areValidParams(L, N, p, q, g):
    return ((q.bit_length() == N) and
            challenge39.isProbablePrime(q, 5) and
            (p.bit_length() == L) and
            challenge39.isProbablePrime(p, 5) and
            ((p-1) % q == 0) and
            pow(g, q, p) == 1)
Beispiel #2
0
def genP(L, q):
    minK = (2**(L - 1) + q - 1) // q
    maxK = (2**L - 1) // q
    while True:
        k = random.randint(minK, maxK)
        p = k * q + 1
        if challenge39.isProbablePrime(p, 5):
            return (k, p)
Beispiel #3
0
def genP(L, q):
    minK = (2**(L-1) + q-1)//q
    maxK = (2**L - 1)//q
    while True:
        k = random.randint(minK, maxK)
        p = k*q + 1
        if challenge39.isProbablePrime(p, 5):
            return (k, p)
Beispiel #4
0
def areValidParams(L, N, p, q, g):
    return ((q.bit_length() == N) and challenge39.isProbablePrime(q, 5)
            and (p.bit_length() == L) and challenge39.isProbablePrime(p, 5)
            and ((p - 1) % q == 0) and pow(g, q, p) == 1)