The first site (
http://www.proofofexistence.com/) does a digital "fingerprint" (SHA256) of the document and then puts that on the blockchain -- so it does not do a digital signature.
Yes, I want to hash the document and then just sign it (i.e., no writing to the blockchain). My note in the image just meant that the code to drag and drop the file, and then hash it, was available from proofofexistence.com. Sorry for the confusion.
If you look at the second site closely (
https://brainwallet.org/#sign), you'll see that it is capable of "signing" the document using a variety of different flavors. This is because the actual digital signature algorithm can be different. Do you want a particular algorithm (which might be trickier because the engineer would need to research it, and do interoperability testing) or do you just need your own digital signature algorithm (only works in your web site in the 2 tabs you described).
Thanks for the clarification. I was originally going to accept what I got as long as it was consistent between the two tabs, but since you asked
...
...ideally, I think it would be most useful to extend the "bitcoin signed message" format to arbitrary files. The idea being that if you uploaded a plain text file, the signature the page returned would be the same as if you generated a standard bitcoin signed message using the file's contents as a string.
My understanding, then, is that we'd append the bytes:
"\x18Bitcoin Signed Message:\n"
to the file, and hash the result with SHA256 to get a 32-byte digest. We'd hash this digest
again using SHA256, and then sign that digest with the specified private key.
As for the encoding of the signature, I'd like it expressed in B64 in the format used by pybtctool, blockchain.info and I believe multibit and bitcoin-qt. This means that whether the pubkey is compressed or uncompressed must be indicated by the first byte of the signature, as I learned
here.
I think the code at brainwallet.org already takes these details into account so I think it's just a matter of copying the correct code.