update for beem: improved key generation in beempy and new beempy command for changing keys

in HiveDevs4 years ago

Repository

https://github.com/holgern/beem


beem-logo

beem is a python library for STEEM and HIVE. The current version is 0.23.1.

There is also a discord channel for beem: https://discord.gg/4HM592V

The newest beem version can be installed by:

pip install -U beem

Check that you are using hive nodes. The following command

beempy updatenodes --hive

updates the nodelist and uses only hive nodes. After setting hive as default_chain, beempy updatenodes can be used without switching to steem.

The list of nodes can be checked with

beempy config

and

beempy currentnode

shows the currently connected node.

Changelog for versions 0.23.1

  • setproxy function added to Account (thanks to @flugschwein)
  • addproxy and delproxy added to beempy (thanks to @flugschwein)
  • updatenodes works in shell mode
  • Fix offline mode for Hive
  • add about command to beempy
  • Add hive node
  • update_account function added to blockchaininstance for improved key changing
  • normalize added to PasswordKey, so that a Brainkey can be set as PasswordKey
  • Fixed vote percentage calculation when post rshares is negative
  • new beempy command changekeys
  • beempy keygen can be used to generate account keys from a given password and is able to generate new passwords
  • add option to beempy keygen to export pub account keys as json file
  • add option to beempy newaccount and changekeys to import pub account keys from a json file

beempy keygen

The beempy keygen command can be used to generate new account keys from an imported or a generated password / brainkey.

Create a single private key for a witness

beempy keygen

returns a single private private key which can be used in a witness server

+------------+-------------------------------------------------------+
| Key        | Value                                                 |
+------------+-------------------------------------------------------+
| Public Key | STM6rfJBedPNtCYfBnX2dNNhnusfVn13Cnnerc5WarWnNUoLGGsdh |
+------------+-------------------------------------------------------+

+-------------+--------------------------------------------------------------------------------------------------------------------+
| Key         | Value                                                                                                              |
+-------------+--------------------------------------------------------------------------------------------------------------------+
| Brain Key   | jewely spouter defeat charbon thing finkel force smally termino reduced sorty inkfish leaser odalisk tanha adipoma |
| Private Key | 5Jt9QUH1xc6hr4ADPbwhunu12Ej3JT7gx1Wn3ryZq7q8WKH9m9B                                                                |
+-------------+--------------------------------------------------------------------------------------------------------------------+

Creating/Importing a master password

It is possible to create a new master password (length is 32 chars) with beempy keygen --create-password -a account_name The derived account keys depends on the account name, so it needs to be specified.

When I already have a new Master password, I can import it with
beempy keygen --import-password -a account_name

I will then be asked for the new master password.

Create new account keys similar to PeakD

In peakd.com, I can create a claimed account. When I'm doing this i receive the following dialog, showing four account keys and a Backup (Master) Password

image.png

It is now possible to do the same with beempy:

beempy keygen --create-password -a test02

This command creates a new password with 32 chars and derives the four account keys from it.

When I already have a Master password, i can enter a password with the --import-password flag.

beempy keygen --import-password -a test02

returns the following (I entered the same master password as shown on PeakD)

+--------------------+-------------------------------------------------------+
| Key                | Value                                                 |
+--------------------+-------------------------------------------------------+
| Username           | test02                                                |
| owner Public Key   | STM6xKGVyXVzSdpjFSVhnSFT96JvfCVcHGBk4TgXiKrP65dADB3fR |
| active Public Key  | STM8LzsYrUah85oYUk2GzJwXcmVLyEDdPUNm2Q3syHsRESx5vkiWD |
| posting Public Key | STM7juDTJhT72BqnFvW5CDtsDureimFSdbisxEN3CxojDRFMuciNR |
| memo Public Key    | STM7zYRyLxxmDWxFuHKQuKWB12FgC44pwpUp4LtVAQTWawArU6ccS |
+--------------------+-------------------------------------------------------+
+--------------------------+-----------------------------------------------------+
| Key                      | Value                                               |
+--------------------------+-----------------------------------------------------+
| Username                 | test02                                              |
| owner Private Key        | 5KZyMzN3NpqYFsc1x9uS7VduYsR62TrUekSsUEMgJH4Q7Sk8vBN |
| active Private Key       | 5Js5rMaFDLkwUwjRZ5Ah6Up5HHFDvgDEunwYRUSpj6oPZZJ9P9r |
| posting Private Key      | 5Jyxji5qQbDrwCGpZAe7FFtjhpQV1NAcXDX1QasSTACbzo1Atu3 |
| memo Private Key         | 5KAcBjgQNSzyK3BtCGTtDTYuhhoemPm3KQsuyQFbpBUUt43rmj8 |
| Backup (Master) Password | b9RaASfReChURywfDgj2EKGkar5t1PAB                    |
+--------------------------+-----------------------------------------------------+

