beem.memo module

class beem.memo.Memo(from_account=None, to_account=None, steem_instance=None)

Bases: object

Deals with Memos that are attached to a transfer


A memo is encrypted with a shared secret derived from a private key of the sender and a public key of the receiver. Due to the underlying mathematics, the same shared secret can be derived by the private key of the receiver and the public key of the sender. The encrypted message is perturbed by a nonce that is part of the transmitted message.

from beem.memo import Memo
m = Memo("steemeu", "wallet.xeroc")
enc = (m.encrypt("foobar"))
>> {'nonce': '17329630356955254641', 'message': '8563e2bb2976e0217806d642901a2855'}
>> foobar

To decrypt a memo, simply use

from beem.memo import Memo
m = Memo()

if op_data being the payload of a transfer operation.

In BitShares, memos are AES-256 encrypted with a shared secret between sender and receiver. It is derived from the memo private key of the sender and the memo publick key of the receiver.

In order for the receiver to decode the memo, the shared secret has to be derived from the receiver’s private key and the senders public key.

The memo public key is part of the account and can be retreived with the get_account call:

get_account <accountname>
  "options": {
    "memo_key": "GPH5TPTziKkLexhVKsQKtSpo4bAv5RnB8oXcG4sMHEwCcTf3r7dqE",

while the memo private key can be dumped with dump_private_keys

The take the following form:

  "from": "GPH5mgup8evDqMnT86L7scVebRYDC2fwAWmygPEUL43LjstQegYCC",
  "to": "GPH5Ar4j53kFWuEZQ9XhxbAja4YXMPJ2EnUg5QcrdeMFYUNMMNJbe",
  "nonce": "13043867485137706821",
  "message": "d55524c37320920844ca83bb20c8d008"

The fields from and to contain the memo public key of sender and receiver. The nonce is a random integer that is used for the seed of the AES encryption of the message.

The high level memo class makes use of the pysteem wallet to obtain keys for the corresponding accounts.

from beem.memo import Memo
from beem.account import Account

memoObj = Memo(
encrypted_memo = memoObj.encrypt(memo)
from getpass import getpass
from beem.block import Block
from beem.memo import Memo

# Obtain a transfer from the blockchain
block = Block(23755086)                   # block
transaction = block["transactions"][3]    # transactions
op = transaction["operations"][0]         # operation
op_id = op[0]                             # operation type
op_data = op[1]                           # operation payload

# Instantiate Memo for decoding
memo = Memo()

# Unlock wallet

# Decode memo
# Raises exception if required keys not available in the wallet

Decrypt a memo

Parameters:memo (str) – encrypted memo message
Returns:encrypted memo
Return type:str
encrypt(memo, bts_encrypt=False)

Encrypt a memo

Parameters:memo (str) – clear text memo message
Returns:encrypted memo
Return type:str
unlock_wallet(*args, **kwargs)

Unlock the library internal wallet