Exemplo n.º 1
0
def get_privkey(address):
    """ given an address, get decrypted hex private key from DB
    """

    entry = registrar_addresses.find_one({"address": address})

    if entry is None:
        log.debug("Address not found in DB, can't fetch privkey")
        return None

    encrypted_privkey = entry['encrypted_privkey']
    hex_privkey = aes_decrypt(encrypted_privkey, SECRET_KEY)

    return hex_privkey
Exemplo n.º 2
0
def get_privkey(address):
    """ given an address, get decrypted hex private key from DB
    """

    entry = registrar_addresses.find_one({"address": address})

    if entry is None:
        log.debug("Address not found in DB, can't fetch privkey")
        return None

    encrypted_privkey = entry['encrypted_privkey']
    hex_privkey = aes_decrypt(encrypted_privkey, SECRET_KEY)

    return hex_privkey
Exemplo n.º 3
0
def test_registrar_users():
    """ Test if registrar has access to correct private keys
    """

    for entry in registrar_users.find():

        fqu = entry['username'] + ".id"

        data = c.get_name_blockchain_record(fqu)

        if 'error' in data:
            log.debug("Error while processing: (%s, %s)" % (fqu, data))
            continue

        if entry['btc_address'] != data['address']:
            log.debug("registrar doesn't own: %s" % fqu)
            continue

        privkey = aes_decrypt(entry['encrypted_privkey'], SECRET_KEY)

        if get_address_from_privkey(privkey) == entry['btc_address']:
            log.debug("Correct pvtkey: %s" % fqu)
        else:
            log.debug("ERROR: wrong pvtkey: %s")
Exemplo n.º 4
0
def test_registrar_users():
    """ Test if registrar has access to correct private keys
    """

    for entry in registrar_users.find():

        fqu = entry['username'] + ".id"

        data = c.get_name_blockchain_record(fqu)

        if 'error' in data:
            log.debug("Error while processing: (%s, %s)" % (fqu, data))
            continue

        if entry['btc_address'] != data['address']:
            log.debug("registrar doesn't own: %s" % fqu)
            continue

        privkey = aes_decrypt(entry['encrypted_privkey'], SECRET_KEY)

        if get_address_from_privkey(privkey) == entry['btc_address']:
            log.debug("Correct pvtkey: %s" % fqu)
        else:
            log.debug("ERROR: wrong pvtkey: %s")