update for beem: encrypt / decrypt files with your memo key

in HiveDevs5 years ago

Repository

https://github.com/holgern/beem


beem-logo

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

Sort:  

Something I was asking for years on this blockchain... really nice... once my life allows it, I am going to give this a try.

I have searched for this of information almost all my life, am so happy you could cease the time to give us such useful information thank you so much thanks @hivedevs

I applaud your commitment and work with the Hive community. And even better for the use of python, the programming language of my interest. Greetings

Too good tool

Looking good!

Keep up the good work @holger80

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

Your post got the highest payout of the day

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

Support the HiveBuzz project. Vote for our proposal!

I have picked your post for my daily hive voting initiative, Keep it up and Hive On!!

hello guys can you guide me how to earn please...
Uploading 13.jpg #71

hey @joliajolie

First thing first, focus on writing great/ good content. money will comes easy.

write a content that you think people like and that you can relate to yourself. A good content is at least 300 words of more. With pictures taken by you gives drama to your content.

if you like to create videos, you can go to @3speak you can upload your video there.

If you like fitness - you can go to @actifit and create a post there with your daily fitness. There is an app that you can download called actifit.

Join the community.. introduce yourself.
Always think to give something beneficial to the community. People will like and follow you as you along the way..

Good luck and welcome..

@joliajolie

Commenting on unrelated posts would only get your comment downvoted, and your reputation lower. I have looked at your Hive profile and another account @robertchain that appears to be owned by you, and I saw only pictures that have a lot of unrelated tags but have no captions. This strategy of yours would only prevent you from earning any money from Hive at all. If you still want to continue trying to earn from Hive, at least try to study the posting habits of people posting on #introduceyourself.