Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blockhash values differ from other implementations' values #41

Open
chrysn opened this issue May 28, 2020 · 0 comments
Open

blockhash values differ from other implementations' values #41

chrysn opened this issue May 28, 2020 · 0 comments

Comments

@chrysn
Copy link
Contributor

chrysn commented May 28, 2020

The results using the blockhash algorithm in a simple test differed from those of other implementations.

In particular, I compared the blockhash crate (v0.2) and the Python implentation on their results for a 16bit hash of the 16x16_rgb.png image shipped with the blockhash crate (which both produced the same results):

$ ./blockhash.py ~/git/crates/blockhash/images/16x16_rgb.png --bits 16
ff00ff00ff00fe20fc3efc18f900f980f3c0f7c0ef80fe40fee07ee05e7a1804  [...]
$ cargo run ~/git/crates/blockhash/images/16x16_rgb.png
ff00ff00ff007f043f7c3f189f009f01cf03ef03f7017f007f077e077a1e1820

The img_hash program was the hash_image base program modified by #40 and with this configuration:

let hash = HasherConfig::new().hash_size(16, 16).hash_alg(img_hash::HashAlg::Blockhash).to_hasher().hash_image(&image);

Most of the difference can be explained by blockhash.py/blockhash-crate and img_hash using different bit orders -- once you flip the bits in the bytes, most of the difference goes away. By majority voting (and without looking into the spec of blockhash), I'm opening this as a bug here -- if you insist this behavior is correct, I'm happy to move it to the other projects.

The remaining two bit errors could be explained by rescaling; is there a hash configuration that can be documented and tested to be produce the exact hashes as the other implementations?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant