Message metadata is extracted after decoding the contents of an envelope. This provides the URL, IntegrityHash, and ContentsHash. With this metadata the message can be downloaded, decrypted, and decoded.
The envelope contains a URL field which specifies the location of a message which is accessible to the recipient to download.
Envelopes have an optional IntegrityHash which returns a hash represented as a byte array. If this field is available, the hash must be used to validate the contents of the downloaded message before proceeding. This ensure the contents of the message has not been altered.
If appropriate, to ensure a message can only be read by the recipient it is encrypted with the recipient public key. Once the contents have been downloaded and validated they can be decrypted. The first byte of the encrypted contents describes the encryption method used. This indicates which cipher is required for decryption. After the message contents have been decrypted successfully, it can be verified by comparing the ContentsHash contained in the envelope with a hash of the decrypted contents. The default hash function is
Mailchain message contents can be encoded with different methods depending on the type and contents. To ensure that the correct method is used to decode the message inspect the
Content-Transfer-Encoding message headers that were set when preparing to send the message.
Once decoded, the message fields (headers, subject, body, etc.) can be extracted and displayed to a user through an interface.