Closed gh-andre closed 1 year ago
Ok, after wading through the code, it appears that I've been misinterpreting where parallelism is applied and that multiple hashes may be processed in an optimized way, not so much processing of a single hash that can be parallelized.
I still would appreciate your insights about multi-hashes - is it possible to produce an actual SHA-256 with a multi-hash, or it's just that it provides same cryptographic strength, but the value would be different from a SHA-256 value generated via a conventional hash function?
Thank you.
Thank you for the library. I wonder if you can point me in the right direction in what I'm doing incorrectly with this code, which yields correct hashes only when I use a single buffer (i.e.
max_ctx
is set to 1).I did look at the tests, but they are using multiple buffers to compute different hashes and my understanding was that this library can collect and prepare multiple buffers via
HASH_FIRST
/HASH_UPDATE
in order to compute a single hash and will generate the final hash using some parallelization magic behind the scenes when eitherHASH_LAST
is used or the final flush loop runs.Here's the trimmed down code I experimented with. I removed all error handling for brevity. It basically checks the context error every time it gets it back from the context manager.
I experimented with ending input for each context where I called
HASH_FIRST
and a bunch of other configurations, but I cannot get it work for anything, but a single context, which kind of defies the whole purpose of a multi-buffer hash in my mind. It also produces multiple completed contexts, like the commented out lines at the end, which will print hashes for their contexts.Any pointers on what's missing from this code would be greatly appreciated.
Also, unrelated to the above (considered it as an alternative initially). Am I correct in understanding that hashes produced by Multi-Hash functions (mh_sha256.h) will not be valid hashes for their nomenclature, like SHA256, because in the end they compute hashes of hashes to facilitate parallelism? If that's incorrect, I will post another question to keep it separate.