inblockio / mediawiki-extensions-Aqua

This MediaWiki extension includes the Aqua implementation. Turning MediaWiki into a powerful versioned notary service with API's for import and export of Data in JSON format.
GNU General Public License v3.0
6 stars 6 forks source link

[Protocol Upgrade] Hash hashes as binary instead of hex representation #386

Open FantasticoFox opened 1 month ago

FantasticoFox commented 1 month ago

Currently the hasher is using strings which are concatenated and then hashed again. We would like to change this behavior to use the binary representation of the hashes instead.

If a hash is not present (like signature or witness as optional input hashes) they are not added to the hasher-digest (input hashes for the verifiction_hash).

Example: using binary-representation of hashes and using a SHA3 hasher like this one to hash it.

In PHP this is done via:

<!DOCTYPE html>
<html>
<body>

<?php
$hash = "a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26";
$binhash = hex2bin($hash);
$hashed = hash('sha3-512', $binhash);
echo "$hashed";
?>

</body>
</html>

When calculating the different hashes we choose binary input or string input as follows.

binary

text

FantasticoFox commented 1 month ago

Plus https://github.com/inblockio/mediawiki-extensions-Aqua/issues/385