Ejemplo n.º 1
0
def _single_generate(index, **kwargs):
    sk_hex = secret_key()
    sk = unhexlify(sk_hex.encode())
    if kwargs['encrypt_key']:
        sk = AESCipher.encrypt(key=kwargs['encrypt_key'], raw=sk)
    pk_hex = public_key(sk_hex)
    pk = unhexlify(pk_hex.encode())
    ck = get_address(pk=pk_hex, prefix=kwargs['prefix'])
    t = int(time.time() - kwargs['genesis_time'])
    return sk, pk, ck, C.ANT_RESERVED, t
Ejemplo n.º 2
0
def _process(que, number, request, main_net, prefix):
    count = 0
    while True:
        count += 1
        sk = secret_key()
        pk = public_key(sk)
        ck = get_address(pk, main_net, prefix)
        if request in ck:
            que.put((True, sk, pk, ck))
            exit(1)
        elif count % 100 == 0:
            que.put((False, number, count))
            count = 0
Ejemplo n.º 3
0
def is_locked_database(cur):
    d = cur.execute("SELECT `sk`,`pk` FROM `pool` LIMIT 1").fetchone()
    if d is None:
        return False  # Unlocked
    sk, pk = d
    try:
        sk = AESCipher.decrypt(V.ENCRYPT_KEY, sk) if V.ENCRYPT_KEY else sk
        sk = hexlify(sk).decode()
    except ValueError:
        return True
    if len(sk) != 64:
        return True
    elif public_key(sk) == hexlify(pk).decode():
        return False  # Unlocked
    else:
        return True
Ejemplo n.º 4
0
import time

b32alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'
request = 'NAMU'
main_net = True
prefix = None

for i in list(request):
    if i not in b32alphabet:
        raise ValueError('\"%s\" is not include base32 strings.' % i)

count = 0
start = time.time()
print("Prefix={}, mainnet={}, Find \"{}\"".format(prefix, main_net, request))
while True:
    count += 1
    sk = secret_key()
    pk = public_key(sk)
    ck = get_address(pk, main_net, prefix)
    if request in ck:
        print("Secret", sk)
        print("Public", pk)
        print("Compressed", ck)
        print("finished")
        exit(0)
    elif count % 100 == 0:
        print("{}processed, {}mS/cycle".format(count, (time.time() - start) *
                                               1000 // count))
    else:
        continue
Ejemplo n.º 5
0
import time

from nem_ed25519.key import secret_key, public_key, get_address, is_address

start = time.time()
result = list()
COUNT = 10
for i in range(COUNT):
    sk = secret_key()
    pk = public_key(sk)
    ck = get_address(pk)
    if not is_address(ck):
        raise Exception('not correct key')
    result.append((sk, pk, ck))
print((time.time() - start) * 1000 // COUNT, "mS/create_pair")

print("\ntry check")
sk = '78f8932df54d22319a16dc4940c269205ae0946f98d38ef30aea488a47426153'
pk = '77041bfb4b6afebc31aaab7b02d68e577fe069524b3c661c804b42ef381f717b'
ck = 'NBOGOGSENUPBFMAPTGHVI4UIAQPVSNKJLWUVHBED'
assert pk == public_key(sk), 'Not correct sk'
assert ck == get_address(pk), 'Not correct pk'
print("all ok.")