feat: replace sha1 and tiny-keccak with sha-1 and sha3#52
Conversation
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
BenchmarkThe results are not significantly different on my machine. beforeafter |
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
|
Thanks for adding benchmarks. With the merge of #45 the codebase changed quite a lot. Could you please rebase the benchmarks? Why switching crates if there is not really a perf difference? |
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
Because |
|
Question: Why not that? |
vmx
left a comment
There was a problem hiding this comment.
I want to run the benchmarks myself locally (also with bigger data sizes), but until I've done that I've one more comment (rest looks good). I thought I publish it now before I run the benchmarks, so you can comment/react on it (or not :)
| use blake2b_simd::Params as Blake2b; | ||
| use blake2s_simd::Params as Blake2s; | ||
| use digest::Digest; | ||
| use sha1::Sha1 as Sha1Hasher; |
There was a problem hiding this comment.
This is a nitpick and not a reason for not merging this PR. I just want to bring it up that I did those imports at the top, so things are easy to grep for. Having absolute imports within the code makes it harder to scan over files if you like to manually refactor something or just want to get an overview over the files.
|
So it's about API ergonomics. The reason for having an Most simple case is: use multihash:Sha2_256;
Sha2_256::digest("some data");If you always implement the trait, you also always need to import it. Hence it's use multihash:{MultihashDigest, Sha2_256};
Sha2_256.digest("some data");Which is not as nice. Also the trait is using instance methods ( Though I'm happy for cleaner/better ideas for the API. I find the current API better than the old one, the once it is used more widely I expect that it still changes based on experiences using it. |
Okay, I got it. |
vmx
left a comment
There was a problem hiding this comment.
I did run the benchmark locally with bigger sizes. There wasn't really any difference (some slower, some faster, but all in the range of just being noise (especially on my laptop where many other processes run in the background).
Also this PR #30 included that change of the hashing functions.
Thanks for the PR and also for adding more comments!
The only thing left if waiting for a final approval from @dignifiedquire.
Signed-off-by: koushiro <koushiro.cqx@gmail.com>
sha1andtiny-keccakwithsha-1andsha3