コード例 #1
0
ファイル: bsgs_v5_gmp.py プロジェクト: iceland2k14/bsgs
def bsgs_keys(pubkey_point, k1, k2):
    found = False
    S = ec.Point_Addition(pubkey_point, -k1G)
    if S == Zp:
        print('BSGS FOUND PrivateKey ', hex(k1))
        found = True
        return found

    found = False
    step = 0

    while found is False and step < (1 + k2 - k1):
        hex_line = hex(S.x)[2:].zfill(64)
        if check_in_bloom(hashit(hex_line, bloom_hashes, bloom_bits),
                          bloom_bits, bloom_filter) == True:
            bsgs_exact_key(pubkey_point, k1 + step, k1 + step + m)

            #            print('A False collision ignored between ',hex(k1+step), ' and ', hex(k1+step+m))
            S = ec.Point_Addition(S, -mG)
            step = step + m


# =============================================================================

        else:  # Giant step
            S = ec.Point_Addition(S, -mG)
            step = step + m

    return found
コード例 #2
0
def create_table(start_value, end_value):
    # create a table:  f(x) => G * x
    P = ec.Scalar_Multiplication(start_value, G)
    baby_steps = []
    for x in range(start_value, end_value):
        baby_steps.append(P.x)
        P = ec.Point_Addition(P, G)
    baby_steps.append(P.x)  # last element
    return baby_steps
コード例 #3
0
def create_table(this_list):
    start_value, end_value, m = this_list
    print('[+] Working on Chunk {} ...'.format(m))
    # create a table:  f(x) => G * x
    P = ec.Scalar_Multiplication(start_value, G)
    baby_steps = []
    for x in range(start_value, end_value):
        baby_steps.append(P.x)
        P = ec.Point_Addition(P, G)
    baby_steps.append(P.x)  # last element
    return baby_steps
コード例 #4
0
def bsgs_keys(pubkey_point, k1, k2):
    found = False
    S = ec.Point_Addition(pubkey_point, -k1G)
    if S == Zp:
        print('PVK found ', hex(k1))
        found = True
        return found

    found = False
    step = 0

    while found is False and step < (1 + k2 - k1):
        hex_line = hex(S.x)[2:].zfill(64)
        if hex_line in baby_steps:
            idx = baby_bin.find(bytes.fromhex(hex_line), 0)
            print('PVK found ', hex(k1 + step + int(idx / 32) + 1))
            found = True
            break

        else:  # Giant step
            S = ec.Point_Addition(S, -mG)
            step = step + m

    return found