Arbitrary Message System Operations
Decrypt From
Decrypt an AES-encrypted message.
Request:
requestType
isdecryptFrom
secretPhrase
is the secret passphrase of the recipientaccount
is the account ID of the recipientdata
is AES-encrypted datanonce
is the unique nonce associated with the encrypted datadecryptedMessageIsText
isfalse
if the decrypted message is a hex string, otherwise the decrypted message is text (optional)uncompressDecryptedMessage
isfalse
to prevent gzip uncompression after decryption (optional)
Response:
decryptedMessage
(S) is the decrypted messagerequestProcessingTime
(N) is the API request processing time (in millisec)
Example: Refer to Decrypt From example.
Download Prunable Message
Download prunable message attachments directly as binary data. An optional secretPhrase
parameter is supported, to allow decryption and downloading of the encrypted part of the message instead of the plain text part.
Request:
requestType
isdownloadPrunableMessage
transaction
is the transaction IDsecretPhrase
is the secret passphrase used to decrypt the encrypted part of the message (optional)sharedKey
is the shared key used to decrypt the message (optional) (see Get Shared Key)retrieve
istrue
to retrieve the message from achival node if needed (optional)requireBlock
is theblock ID of a block that must be present in the blockchain during execution (optional)requireLastBlock
is the block ID of a block that must be last in the blockchain during execution (optional)
Response: The prunable data as a binary file.
Example: Refer to Download Prunable Message example.
Encrypt To
Encrypt a message using AES without sending it.
Request:
requestType
isencryptTo
secretPhrase
is the secret passphrase of the senderrecipient
is the account ID of the recipientmessageToEncrypt
is either UTF-8 text or a string of hex digits to be compressed and converted into a 1000 byte maximum bytecode then encrypted using AESmessageToEncryptIsText
isfalse
if the message to encrypt is a hex string, otherwise the message to encrypt is text (optional)compressMessageToEncrypt
isfalse
to prevent gzip compression before encryption (optional)
Response:
data
(S) is the AES-encrypted datanonce
(S) is a 32-byte pseudorandom noncerequestProcessingTime
(N) is the API request processing time (in millisec)
Example: Refer to Encrypt To example.
Get All Prunable Messages
Get all available prunable messages in reverse block timestamp order.
Request:
requestType
isgetAllPrunableMessages
timestamp
is the earliest message (in seconds since the genesis block) to retrieve (optional)firstIndex
is a zero-based index to the first prunable message to retrieve (optional)lastIndex
is a zero-based index to the last prunable message to retrieve (optional)requireBlock
is the block ID of a block that must be present in the blockchain during execution (optional)requireLastBlock
is the block ID of a block that must be last in the blockchain during execution (optional)
Response:
prunableMessages
(A) is an array of prunable messages (refer to Get Prunable Message)lastBlock
(S) is the last block ID on the blockchain (applies ifrequireBlock
is provided but notrequireLastBlock
)requestProcessingTime
(N) is the API request processing time (in millsec)
Example: Refer to Get All Prunable Messages example.
Get Prunable Message
Get the prunable message given a transaction ID, optionally decrypting it if encrypted and if a secretPhrase is provided, if it is still available.
Request:
requestType
isgetPrunableMessage
transaction
is the transaction IDsecretPhrase
is the secret phrase needed for decryption (optional)sharedKey
is the shared key used to decrypt the message (optional) (see Get Shared Key)retrieve
istrue
to retrieve pruned data from other nodes if not available (optional)requireBlock
is the block ID of a block that must be present in the blockchain during execution (optional)requireLastBlock
is the block ID of a block that must be last in the blockchain during execution (optional)
Response:
sender
(S) is the sender account numbersenderRS
(S) is the Reed-Solomon address of the sender accountrecipient
(S) is the recipient account numberrecipientRS
(S) is the Reed-Solomon address of the recipient accountmessage
(S) is the plain message textmessageIsText
(B) istrue
if the plain message is text,false
if it is a hex stringencryptedMessage
(O) is the encrypted message object, containingdata
(S) andnonce
(S) fieldsencryptedMessageIsText
(B) istrue
if the encrypted message is text,false
if it is a hex stringdecryptedMessage
(S) is the decrypted and decompressed (if necessary) encrypted message, if applicable and ifsecretPhrase
is providedisCompressed
(B) istrue
if the encrypted message was compressed before encryption, if applicabletransaction
(S) is the transaction IDtransactionTimestamp
(N) is the transaction timestamp (in seconds since the genesis block)blockTimestamp
(N) is the block timestamp (in seconds since the genesis block)lastBlock
(S) is the last block ID on the blockchain (applies ifrequireBlock
is provided but notrequireLastBlock
)requestProcessingTime
(N) is the API request processing time (in millsec)
Example: Refer to Get Prunable Message example.
Get Prunable Messages
Get all still-available prunable messages given an account id, optionally limiting to only those with another account as recipient or sender, in reverse chronological order.
Request:
requestType
isgetPrunableMessages
account
is the account IDotherAccount
is another account ID, either sender or recipient, to limit the responsesecretPhrase
is the secret phrase needed for decryption (optional)timestamp
is the earliest prunable message (in seconds since the genesis block) to retrieve (optional)firstIndex
is a zero-based index to the first prunable message to retrieve (optional)lastIndex
is a zero-based index to the last prunable message to retrieve (optional)requireBlock
is the block ID of a block that must be present in the blockchain during execution (optional)requireLastBlock
is the block ID of a block that must be last in the blockchain during execution (optional)
Response:
prunableMessages
(A) is an array of prunable message objects (refer to Get Prunable Message for details)lastBlock
(S) is the last block ID on the blockchain (applies ifrequireBlock
is provided but notrequireLastBlock
)requestProcessingTime
(N) is the API request processing time (in millsec)
Example: Refer to Get Prunable Messages example.
Get Shared Key
Get the one-time shared key used for encryption of messages.
Request:
requestType
isgetSharedKey
account
is the recipient account IDsecretPhrase
is the secret phrase of the sendernonce
is the 32-byte pseudorandom nonce
Response:
sharedKey
(S) is shared key as a hexadecimal stringrequestProcessingTime
(N) is the API request processing time (in millisec)
Example: Refer to Get Shared Key example.
Read Message
Get a message given a transaction ID.
Request:
requestType
isreadMessage
transaction
is the transaction ID of the messagesecretPhrase
is the secret passphrase of the account that received the message (optional)sharedKey
is the shared key used to decrypt the message (optional) (see Get Shared Key)retrieve
istrue
to retrieve pruned data from archival nodes (optional)requireBlock
is the block ID of a block that must be present in the blockchain during execution (optional)requireLastBlock
is the block ID of a block that must be last in the blockchain during execution (optional)
Response:
messageIsPrunable
(B) istrue
if there is a plain message and it is prunable,false
if it is not prunablemessage
(S) is the plain message, if applicableencryptedMessageIsPrunable
(B) istrue
if there is an encrypted message and it is prunable,false
if it is not prunabledecryptedMessage
(S) is the decrypted message, if applicable and only if the providedsecretPhrase
belongs to either the sender or receiver of the transactiondecryptedMessageToSelf
(S) is the decrypted message sent to self, if applicable and only if the providedsecretPhrase
belongs to the sender of transactionlastBlock
(S) is the last block ID on the blockchain (applies ifrequireBlock
is provided but notrequireLastBlock
)requestProcessingTime
(N) is the API request processing time (in millisec)
Example: Refer to Read Message example.
Send Message
Create an Arbitrary Message transaction. POST only.
Request: Refer to Create Transaction Request for common parameters.
requestType
issendMessage
recipient
is the account ID of the recipient (optional)recipientPublicKey
is the public key of the receiving account (optional, enhances security of a new account)message
is either UTF-8 text or a string of hex digits (perhaps previously encoded using an arbitrary algorithm) to be converted into a bytecode with a maximum length of one kilobyte, 42 kilobytes if prunable (optional)messageIsText
isfalse
if the message is a hex string, otherwise the message is text (optional)messageIsPrunable
istrue
if the message is prunable (optional)messageToEncrypt
is either UTF-8 text or a string of hex digits to be compressed (unlesscompressMessageToEncrypt
isfalse
) and converted into a bytecode with a maximum length of one kilobyte, 42 kilobytes if prunable, then encrypted using AES (optional)messageToEncryptIsText
isfalse
if the message to encrypt is a hex string, otherwise the message to encrypt is text (optional)encryptedMessageData
is already encrypted data which overridesmessageToEncrypt
if provided (optional)encryptedMessageNonce
is a unique 32-byte number which cannot be reused (optional unlessencryptedMessageData
is provided)encryptedMessageIsPrunable
istrue
if the encrypted message is prunable (optional)compressMessageToEncrypt
isfalse
to prevent gzip compression before encryption (optional)messageToEncryptToSelf
is either UTF-8 text or a string of hex digits to be compressed (unlesscompressMessageToEncryptToSelf
is false) and converted into a one kilobyte maximum bytecode then encrypted with AES, then sent to the sending account (optional)messageToEncryptToSelfIsText
isfalse
if the message to self-encrypt is a hex string, otherwise the message to encrypt is text (optional)encryptToSelfMessageData
is already encrypted data which overrides messageToEncryptToSelf if provided (optional)encryptToSelfMessageNonce
is a unique 32-byte number which cannot be reused (optional unless encryptToSelfMessageData is provided)compressMessageToEncryptToSelf
isfalse
to prevent gzip compression before encryption (optional)
Note: Any combination (including none or all) of the three options plain message
, messageToEncrypt
, and messageToEncryptToSelf
will be included in the transaction. However, one and only one prunable message may be included in a single transaction if there is not already a message of the same type (either plain or encrypted).
Note: The encryptedMessageData-encryptedMessageNonce
pair or the encryptToSelfMessageData-encryptToSelfMessageNonce
pair can be the output of Encrypt To
Response: Refer to Create Transaction Response.
Example: Refer to Send Message example.
Verify Prunable Message
Verify that a prunable message obtained from any source, when hashed, matches the hash of the original prunable message.
Request: Refer to Send Message for more details about the following request parameters.
requestType
isverifyPrunableMessage
message
is the plain message, if applicable (optional)messageIsText
isfalse
if the provided plainmessage
is a hex string (optional)encryptedMessageData
is the data part of the encrypted data-nonce pair (optional ifmessage
provided)encryptedMessageNonce
is the nonce part of the encrypted data-nonce pair (required ifencryptedMessageData
provided)messageToEncryptIsText
isfalse
if the encrypted message was a hex string before encryption (optional)compressMessageToEncrypt
isfalse
if the encrypted message was not compressed before encryption (optional)requireBlock
is the block ID of a block that must be present in the blockchain during execution (optional)requireLastBlock
is the block ID of a block that must be last in the blockchain during execution (optional)
Note: The hash is computed from the message itself plus its associated flag(s) isText
and isCompressed
(encrypted only); therefore the flag(s) must be provided for verification if different from the default(s). The original encryptedMessageData-encryptedMessageNonce
pair used to compute the original hash must be provided again to recompute the hash for verification of a prunable encrypted message.
Response:
version.PrunablePlainMessage
orversion.PrunableEncryptedMessage
(N) is1
, the version numberverify
(B) istrue
if the original hash matches the hash computed from the provided valuesmessage
(S) orencryptedMessage
(O) is the prunable plain message or the prunable encrypted message object containing the fields:data
(S)nonce
(B)isText
(B)isCompressed
(B)
messageIsText
(B) istrue
if the plain message is text,false
if it is a hex string, if applicablemessageHash
orencryptedMessageHash
(S) is the hashlastBlock
(S) is the last block ID on the blockchain (applies ifrequireBlock
is provided but notrequireLastBlock
)requestProcessingTime
(N) is the API request processing time (in millsec)
Example: Refer to Verify Prunable Message example.