beem is a python library and command line tool for HIVE. The current version is 0.23.12.
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.
The list of nodes can be checked with
shows the currently connected node.
Changelog for versions 0.23.12
- add participation_rate to Blockchain
- beembase.transactions is deprecated
- get_block_params added to TransactionBuilder
- add Prefix class for PasswordKey, Brainkey, Address, PublicKey, PrivateKey, Base58
- New Class BitcoinAddress
- Address class has now from_pubkey class method
- Message class improved
- beempy message can be used to sign and to verify a message
- decryption of long messages fixed
- varint decoding added to memo decryption
- beempy encrypt / decrypt can be used to encrypt/decrypt a memo text with your memo key
Sign and verify a message
I can now sign a message with my private memo key and everyone can verify the signature.
Assuming I would like to sign the following message with my memo key:
This is a text message from holger80!
I can do this by storing the message into a text file and run
beempy message -a holger80 my_message.txt
The message is read and signed and the following result is stored in the text file:
-----BEGIN HIVE SIGNED MESSAGE----- This is a text message from holger80! -----BEGIN META----- account=holger80 memokey=STM6MQBLaX9Q15CK3prXoWK4C6EqtsL7C4rqq1h6BQjxvfk9tuT3N block=44092995 timestamp=2020-06-07T20:26:54 -----BEGIN SIGNATURE----- 203020dbdde48c910ccf565413c6b44eeb7d8908c70169ce27be99d8907cf35e661e5e08abd77309b6bab4dceb9a3c6f48c0bc3ba27445b957a47b3019ec810cc1 -----END HIVE SIGNED MESSAGE-----
Any receiver of my signed message can now verify that the message was not modified and that it's signed with the memo key from my account.
beempy message --verify my_message.txt
Could verify message!
I merged new changes of python-graphenelib to
beemgraphenebase.account which handle public and private keys as well as address generation. Prefix (
STM for hive) handling is now improved.
Did you know that each hive account has also 4 bitcoin addresses that are able to receive bitcoin? You could use the corresponding private key to move then received bitcoin. Let's check if there any bitcoin on the bitcoin address corresponding to my active key.
from beem.account import Account from beemgraphenebase.account import BitcoinPublicKey account = Account("holger80") pub_key = account["active"]["key_auths"] btc_address = BitcoinPublicKey(pub_key).address print(str(btc_address))
Nothing there yet. It would be also possible to convert the private key into a segwit or bech32 address (but not with beem, as do not think this is very useful).
Bitcoin address generation is used in beem for encrypting wifs for storing them in the beempy wallet according to BIP38. The bitcoin address is used in
decrypt which is then used in
Encrypting / Decrypting memos
I finally fixed memo encryption / decryption in beem and added a new beempy command for easier memo encrytion/decryption. It is now possible to encrypt/decrypt long messages.
I estimated the length of the varint part of the encrypted message by
numBytes = 16 - len(cipher) % 16 n = 16 - numBytes message = cipher[n:]
n was fixed to 2 (assuming that the varint has a length of 2), which did not work for long messages, as the varint has then 4 bytes or even more.
I fixed the memo decryption (prevously the first chars of a decrypted memo were wrong) by doing a varintdecode on the decrypted memo:
n = varintdecode(message) return '#' + message[len(message) - n:].decode("utf8")
which allows me to remove the varint (stores the message length) part at the beginning of the decrypted message correctly.
I can now decrypt the following long message beempy:
The encrypted memo should be put into quotes:
beempy decrypt -a holger80 hive.revolution "#2BVUtjeRYh3en8QLHgLDRojcRWMZEiKLaqPkxD9gubLcfFyH3c3JmwgGGScoEAWVTDAgsVpvC4HtsEbmsKkQuMksK8UhXu5eG2sYk1rJg3ry42bn31D5bopjmk1nAXhxenTUbsBPmeW2AQtj4CJg3DtPeUc9JCUPKd5sEbYpN2oJks3fDqcVSx8xAtw3Hk51zkxxnwECKsQ1moricvjA4rTmexCxx2RLQ89NdzQxvzQdVooJcFKRWqF3RiMdihif7bExuKffTAeqonYfN6FynA1T4hjL3y1BpYAYdPYBigdxSzNuS6EcmqRXF7vGeVeGMqZjrDZ73odakLziAW15xqTQGQYbFdo1Y72Gpt49jdk5WqQSSecNAvagCN7qYXwLUteHg84nA7mQp2mLSy2uBsftK9Q53vHbDZbu9Ldo8arF4ijBj3YDkjj5TNQq6EB4adp5JTY4tCV6AWRgBEPVHDCvTXCMQBM85L9DK9fctCou8yr61daCyxUVnfiPA9SMvTJdk4sFz6AYF7t5ZJeuLzEVE1XNYDVDfSqXoLTdkHfJv8rHiqEPny4ZqWjQNrhgqaZUvxEE7Zqvkb5UXwgWnAmR6KEP5p1U3An1USjndThtYTsRWRenWvBHZj617eunGAghr5ikFxn2fn9gqBMmyLEC1tiX3KfyYPvwtoxvU7AQqkdQhgeAdGaNezx"
Returns now the correct beginning and is able to decrypt the memo (in previous beem versions, the decryption of this memo did not work at all):
#Hello comrade, ...
It is also possible to encrypt a message:
beempy encrypt -a holger80 beempy "#test1"
or more than one message:
beempy encrypt -a holger80 beempy "#test1" "#test2"
I can also encrypt a memo that is only decryptable by myself:
beempy encrypt -a holger80 holger80 "#test1" "#test2"
When using the
--text flag, the memo text is read from the provided text file and overwritten by the encrypted/decrypted text.
beempy encrypt -a holger80 --text beempy my-memo-text.txt