I am wondering if Ethereum can be used for encrypted peer to peer communication like delivering encrypted short messages or encrypted data in bulk between two or multiple parties.
Are there any examples or applications that I can review?
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communityCheck out the Use Cases section in the Ethereum Whisper protocol at https://github.com/ethereum/wiki/wiki/Whisper-Overview :
shh.post({ "topic": t, "payload": p });
No signature, no encryption: Anonymous broadcast; a bit like an anonymous subject-filtered twitter feed.shh.post({ "from": myIdentity, "topic": t, "payload": p });
Open signature, no encryption: Clear-signed broadcast; a bit like a normal twitter feed - anyone interested can see a particular identity is sending particular stuff out to no-one in particular.shh.post({ "to": recipient, "topic": t, "payload": p });
No signature, encryption: Encrypted anonymous message; a bit like an anonymous drop-box - message is private to the owner of the dropbox. They can't tell from whom it is.shh.post({ "from": myIdentity, "to": recipient, "topic": t, "payload": p });
Secret signature, encryption: Encrypted signed message; like a secure e-mail. One identity tells another something - nobody else can read it. The recipient alone knows it came from the sender.shh.post({ "from": myIdentity, "to": recipient, "topic": t, "payload": p, "deniable": d });
Secret signature, encryption with optional plausible deniability. If boolean parameter d is false, it is equivalent to the previous call. If d is true, recipient cannot prove to any third party that the message originates from sender, though still can verify it for herself. This is achieved by the digital signature being calculated on the symmetric session encryption key instead of the message body.Response to your comment below
Quoting Péter Szilágyi
from What are effective techniques to encrypt/decrypt data stored in a smart contract?:
Since all transactions and data on the blockchain are public, you need to encrypt the data outside of Ethereum and insert the already encrypted data. Similarly you need to pull the encrypted data and decrypt it locally. I'm sure there are a lot of crypto libraries for javascript that will allow you to do this, web3 I doubt contains such functionality as it's out of scope for it.
And quoting dbryson
from Can smart contracts compute on encrypted data?:
If I understand your question correctly, what you are referring to is called secure multi-party computation which is not a current capability of smart contracts. In fact, it's a challenging problem that is probably best done off the blockchain as it can be computationally intensive. I'd recommend looking at MIT's enigma and openPDS projects for starters. I've not seen any planned milestones for this capability in Ethereum.
You may also want to check out the following:
We have just propose our project UnwiredApp based on Ethereum. that is basically a Smart Contract that records messages related to a given user and let the recipient and only him to read them. The pitch video is here.
Essential solidity code in the smart contract is the following:
struct mess {
uint256 idMessage;
uint256 idPrevious;
uint256 timestamp;
address from;
string message;
}
/* Array with all messages with structure messages[to][idMessage] */
mapping (address => mapping (uint256 => mess)) public messages;
So, every stored message is an structure holding values for the id, a pointer to the previous message, the timestamp, the sender (from) and message itself as a string.
All messages are stored on a mapping with 2 indexes, "to" and "idMessage". This way the smart contract can always answer about last messages for a given account.