Repository
https://github.com/holgern/beem
beem is a python library and command line tool for HIVE. The current version is 0.23.13.
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
beempy config
and
beempy currentnode
shows the currently connected node.
Changelog for versions 0.23.13
- receiver parameter removed from
beempy decrypt
- beempy encrypt / decrypt is able to encryp/derypt a binary file
- encrypt_binary, decrypt_binary and extract_decrypt_memo_data added to beem.memo
- extract_memo_data added to beembase.memo
Encrypting / decrypting a binary file with your memo key
It is now possible to encrypt a binary file with your memo key such that only one receiver is able to decrypt the file.
An encrypted memo contains:
- the public memo key of the sender
- the public memo key of the receiver
- the used nonce
- the checksum
- the encrypted message
As a file could be very huge, it is not the best way to encrypt the complete file at once. Thus I modified the structure as follows:
An encrypted binary file contains:
- The length of an encrypted memo containing the beem version
- the public memo key of the sender
- the public memo key of the receiver
- the used nonce
- the checksum of the part which stores the beem version
- the encrypted beem version
- The file size of the original file
- The encrypted bytes of the file, using the same AES algorithm from the memo before
When decoding, the stored memo in the beginning of the file can be used to decrypt the used beem version and for receiving all necessary information for setting up the AES decryption. The remaining bytes are then decrypted by using the same AES.
By storing a short encrypted memo in the standard form followed by the encrypted file, it is possible to initialize the AES and process the binary file piece by piece using a small buffer. I set the buffer size to 2048 bytes for encryption and decryption.
How to encrypt a file
Let's try to encrypt a binary file.
beempy encrypt --binary -a holger80 beembot .\Vessel.Setup.0.4.3.exe
This creates a new file Vessel.Setup.0.4.3.exe.enc which can only be decrypted by the memo keys of holger80 and beembot. It is also possible to set a different output name by using --output my_file.enc
How to decrypt a file
beempy decrypt --binary --info .\Vessel.Setup.0.4.3.exe.enc
returns
+--------------+-------------------------------------------------------+
| Key | Value |
+--------------+-------------------------------------------------------+
| file | .\Vessel.Setup.0.4.3.exe.enc |
| file_size | 40024891 |
| from_key | STM6MQBLaX9Q15CK3prXoWK4C6EqtsL7C4rqq1h6BQjxvfk9tuT3N |
| to_key | STM4vBYJCx74s5KYR3Aj35SemcvCdxyzQgbCno18nqYGaV9nDB1SV |
| nonce | 13521579752536098441 |
| beem_version | #beem/0.23.13 |
+--------------+-------------------------------------------------------+
and creates a new file Vessel.Setup.0.4.3.exe.enc.dec
.
The --info
flag can be used to show more information about the used memo keys, the used nonce and the used beem version.
It is not necessary anymore to enter the receiver account name to beempy decrypt
as the receiver is stored in the encrypted memo.
The file had a size of 43 Mb and processing was finished within a second.
Encrypting / decrypting binary files in python
I provided also a new python function for encrypting / decrypting a binary file. They can be found in
beem.memo.Memo
at encrypt_binary
and decrypt_binary
.
Possible use cases
This could be used to provide files that should only be used by the person which is in possession of the correct memo key.
If you like what I do, consider casting a vote for me as witness on Hivesigner or on PeakD