hash type at beginning, hash itself at end.

Reinier Zwitserloot reinier at zwitserloot.com
Tue Mar 16 15:58:19 PDT 2010


In Mr. Mullen's proposal for signatures, it looks like the hash (the one
that's been in the proposal for a while now, for data integrity, not for
verification of author) is still at the top of the file. This is convenient
for readers, but not for writers. You don't know the hash yet at the
beginning!

The easy workaround is to rewrite the file after you're done, but this is
only possible when the target is on the file system. You can't rewrite parts
of the stream when the target is a db, a pipe, or the network.

If you can't rewrite the stream, then the process is hopeless:

 - store the entire file in memory first, hash it, then write it.
 - store the entire file with a dummy hash in a temporary file, then stream
that file, filling in the right hash.


A true solution to this problem is trivial: Send the *type* of the hash
algorithm at the top, and send the actual hash content at the bottom. This
is easy for both readers and writers.

--Reinier Zwitserloot



More information about the jigsaw-dev mailing list