Is it possible to have a single hash function output simultaneously verify a compressed block of data as well as its uncompressed counterpart?
Trivially one could just use a hash function twice (once on the uncompressed version and again on the compressed version) and concatenate the outputs, or use a hash function that internally does that, but I wonder if it's possible otherwise.
For example, imagine we've got these functions:
Hash getHash(byte data); byte compress(byte data); byte decompress(byte data); bool verify(byte data, Hash hash);
...then I'm looking for these properties for a nontrivial byte array
D (that is uncompressed):
verify(compress(D), getHash(D)) == verify(D, getHash(compress(D))) == verify(D, getHash(D)) == true
D == decompress(compress(D))for all
D, i.e. lossless compression
verify(E, getHash(D)) == false"most of the time" when
E != D, i.e. collision "resistant" hashing
This could be useful when verifying persisted compressed data: you could verify the correctness of the compression algorithm and of the uncompressed data both at the same time without having to decompress it or store multiple hashes.
I'm not sure where to start looking for this. I think what I'm describing is some kind of homomorphism but apparently I need to level up my search skills. It seems like a Difficult Problem™; for example, the Deflate algorithm outputs data structures like a Huffman tree/table, and the mathematical relationships of serialized data structures being run through hash functions aren't immediately obvious to this OP.