Sendfrom en senttoaddress both have [comment] and [comment-to] as arguments. Comment uses the script to put in a message, thus in a semi-standardized manner. Does comment-to encrypt the message with that public key? I'm kind of guessing in the dark without any explanation. (I'd suggest the tags API, RPC or JSON-RPC but I've no reputation)
With what public key?– David SchwartzJan 13, 2012 at 2:56
You could specify a target address for you comment. Simply encrypting it using the public key that that address is would make it possible only for the recipient to decode the message. But I'm not sure that's what this actually does, there's no documentation!– LodewijkJan 14, 2012 at 17:41
2That wouldn't work for two reasons. First, you don't necessarily know the public key. A bitcoin address is not a public key, it's a hash. Second, the public key is useful only to validate signatures, you can't encrypt anything with it. (This isn't RSA, where the public key can be used to encrypt, it's ECDSA, where the public key can only validate signatures.)– David SchwartzJan 14, 2012 at 20:56
Thanks for clearing that up. Any idea what then the comment-to is for?– LodewijkJan 14, 2012 at 21:49
comment and comment-to are both just stored as text with the transaction. The intent is that comment be used to store what the transaction is for, and comment-to be used to store the name of the person or organization to which you're sending the transaction.
Neither are stored anywhere besides your wallet (they're not sent with transactions), and neither are encrypted in any way.