Understanding Memo Encryption
Hive uses the following encryption scheme for memos:- ECDH Key Exchange: Compute shared secret from sender’s private key and recipient’s public key
- AES Encryption: Encrypt message using the shared secret
- 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:Security Considerations
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
- Learn about Key Management best practices
- Explore Creating Transactions
- Set up Multi-signature transactions