How do I encode a transaction message so that it displays correctly in the Radix Desktop Wallet?

The Radix Desktop Wallet expects messages to be hex encoded strings prefixed with 0000

For example, to send a message that will display as Hello in the wallet, you could use the following python snippet:

"0000" + "Hello".encode('utf-8').hex()

# '000048656c6c6f'

The message field in your transaction would be: 000048656c6c6f

Message Prefix explained:

Message Type (Byte 1):

  • 00 → Plaintext/Unencrypted
  • 01 → Encrypted

Encryption Scheme (Byte 2):

  • 00 → None
  • FF → DH_ADD_EPH_AESGCM256_SCRYPT_000

So a prefix of 0000 means a plaintext message with no encryption scheme.

Hi Stuart, how could I use the encrypt method DH_ADD_EPH_AESGCM256_SCRYPT_000 ? could you give some python example to encrypt and decrypt the message ?

I’m working on that right now :slight_smile:

It uses a form of Elliptic Curve Integrated Encryption Scheme (ECIES) where an ephemeral key, the private key of the sender, and the public key of the receiver are combined to encrypt/decrypt the message. As soon as I have some working code I’ll create howto post.

The relevant code in Typescript from the radixdlt/radixdlt-javascript repo is in this file: messageEncryption.ts

And here’s a StackOverflow posting by the RadixDLT dev who created the scheme:

Thanks, I will have a look at your link soon. Btw do you know which Java file also implement this encrypt/decrypt in the GitHub - radixdlt/olympia-node: Radix monorepo Java implementation?

I couldn’t find a Java implementation in the GitHub - radixdlt/olympia-node: Radix monorepo unfortunately. It looks like there is only a Typescript implementation.

The good news is that I have figured out how to get decryption working with Python :raised_hands:
I’m just working on the encryption now which shouldn’t take long and then I’ll write some howto posts.

Thanks a lot, and I am looking forward to your howto post.

Part 1: Decrypting Encrypted Messages

Part 2: Encrypting Messages