Skip to main content
The Memo class provides secure message encryption for private communication between Hive users. This guide shows you how to encrypt and decrypt memos using AES encryption with ECDH key exchange.

Understanding Memo Encryption

Hive uses the following encryption scheme for memos:
  1. ECDH Key Exchange: Compute shared secret from sender’s private key and recipient’s public key
  2. AES Encryption: Encrypt message using the shared secret
  3. Base58 Encoding: Encode encrypted data for transmission
Memos must start with # to be encrypted. Messages without # are sent as plain text.

Basic Memo Encryption

1

Import required classes

2

Get sender's private key and recipient's public key

3

Encrypt the message

4

Use encrypted memo in transfer

Decrypting Memos

The recipient can decrypt the memo using their private memo key:
The decrypted message includes the # prefix. Remove it if needed: decrypted.substring(1)

Plain Text Memos

Messages without # prefix are not encrypted:

Complete Transfer with Encrypted Memo

Here’s a complete example of sending a transfer with an encrypted memo:

Decrypting Received Memos

Retrieve and decrypt memos from incoming transfers:

Working with Shared Secrets

Understand how shared secrets work under the hood:
The shared secret is a 64-byte hash computed using ECDH key exchange. The Memo class uses this internally for AES encryption.

Sender Can Also Decrypt

Both sender and recipient can decrypt the memo:
This allows senders to keep records of encrypted messages they’ve sent.

Security Considerations

Memo keys are separate from posting/active keys. Always use memo keys for encryption, never posting or active keys.
Memos are stored on the blockchain forever. Even encrypted memos will be visible to anyone who has both the sender’s and recipient’s private keys.
Never send highly sensitive data like passwords, seed phrases, or financial credentials via memos, even encrypted.
For maximum privacy, consider using off-chain messaging systems for truly confidential communications.

Unicode and Special Characters

Memos support Unicode characters:

Error Handling

Handle encryption and decryption errors:

Testing Memo Encryption

The library includes a self-test for encryption:

Next Steps