Hi Christian, On Mon, Apr 3, 2017 at 8:44 PM, Christian Schneider <cschn...@cschneid.com> wrote:
> Two things I noticed: > 1) As far as I understand Ruby (and as far as I tested it) this does not > execute the function at all. You probably mean something like > while $i > 0 do > Oops, forgot to add "== 0" [yohgaki@dev ~]$ cat t.rb #!/usr/bin/env ruby require 'digest/sha2' $i = 1000000 until $i == 0 do Digest::SHA2.hexdigest("abcdedf", 256) $i -= 1 end [yohgaki@dev ~]$ time ruby t.rb real 0m1.790s user 0m1.596s sys 0m0.194s [yohgaki@dev ~]$ cat t2.rb #!/usr/bin/env ruby require 'digest/sha2' $i = 1000000 until $i == 0 do Digest::SHA3.hexdigest("abcdedf", 256) $i -= 1 end [yohgaki@dev ~]$ time ruby t2.rb real 0m2.594s user 0m2.429s sys 0m0.165s PHP's sha3 seems slower than it could be. I knew DJB benchmark before the tests, so I was sloppy. > 2) For some reason the Ruby implementation yields different results, I > didn't track down why. > - hash("sha3-256", "abc"); => 3a985da74fe225b2045c172d6bd390 > bd855f086e3e9d525b46bfe24511431532 > which matches the test vector at http://www.di-mgt.com.au/sha_t > estvectors.html > - Digest::SHA3.hexdigest("abc", 256) => > 4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45 > > For whatever reason this is, it means that you can't really compare those > two functions. > Nice finding. https://github.com/phusion/digest-sha3-ruby seems a little old. It may not implement final version. Whichever is wrong, we may be better look into this. Anyway, it seems someone is better to try to improve SHA3 performance. Regards, -- Yasuo Ohgaki yohg...@ohgaki.net