Пример #1
0
def suggest_keys(account, custom_password):
    """Suggest a set of new keys for ACCOUNT. This should be called by the
    owner of the account to be recovered.

    """
    acc = Account(account)
    if acc.get_owner_history() == []:
        logger.warning("@%s has an empty owner history - recovering "
                       "this account won't be possible!" % (acc['name']))

    # Ask or generate a new master password
    if custom_password:
        new_password = getpass("Enter new master password for %s: " %
                               (acc['name']))
        repMasterPwd = getpass("Repeat new master password for %s: " %
                               (acc['name']))
        if new_password != repMasterPwd:
            raise ValueError("The passwords do not match!")
    else:
        new_password = "******" + str(PrivateKey(prefix=acc.steem.prefix))

    # Derive the new keys
    owner = PasswordKey(acc['name'],
                        new_password,
                        role='owner',
                        prefix=acc.steem.prefix)
    active = PasswordKey(acc['name'],
                         new_password,
                         role='active',
                         prefix=acc.steem.prefix)
    posting = PasswordKey(acc['name'],
                          new_password,
                          role='posting',
                          prefix=acc.steem.prefix)
    memo = PasswordKey(acc['name'],
                       new_password,
                       role='memo',
                       prefix=acc.steem.prefix)

    # Print results
    print("\n1.) Store the new master password and keys safely!")
    if not custom_password:
        t = PrettyTable([
            'New PRIVATE keys', 'DO NOT PUBLISH OR FORWARD, '
            'STORE SAFELY!'
        ])
        t.add_row(['Account', acc['name']])
        t.add_row(['New private master password', new_password])
        t.add_row(['New private active key', active.get_private()])
        t.add_row(['New private posting key', posting.get_private()])
        t.add_row(['New private memo key', memo.get_private()])
        print(t)

    print("\n2.) Make sure you stored the new password and keys safely!")
    print("\n3.) Forward the new PUBLIC owner key to your recovery account:")
    t = PrettyTable(
        ['New PUBLIC owner key', 'Forward this to your '
         'recovery partner'])
    t.add_row(["Account", acc['name']])
    t.add_row(
        ["New public owner key",
         format(owner.get_public(), acc.steem.prefix)])
    t.add_row(["Recovery partner", acc['recovery_account']])
    print(t)
                      prefix=stm.prefix)
memo = PasswordKey(account['name'],
                   new_password,
                   role='memo',
                   prefix=stm.prefix)

#####################################################################
# Print results
#####################################################################
print("\n1.) Store the new master password and keys safely!")
if not args.custom_password:
    t = PrettyTable(
        ['New PRIVATE keys', 'DO NOT PUBLISH OR FORWARD, '
         'STORE SAFELY!'])
    t.add_row(['Account', account['name']])
    t.add_row(['New private master password', new_password])
    t.add_row(['New private active key', active.get_private()])
    t.add_row(['New private posting key', posting.get_private()])
    t.add_row(['New private memo key', memo.get_private()])
    print(t)

print("\n2.) Make sure you stored the new password and keys safely!")

print("\n3.) Forward the new PUBLIC owner key to your recovery account:")
t = PrettyTable(
    ['New PUBLIC owner key', 'Forward this to your '
     'recovery partner'])
t.add_row(["Account", account['name']])
t.add_row(["New public owner key", format(owner.get_public(), stm.prefix)])
print(t)
Пример #3
0
#!/usr/bin/env python3
from getpass import getpass

from beemgraphenebase.account import PasswordKey
from tabulate import tabulate

hive_id = input("Hive User ID: ")
brain_key = getpass(prompt="Master Password: "******"owner", "active", "posting", "memo"]
data = []
for role in roles:
    keys = PasswordKey(hive_id, brain_key, role=role, prefix="STM")
    priv_key = keys.get_private()
    pub_key = keys.get_public()
    data.append([role, str(pub_key), str(priv_key)])

print(tabulate(data, headers=["Role", "Public Key", "Private Key"]))
Пример #4
0
# script for a tutorial: https://steemit.com/utopian-io/@blockchainstudio/owner-key-vs-master-password-offline-private-key-derivation-from-master-password-public-key-derivation-from-private-key

try:
    from beemgraphenebase.account import PasswordKey
except:
    from steem.steem import Steem
    from steembase.account import PasswordKey
import getpass

roles = ["posting", "active", "memo", "owner"]

print(
    "Warning! This will show your private keys on the screen if you enter your master password correctly."
)
print(
    "To show that key derivations can be done offline, it will not check whether the password is correct."
)

account = input("Enter account name: ")
password = getpass.getpass("Enter master password: "******"%s key" % role)

    pk = PasswordKey(account, password, role=role)

    print("  public:  %s" % pk.get_public())
    print("  private: %s" % pk.get_private())