chaintip / bounties

A list of the ChainTip bounties available
http://www.chaintip.org/github#tip-issue
26 stars 5 forks source link

[memocash/memo]: Add private/direct message support? #40

Open chaintip opened 6 years ago

chaintip commented 6 years ago

Repository: memocash/memo Issue #58: Add private/direct message support?

I suggest adding a new memo message type to the protocol which would be I guess 0x6d15?

It would simply be an encrypted message, where the encryption is via your private key and the public key of the address you are sending the message to. You can encrypt via https://github.com/kevinejohn/bitcoin-encrypt (with the binary encrypted message then base64 encoded and posted to memo), and you can find people's public keys by doing something like https://github.com/zhoujianfu/Public-Key-from-BCH-Address .

Note, if an encrypted message is too long for the OP_RETURN, it should instead be posted to a public url, and just that URL is encrypted and posted in the memo message. Kind of like a pointer. Here's a little php script to post a too-long encrypted message to pastebin site paste.city for example (and get the URL to the text).

$txt = 'txt='.urlencode('encryptedtextthatistoolongforanOP_RETURN');
$url = 'https://paste.city';

$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS, $txt);
curl_setopt($ch,CURLOPT_HEADER, 1);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);

$result = curl_exec($ch);
$headers = get_headers_from_curl_response($result);
$parts = preg_split("/\//",$headers['Location']);
print $url.'/'.$parts[1]."\n";

curl_close($ch);

function get_headers_from_curl_response($response) {
    $headers = array();
    $header_text = substr($response, 0, strpos($response, "\r\n\r\n"));
    foreach (explode("\r\n", $header_text) as $i => $line) {
        if ($i === 0) {
            $headers['http_code'] = $line;
        } else {
            list ($key, $value) = explode(': ', $line);
            $headers[$key] = $value;
        }
    }
    return $headers;
}

When going to read DMs, memo.cash would just look at the stream of ALL 0x6d15 messages (since the last time they attempted to read DMs), and attempt to decrypt them with their own private key. If you can decrypt it, that means the message was to you! By using this technique, nobody can actually even see publicly who is DMing whom! Hmm, I suppose you'd need an automated way to know if a message was successfully decrypted. Maybe each decrypted message should start with some short standard code like "OK"?

Here's a little discussion of the idea on memo.cash: https://memo.cash/topic/Direct%2FPrivate+Messages

Overall, I think this would be super-duper awesome and allow a whole wealth of new features in the memo protocol! Like, you can basically reproduce craigslist if you have private messages! And make all sorts of decentralized marketplaces as well.

Please please please consider implementing it!


Total Bounty: 0 BCH| ~ 0.00 USD

To claim this bounty, get a pull request merged with @chaintip fixes #58 in the creation comment.

Returned Tips:


Pull Requests Fixing Issue:

DJMcNab commented 5 years ago

@chaintip has the bot bugged out - it is more than two weeks after the bounty was set!

Edit: I wasn't trying to tip it 🥇

chaintip commented 5 years ago

You can't tip a bounties issue... it creates all sorts of confusion :)

testtip commented 5 years ago

@DJMcNab, yeah, sorry, it seems that it has. Looking into it now. Wow, that took a long time!

testtip commented 5 years ago

@zhoujianfu please check your email. I've sent you to check what's up here.