Messages are sent by creating a transaction with the data field containing an encoded envelope. Each blockchain protocol may have differences in the way data and transactions are handled. Mailchain uses a standard format plus any protocol specifics.
In the web interface, a user composes a message which is sent to the Mailchain client via an API, messages can also be sent programmatically via the API. The following fields are available to compose a message:
Recipient public address
Sender public address
Encoded Address (Optional)
Public address responses should be sent to [optional]
This is my first Mailchain message
Encoded Public Key
The recipient public key
The client adds the following fields to each message:
RFC1123 date format
Date and time of message
A unique message id composed of 64 chars (32 bytes) +
String RFC6532 content type
Describe the contents of the message
The message body is encoded according to this field
The contents hash is used to verify the message has not changed since being sent. To generate the hash, the message is encoded using the specified method in the
Content-Type-Encoding fields into a bytes representation. The bytes representation is then passed to the hash function.
The message is encrypted using the recipient public key, the default encryption method is
AES-256-CBC. The encrypted message can only be decrypted by the owner of the private key that corresponds to the public key.
An integrity hash is created from the encrypted message, providing a basic integrity protection layer prior to message decryption.
A consistent characteristic of blockchain protocols is that storing bytes has a cost. Mailchain messages are stored 'off-chain' to minimise the costs of storing messages 'on-chain'. The Mailchain specification details the requirements for a message store.
Programmable envelopes provide a specific wrapper around each message. Envelopes differ in functionality to support different message use cases. Envelopes are marshalled into bytes and can be encoded per the blockchain protocol encoding requirements.
To transmit the message to the recipient, a transaction is sent from the message sender to the message recipient. These transactions are similar to standard transactions with the exception that the
data or equivalent type of field is used. The information included in this data field includes: a protocol prefix followed by the mailchain prefix, and then the envelope represented as bytes.
The following fields are then encoded to build the transaction data:
Optional and varies per protocol
Bytes of envelope
The data is combined as