inblockio / Aqua-Improvement-Process

Aqua-Improvement-Processs (AIP) is the backlog for proposed protocol improvements.
0 stars 0 forks source link

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

Open FantasticoFox opened 3 months ago

FantasticoFox commented 3 months 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 3 months ago

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