Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98725 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 38136 invoked from network); 3 Apr 2017 11:44:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Apr 2017 11:44:26 -0000 Authentication-Results: pb1.pair.com smtp.mail=cschneid@cschneid.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=cschneid@cschneid.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain cschneid.com from 195.226.6.51 cause and error) X-PHP-List-Original-Sender: cschneid@cschneid.com X-Host-Fingerprint: 195.226.6.51 darkcity.gna.ch Received: from [195.226.6.51] ([195.226.6.51:36172] helo=mail.gna.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 54/90-28750-89532E85 for ; Mon, 03 Apr 2017 07:44:25 -0400 Received: from [10.183.1.94] (ls-zhfoer [217.192.174.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by darkcity.gna.ch (Postfix) with ESMTPSA id AD48BDC0F41; Mon, 3 Apr 2017 13:44:20 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) In-Reply-To: Date: Mon, 3 Apr 2017 13:44:24 +0200 Cc: "internals@lists.php.net" Content-Transfer-Encoding: quoted-printable Message-ID: <45858E8B-05A8-4EAB-97B0-A17C3D8BDD96@cschneid.com> References: To: Yasuo Ohgaki X-Mailer: Apple Mail (2.3273) Subject: Re: [PHP-DEV] SHA3 is very slow From: cschneid@cschneid.com (Christian Schneider) Am 01.04.2017 um 05:12 schrieb Yasuo Ohgaki : > I noticed that our SHA-3 is inefficient. >=20 > =3D=3D=3D Ruby SHA3-256 =3D=3D=3D > [yohgaki@dev ~]$ cat t2.rb > #!/usr/bin/env ruby >=20 > require 'digest/sha2' >=20 > $i =3D 1000000 > until $i do > Digest::SHA3.hexdigest("abcdedf", 256) > $i -=3D 1 > end 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 2) For some reason the Ruby implementation yields different results, I = didn't track down why. - hash("sha3-256", "abc"); =3D> = 3a985da74fe225b2045c172d6bd390bd855f086e3e9d525b46bfe24511431532 which matches the test vector at = http://www.di-mgt.com.au/sha_testvectors.html - Digest::SHA3.hexdigest("abc", 256) =3D> = 4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45 For whatever reason this is, it means that you can't really compare = those two functions. Regards, - Chris