Contract for sending keyed encrypted messages via the EVM
This contract uses topic hashes as keys and can store a single arbitrary encrypted message per topic at any given time. Note: there’s technically nothing that requires the topics hashed or for the messages to be encrypted. This contract is built for the following specific use case:
The sender and recipient know the topics ahead of time. This can either be communicated elsewhere or be implicit.
Only one message per topic is stored at any given time.
Only addresses that are authorized by the recipient can send messages. These authorized parties can overwrite, but not delete the previous message for a particular topic.
Revokes `sender’s authorization to send messages to the caller.
Gets the current stored message corresponding to
To decrypt messages (this requires access to the recipient’s private keys), use the decryptMessage() function in common/Crypto.js.
Gets the stored public key for a particular
topicHash. Return value will be 0 length
if no public key has been set.
Senders may need this public key to encrypt messages that only the
recipient can read. If the public key
is communicated offchain, this field may be left empty.
recipient_ categorized by a particular
topicHash. This will overwrite any
previous messages sent to this
recipient with this
To construct an encrypted message, use the encryptMessage() in common/Crypto.js. The public key for the recipient can be obtained using the getPublicKey() method.
Sets the public key for this caller and topicHash.
Note: setting the public key is optional - if the publicKey is communicated or can be derived offchain by the sender, there is no need to set it here. Because there are no specific requirements for the publicKey, there is also no verification of its validity other than its length.