I decided to add a couple of functions to CIYAM's crypto keys implementation (
https://github.com/ciyam/ciyam/blob/master/src/crypto_keys.cpp#L730) to emulate a "vanitygen" approach to "mining addresses" in order to encode a message in the address itself (just one byte per address for simplicity and because the code would need to be optimised to do more and it's obvious that vanitygen is very well optimised when I checked the timing).
Code to "encode the encrypted message" into a bunch of private keys is as follows ("Hello!" would of course be replaced with an encrypted message). The addresses and private keys are then output to the console.
vector< string > secrets;
generate_secrets_for_leading_byte_encoded_message( "Hello!", secrets );
vector< string > addresses;
for( size_t i = 0; i < secrets.size( ); i++ )
{
addresses.push_back( private_key( secrets[ i ] ).get_address( ) );
cout << addresses.back( ) << ' ' << secrets[ i ] << endl;
}
the other side (to decode the encrypted message) is as follows:
cout << decode_message_from_leading_byte_encoded_addresses( addresses ) << endl;
and this is a sample of the console output:
17crfGDDU1MJSdM2rrFGNXYm6db4hEQo6A bdad968085aa4b7b6cd653e4341c8845a84ccc37ce2438c3965c814d3cc686de
1AEqwSMc8rdR3jMUsSMU1Fx1x6sBKtLyhA a8f3b581a5fd2af58c7b9841df878f4631e189f69143ba6f34874ad527f6c435
1AurJRfZ8mLZfLAEonYnB2fRNKJj2sM52g a67bb9045d5bf12f89a871be3554aa798e69ab088740c3136d8111f21ba53c3b
1AujLMPYW3nkEte13PSmmrLJe6pJZYswgu 1bffc5f7d38e7a609511c89d24127b78324d74328a301ef803d539f6adcc65f6
1B85SG1dvTaF9JsM1UMaeLoQyb6MT6FHxr c180c4c1256e6b9dc1cf9ca9f9468953b3c9de9b7c25cd90969f25bb709a3164
145KFvZFLSYWHfDtJrmghcTKvaKAkp9rKu 1639eb3dce0143dd8b468abdcfe05e4f9ede0cf9a4621c6d07fc1eca44a4d56d
Hello!
Granted that only using 1 byte per address (and assuming 1 UTXO as the input) you could only fit 25 bytes for a 1K tx but it is at least a template of how this could be used by an application in order to send private messages via Bitcoin.