Arbitrary Message System Operations
Decrypt From
Decrypt an AES-encrypted message.
Request:
requestTypeisdecryptFromsecretPhraseis the secret passphrase of the recipientaccountis the account ID of the recipientdatais AES-encrypted datanonceis the unique nonce associated with the encrypted datadecryptedMessageIsTextisfalseif the decrypted message is a hex string, otherwise the decrypted message is text (optional)uncompressDecryptedMessageisfalseto 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:
requestTypeisdownloadPrunableMessagetransactionis the transaction IDsecretPhraseis the secret passphrase used to decrypt the encrypted part of the message (optional)sharedKeyis the shared key used to decrypt the message (optional) (see Get Shared Key)retrieveistrueto retrieve the message from achival node if needed (optional)requireBlockis theblock ID of a block that must be present in the blockchain during execution (optional)requireLastBlockis 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:
requestTypeisencryptTosecretPhraseis the secret passphrase of the senderrecipientis the account ID of the recipientmessageToEncryptis either UTF-8 text or a string of hex digits to be compressed and converted into a 1000 byte maximum bytecode then encrypted using AESmessageToEncryptIsTextisfalseif the message to encrypt is a hex string, otherwise the message to encrypt is text (optional)compressMessageToEncryptisfalseto 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:
requestTypeisgetAllPrunableMessagestimestampis the earliest message (in seconds since the genesis block) to retrieve (optional)firstIndexis a zero-based index to the first prunable message to retrieve (optional)lastIndexis a zero-based index to the last prunable message to retrieve (optional)requireBlockis the block ID of a block that must be present in the blockchain during execution (optional)requireLastBlockis 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 ifrequireBlockis 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:
requestTypeisgetPrunableMessagetransactionis the transaction IDsecretPhraseis the secret phrase needed for decryption (optional)sharedKeyis the shared key used to decrypt the message (optional) (see Get Shared Key)retrieveistrueto retrieve pruned data from other nodes if not available (optional)requireBlockis the block ID of a block that must be present in the blockchain during execution (optional)requireLastBlockis 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) istrueif the plain message is text,falseif it is a hex stringencryptedMessage(O) is the encrypted message object, containingdata(S) andnonce(S) fieldsencryptedMessageIsText(B) istrueif the encrypted message is text,falseif it is a hex stringdecryptedMessage(S) is the decrypted and decompressed (if necessary) encrypted message, if applicable and ifsecretPhraseis providedisCompressed(B) istrueif 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 ifrequireBlockis 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:
requestTypeisgetPrunableMessagesaccountis the account IDotherAccountis another account ID, either sender or recipient, to limit the responsesecretPhraseis the secret phrase needed for decryption (optional)timestampis the earliest prunable message (in seconds since the genesis block) to retrieve (optional)firstIndexis a zero-based index to the first prunable message to retrieve (optional)lastIndexis a zero-based index to the last prunable message to retrieve (optional)requireBlockis the block ID of a block that must be present in the blockchain during execution (optional)requireLastBlockis 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 ifrequireBlockis 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:
requestTypeisgetSharedKeyaccountis the recipient account IDsecretPhraseis the secret phrase of the sendernonceis 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:
requestTypeisreadMessagetransactionis the transaction ID of the messagesecretPhraseis the secret passphrase of the account that received the message (optional)sharedKeyis the shared key used to decrypt the message (optional) (see Get Shared Key)retrieveistrueto retrieve pruned data from archival nodes (optional)requireBlockis the block ID of a block that must be present in the blockchain during execution (optional)requireLastBlockis the block ID of a block that must be last in the blockchain during execution (optional)
Response:
messageIsPrunable(B) istrueif there is a plain message and it is prunable,falseif it is not prunablemessage(S) is the plain message, if applicableencryptedMessageIsPrunable(B) istrueif there is an encrypted message and it is prunable,falseif it is not prunabledecryptedMessage(S) is the decrypted message, if applicable and only if the providedsecretPhrasebelongs to either the sender or receiver of the transactiondecryptedMessageToSelf(S) is the decrypted message sent to self, if applicable and only if the providedsecretPhrasebelongs to the sender of transactionlastBlock(S) is the last block ID on the blockchain (applies ifrequireBlockis 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.
requestTypeissendMessagerecipientis the account ID of the recipient (optional)recipientPublicKeyis the public key of the receiving account (optional, enhances security of a new account)messageis 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)messageIsTextisfalseif the message is a hex string, otherwise the message is text (optional)messageIsPrunableistrueif the message is prunable (optional)messageToEncryptis either UTF-8 text or a string of hex digits to be compressed (unlesscompressMessageToEncryptisfalse) and converted into a bytecode with a maximum length of one kilobyte, 42 kilobytes if prunable, then encrypted using AES (optional)messageToEncryptIsTextisfalseif the message to encrypt is a hex string, otherwise the message to encrypt is text (optional)encryptedMessageDatais already encrypted data which overridesmessageToEncryptif provided (optional)encryptedMessageNonceis a unique 32-byte number which cannot be reused (optional unlessencryptedMessageDatais provided)encryptedMessageIsPrunableistrueif the encrypted message is prunable (optional)compressMessageToEncryptisfalseto prevent gzip compression before encryption (optional)messageToEncryptToSelfis either UTF-8 text or a string of hex digits to be compressed (unlesscompressMessageToEncryptToSelfis false) and converted into a one kilobyte maximum bytecode then encrypted with AES, then sent to the sending account (optional)messageToEncryptToSelfIsTextisfalseif the message to self-encrypt is a hex string, otherwise the message to encrypt is text (optional)encryptToSelfMessageDatais already encrypted data which overrides messageToEncryptToSelf if provided (optional)encryptToSelfMessageNonceis a unique 32-byte number which cannot be reused (optional unless encryptToSelfMessageData is provided)compressMessageToEncryptToSelfisfalseto 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.
requestTypeisverifyPrunableMessagemessageis the plain message, if applicable (optional)messageIsTextisfalseif the provided plainmessageis a hex string (optional)encryptedMessageDatais the data part of the encrypted data-nonce pair (optional ifmessageprovided)encryptedMessageNonceis the nonce part of the encrypted data-nonce pair (required ifencryptedMessageDataprovided)messageToEncryptIsTextisfalseif the encrypted message was a hex string before encryption (optional)compressMessageToEncryptisfalseif the encrypted message was not compressed before encryption (optional)requireBlockis the block ID of a block that must be present in the blockchain during execution (optional)requireLastBlockis 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.PrunablePlainMessageorversion.PrunableEncryptedMessage(N) is1, the version numberverify(B) istrueif 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) istrueif the plain message is text,falseif it is a hex string, if applicablemessageHashorencryptedMessageHash(S) is the hashlastBlock(S) is the last block ID on the blockchain (applies ifrequireBlockis provided but notrequireLastBlock)requestProcessingTime(N) is the API request processing time (in millsec)
Example: Refer to Verify Prunable Message example.