Overview
TheMemo utility provides AES encryption and decryption for private messages between Hive users. It uses ECDH (Elliptic Curve Diffie-Hellman) key exchange to derive shared secrets and AES encryption for secure communication.
Messages must start with # to be encrypted/decrypted. Plain text messages (without #) are returned unchanged.
Methods
encode
Encrypts a memo using AES encryption for secure private messaging on Hive.string | PrivateKey
required
Sender’s private memo key (WIF string or PrivateKey instance)
string | PublicKey
required
Recipient’s public memo key (string or PublicKey instance)
string
required
Message to encrypt. Must start with
# for encryption. Plain text (without #) is returned unchanged.any
Optional nonce for testing purposes (advanced usage)
string
Encrypted memo string prefixed with
#, or original string if not encryptedExample
decode
Decrypts an encrypted memo using AES decryption.string | PrivateKey
required
Recipient’s private memo key (WIF string or PrivateKey instance)
string
required
Encrypted memo string. Must start with
# for decryption. Plain text (without #) is returned unchanged.string
Decrypted memo content with
# prefix, or original string if not encryptedExample
Complete Example: Encrypted Transfer
Decrypting Received Memos
Bidirectional Encryption
Memos can be decrypted by both sender and recipient:Unicode Support
Memos fully support Unicode characters:Fetching Public Memo Keys
To encrypt a memo, you need the recipient’s public memo key:Error Handling
Plain Text vs Encrypted
Memos without the# prefix are treated as plain text:
Security Considerations
Secure Memo Example
How It Works
Memo encryption uses the following process:- Shared Secret: ECDH key exchange between sender’s private memo key and recipient’s public memo key creates a shared secret
- AES Encryption: The message is encrypted with AES using the shared secret as the key
- Nonce: A random nonce ensures different ciphertexts for identical messages
- Checksum: A checksum is included to detect corruption
- Base58 Encoding: The encrypted data is encoded in Base58 for transmission
- Format:
#[base58_encoded(from_key + to_key + nonce + checksum + encrypted_message)]
Type Definition
See Also
- PrivateKey - Private key management
- PublicKey - Public key management
- Transaction - Sending transfers with memos
- Operations - Transfer operation reference