As all keys can be derived from the Master password, it is the only key that must be stored. It is a good idea to backup also the other private keys. When I have stored the master key b9RaASfReChURywfDgj2EKGkar5t1PAB , I can derive all four account keys from it with ``beempy keygen`. You can try this and you should see the same private keys as result.

Obscuring the password with WIF generation

It is possible to obscure the entered password with a WIF generation from the key. This can be repeated several times. A big P is added as first letter afterwards, to indicate that this is not a private key but a Master password.

This allows it to choose a easily to remember password combined with a number of WIF generations. Let's assume I would like to change my master password to something that I can easily remember:

beempy keygen --import-password -a holger80 -w 80

returns (I enteredholger as password):

+--------------------+-------------------------------------------------------+
| Key                | Value                                                 |
+--------------------+-------------------------------------------------------+
| Username           | holger80                                              |
| owner Public Key   | STM6cUk6kMz2xBYApmsvn3jK2V4UKtxwYA5v7zJGbozgu5N26k2KD |
| active Public Key  | STM8W5aLo15SJkEDKGtZWFnuZHdNCaRNMosrkuoHfvRq6iqdvb7sA |
| posting Public Key | STM5XsbCxHqsmArtBXChihFWQ4R8NdAAasLo5v8Kn7wLi7Daptycj |
| memo Public Key    | STM5fpZoJUyRQSyg9VB4wkqyAzNBpmZq2n5YvjVgeaRkaU8no6hyY |
+--------------------+-------------------------------------------------------+
+--------------------------+------------------------------------------------------+
| Key                      | Value                                                |
+--------------------------+------------------------------------------------------+
| Username                 | holger80                                             |
| owner Private Key        | 5JovbqiMD2hsud7F9QMLJNxbyYDtuwKU6PtUnyqTRnRT3XSBiHE  |
| active Private Key       | 5KXtJLBt2kLf5AZdNnQKgbLEkNsFcndEW75AUANEERva6mrUDCB  |
| posting Private Key      | 5KdQNdjS9PYXFCB5TutwZYefhBYtuHdHm629ngNPtL4zddDvmuE  |
| memo Private Key         | 5K7Lqg5GQjyZK3TQ4N9sKEq58EXqLLw7YRiwSyxX6wTCsKpGUWZ  |
| Backup (Master) Password | P5JA6yuKBkkSbvW9sENxMfsyJQMdb9EVxLfbCgDyhYKxjnqWbQ7v |
| WIF itersions            | 80                                                   |
| Entered/created Password | holger                                               |
+--------------------------+------------------------------------------------------+

I need to store only the entered password (holger) and the correct number of WIF iterations (80) to be able to restore the Master password and all account keys.

Someone who is trying to guess my keys, needs now to brute force these both parameters. As a WIF iteration takes some time, this is good measure to defeat brute force attacks. Provided that the initial password and iteration number are not easy to guess, as in the example.

Exporting the results to a file

It is possible to export the results into a file without showing it to the terminal.

beempy keygen --create-password -a test02 --export test02_keys.txt

Exporting the public accounts keys to a json file

For creating a new account or changing the keys, only the new public account keys are necessary. It is possible to store all public accounts keys in a json file, which can be imported by beempy newaccount and beempy changekeys

beempy keygen --create-password -a test02 --export test02_keys.txt --export-pub test02_pub.json

This saves the public keys in test02_pub.json which can be imported with beempy newaccount --import-pub test02_pub.json test02 or beempy changekeys --import-pub test02_pub.json test02

Create a 16 word brain key as new Master password

It is also possible to create a 16 word brain key and derive the account keys from it. --account-keysflag returns four account keys instead of one, when a brain key should be used.

beempy keygen --account-keys -a holger80

Obscuring with flag --wif n is also possible.

Updating account keys with a master password or public account keys

It is now possible to change account keys with beempy changekeys. Either a new master password or four new public account keys are needed for changing the keys. It is possible to import the public keys from a json file:

beempy keygen --create-password -a beembot --export-pub beembot_pub.json
beempy changekeys --import-pub beembot_pub.json beembot

This creates a new master password for beembot and exports the newly created public account keys to beembot_pub.json. This file is then loaded by beempy changekeys and broadcasted.

image.png

Worked and I'm able to login with my new keys.

beempy changekeys sets the previously set posting authority and json_metadata field but clears all previously set active authorities and owner authorities. Additionally set key_auths are cleared.

A set authority allows an account to broadcast all operation in this scope, e.g a set posting authority allows the specified account to vote.

Creating a new account

It is also possible to create a new account and importing the needed public keys:

beempy keygen --create-password -a test02 -wif 1 --export test02_keys.txt --export-pub test02_pub.json
beempy newaccount --import-pub test02_pub.json --create-claimed-account -a holger80 test02

beempy addproxy / delproxy

beempy has now two new commands for setting and clearing proxy accounts (thanks to @flugschwein)

beempy setproxy -a beempy holger80

sets holger80 as proxy for beempy

beempy delproxy -a beempy

clears the previously set proxy account


If you like what I do, consider casting a vote for me as witness on Hivesigner or on PeakD.

Sort:  

Glad to see you back with time for blockchain dev, thanks for your contributions!

Thanks, I recharged my batteries and I'm back exclusively on HIVE:).

Great job! Love beempy

Thanks, let me know if you are missing something. Ideas and improvements are also welcome.

Valuable work of course! Support for Beem/Beempy would be worthy of HPS funds, don't you think?

DV for reward disagreement, but you are still awesome!

Please what is Beem? I need enlightenment here.

Beem is a python library to interact with the HIVE blockchain (github).
beempy is a command line based wallet than can be used to broadcast operation to the HIVE blockchain, as vote, comment, transfer and much more
It is automatically installed, when the been library is installed.

Thanks for your explanation.


A huge hug from @amico! 🤗

Thank you so much for doing this!

A very big thumbs up from me to you... This is so wonderful

It will be great development

Congratulations @holger80! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s) :

You got more than 1000 replies. Your next target is to reach 1250 replies.

You can view your badges on your board and compare to others on the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @hivebuzz:

Revolution! Revolution!
HiveBuzz - Hive Gamification Experience
Vote for us as a witness to get one more badge and upvotes from us with more power!

Is this still working?