EncryptedSender

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.

addAuthorizedSender(address sender) external

Authorizes sender to send messages to the caller.

removeAuthorizedSender(address sender) external

Revokes `sender’s authorization to send messages to the caller.

getMessage(address recipient, bytes32 topicHash) → bytes external

Gets the current stored message corresponding to recipient and topicHash.

To decrypt messages (this requires access to the recipient’s private keys), use the decryptMessage() function in common/Crypto.js.

getPublicKey(address recipient, bytes32 topicHash) → bytes external

Gets the stored public key for a particular recipient and 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.

sendMessage(address recipient_, bytes32 topicHash, bytes message) public

Sends message to recipient_ categorized by a particular topicHash. This will overwrite any previous messages sent to this recipient with this topicHash.

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.

removeMessage(address recipient_, bytes32 topicHash) public

setPublicKey(bytes publicKey, bytes32 topicHash) public

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.

isAuthorizedSender(address sender, address recipient) → bool public

Returns true if the sender is authorized to send to the recipient.

© UMA Project 2018-2019